rynorris / nes

NES emulator written in Rust
MIT License
11 stars 0 forks source link

Metal Fighter #54

Open rynorris opened 5 years ago

rynorris commented 5 years ago

Visual scroll glitches on title screen and crashes when trying to start the game.

Looks like some kind of scroll split issue, maybe sprite 0-hit related.

rynorris commented 5 years ago

The loop it gets stuck in when you try to start the game is:

82C5  E6 0F     INC $0F                         A:00 X:00 Y:00 P:06 SP:F7
82C7  AD 02 20  LDA $2002                       A:00 X:00 Y:00 P:04 SP:F7
82CA  29 40     AND #$40                        A:00 X:00 Y:00 P:06 SP:F7
82CC  F0 F7     BEQ $F7                         A:00 X:00 Y:00 P:06 SP:F7

Indeed, this is waiting for a sprite 0-hit.

rynorris commented 5 years ago

Or it gets stuck in:

8002  AD 02 20  LDA $2002                       A:00 X:00 Y:05 P:46 SP:57
8005  29 80     AND #$80                        A:00 X:00 Y:05 P:46 SP:57
8007  F0 F9     BEQ $F9                         A:00 X:00 Y:05 P:46 SP:57

Which is waiting the vblank flag to be set. But in the NMI handler it reads from PPUSTATUS, thus clearing the flag. So this condition would never be met. 🤔

rynorris commented 5 years ago

I wonder if this is another instance of

These rely on 1 cycle NMI delay when PPUSTATUS ($2002) bit 7 gets set inside vblank (if $2002 has not been read yet), in which PPUSTATUS bit 7 can be read as true.

rynorris commented 5 years ago

55 fixes the crash when exiting the demo screen. The game now appears fully playable.

Visual glitch on title screen still persists. Downgrading severity.