ITotalJustice / notorious_beeg

gba emulator written in c++23
https://notorious-beeg.netlify.app/
GNU General Public License v3.0
41 stars 4 forks source link

[Tony Hawk's Pro Skater 2] freezes on starup #18

Closed ITotalJustice closed 2 years ago

ITotalJustice commented 2 years ago

gets as far as the first screen, then hangs.

image

ITotalJustice commented 2 years ago

the game halt's itself until vblank int. however, dispstat never has the vblank irq bit enabled, so vblank is never fired. this means that game is stuck in halt.

even if halt is skipped, the game needs the vblank irq.

ignoring stat and always firing the irq allows the game to continue to work, although it has many bugs.

ITotalJustice commented 2 years ago

i found the bug. its amazing that any games work at all lol.

so what's happening? the game does 8bit writes to dispstat, nothing wrong there.

however, the way i was handling 8bit io writes was broken. https://github.com/ITotalJustice/notorious_beeg/blob/2f41c52906fd19b4639f944c50d6d2baae287ca2/src/core/mem.cpp#L485-L496

so what i thought i was doing here was this: if writing the hi-byte, get the current LO byte of the io reg, OR it with the value and do a 16bit write.

that is not what was happing however due to this line inside the hi-byte write. https://github.com/ITotalJustice/notorious_beeg/blob/2f41c52906fd19b4639f944c50d6d2baae287ca2/src/core/mem.cpp#L489

i am actually taking the current hi-byte and making it the low byte!

and with this https://github.com/ITotalJustice/notorious_beeg/blob/2f41c52906fd19b4639f944c50d6d2baae287ca2/src/core/mem.cpp#L493 i am taking the low byte and making it the hi-byte...

the above should fix the need of having a dedicated 8-bit write for the apu dmg channels. need to verify it first