Pallet Town into Twinleaf Town conversion

From Glitch City Wiki
Jump to navigation Jump to search
"Twinleaf Town"

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.

Summary

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![57]" 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.

Setup

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)

8F x(any)

X Accuracy, x97

Burn Heal, x126

Parlyz Heal, x15

HP UP, x15

Ice Heal, x15

Potion, x134

TM34, x20

TM20, x46

Leaf Stone, x52

Great Ball, x201

TM10, x1

TM15, x46

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.

Data:

Raw code:

C3DFDC0F0F0F0F0F0F7B7B0F0F0F0F0F

0F0F0F0F0F0F0F0F0F7B7B0F0F0F0F0F

0F0F0F0F0F0F0F0F0F0A0A0F0F0F0F0F

0F0F0F0F0F0F0C0E0A0A0A0A0A0A0F0F

0F0F0F0F0F0F10120A7B7B0A02030F0F

0F0F0F0F0F0F0A7B7B7B797B7B0A0F0F

0F0F0F0F0F0F74740A7B7B0A74740F0F

0F0F0F0F0F0F0A0A0A7B7B0A0C0E0F0F

0F0F0F0F0F0F02030A7B7B0A10120F0F

0F0F0F0F0F0F0A7B7B7B7B7B7B0A0F0F

0F0F0F0F0F0F0F0F1D1F1F1E0F0F0F0F

0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F

0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F

0F01CE002104DC11F9C6CDB500C9010D

0021D2DC113EDBCDB5003E15EAF1D5C9

ASM (Program 1):

jp DCDF

db 0F0F0F0F0F0F7B7B0F0F0F0F0F

0F0F0F0F0F0F0F0F0F7B7B0F0F0F0F0F

0F0F0F0F0F0F0F0F0F0A0A0F0F0F0F0F

0F0F0F0F0F0F0C0E0A0A0A0A0A0A0F0F

0F0F0F0F0F0F10120A7B7B0A02030F0F

0F0F0F0F0F0F0A7B7B7B797B7B0A0F0F

0F0F0F0F0F0F74740A7B7B0A74740F0F

0F0F0F0F0F0F0A0A0A7B7B0A0C0E0F0F

0F0F0F0F0F0F02030A7B7B0A10120F0F

0F0F0F0F0F0F0A7B7B7B7B7B7B0A0F0F

0F0F0F0F0F0F0F0F1D1F1F1E0F0F0F0F

0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F

0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F

0F ["Twinleaf Town" 4x4 blocks]

ld bc,00CE

ld hl,DC04

ld de,C6F9

call 00B5

ret

ld bc,000D

ld hl,DCD2

ld de,DB3E

call 00B5

ld a,15

ld [D5F1],a

ret

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").

Raw code:

C364DD05FFFFFFFFFFFFFFFF070B0093

B6A8ADABA4A0A57F93AEB6AD4E85B1A4

B2A77FA0ADA37F85B1A4A4E757040504

0027050F00760D0300280D100025010B

002104DD11B0D4CDB500011F00210FDD

1101CACDB500011100212EDD11AED3CD

B500C9012500213FDD114ADBCDB500C9

ASM (Program 2):

jp DD64

db 05FFFFFFFFFFFFFFFF070B [# of Signs, Sign coordinates]

db 0093B6A8ADABA4A0A57 [Custom text]

db 0405040027050F00760D0300280D100025 [Warps]

ld bc,000B

ld hl,DD04

ld de,D4B0

call 00B5

ld bc,001F

ld hl,DD0F

ld de,CA01

call 00B5

ld bc,0011

ld hl,DD2E

ld de,D3AE

call 00B5

ret

13) The next time you go to "Twinleaf Town", the signs and warps should be functioning.

YouTube video

YouTube video by ChickasaurusGL


Attribution

  • ChickasaurusGL (concept, creation, meta-script ACE research)
  • Pokémon Red disassembly, TheZZAZZGlitch (previous meta-script documentation)