irixxxx / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
47 stars 24 forks source link

Support multiple pixel formats at runtime? #118

Open ccawley2011 opened 3 months ago

ccawley2011 commented 3 months ago

At the moment, the pixel format used by the 16-bit renderer is specifed at compile time using the USE_BGR555 and USE_BGR565 defines. Would it be possible for it to be selected at runtime? It would be useful to have for porting to RISC OS, where different machines may not have hardware support for the format specified at compile time.

irixxxx commented 3 months ago

I recently abstracted the menu stuff into some macros in platform/libpicofe, so that shouldn't pose a lot of problems. Just modify the pixel conversion macros in platform/libpicofe/plat.h.

The emulator screen rendering takes place in pico/draw* and pico/mode4.c. Some of it is in ARM assembly and very hardcoded for speed reasons. The 8bit renderers generate a colour indexed image along with a 256 entry colour palette. This palette is generated in one of the last steps in the rendering process and shouldn't pose much of a problem. The 16bit renderer is directly generating display ready pixel output by replacing the colour indexed data by their converted output data right away. It however uses the same colour palette conversion functions, just that they are called more often for higher rendering accuracy, depending on how often the emulated software modifies it.

So in a nutshell: yes, it should be possible. If you want to tackle that I can help in the process by pointing at the right functions to look at and do some infrastructure work to support this better. E.g. on my wish list is to abstract the conversion macros in the drawing code so that the conversion core comes from some macros in the platform directory.

irixxxx commented 3 months ago

Ah, RISC OS is running on early ARM, isn't it? So, the ARM assembler functions would need to be modified. Just to say it, it's usually much more work to write the asm stuff and, more importantly, debug it. Besides, most of the ARM assembly relies on having at least an ARMv4 architecture.

tlsa commented 3 months ago

There's a very old RISC OS port here: http://picodrive.acornarcade.com/

irixxxx commented 3 months ago

After my experience with psp and ps2 I'm certainly not too inclined of doing another emulator-only port. Too many cases of it running fine in the emulation but not on real hardware, which has cost me quite some time to sort out without a clue why it's not working. So, IMHO someone with some porting experience and the real hardware should take this on.

I'm however willing to assist with knowledge about the internal platform API, and I'm willing to discuss and consider integrating the result with the official repo.