zephray / VerilogBoy

A Pi emulating a GameBoy sounds cheap. What about an FPGA?
https://hackaday.io/project/57660-verilogboy
Other
454 stars 57 forks source link

Super Mario Land hangs when entering bonus game #29

Closed blazer82 closed 2 years ago

blazer82 commented 2 years ago

As you know, I use your VerilogBoy with real cartridges instead of ROM images and I ran into an issue with Super Mario Land that I'm not sure where it's originating.

Issue

When Super Mario Land is supposed to enter the bonus game (triggered by exiting through the upper door in level 1 and 2 or by finishing level 3), the execution of the game hangs.

So far I have determined that:

LDH A, [$FF41]
ADD $03
JR NZ, $FA

Steps to reproduce

Exit level 1 or 2 through the upper door or finish level 3.

Further considerations

I'm not sure yet whether this is a general issue with VerilogBoy or whether this only arises when using real cartridges. It may be helpful to know if you can reproduce this behavior at all.

I'll keep looking for the root cause but any suggestions on what might be the issue are very welcome 😊

zephray commented 2 years ago

Hi, thanks for the feedback. My initial guess would be that's a bug in the PPU. While the CPU/ Timer/ PSG are well tested, the PPU isn't. But the fact that the PPU stays in IDLE tends to suggest that the PPU is turned off for some reason. Just by looking at the PPU logic, it would exit IDLE when vblank comes and the LCD is enabled. HV timing counter is always running regardless of the other states or registers, so the Vblank would always come. That means the LCD is disabled. So the next step would be:

  1. Verify if LCD is really disabled or not.
  2. If it is disabled, should it be disabled?
  3. If it should be disabled, should STAT register indicate the LCD is in VBlank or not?
blazer82 commented 2 years ago

@zephray thanks for the very fast reply! 😊

That means the LCD is disabled

From looking at the code, that's my current best guess, too. I'll try to verify that and if successful try to answer the to follow-up questions you mentioned.

Very helpful, thank you! I'll update this thread with any findings.

blazer82 commented 2 years ago
  1. Verify if LCD is really disabled or not.

I confirmed that the LCDC goes to 0x00, so the LCD really is disabled at that point.

blazer82 commented 2 years ago

I found this reddit post that seems to suggest that

the LCD enters Mode 0

when disabled which would provide an answer to

  1. If it should be disabled, should STAT register indicate the LCD is in VBlank or not?

while most likely also resolving the issue.

I'll be back with updates...

blazer82 commented 2 years ago

Fixed it! I'll create a pull request.