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 I Glitch Discussion

Rhydon glitch:- bug or valid error handler? - Page 1

Rhydon glitch:- bug or valid error handler?

Posted by: Torchickens
Date: 2014-06-09 12:43:33
FSX raised an interesting point on Bulbapedia's talk page for Rhydon glitch. He/she thinks it is error handling code working as designed, and it sounds convincing, but can anyone prove it? I'd appreciate it if anyone experienced with ASM could walk through the routine, say what's happening, then make a judgement from there.

For people who don't know; when a glitch family (0, 152-255) Pokémon is obtained and then an invalid Pokédex entry is loaded, the Pokémon reverts into a perfectly stable Rhydon, or an unstable hybrid with Rhydon as the donor and the glitch Pokémon as the recipient if it is sent to Bill's PC.

Re: Rhydon glitch:- bug or valid error handler?

Posted by: Stackout
Date: 2014-06-10 07:27:56
On first sight, I don't think it's intentional. If the capture flag hasn't been set, pc ends up here:

ld hl,ItemUseBallText06
call PrintText
call CleanLCD_OAM
ld a,[$cfe5] ;caught mon_ID
ld [$d11e],a
ld a,$3d
call Predef


..which shows the "dex entry will be added" text and runs predefined call $3d (10:42d1, ShowPokedexData).

ShowPokedexData just does some initial stuff and falls through to the code that's ran when you open a dex entry inside the Pokédex.

AddPokemonToParty adds the Pokémon whose index number is in $CF91. I'm assuming that $CF91 gets corrupted somewhere inside ShowPokedexDataInternal.

The unnamed function that adds a Pokémon to the current box also gets the index number from $CF91.

The easiest way to check this is to set a breakpoint on write to $CF91 on the "dex data will be added…" textbox after capturing a glitch family Pokémon without its capture flag set.

edit: fixed mistakes in rushed analysis

Re: Rhydon glitch:- bug or valid error handler?

Posted by: camper
Date: 2014-06-10 08:38:18
Some quick test: $CF91 changes to $01 on the exact frame that the dex entry is shown.

Re: Rhydon glitch:- bug or valid error handler?

Posted by: Stackout
Date: 2014-06-10 09:09:17

Some quick test: $CF91 changes to $01 on the exact frame that the dex entry is shown.


I'm going to assume it's something related to sprites being invalid. I'll run it in bgb's debugger setting appropriate breakpoints later.

Re: Rhydon glitch:- bug or valid error handler?

Posted by: TheZZAZZGlitch
Date: 2014-06-10 09:57:23
Yes, it is an intended feature.

The decision comes from an undocumented function at address $1389:

[tt] and a              ; Is the dex number 000?
pop hl
jr z, .asm_13a7    ; If it is, it's invalid
cp $98            ; Is the dex number less than 152?
jr c, .asm_13ad    ; If it is, it's valid

Invalid:
ld a, $1
ld [$cf91], a      ; Set the index number to 01 (Rhydon)
ret                ; Return as if nothing ever happened

Valid:
  push hl
(…)[/tt]

Re: Rhydon glitch:- bug or valid error handler?

Posted by: Torchickens
Date: 2014-06-10 10:45:26
OK, that's excellent. Thanks TheZZAZZGlitch.

Thank you Wack0 too for your research, even though you didn't come to the right conclusion.

Re: Rhydon glitch:- bug or valid error handler?

Posted by: Stackout
Date: 2014-06-10 10:49:57

Thank you Wack0 too for your research, even though you didn't come to the right conclusion.


Heh, would have probably figured that out when I ran it in a debugger. Rush analysis generally means wrong conclusions.

Nice to know there's some form of error handling related to invalid Pokémon.. although not much!