Site cover image

🐾flag3

RAM Writer in Pokémon Gold/Silver (JP)

This is a translation of the original article:

📄Arrow icon of a page linkポケットモンスター 金・銀 バイナリエディタ

It was mostly processed by Claude 3.5 Sonnet.

The RAM Writer is the ultimate arbitrary code execution tool for first generation Pokémon games. The RAM Writer introduced here is a version ported for the second-generation games. With this writer, you can read and write any value to any memory address using this writer. You can even write and execute entire programs, making it a powerful tool for installing and playing games.

This article serves as an accompanying guide for the following video.

RAM Writer Installation Procedure

Environment

This guide only works with the Japanese versions of Pokémon Gold, and Silver. It does not work with Pokémon Crystal or non-Japanese versions. It also does not work with Pokémon Stadium 2's GB Tower or some emulators. This guide assumes starting a new game. Please refer to the following article for information on installing a binary editor in the Japanese versions of Pokémon Crystal.

📄Arrow icon of a page linkRAM Writer in Pokémon Crystal (JP)

Step 1: Progress to the National Park

  1. Set the player's name to "えてびま".
  2. If the quotient or remainder when dividing the Trainer ID by 256 is 255, restart the game.
  3. Set the day of the week to Tuesday, Thursday, or Saturday.
  4. Catch 3 wild Pokémons and deposit them, along with an Egg, into a Box.
    • From here on, we’ll refer to these 3 wild Pokémon as Wild 1, Wild 2, Wild 3.
  5. Receive the Lure Ball from Kurt.
  6. Enter the Goldenrod City Pokémon Center.
    • This is necessary to set Goldenrod City as a Teleport destination.
  7. Obtain the Bicycle and register it to the Select button.
  8. Obtain an Abra.
    • You can catch it in the wild or get it from the Goldenrod Game Corner. If getting it from the Game Corner, you’ll need to obtain the Coin Case in the Underground Path.
  9. Obtain "ひきゃく" (Spearow).

Step 2: Obtaining a bad clone

  1. Have at least 2 Pokémon in your party, with Abra as the first party Pokémon. Participate in the Bug-Catching Contest.
  2. After starting the bug-catching contest, turn around immediately and head back into the building. You’ll be asked if you want to quit the contest. Select "いいえ" and reenter the National Park.
  3. Teleport to Goldenrod City.
  4. Deposit all Pokémon except Abra. Return to the National Park and end the Bug-Catching Contest.
  5. You will obtain a Level 0 Pokémon to your party that looks similar to the Pokémon you previously had in the second party slot.
  6. Deposit a Level 0 Pokémon in the Day Care, then immediately retrieve it.

Step 3: Obtaining a Second Bicycle

  1. Get TM48 from the Goldenrod Department Store and teach Fire Punch to Abra.
  2. Withdraw Wild 1, Wild 2, "ひきゃく" (Spearow), and the Egg from the Box, and arrange your party in this order:
    🐭
    Bad Clone

    Abra

    Wild 1

    Wild 2

    "ひきゃく" (Spearow)

    Egg

  3. From the PC, select "ボックスせいり/メールはずしてね" and add Wild 3 to the front of your party.
  4. Switch the 2nd Pokémon in your party (Bad Clone) with the 5th (Wild 2).
  5. From the PC, select "ポケモンをあずける" and deposit the top two Pokémons from your party. Then withdraw the starter Pokémon in the Box.
  6. Abra will be holding a bicycle. Take this held item to add it to the bottom of the Key Item list.

Step 4: Arbitrary Code Execution Setup

  1. Switch "ひきゃく" (Spearow) with the starter Pokémon and arrange your party in this order:
    🐭
    Abra

    Wild 1

    Bad Clone

    Starter

    "ひきゃく" (Egg)

    "ひきゃく" (Spearow)

  2. Open the Ball pocket and set the 1st slot to Lure Ball ×1, and the 2nd slot to Poké Ball. Set the number of Poké Balls to 1, 2, 4, or 5.
  3. Open the Key Items pocket, press Select on the first Bicycle, then press Select on the second Bicycle to swap them.
  4. The 2nd Ball in the Ball pocket will become 255. Toss balls until 17 remain.
  5. Swap the 2nd and 65th items in the Ball pocket.
    • The 64th-67th items in the Ball pocket should look like this, which can be used as a reference:
      🔍
      64th item in Ball pocket: ? ×??

      65th item in Ball pocket: ? ×0

      66th item in Ball pocket: ? ×129

      67th item in Ball pocket: Bicycle

  6. If the "ポケギア" disappears from the menu, the arbitrary code execution environment setup is complete.

