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

Unused team found in Red and Blue - Page 1

Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 10:51:04
Dannye (I presume this is Danny-E 33 from the Skeetendo forums) recently added this to the Pokémon Red disassembly. It is unused code found at 1:64CA for giving the player a set of Pokémon that are probably Tsunekazu Ishihara's favourite Pokémon.

It features a level 90 Exeggutor along with other Pokémon, and it's noteworthy that according to an ABC News interview, Tzunekazu Ishihara was always using an Exeggutor when debugging the program.

The team is as follows:

Exeggutor, level 90
Mew, level 20 (this may suggest the code was added late as an easter egg and not as a debugging feature, because according to the Iwata Asks for HeartGold/SoulSilver, Mew was added after the debugging features were removed)
Jolteon, level 56
Dugtrio, level 56
Articuno, level 57
(Nothing)

I've been trying to get it to work but haven't been having much luck.

I tried editing Master Ball's pointer to CA 64 and then using it with D35E as 0B, CC, CD, CE or E7 in Pallet Town; a 'safe' area that doesn't freeze the game because according to this, 0B, CC, CD, CE and E7 are all bank 1 maps. Unfortunately nothing happened. I wondered if I might have got them the values the wrong way round but when I set it to 64 CA it still didn't work.

I also tried activating a bank switch (35D6) with 'b' as 01 instead of using one of those aforementioned maps IDs but the game froze for some reason. :(

My original intention was that we could try getting this team using the original code with w sm. 8F might not work as the 01 (ld bc,$aabb) opcode for the number of party Pokémon and exiting the menu would mess things up (freezed the game when testing with random values).

I haven't looked into it but I suspect you could direct w sm in Yellow from the boxed Pokémon to the items as usual, switch to the right bank (probably via the map ID method), swap your items, then execute the code via w sm. This is presuming the code still exists in Yellow though.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 11:31:12
The code seems to exist in all languages of Red that I checked.
In Spanish Red at 0x6529, in Italian Red at 0x64ca, in German Red at 0x64f1 and in French Red at 0x6565

In Japanese Red, it seems to exist (at 0x645c), but the team is different:

Exeggutor lv90
Ekans lv90
Rhydon lv5

Japanese Green uses the same team as Japanese Red, the function is at 0x645d.
Japanese Red v1.1 uses the same team, the function is at 0x6401.
Japanese Green v1.1 uses the same team, the function is at 0x6402.

In Japanese Yellow it exists at 0x62e2, the team is again different:

Snorlax lv80
Persian lv80
Jigglypuff lv15
Pikachu lv5

This team persists into Japanese Yellow v1.1 and v1.2 (the function exists in both of these at 0x62e2), English Yellow (at 0x623e), German Yellow (at 0x6253), French Yellow (at 0x62c7), Italian Yellow (at 0x628d) and Spanish Yellow (at 0x6285).

The code was removed by Japanese G/S release. (gen 2 was based on gen 1 after all; I figured there'd be no harm done to check Gold too!)

Tried changing the pointer of a potion to 0x64ca? (and seeing as GB is little endian, CA 64 is right.)
Maybe it didn't work because Master Ball is an in battle item.
I suggest Potion because you can get it out of your PC and use it in your room with no Pokémon.

EDIT: Just checked Japanese Blue. The function exists at 0x656f.

The team is different there:

Exeggutor lv90
Chansey lv100
Rhydon lv5

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 12:26:14
Nice finds! Thanks for posting them. I tried replacing the Potion's item pointer with CA 64 in Red/Blue (for reference, this is offset $D607) but when I used the item with D35E set to 0B the game just loaded a white screen and then returned to the items pack.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 12:31:09

Nice finds! Thanks for posting them. I tried replacing the Potion's item pointer with CA 64 in Red/Blue (for reference, this is offset $D607) but when I used the item with D35E set to 0B the game just loaded a white screen and then returned to the items pack.


Odd. I'll try it inside bgb (with a breakpoint at 64ca of course)

EDIT: pc ends up at 0x64ca.. in rom bank 3.
Which is a ret.

This is 0xe4ca.. e4ca-64ca=8000… 8000-64ca=1b36… ffff-1b36=e4c9.. hmm what happens if we set 0xd607 to C9 E4?

…Aaaand i resume my saved game to find myself in a glitch city.. hahaha… I wonder what happens now with d607 set to ca64…

NOTHING. heh.

Basically.. item related functions are in bank 3. So modifying item pointers won't work.

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 13:05:07


Nice finds! Thanks for posting them. I tried replacing the Potion's item pointer with CA 64 in Red/Blue (for reference, this is offset $D607) but when I used the item with D35E set to 0B the game just loaded a white screen and then returned to the items pack.


Odd. I'll try it inside bgb (with a breakpoint at 64ca of course)

EDIT: pc ends up at 0x64ca.. in rom bank 3.
Which is a ret.


Thanks Wack0. I suspected that something like that was probably the problem. I think I made a little progress re: actually executing the code, but now I've encountered another problem.

It seems the problem was that those ROM bank values only applied for the overworld, and not for using an item from the items screen but if from BGB you go to Run->Jump to cursor from 1:64CA, then game will jump to the code but on the actual bank it's on. On the overworld it will jump to a different bank depending on D35E, and these match with the values on the Pastebin link on the top post, so Pallet Town is bank 6 and the unused map 0B is bank 1.

I think I successfully got BGB to read code from 1:64CA but the game froze for some reason. (BGB's cursor says ROM0:20B5 after, so I think it froze after jumping to bank 0, if which I know rightly can be jumped to without a bank switch).

edit: Ninja'd by your edits.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 13:18:05
Got it working, and so you should be able to call the function using 8F..

ld b,1
ld h,$64
ld l,$ca
call $35d6
ret


06 01 26 64 2e ca cd d6 35 c9

Bicycle x1
Carbos x100
X Accuracy x202
TM05 x214
Revive x201

This is for US Red.

Offsets would be different for other languages.

[img]http://goput.it/o6je.png[/img]

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 13:53:30
Great! Thanks. I'm rather unfamiliar with ASM and noticed that you made 'hl' $64CA. Am I right in thinking that makes the machine load code from there after a ret?

I'll have a go at making an equivalent Yellow version for 'w sm' since the way 8F in Red/Blue starts at the current number of party Pokémon and how TheZZAZZGlitch's bootstrap code requires specific Pokémon messes it up.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 14:36:44

Great! Thanks. I'm rather unfamiliar with ASM and noticed that you made 'hl' $64CA. Am I right in thinking that makes the machine load code from there after a ret?


Look at the pokered disassembly. $35d6 is the bankswitching function, it switches to the bank specified in a and jumps to the location specified in hl.

and btw, 8F requiring specific pokemon shouldn't mess it up. the pokemon should just go to your current box instead.

EDIT: nope, you just won't get the pokemon when your party's full. just checked.

In the meantime you can modify the pointer of a potion to be d321 (21D3 in little endian), then start a new game, get the potion out your PC then use bgb's debugger to modify D321 to be 06 01 21 ca 64 cd d6 35 c9.
Then you can use the potion and it'll call the debug function.

Should be easily ported to pokemon yellow: in fact i'll do that now.

EDIT: Yellow version [now tested working]:
ld b, 1
ld h, $62
ld l, $3e
call $3e84
ret


06 01 26 62 2e 3e cd 84 3e c9

Bicycle x1
Carbos x98
X Accuracy x62
TM05 x132
Lemonade x201

EDIT: Ported this "simpler-items" version back to Red, tested it, it worked OK (well, it hit the breakpoint i had set on 64CA), modified my other post to use that version instead.
So basically, if I got the offset to Bankswitch() right, this will work. And I had to work it out by hand, so it may be wrong.

And as I mentioned earlier, Yellow has a different team: if you run this code with 4 free spots in your party you get the following:
Snorlax lv80
Persian lv80
Jigglypuff lv15
Pikachu lv5

So you might want to have a party of 4 so you only get the level 80 Snorlax and Persian :)

EDIT 2: Bankswitch in Yellow definitely seems to be at 3e84, I'll do some debugging.

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 15:59:13


Great! Thanks. I'm rather unfamiliar with ASM and noticed that you made 'hl' $64CA. Am I right in thinking that makes the machine load code from there after a ret?


Look at the pokered disassembly. $35d6 is the bankswitching function, it switches to the bank specified in a and jumps to the location specified in hl.


I see. Didn't look at it properly before.

I've found what appears to be Pokémon Yellow's bank switch function at 0x3E84. I haven't been successful at getting the Pokémon in Yellow though and got an Omastar (worth stressing it's not Omanyte) for some reason, though.

This is my code:

06 01 | ld b -> 01
21 62 3E | ld hl,$3E62
CD 84 3E | call $3E84
C9 | ret

Jumping to hl definitely works. 01:3E62 must be wrong. I'll try again tomorrow, unless someone else wants to make the equivalent code for Yellow.

Edit: Didn't notice you already had a go at making it work on Yellow. Unfortunately it doesn't seem to work. (I get a large amount of glitch text)

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 16:12:27



Great! Thanks. I'm rather unfamiliar with ASM and noticed that you made 'hl' $64CA. Am I right in thinking that makes the machine load code from there after a ret?


Look at the pokered disassembly. $35d6 is the bankswitching function, it switches to the bank specified in a and jumps to the location specified in hl.

Edit: Didn't notice you already had a go at making it work on Yellow. Unfortunately it doesn't seem to work. (I get a large amount of glitch text)

OK, so we just need to find the bank switching function in Yellow…

EDIT: it's definitely at 3E84. I tried it myself and got Arcanine. WTF?

Umm, that's because I got h and l around the wrong way. *facepalm*.

It definitely runs the function, it just doesn't do anything. Maybe it's broken in Yellow?

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-28 16:41:37
No luck so far. I'm starting to wonder if 0x3E84 is wrong, too. Thanks for your help Wack0. I'll be back tomorrow.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-28 16:51:59
OK, so I reset and tried again and it worked fine. Maybe all those Arcanine fucked up the number of pokemon in party byte.

[img]http://goput.it/iilf.png[/img]

My earlier post has been edited, to show the working compiled opcodes and a working item list.

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-29 06:10:22
Nice. So all I did wrong was get 3E and 62 the wrong way round in the code. I did better than I thought.

For reference, here is my code:

06 01 21 3E 62 CD 84 3E C9

Bicycle x1
X Accuracy x62
glitch item 'w m' (62h) x205
glitch item (84h) x62
TM01

Yours is a lot better though because no extra glitch items are needed, and it doesn't help that both glitch item 62h and 84h are key items.

I think I'll make a video of this and the R/B version.

Edit: OK, here's the video.

Re: Unused team found in Red and Blue

Posted by: Stackout
Date: 2013-11-29 07:44:32
Heh, I was going to make a video of it myself, setting a breakpoint in bgb's debugger and showing it hit the breakpoint..
But you've made a video so.. I don't have to do it, yay.

I just commented on your video, so you know my youtube name :)

Re: Unused team found in Red and Blue

Posted by: Torchickens
Date: 2013-11-29 08:44:30
Glad I saved you time then.  :) Maybe I should of videod it hitting the breakpoint too, although the ASM is enough to show that it called the bank switch and jumped to the unused function at hl.

I recognize your Youtube username from somewhere else before.