Libretro – Recap of progress last week

By Squarepusher – Besides the Desmume and TGB Dual ports that appeared out of the blue, a lot of other work has been done. Here is a brief recap.

Genesis Plus GX

Ekeeke (the author of Genesis Plus GX – still not sure about the pronunciation) added CD audio support to Genesis Plus GX. The libretro port has been pushed to the official Genesis Plus GX repository some time ago so it’s very easy for either me or ekeeke himself to update it to reflect changes made to the emulator.

Link to official repository (ekeeke): https://github.com/ekeeke/Genesis-Plus-GX

Link to libretro experimental fork:  https://github.com/libretro/Genesis-Plus-GX

Mednafen libretro

I’m currently working on making the Mednafen libretro ports more sustainable in the future. Right now we have a lot of standalone Mednafen repositories with a lot of duplicate code.

I’m aiming at bringing them all together. Right now, the mednafen-psx repository allows building three separate cores – Mednafen PSX, Mednafen PC Engine Fast, and Mednafen Wonderswan. More will be added.

The backend right now is a modified Mednafen backend with lots if ifdefs strewn around such as NEED_CD, NEED_THREADING, and so on so that – for instance – the libretro port of Mednafen Wonderswan won’t be bloated by including lots of threading and CD-ROM code that the Wonderswan emu will never ever use.

At the moment a lot of work still remains to be done – to begin with, all the Visual Studio solutions need to be updated (for Xbox 1/360/PC), and the console ports have to be all tested.

RGB565 support

Previously, a libretro port would have either the option of using a 32bit color format (XRGB8888) or a 15/16bpp color format (ORGB1555 – picked implicitly if you did not specify anything). Now that the OpenGL driver has been completely overhauled to better accomodate OpenGL ES devices, we’ve found that ORGB1555 is an unlucky fit on most of these devices and isn’t natively supported.

Hence the introduction of a new pixel format to libretro if 15/16-bit color is desired (RGB565). The PS3, Raspberry Pi, Wii and PC ports have currently been updated to properly display libretro cores using RGB565. If pixel format is not explicitly defined, then it will assume ORGB1555 and the libretro frontend (ie. RetroArch) will perform automatic color format conversion to RGB565 behind the scenes. This will undoubtedly be slower, so it’s imperative that a libretro port picks a color format.

An example from – say – Gambatte, where 32bit color is used:

<code>
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
g_has_rgb32 = true;
</code>

You can select a different color format on a per-game basis (in this case, you would want to put this into your retro_load_game implementation) or you can choose to just have it apply for all games (in Genesis Plus GX/VBA Next/SNES9x Next/FCEUmm, a snippet similar to this has been put into retro_init for exactly this reason).

At the moment, the following emulators have been updated to support RGB565:

  • SNES9x Next
  • FCEUmm
  • Genesis Plus GX
  • iMAME4All
  • TGB Dual
  • PCSX ReARMed
  • VBA Next
  • Mednafen PC Engine Fast
  • Mednafen Wonderswan

Libretro-prboom will require a port from scratch to support RGB565 since the initial implementation required some sweeping changes that would preclude a merge into prboom mainline. FBA will be looked at later. Gambatte as it is uses ARGB 32bit color instead and so does Mednafen PSX, so these will not be looked at since color format is already ideal for these ports.