This program for Pokémon Red and Blue created by ChickasaurusGL, allows for the player to convert Pallet Town into a recreation of Twinleaf Town, complete with signs.
The program can be modified to create other maps, and can be ported to Pokémon Yellow using a different glitch meta-map script activation.
Code is stored from DC01-DCF0 (program 1) and from DD01-DD70 (program 2).
All of this data is supposed to be for data about Pokémon in the current box, so the code effectively stays there to be executed whenever you want until you change boxes or mess with a box's contents.
Once the code is executed, Pallet Town's meta-map script byte (D5F1) is set to invalid value hex:15. This tells the game to execute arbitrary code from DB3E whenever you enter Pallet Town.
Program 1 (240 bytes) changes Pallet Town into a recreation of Twinleaf Town, created with a tool called Pokemap) surrounded by some trees. This was done by modifying the 4x4 tile blocks in memory from C6F9. The program tells the game to write some data to the DB3E address, and the DB3E code copies 4x4 block addresses from DC04 into C6F9 using a 'call CopyData' with C6F9 (4x4 blocks on the screen) as the destination. In order for 8F not to execute the Twinleaf Town layout information as code, there is a jp DCDF at DC01 to jump over it.
Program 2 (112 bytes) adds custom text to the sign and adjusts the map's warps/gives all four doors a suitable warp. To add the custom text, the sign coordinates/number of signs were set by adjusting D4B0 onward. The number of signs was set to 05, and coordinates were added for sign 05, a glitch sign that doesn't normally exist. Sign 05 gets its text data from CA01; so the program writes data beginning with 00 ('print text') to CA01, followed by character bytes that read "Twinleaf Town[NL]Fresh and Free!" The program writes to DB4A (overwriting the last byte, a ret in program 1, and overwriting the data onward) with three CopyData iterations. Like in program 1, the code at DD01 jumps over the variables (warp data, sign data, sign text data) to copy before writing to DB4A and DB4A taking the data from the variables past DD01.
To adjust the warps, D3AE (number of warps) was modified to 04 then the bytes that follow it that control the coordinates of warps and where they go.
Warps: Rival's house (top-left), Hall of Fame (top-right), Oak's Lab (bottom-left), Your house (bottom-right)
When you enter Pallet Town, parts of the map may originally look unchanged. You need to move them off the screen to load Twinleaf Town.
1) Get 8F. One way is to use dry underflow glitch and the looping map glitch to get 8F.
Another way is to use a double distort CoolTrainer with a Good Rod in the fourth position using x (multiplication sign), however, CoolTrainer has to work on your save.
2) Get specific Pokémon in your party to redirect the code to item 3. They are needed for your code to work.
3) A modified version of TheZZAZZGlitch's 'jailbreak' trick to turn Pokémon Red into Pong:
Prepare the following items from item 1:
Max Repel x99 (optional but recommended)
X Accuracy, x97
Burn Heal, x126
Parlyz Heal, x15
HP UP, x15
Ice Heal, x15
Leaf Stone, x52
Great Ball, x201
TM21 x46 (if you want to execute program 2 later to get warps and the sign to work)
4) Swap TM20 x46 with TM15 x46, use 8F and jump off a ledge to walk through walls.
5) Swap TM20 and TM15 back, toss TM34 until only one of them remains. The program is now in entering mode, and upon using 8F one byte is written to DC01 onward, with its value depending on your X and Y positions (i.e. y=01, x=F is a value of 1F, y=00 x=05 is a value of 05, etc). TM34's value will increase each time you put in a byte.
6) Write the following data ("Program 1") by walking to the right position (e.g. first you need to walk to y=C x=3), preferably while using repels to avoid grass encounters. You can use a memory viewer to keep track of what spots have which coordinates. But if this is not an option, here is a map that tells you the coordinates of spots.
ASM (Program 1):
0F ["Twinleaf Town" 4x4 blocks]
7) Swap TM10 x1 with TM34 and use 8F to execute your code.
8) Congratulations, program 1 (map layout into Twinleaf Town) is complete.
9) Go back to Route 1 and set up your items like they were at the beginning (i.e. toss TM34 until you have 20). However, this time the TM21 x46 needs to be in the place of the TM20 x46, so that you begin writing at DD01 onwards instead of DC01 onward.
10) Swap TM21 x46 with TM15 x46, use 8F and jump off a ledge to walk through walls.
11) Swap TM21 and TM15 back, toss TM34 until only one of them remains. The program is now in entering mode, and upon using 8F one byte is written to DD01 onward, with its value depending on your X and Y positions (i.e. y=01, x=F is a value of 1F, y=00 x=05 is a value of 05, etc). TM34's value will increase each time you put in a byte.
12) Write the following data ("Program 2").
ASM (Program 2):
db 05FFFFFFFFFFFFFFFF070B [# of Signs, Sign coordinates]
db 0093B6A8ADABA4A0A57 [Custom text]
db 0405040027050F00760D0300280D100025 [Warps]
13) The next time you go to "Twinleaf Town", the signs and warps should be functioning.
- ChickasaurusGL (concept, creation, meta-script ACE research)
- Pokémon Red disassembly, TheZZAZZGlitch (previous meta-script documentation)