Step 5: Simplified RAM Writer Setup

Change the Box names as follows:

📦
Box 1: ダだギョにヂだゾ

Box 2: ダだゲムよダだガ

Box 3: だじダムキづごぱ

Box 4: ヅまてへぎまぴよ

Box 5: へぎまボぷへぎま

Box 6: へォひひ はァリ

Box 7: どダれはリダだや

Box 8: ざダれ?よダリ

Box 9: だかがよぜ?だを

After changing the Box names, give a Pokémon the following Mail:

✉️
へロどて6リなひだへぜまちぼダメ
に0ぞ?ムぞボデのよなゥゅリだっ

After creating the Mail, read its contents. Then you can start the simplified RAM Writer by opening the Pokédex.

Simplified RAM Writer

From now on, you can start the simplified RAM Writer each time you read the above Mail and then open the Pokédex.

Image in a image block

D6E6 on the left is the memory address being written to, and 00 on the right is its content. Note that the display of A, B, and C is abnormal in this simplified RAM Writer. A is g, B is a horizontal line, and C is a phone icon.

🎮
Simplified RAM Writer Controls

B: Address -01

A: Address +01

↑: Value -01

↓: Value +01

←: Value -10

→: Value +10

START: Exit

SELECT: Execute code from D6E6 (be careful not to press this before entering a program)

Step 6: RAM Writer Setup

Use the simplified RAM Writer to input the RAM Writer program. Once input is complete, you can start the RAM Writer by pressing the Select button. It is recommended to press the Start button to exit the simplified RAM Writer and save before starting the RAM Writer.

AddressValue
D6E6CD
D6E7A8
D6E834
D6E9CD
D6EAAE
D6EB33
D6ECCD
D6ED87
D6EE0D
D6EFCD
D6F095
D6F10D
D6F211
D6F3F2
D6F440
D6F521
D6F600
D6F796
D6F801
D6F919
D6FA3E
D6FBCD
D6FC5B
D6FD0E
D6FEF0
D6FF9F
D700F5
D70121
D70200
D703D0
D704CD
D70542
D706D7
D707E5
D70811
D709F8
D70AFF
D70B19
D70CE5
D70DD1
D70E21
D70FA9
D710C3
D711F0
D7129F
D713CD
D7149D
D71530
D716CD
D7178B
D718D7
D71901
D71A0C
D71B00
D71C36
D71D7C
D71E23
D71F7A
D720CD
D7218B
D722D7
D7237B
D724CD
D7258B
D726D7
D72736
D7287F
D72923
D72A1A
D72BCD
D72C8B
D72DD7
D72E13
D72F36
D7307C
D73109
D7327C
D733FE
D734C6
D73520
D736E5
D737CD
D738AD
D73930
D73A3E
D73BED
D73CEA
D73D4B
D73EC4
D73FE1
D74018
D741C2
D742CD
D743F4
D74436
D745F0
D746AB
D7475F
D74801
D74901
D74A00
D74B07
D74C38
D74D18
D74E0B
D74F0B
D75007
D75138
D75213
D7530E
D754F0
D75507
D75638
D7570E
D75801
D75910
D75A00
D75B07
D75C38
D75D08
D75E48
D75F07
D76030
D76104
D762E1
D763F1
D764D7
D765C9
D7667B
D7670F
D76830
D76910
D76A0F
D76B0F
D76C30
D76D01
D76EE9
D76FF0
D7709F
D771CD
D7729D
D77330
D77479
D77586
D77677
D777C3
D778AD
D77930
D77A0F
D77B38
D77C05
D77D0F
D77E38
D77F06
D78009
D781C9
D78279
D78384
D78467
D785C9
D786F0
D7879F
D78881
D789D7
D78AC9
D78BF5
D78CCB
D78D37
D78ECD
D78F92
D790D7
D791F1
D792E6
D7930F
D794C6
D795F6
D796F6
D79760
D79822
D799C9

RAM Writer

From now on, you can start the RAM Writer each time you start the simplified RAM Writer and press the Select button.

Image in a image block

The 10 on the top of the screen is the current ROM bank and SRAM bank.

🎮
RAM Writer Controls

↑: Address -01

↓: Address +01

←: Address -10

→: Address +10

B+↑: Address -100

B+↓: Address +100

B+←: Address -1000

B+→: Address +1000

A+↑: Value -01

