Re: Arbitrary code execution in Red/Blue using the "8F" item
Posted by: camper
Date: 2013-04-27 12:40:50
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.
Due to having an invalid encounter flag, 94 and 94h's Pokédex number #213 means that they add 16 to the fourth item identifier provided that it is not $X4 $X5 $X6 $X7 $XC $XD $XE $XF. If you put a Good Rod in the fourth position, and then use this glitch or the Cable Club escape glitch with a 94 or 94h, you can easily turn your Good Rod (4Dh) into an 8F (5Dh)
Well, that's amazing. However, it still requires having a right name. Also, no matter which roster (letter after the MN symbol) I try, Prof. Oak will throw a " 8" (hex C9) out. Maybe this roster on the video has something to do with that Rocket in Silph Co. the author of the video fought previously and lost to?
Anyways, thank you about all those information on encounter flags - maybe I will be able to use this to shorten up my first obtainment method.
Few glitched rosters can be found by the Ditto trick. (2, to be exact, without the use of a Pokemon with Swords Dance)
Due to having an invalid encounter flag, 94 and 94h's Pokédex number #213 means that they add 16 to the fourth item identifier provided that it is not $X4 $X5 $X6 $X7 $XC $XD $XE $XF. If you put a Good Rod in the fourth position, and then use this glitch or the Cable Club escape glitch with a 94 or 94h, you can easily turn your Good Rod (4Dh) into an 8F (5Dh).
Due to having an invalid encounter flag, 94 and 94h's Pokédex number #213 means that they add 16 to the fourth item identifier provided that it is not $X4 $X5 $X6 $X7 $XC $XD $XE $XF. If you put a Good Rod in the fourth position, and then use this glitch or the Cable Club escape glitch with a 94 or 94h, you can easily turn your Good Rod (4Dh) into an 8F (5Dh).
I assume this could also be done with RB:E8, RB:E2 and RB:E5, which have dex #245, and therefore do the same thing but to the sixth slot?
Few glitched rosters can be found by the Ditto trick. (2, to be exact, without the use of a Pokemon with Swords Dance)
I don't know what you mean. You can access 6 unique glitch rosters with Lance (as the roster number starts at 7 and can be reduced with Growls), and more with glitch Trainer classes (though they activate the ZZAZZ glitch).
In total this comes to 6 + 7*9 = 69 rosters.
will it work on yellow?
The shown method of obtaining 8F won't work in Yellow, as it uses Super Glitch, which works differently for this game.
Also, 8F does not execute code from $D163 in Yellow, but from $04FE instead - which has a less beneficial effect of teleporting you to a messed up version of a Pokemon Center.
Yellow has a relatively similar item "ws m" (hex 63), which executes code from $DA7F (number of Pokemon in the current box), but we still don't know how to obtain it though.
; initial value of hl = DA7F
WRA1:DA7F 14 inc d ; offset hack: 20 Pokémon in the box
WRA1:DA80 25 dec h ; hl = D97F
WRA1:DA81 25 dec h ; hl = D87F
WRA1:DA82 25 dec h ; hl = D77F
WRA1:DA83 25 dec h ; hl = D67F
WRA1:DA84 25 dec h ; hl = D57F
WRA1:DA85 25 dec h ; hl = D47F
WRA1:DA86 06 21 ld b,21
WRA1:DA88 68 ld l,b ; hl = D423
WRA1:DA89 A9 xor c ; offset hack: do nothing until ip=DA93
WRA1:DA8A A9 xor c
WRA1:DA8B A9 xor c
WRA1:DA8C A9 xor c
WRA1:DA8D A9 xor c
WRA1:DA8E A9 xor c
WRA1:DA8F A9 xor c
WRA1:DA90 A9 xor c
WRA1:DA91 A9 xor c
WRA1:DA92 A9 xor c
WRA1:DA93 06 FF ld b,FF ; offset hack: making an end of list FF byte an operand so it doesn't translate to [rst 38]
WRA1:DA95 25 dec h ; hl = D323
WRA1:DA96 00 nop
WRA1:DA97 E9 jp hl
Note in Yellow D323 is the identifier of item 4, not item 3. You could replace step 9 with having Growlithe (21h) as the 8th Pokémon instead of Fearow (23h) to get b = 21 (where D321 = item 3).
D322: 3E xx ld a, xx
D324: 2E xx ld l, xx
D326: 26 xx ld h, xx
D328: 04 inc b
D329: 77 ld (hl), a
D32A: 3C inc a
D32B: C9 ret