libretro / snes9x2002

Snes9x 2002. Port of SNES9x 1.39 for libretro (was previously called PocketSNES). Heavily optimized for ARM.
37 stars 46 forks source link

Backport color operations from Snex9x 1.60 #39

Closed m45t3r closed 3 years ago

m45t3r commented 4 years ago

The current Snex9x have a different implementation on COLOR_ADD and COLOR_SUB functions. For example:

https://github.com/snes9xgit/snes9x/blob/master/gfx.h#L132-L148 https://github.com/snes9xgit/snes9x/blob/master/gfx.h#L180-L193

As you can see, they don't use the a color table anymore, instead using just bitshifts to calculate the new color. It also seems to be faster.

I ported this code to some of my emulators. Here is the commit for one of them:

https://github.com/m45t3r/snesemu/commit/435a5ef19ed64121a87df4d4e7b420ae8b5a1ea4

Since this core is focused in speed, it may make sense to also port this code to Snes9x2002 (and maybe Snes9x2005?).

The only issue of backporting this code is that it is only available for RGB565 and RGB555 pixelformats. I don't know if some of the targets that Snes9x2002 supports use one of the other pixelformat supported, if not we could just drop those pixelformat like I did in https://github.com/m45t3r/snesemu/commit/435a5ef19ed64121a87df4d4e7b420ae8b5a1ea4. If not, we could use the new color operation code only for RGB565 and RGB555 and in the other cases fallback to the older code. Or maybe find a way to make this code works in other pixelformats?

jdgleaver commented 3 years ago

I know I'm late to the party, but thank you so much for raising this issue, and for providing the link to your repo. I've just backported these changes (plus the PocketSNES optimisations) to the Snes9x2005 core: https://github.com/libretro/snes9x2005/pull/76 - the performance improvement is fantastic.

Snes9x2002 isn't of so much interest to me, but I'll have a go at updating this core as well once I've cleared some things off the TODO list.

jdgleaver commented 3 years ago

I went ahead and added the new colour ops: #42 :)