A+↓: Value +01

A+←: Value -10

A+→: Value +10

START: Exit

SELECT+↑: Bank -01

SELECT+↓: Bank +01

SELECT+←: Bank -10

SELECT+→: Bank +10

SELECT+A: Execute code from the current address (use with caution)

Use the RAM Writer to change the contents of addresses D418-D41A and DD90-DD9B as follows:

AddressValue
D418C3
D419E6
D41AD6
DD903E
DD91E1
DD92EA
DD93FC
DD94CF
DD953E
DD9603
DD9721
DD9831
DD9956
DD9ACF
DD9BC9

After changing, put the cursor on address DD90 and press SELECT+A to obtain TM33 in the key items pocket. Each time you use this TM33, you can directly start the RAM Writer.

Image in a image block

Step 7: Restoring to Normal State

Various side effects occur from the RAM Writer setup.

  • Player's name
  • Ball pocket
  • PC Items
  • Pokégear
  • Pokédex
  • Box names
  • Party Pokémon
Player's Name

Set the ROM bank to 01, move the cursor to address 6237, and press SELECT+A to set the player's name. After naming, press the START button once to exit the RAM Writer.

Ball Pocket

Set the contents of addresses D5EF to D5F4 to 02 A0 01 05 02 FF to normalize the Ball pocket.

PC Items

Set the content of address D60A to FF to restore the PC Items section.

Pokégear

Move the content of address D66D to address D66F and set the content of address D670 to 00 to restore it.

Pokédex

Set the content of address D671 to 00 to normalize the Pokédex.

Box Names

After setting up the RAM Writer with TM33, you can change Box names as you like.

Set the ROM bank to 01, move the cursor to address 5D16, and press SELECT+A to reset Box names to their defaults.

Party Pokémon

Set your first Pokémon as the party leader, set the content of address D9E8 to 01, and set the content of address D9EA to FF to make your party consist of only your first Pokémon.

OT Name

Use the RAM Writer to change the contents of addresses DDA0-DDAB as follows:

AddressValue
DDA001
DDA106
DDA200
DDA311
DDA410
DDA5DB
DDA621
DDA7B5
DDA8D1
DDA9C3
DDAAD6
DDAB30

After changing, move the cursor to address DDA0 and press SELECT+A to change the OT name of your first party Pokémon to the protagonist's name.

Reacquiring Egg, Abra, and Spearow

Use the RAM Writer to change the contents of addresses DDB0-DDCE as follows:

AddressValue
DDB03E
DDB122
DDB221
DDB3B8
DDB4DD
DDB5C3
DDB6F5
DDB726
DDB847
DDB92E
DDBAAF
DDBB05
DDBC2D
DDBD3F
DDBE0A
DDBF00
DDC000
DDC12D
DDC215
DDC30A
DDC400
DDC501
DDC649
DDC76E
DDC84E
DDC96E
DDCA2F
DDCB2C
DDCC6E
DDCD49
DDCE90

After changing, move the cursor to address DDB0, press SELECT+A, then close the menu to obtain a Togepi Egg, Abra, and Spearow.

Usage Guide

Once you have installed a RAM Writer, see the following article to learn how to use it.

📄Arrow icon of a page linkRAM Writer Usage Guide in Pokémon Gold/Silver/Crystal (JP)

Precautions

Do not edit addresses D418-D41A, and D6E6-D799 with the RAM Writer.

Speedrun Guide (only available in Japanese)

I will not translate this part into English.

Technical Notes

Ball Pocket Swap Operation

The address corresponding to the 65th Ball pocket item is as follows:

NumberItem IDQuantity
65D670D671

Address D671 stores the Pokédex mode. By setting the second Ball to 17 and then swapping the 2nd and 65th items in the Ball pocket, we can set address D671 to 11 (in hexadecimal). Setting the Pokédex mode to 11 and opening the Pokédex allows execution of address FB20.

Simplified RAM Writer

Explanation

Opening the Pokédex with mode 11 executes address FB20. Addresses CF21 to CF41 store the contents of the last viewed Mail, so by reading a Mail and then opening the Pokédex, you can start the simplified RAM Writer.

When executing address FB20, register a contains 20, and register hl contains FB20. So when executing address CF3D, a register contains 36, and the content of address D8E1 becomes 36.

The simplified RAM Writer is a program that outputs the address pointed to by the hl register and its contents. It changes the address pointed to by the hl register and its contents based on key inputs.

