Zal0 / ZGB

Game Boy / Color engine with lots of features
MIT License
708 stars 50 forks source link

SGB Borders don't load on PAL Snes / Super GameBoy #45

Closed joyrider3774 closed 2 years ago

joyrider3774 commented 2 years ago

Hey,

I have a PAL Snes as well as PAL Super Gameboy and SGB Borders don't load with ZGB on it. I had initially noticed it in my GBDK-2020 game and toxa mentioned there is a timing issue on PAL Systems, added a delay of 4 frames fixed it on my GBDK-2020 game. He also suggested to test ZGB, so i took the latest version (by first grabbing the release and then overwriting with latest github version sources so i also had the environment) and i took the ZGB Template and added a border as per the documentation, but on my PAL SNES / SGB the border did not load. It did work in BGB and it also worked when using the the easy flash junior, but it did not work if i used GBX-RW to flash an empty cartridge. I'm guessing easy flash junior and perhaps everdrive do some other things that don't require the delay or so.

GB Studio used a similar delay https://github.com/chrismaltby/gbvm/blob/master/src/core/core.c#L192-L196 (its what toxa was refering to as well) and we've seen other games incorporating such delays ... (https://sourcegraph.com/github.com/SimonLarsen/tobutobugirl-dx/-/blob/init.c?L125 and https://sourcegraph.com/github.com/SimonLarsen/tobutobugirl-dx/-/blob/main.c?L34:3)

Initially i had put the same delay in the LOAD_SGB_BORDER Function but this still did not work, if i moved that delay to right at the beginning of main it started working also on my PAL SNES / SGB.

So basically (if wait_vbl_done) does not interfere we can either delay 4 frames or at a fixed delay as other examples did. we are guessing interrupts could interfere and the delay has to be set before them or the SGB Border does not load but it's only guessing as i did not really verify this.

I'll create a pull request to add the delay

Zal0 commented 2 years ago

Thanks a lot for testing and fixing this!