ams-hackers / gbforth

👾 A Forth-based Game Boy development kit
https://gbforth.org
MIT License
121 stars 23 forks source link

Rare Bug in Aces Up Example #340

Open hendursaga opened 8 months ago

hendursaga commented 8 months ago

First off, thanks for GBForth and for the excellent example game.

I found a bug in (presumably) all-unique-tops? where it prematurely quits the game when there are no more cards to deal with, but there's at least one empty pile. See attachment below.

gbforth-aces-up-bug

I had some trouble reproducing this issue, as I couldn't take a screenshot in time before the "explosions" happened and the score was displayed, so I commented that out.

Out of curiosity, suppose I had a dump of the RAM after "winning" prematurely, but before pressing any key, so that reset-game would have not been called yet. What could I have done to look at what the piles / stacks were?

tkers commented 8 months ago

Thanks for having a look at our project and taking the time to submit this bug!

That does sound hard to reproduce, yes 😄 But I can indeed imagine that all-unique-tops does not consider the case of "empty pile" correctly and basically considers it a 5th suit instead. An extra check for empty spots would probably be in place to determine the gameover state.

If you have the RAM contents, you could check at what address pile-1 is located by looking it up in the aces-up.sym file. You'd need to look for the one marked with (BODY) specifically, as that's the part that holds the data (the other one is the word itself, located in the ROM, that fetches the value). From there you'll find 1 cell (2 bytes) containing the size of the pile, and up to 13 cells (26 bytes) of data representing the cards on that stack, which you can decode with card>suit and card>rank.