WRA0:CF21 CD A8 34         call 34A8
WRA0:CF24 C3 FC D8         jp   D8FC
WRA0:CF27 C5               push bc
WRA0:CF28 CB 30            swap b
WRA0:CF2A CD 2E CF         call CF2E
WRA0:CF2D C1               pop  bc
WRA0:CF2E 3E 0F            ld   a,0F
WRA0:CF30 A0               and  b
WRA0:CF31 4E               ld   c,(hl)
WRA0:CF32 C6 F6            add  a,F6
WRA0:CF34 2F               cpl  
WRA0:CF35 E6 9F            and  a,9F
WRA0:CF37 2F               cpl  
WRA0:CF38 1C               inc  e
WRA0:CF39 12               ld   (de),a
WRA0:CF3A C9               ret  
WRA0:CF3B D6 C5            sub  a,C5
WRA0:CF3D EA E1 D8         ld   (D8E1),a
WRA0:CF40 30 DF            jr   nc,CF21

WRA1:D8B2 0F               rrca 
WRA1:D8B3 30 06            jr   nc,D8BB
WRA1:D8B5 AF               xor  a
WRA1:D8B6 C6 10            add  a,10
WRA1:D8B8 30 0E            jr   nc,D8C8
WRA1:D8BA 50               ld   d,b
WRA1:D8BB 0F               rrca 
WRA1:D8BC 30 08            jr   nc,D8C6
WRA1:D8BE 9F               sbc  a
WRA1:D8BF D6 0F            sub  a,0F
WRA1:D8C1 30 05            jr   nc,D8C8
WRA1:D8C3 50               ld   d,b
WRA1:D8C4 30 2C            jr   nc,D8F2
WRA1:D8C6 0F               rrca 
WRA1:D8C7 9F               sbc  a
WRA1:D8C8 86               add  (hl)
WRA1:D8C9 32               ldd  (hl),a
WRA1:D8CA 2A               ldi  a,(hl)
WRA1:D8CB 44               ld   b,h
WRA1:D8CC 50               ld   d,b
WRA1:D8CD 11 CF C3         ld   de,C3CF
WRA1:D8D0 CD 27 CF         call CF27
WRA1:D8D3 45               ld   b,l
WRA1:D8D4 D6 50            sub  a,50
WRA1:D8D6 CD 27 CF         call CF27
WRA1:D8D9 1C               inc  e
WRA1:D8DA 46               ld   b,(hl)
WRA1:D8DB CD 27 CF         call CF27
WRA1:D8DE 50               ld   d,b
WRA1:D8DF CD F4 CB         call CBF4
WRA1:D8E2 CB 7F            bit  7,a
WRA1:D8E4 CA E9 D8         jp   z,D8E9
WRA1:D8E7 50               ld   d,b
WRA1:D8E8 34               inc  (hl)
WRA1:D8E9 0F               rrca 
WRA1:D8EA DA CA D8         jp   c,D8CA
WRA1:D8ED 0F               rrca 
WRA1:D8EE 30 D4            jr   nc,D8C4
WRA1:D8F0 50               ld   d,b
WRA1:D8F1 2B               dec  hl
WRA1:D8F2 0F               rrca 
WRA1:D8F3 DA E6 D6         jp   c,D6E6
WRA1:D8F6 0F               rrca 
WRA1:D8F7 D8               ret  c
WRA1:D8F8 50               ld   d,b
WRA1:D8F9 00               nop  
WRA1:D8FA 30 B6            jr   nc,D8B2
WRA1:D8FC 26 D6            ld   h,D6
WRA1:D8FE 2E E6            ld   l,E6
WRA1:D900 30 DD            jr   nc,D8DF
WRA1:D902 50               ld   d,b

ECH1:FB20 64               ld   h,h
ECH1:FB21 00               nop  
ECH1:FB22 B4               or   h
ECH1:FB23 C3 3B CF         jp   CF3B
Binary
CF21:
CD A8 34 C3 FC D8 C5 CB 30 CD 2E CF C1 3E 0F A0 4E
C6 F6 2F E6 9F 2F 1C 12 C9 D6 C5 EA E1 D8 30 DF

D8B2:
0F 30 06 AF C6 10 30 0E 50
0F 30 08 9F D6 0F 30 05 50
30 2C 0F 9F 86 32 2A 44 50
11 CF C3 CD 27 CF 45 D6 50
CD 27 CF 1C 46 CD 27 CF 50
CD F4 CB CB 7F CA E9 D8 50
34 0F DA CA D8 0F 30 D4 50
2B 0F DA E6 D6 0F D8 50 00
30 B6 26 D6 2E E6 30 DD 50

