Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation II Glitch Discussion

Winning the Lucky Number Show with out of bounds Pokémon? - Page 1

Winning the Lucky Number Show with out of bounds Pokémon?

Posted by: TheZZAZZGlitch
Date: 2020-06-14 05:13:31
In some unknown circumstances, checking the Lucky Number lottery in Goldenrod City seems to draw data from out of bounds Pokémon entries. There are multiple reports scattered across the Internet, where people got ID matches with Pokémon "in their PC box" which they never owned.

One of my old friends got this to happen too, a very long time ago - the game stated he had a ????? in his PC. I was a kid back then, so I didn't really think much about it. But now, I decided to revisit this curiosity.

I don't have any save files which reproduce the issue, so I had to go in blind. Lucky Number winners are determined by this CheckForLuckyNumberWinners subroutine in the disassembly.
Unfortunately, even after going through it line by line multiple times, I just can't seem to find the bug.

Boxed Pokémon data is read directly from SRAM. This behavior makes the lottery capable of drawing Pokémon data from previous save files. I wondered how the lottery would behave without any save file present. However, resetting a save file in G/S/C sets all bytes in SRAM to 0x00, not 0xFF. So all of the boxes are correctly considered empty, and there are no out of bounds reads. This seems like a dead end.

Anyone have some ideas?

Re: Winning the Lucky Number Show with out of bounds Pokémon?

Posted by: CasualPokePlayer
Date: 2020-06-14 11:27:27

In some unknown circumstances, checking the Lucky Number lottery in Goldenrod City seems to draw data from out of bounds Pokémon entries. There are multiple reports scattered across the Internet, where people got ID matches with Pokémon "in their PC box" which they never owned.

One of my old friends got this to happen too, a very long time ago - the game stated he had a ????? in his PC. I was a kid back then, so I didn't really think much about it. But now, I decided to revisit this curiosity.

I don't have any save files which reproduce the issue, so I had to go in blind. Lucky Number winners are determined by this CheckForLuckyNumberWinners subroutine in the disassembly.
Unfortunately, even after going through it line by line multiple times, I just can't seem to find the bug.

Boxed Pokémon data is read directly from SRAM. This behavior makes the lottery capable of drawing Pokémon data from previous save files. I wondered how the lottery would behave without any save file present. However, resetting a save file in G/S/C sets all bytes in SRAM to 0x00, not 0xFF. So all of the boxes are correctly considered empty, and there are no out of bounds reads. This seems like a dead end.

Anyone have some ideas?


Well, if save file data has never been cleared and the game had never been played before (well, and also battery dies and save file goes bye bye from that), then I believe the data in SRAM would be non-deterministic, so really could just be something like that?

Also, somewhat unrelated, but interestingly G/S actually used the wrong value for the number of boxes, so it won't check all boxes for Pokemon ID numbers: https://github.com/pret/pokegold/blob/e28325211cfc584ebed4389ab242014cc80ab2c9/engine/events/lucky_number.asm#L99

And interestingly there is a farcall to some mobile function, but it just rets immediately, so no lead there.

https://www.diffchecker.com/o3Zeqx6P

Re: Winning the Lucky Number Show with out of bounds Pokémon?

Posted by: Torchickens
Date: 2020-06-14 14:23:57
Yeah, I remember (when I used emulators) that in BizHawk, SRAM values are seemingly random if you start a game which has never had a save file, or have even cleared one with Up+Select+B; which allowed for different Pokémon Communication Center SRAM glitches and freezes in Japanese Crystal. (This also seemed to occur on my physical dead battery Japanese Crystal). So perhaps like CasualPokePlayer said, if you don't save or clear with Up+Select+B (or maybe use a dead battery cart), you have a random chance to get a match from a Pokémon that doesn't exist?

Wow cool, I didn't know Lucky Number Show was used in Mobile System GB/was planned to be used.

Re: Winning the Lucky Number Show with out of bounds Pokémon?

Posted by: Torchickens
Date: 2020-06-14 16:10:49
I got up to Goldenrod Radio Tower on my dead battery Crystal without saving and it worked. :) It was a Sandshrew even though my only Pokémon were Croconaw and Togepi Egg. https://www.youtube.com/watch?v=_iiE1OZFoL8 On the route I bought some Poké Balls to see if anything happened after putting Pokémon in the boxes if I didn't win (e.g. corrupted box 2 like the Hall of Fame SRAM glitch?) but nothing else happened.

Re: Winning the Lucky Number Show with out of bounds Pokémon?

Posted by: SgvSth
Date: 2020-06-17 17:21:29
Somewhat of a minor thing, but you can pull off getting the '????? in your PC' on VC Gold and Silver without much effort.  Using the Poké Transporter incorrectly due to closing a VC game while it was saving corrupts Box 1 in various ways if you transfer more Pokémon from a different box than the number in Box 1.  That seems to be enough to trigger the game into finding an ????? occasionally.

Poké Transporter glitch: https://forums.glitchcity.info/index.php?topic=8191