Derivatives of 5 in Red/Green
Posted by: Torchickens
Date: 2012-12-21 08:24:47
With 5 ('5F', Item 5Ah) the game runs machine code beginning from WRA1:D123 (Number of Pokémon).
The Game Boy CPU operates on a number of instructions called registers. Each register has an opcode (list of opcodes). The Game Boy typically runs machine code from the ROM, but in the case of using 5, the machine runs data from the WRAM as they were opcodes, when normally its used to store re-writable in-game variables.
Although when using 5 the Game Boy operates machine code beginning from WRA1:D123 (# of Pokémon, Pokémon 1, Pokémon 2…), you can use different opcodes to read from a memory address elsewhere (e.g. items). Jr (relative jump) is useful because the opcode is (18h [xx]h), and 18h corresponds to Tentacool which are easy to obtain.
The quantity of 5 never decreases on use unless you program it to.
[size=14pt]Method to Obtain 5:[/size]
Unfortunately I don't know of an easy way to obtain 5, but it is possible without any side effects that are too bad. I recommend doing the below steps when you have all badges, otherwise at the end your high leveled Pokémon might no longer obey you.
Adding 5 to Post-20 items:
We'll want to explode the items pack to obtain 5 (item 5Ah), but it doesn't appear past item 20 very often, so one way of finding it is if the first byte of the Trainer ID number is 5Ah.
When you start a new game there's a 1/256 chance that your ID number ranges from 23040-23295. This means that byte 1 (D2D8) is 5A, and you'll be able to find it when you scroll past the items pack. Later we'll want to deposit one 5 in the PC Box, so byte 2 (D2D9) might have to be >1 so you can deposit 1 5 without shifting the number of items, which could freeze the game.
Unfortunately, without an emulator, the only way to check is to obtain your starter Pokémon and check its ID number, but with BGB's debugger you can add a breakpoint when D2D8 becomes 5A by going to Debug>Access Breakpoints, entering 'D2D8', '5A', checking 'on write' and clicking 'Add'.
Like this:
http://i.minus.com/jE8UeQepq5aC.png
This will make the emulator pause when you begin a new game and byte 1 of the Trainer ID is set to 5Ah.
Exploding the items pack:
You'll need :-
1) Your starter (Doing it with another Pokémon made the game freeze on switching for some reason)
2) 9 Items and at least 1 Pokémon
3) A Trainer ID Number ranging between 23042-23295 or 23040 (see above)
Requirements for reverting the item pack back to normal/ Getting your starter back:
4) Two or more Pokémon
5) Access to the Day-Care Center on Route 5
6) A place like Saffron City where you can easily walk to the Daycare Center
7) At least 100 Pokédollars, (probably more)
Steps:-
1) Highlight Item 9 in the Bag. Close the menu with B,B.
2) Enter Battle and select your first Pokémon on the menu to swap it with a glitch Pokémon.
[img]http://i.minus.com/jxOskzUx0Qrh3.png[/img]
3) Run. You might have to open the Fight menu first so you don't get a 'sent to Pokémon Center' loop.
4) Walk to a PC, be careful not to encounter any Pokémon on the way. Select your PC and choose Deposit.
:Your item pack should be messed up, like this.
[img]http://i.minus.com/jvuwiIc9yMznh.png[/img]
5) 5 should be item 28. There should be more than one. Deposit one to keep in your PC, but don't deposit all of them because that might freeze the game.
[img]http://i.minus.com/jKPeiWavBP9RA.png[/img] [img]http://i.minus.com/jQQCHvZj6emlW.png[/img]
Now we have 5 to keep. Your Trainer ID has changed to your old ID, minus how many of 5 you deposited.
Getting the items pack back to normal, and your starter back:
1) Take the glitch Pokémon and one other Pokémon to the Daycare Center if you aren't already there.
2) Highlight the ninth item again, then close the menu with B,B and talk to the Daycare Man as if you're going to deposit Pokémon.
[img]http://i.minus.com/jqU1M4lipKy2N.png[/img] [img]http://i.minus.com/jzkJpB6NmaSpt.png[/img]
3) Now, press A to swap the first Pokémon with a glitchy version of your starter.
[img]http://i.minus.com/jbrTjdhtSYZJDm.png[/img]
4) Exit the menu, and open it to find your usual items are back. Repeat steps 2/3 again. You should get a weird version of the old glitchy Pokémon again.
[img]http://i.minus.com/jeiuY9xlbHXrh.png[/img] [img]http://i.minus.com/jbes1YV7MLMZsU.png[/img]
[img]http://i.minus.com/jbvNQRCDXbWXZV.png[/img]
5) Choose to raise the second Pokémon
[img]http://i.minus.com/jbiY73CvrVMNc4.png[/img]
6) Open the menu to find your items are glitched again. Highlight the ninth item once more and exit with B, B. Exit then retrieve your second Pokémon from the Daycare.
[img]http://i.minus.com/jqU1M4lipKy2N.png[/img] [img]http://i.minus.com/jKpYqSBmJ3OO1.png[/img]
7) Talk to the Daycare Man as if going to deposit a Pokémon again. Select the first Pokémon to switch it and receive your real starter back, with your items back to normal. 5 is still available to withdraw in the PC.
[img]http://i.minus.com/jOLeL0NenpMNh.png[/img] [img]http://i.minus.com/jOoPPhyuoK0E6.png[/img]
[size=14pt]1) Encounter any Pokémon based on the quantity of Item 1 [by K)ry][/size]:
K)ry, the author of Kattempla/Pokebug wrote ASM that allows you to easily capture all 151 Pokémon.
Once you meet the following requirements (below), 5 acts like an item that forces a value in 01xx36D0 (instant encounter with a Pokémon), which depends on the quantity of item 1 (D2A3h).
Sub-Requirements
1) 5 (see above)
2) Access to three PP Ups.
Below are locations:
[img]http://i5.minus.com/j327BkQVPLeFb.jpg[/img] [img]http://i5.minus.com/je7iuSTUMfNGq.jpg[/img] [img]http://i5.minus.com/jk4R0jR5OaCNn.jpg[/img]
3) A Pokémon with a Special stat of 182, 183, 184 (modulo 256) so you can encounter a special Missingno. with Trainer-Fly to duplicate your items. You'll need to duplicate your items several times.
4) Access to TM01, TM10, TM50 and Max Revive.
5) Master Balls are desirable, but you won't need them.
6) Access to Meowth. If you're not using Pokémon Green you'll have to trade or use a glitch.
Requirements:
1) 06h: 6 Pokémon (0xD123)
2) xxh: Any first Pokémon (0xD124)
3) 18h: Tentacool as the second Pokémon (0xD125)
4) 4Dh: Meowth as the third Pokémon (0xD126)
5) 18h: 24 PP left on the second Pokémon's first move (0xD174)
6) 56h: 22 PP left on the second Pokémon's second move w/ 1 PP Up used (0xD175)
7) 18h: 24 PP left on the 4th Pokémon's first move (0xD1CC)
8) 56h: 22 PP left on the 4th Pokémon's second move w/ 1 PP Up used (0xD1CD)
9) 18h: 24 PP left on the 6th Pokémon's first move (0xD224)
10) 4Fh: 15 PP left on the 6th Pokémon's second move w/ 1 PP Up used (0xD225)
11) C3h, A4h, D2h: The 6th Pokémon's nickname begins with "て" (0xD275-0xD277)
12) FAh: The second item is TM50 (0xD2A4)
13) A3h: The second item quantity is 163 (0xD2A5)
14) D2h: The third item is TM10 (0xD2A6)
15) EAh: The third item quantity is 234 (0xD2A7)
16) 36h: The fourth item is Max Revive (0xD2A8)
17) D0h: The fourth item quantity is 208 (0xD2A9)
18) C9h: The fifth item is TM01 (0xD2AA)
[img]http://i4.minus.com/iboEFrmbFg5594.png[/img][img]http://i1.minus.com/i0fa3X06zU1kd.png[/img][img]http://i1.minus.com/ibbALiUpaYcCD6.png[/img][img]http://i4.minus.com/iTlyJSZT6ztYR.png[/img][img]http://i3.minus.com/ibwWSDZKti7oKW.png[/img][img]http://i4.minus.com/ibqtrBVmo9Fci5.png[/img]
ASM:
D123 06 xx ;ld B,xx
D125 18 4D ;jr D174
D174 18 56 ;jr D1CC
D1CC 18 56 ;jr D224
D224 18 4F ;jr D275
D275 C3 A4 D2 ;jp D2A4
D2A4 FA A3 D2 ;ld A,(D2A3)D2A3,1ので
D2A7 EA 36 D0 ;ld (D036),Aそ現に対ま
D2AA C9 ;ret
After meeting the requirements above, after using 5 and closing the menu, you'll encounter a Pokémon with an index number that equates to the quantity of the first item. (e.g. 190 of the first item will make you encounter Victreebel)
So if you have 190 Master Balls in that slot, you can look-up the index numbers of every Pokémon and use this as a guide to capture every Pokémon and complete the Pokédex.
[img]http://i6.minus.com/j9rGHIRUbELF.png[/img] [img]http://i2.minus.com/jBWIROWfX5CbD.png[/img]
[img]http://i5.minus.com/jkD6kgqJsA5pV.png[/img]
Video: http://youtu.be/vyt4r0GPKEo