FB20:
64 00 B4 C3 3B CF

RAM Writer

Explanation

The RAM Writer program outputs 18 addresses including the one pointed to by the hl register and their contents. It also displays the ROM bank and SRAM bank at the top of the screen to make them easy to change. You can start the RAM Writer by executing address D6E6.

WRA1:D6E6 CD A8 34         call 34A8
WRA1:D6E9 CD AE 33         call 33AE
WRA1:D6EC CD 87 0D         call 0D87
WRA1:D6EF CD 95 0D         call 0D95
WRA1:D6F2 11 F2 40         ld   de,40F2
WRA1:D6F5 21 00 96         ld   hl,9600
WRA1:D6F8 01 19 3E         ld   bc,3E19
WRA1:D6FB CD 5B 0E         call 0E5B
WRA1:D6FE F0 9F            ld   a,(ff00+9F)
WRA1:D700 F5               push af
WRA1:D701 21 00 D0         ld   hl,D000
WRA1:D704 CD 42 D7         call D742
WRA1:D707 E5               push hl
WRA1:D708 11 F8 FF         ld   de,FFF8
WRA1:D70B 19               add  hl,de
WRA1:D70C E5               push hl
WRA1:D70D D1               pop  de
WRA1:D70E 21 A9 C3         ld   hl,C3A9
WRA1:D711 F0 9F            ld   a,(ff00+9F)
WRA1:D713 CD 9D 30         call 309D
WRA1:D716 CD 8B D7         call D78B
WRA1:D719 01 0C 00         ld   bc,000C
WRA1:D71C 36 7C            ld   (hl),7C
WRA1:D71E 23               inc  hl
WRA1:D71F 7A               ld   a,d
WRA1:D720 CD 8B D7         call D78B
WRA1:D723 7B               ld   a,e
WRA1:D724 CD 8B D7         call D78B
WRA1:D727 36 7F            ld   (hl),7F
WRA1:D729 23               inc  hl
WRA1:D72A 1A               ld   a,(de)
WRA1:D72B CD 8B D7         call D78B
WRA1:D72E 13               inc  de
WRA1:D72F 36 7C            ld   (hl),7C
WRA1:D731 09               add  hl,bc
WRA1:D732 7C               ld   a,h
WRA1:D733 FE C6            cp   a,C6
WRA1:D735 20 E5            jr   nz,D71C
WRA1:D737 CD AD 30         call 30AD
WRA1:D73A 3E ED            ld   a,ED
WRA1:D73C EA 4B C4         ld   (C44B),a
WRA1:D73F E1               pop  hl
WRA1:D740 18 C2            jr   D704
WRA1:D742 CD F4 36         call 36F4
WRA1:D745 F0 AB            ld   a,(ff00+AB)
WRA1:D747 5F               ld   e,a
WRA1:D748 01 01 00         ld   bc,0001
WRA1:D74B 07               rlca 
WRA1:D74C 38 18            jr   c,D766
WRA1:D74E 0B               dec  bc
WRA1:D74F 0B               dec  bc
WRA1:D750 07               rlca 
WRA1:D751 38 13            jr   c,D766
WRA1:D753 0E F0            ld   c,F0
WRA1:D755 07               rlca 
WRA1:D756 38 0E            jr   c,D766
WRA1:D758 01 10 00         ld   bc,0010
WRA1:D75B 07               rlca 
WRA1:D75C 38 08            jr   c,D766
WRA1:D75E 48               ld   c,b
WRA1:D75F 07               rlca 
WRA1:D760 30 04            jr   nc,D766
WRA1:D762 E1               pop  hl
WRA1:D763 F1               pop  af
WRA1:D764 D7               rst  10
WRA1:D765 C9               ret  
WRA1:D766 7B               ld   a,e
WRA1:D767 0F               rrca 
WRA1:D768 30 10            jr   nc,D77A
WRA1:D76A 0F               rrca 
WRA1:D76B 0F               rrca 
WRA1:D76C 30 01            jr   nc,D76F
WRA1:D76E E9               jp   hl
WRA1:D76F F0 9F            ld   a,(ff00+9F)
WRA1:D771 CD 9D 30         call 309D
WRA1:D774 79               ld   a,c
WRA1:D775 86               add  (hl)
WRA1:D776 77               ld   (hl),a
WRA1:D777 C3 AD 30         jp   30AD
WRA1:D77A 0F               rrca 
WRA1:D77B 38 05            jr   c,D782
WRA1:D77D 0F               rrca 
WRA1:D77E 38 06            jr   c,D786
WRA1:D780 09               add  hl,bc
WRA1:D781 C9               ret  
WRA1:D782 79               ld   a,c
WRA1:D783 84               add  h
WRA1:D784 67               ld   h,a
WRA1:D785 C9               ret  
WRA1:D786 F0 9F            ld   a,(ff00+9F)
WRA1:D788 81               add  c
WRA1:D789 D7               rst  10
WRA1:D78A C9               ret  
WRA1:D78B F5               push af
WRA1:D78C CB 37            swap a
WRA1:D78E CD 92 D7         call D792
WRA1:D791 F1               pop  af
WRA1:D792 E6 0F            and  a,0F
WRA1:D794 C6 F6            add  a,F6
WRA1:D796 F6 60            or   a,60
WRA1:D798 22               ldi  (hl),a
WRA1:D799 C9               ret  
Binary
                  CD A8 34 CD AE 33 CD 87 0D CD
