libretro-cap32
libretro-cap32 copied to clipboard
[WIP] Misaligned access fix
Fix misaligned access that caused problems on SF2000 platform.
Context from the data_frog_sf2000 discord at https://discord.com/channels/741895796315914271/1099465777825972347/1176215621025939457
Is something related with big/little endianess, isn't it? What is the endianess of your CPU? maybe we could use a gcc flag to detect when you compile with your MIPS devkit.
Check the endianness file and use your exclusive compiler flag: https://github.com/libretro/libretro-cap32/blob/master/cap32/retro_endianness.h
Thanks @madcock for your PR :)
It's not endianess. RendPos
is uint32_t *
but it points to a byte-aligned address, not a word-aligned one https://github.com/libretro/libretro-cap32/blob/e727310c86ef1dc1d1c3ffa2e7fa73b3c8dd0d0d/cap32/crtc.c#L1243
This upsets some platforms; x86 and ARM are immune, while MIPS is not, and needs a (costly) exception processing each time a write is issued.
The fix is far from perfect (lowest CRTC horizontal position bits would become trimmed) so I vote not merging. And since it's actually relevant, the rendering should be done in byte or halfword quantities, esp. seeing something like this https://github.com/libretro/libretro-cap32/blob/e727310c86ef1dc1d1c3ffa2e7fa73b3c8dd0d0d/cap32/crtc.c#L1013
Also, since it's not obvious here, bnister == osaka in thread above. I asked for an explanation since I knew it would be better than any I could give. ;)
(So sounds like it makes sense to reject this PR, and instead investigate the source of the alignment issues, which is the way rendering is currently done.)
Thanks everyone!
Ook, and thank you very much for the great explanation @bnister!
@madcock when you have the patch, just update this PR and I will be happy to merge it.
Thank you both! :+1:
Hi @DSkywalk , should we merge this or not?
No, as the developer wrote it is a very early fix that needed tweaks and also affects the correct emulation of the screen (crtc), as there has been no news step to close it and if the author wants to recover it in the future there is no problem to revisit it. Thanks!! :+1: