Open Eeems opened 10 months ago
The first thing that stands out is the following: https://github.com/Eeems-Org/remarkable-gameboy/blob/89aff2dc1ec4b595e10ad0cbe50ab908ae5245e1/src/vendor/libqboy/z80register.cpp#L42-L51 https://github.com/Eeems-Org/remarkable-gameboy/blob/89aff2dc1ec4b595e10ad0cbe50ab908ae5245e1/src/vendor/libqboy/z80register.cpp#L61-L69
These should really be macros.
Frankly there's a lot that stands out, I mean I could help optimize it but I'm going to hate every bit of code I look at here 😅
https://github.com/Eeems-Org/remarkable-gameboy/blob/89aff2dc1ec4b595e10ad0cbe50ab908ae5245e1/src/vendor/libqboy/gbgpu.cpp#L155 This should be an array instead of a vector
i.e. gbgpu::preprocessram()
and gbgpu::postprocessram()
should be replaced by interfaces to the memory mapped registers that just keep themselves up to date as part of the main cpu cycle.
https://github.com/Eeems-Org/remarkable-gameboy/blob/89aff2dc1ec4b595e10ad0cbe50ab908ae5245e1/src/vendor/libqboy/z80.cpp#L63-L73
~If (interrupt_occured & interrupt_enabled & 0x1F) == 0
exit loop early.~
EDIT: This is resolved
for all the places there are things like mmu->readbyte(0xFF0F), it might be good to expose a function on the mmu object that accesses directly instead of going down through the two-layer switch statement just to figure out that value is in the 0xFFxx range
If
(interrupt_occured & interrupt_enabled & 0x1F) == 0
exit loop early.
Or actually, exit the function before the loop even starts
The CPU utilization for running this is near 100% on a rM1, so it may be worth looking to see if there is any low-hanging fruit for quick optimizations in libqboy. Maybe @calc84maniac would have some insight, since he's written several gameboy emulators on much more limited platforms.