95 0D 11 F2 40 21 00 96 01 19 3E CD 5B 0E F0 9F
F5 21 00 D0 CD 42 D7 E5 11 F8 FF 19 E5 D1 21 A9
C3 F0 9F CD 9D 30 CD 8B D7 01 0C 00 36 7C 23 7A
CD 8B D7 7B CD 8B D7 36 7F 23 1A CD 8B D7 13 36
7C 09 7C FE C6 20 E5 CD AD 30 3E ED EA 4B C4 E1
18 C2 CD F4 36 F0 AB 5F 01 01 00 07 38 18 0B 0B
07 38 13 0E F0 07 38 0E 01 10 00 07 38 08 48 07
30 04 E1 F1 D7 C9 7B 0F 30 10 0F 0F 30 01 E9 F0
9F CD 9D 30 79 86 77 C3 AD 30 0F 38 05 0F 38 06
09 C9 79 84 67 C9 F0 9F 81 D7 C9 F5 CB 37 CD 92
D7 F1 E6 0F C6 F6 F6 60 22 C9

TM33 in Key Items Pocket

Explanation

By executing address 5631 in ROM bank 03, you can obtain the item corresponding to the content of address CFFC in the key items pocket.

By using TM33 outside the TM pocket, it executes address F418. We have written a jump instruction to D6E6 at address F418, which allows us to start the RAM Writer.

WRA1:DD90 3E E1            ld   a,E1
WRA1:DD92 EA FC CF         ld   (CFFC),a
WRA1:DD95 3E 03            ld   a,03
WRA1:DD97 21 31 56         ld   hl,5631
WRA1:DD9A CF               rst  08
WRA1:DD9B C9               ret  

ECH1:F418 C3 E6 D6         jp   D6E6

Program to Change the OT Name

Explanation

Executing address 30D6 copies a specified length (in the bc register) from the source address (in the hl register) to the destination address (in the de register). The 6 bytes from address D1B5 store the player's name, and address DB10 stores the OT name of the first Pokémon in the party. Therefore, executing the following program can change the OT name of the first Pokémon to the player's name.

WRA1:DDA0 01 06 00         ld   bc,0006
WRA1:DDA3 11 10 DB         ld   de,DB10
WRA1:DDA6 21 B5 D1         ld   hl,D1B5
WRA1:DDA9 C3 D6 30         jp   30D6
Binary
01 06 00 11 10 DB 21 B5 D1 C3 D6 30

Program to Reacquire Egg, Abra, and Spearow

Explanation

Executing address 26F5 allows us to run the script written from the hl address onward, using the content of the a register as the ROM bank. By setting the ROM bank to 22, we can reference data related to the "ひきゃく" (Spearow).

WRA1:DDB0 3E 22            ld   a,22
WRA1:DDB2 21 B8 DD         ld   hl,DDB8
WRA1:DDB5 C3 F5 26         jp   26F5
Script
47                          ; Script_opentext
2E AF 05                    ; Script_giveegg
2D 3F 0A 00 00              ; Script_givepoke
2D 15 0A 00 01 49 6E 4E 6E  ; Script_givepoke
2F 2C 6E                    ; Script_givepokemail
49                          ; Script_closetext
90                          ; Script_end
Binary
3E 22 21 B8 DD C3 F5 26 47 2E AF 05 2D 3F 0A 00
00 2D 15 0A 00 01 49 6E 4E 6E 2F 2C 6E 49 90

Reference

Japanese

English