Advertisement
pigdevil2010

Twinleaf Town in Pokémon Red with custom music

Apr 24th, 2015
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.67 KB | None | 0 0
  1. (Edited from Torchikens' paste: http://pastebin.com/UarVudWr)
  2.  
  3. Read description for more information:
  4. https://www.youtube.com/watch?v=F7TS-a2a26s
  5. https://www.youtube.com/watch?v=ddSHGg4-qSY
  6. I made two new 8F programs that turn Pallet Town into a devamped version of Twinleaf Town from Pokémon Diamond and Pearl!
  7.  
  8. Like TheZZAZZGlitch's Pokémon pong, although this takes time to set up, you can pull this off without a GameShark or an emulator's memory editor if you have the patience to do so. To set everything up, I used a slightly altered version of TheZZAZZGlitch's method for writing programs up to 254 bytes long (https://www.youtube.com/watch?v=D3EvpRHL_vk).
  9.  
  10. Summary:
  11. ----
  12. My code is stored from DC01-DCF0 (program 1) and from DD01-DED4 (program 2).
  13.  
  14. 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.
  15.  
  16. Once the code is executed, Pallet Town's 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.
  17.  
  18. Program 1 (240 bytes) changes Pallet Town into basically this map (http://i.minus.com/iTZQ884Oe5f79.png, created with a tool called Pokemap) (but I made some minor changes to the top section, I will post a better map soon) 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.
  19.  
  20. Program 2 (112 bytes) adds custom text to the sign, adjusts the map's warps/gives all four doors a suitable warp and adds a remix of Twinleaf Town theme from Pokemon DPPt (although it was a shorter version due to memory limit). To add the custom text, I set the sign coordinates/number of signs by adjusting D4B0 onward. The number of signs was set to 05, and I added coordinates for sign 05, a glitch sign that doesn't normally exist. Sign 05 gets its text data from CA01; so I make the program write 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 four 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.
  21.  
  22. To adjust the warps, I modified D3AE (number of warps) to 04 then the bytes that follow it that control the coordinates of warps and where they go.
  23.  
  24. My warps: Rival's house (top-left), Hall of Fame (top-right), Oak's Lab (bottom-left), Your house (bottom-right)
  25.  
  26. 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.
  27. --
  28. Setting things up:
  29. --
  30.  
  31. 1) Get 8F. One way is to use dry underflow (https://www.youtube.com/watch?v=ZyppANEvnh8) and the looping map trick to get 8F. (here is an 8F creation spot after Celadon City loops http://i2.minus.com/ikRWiyNP77Gap.png).
  32.  
  33. Another way is to use a double distort CoolTrainer (https://www.youtube.com/watch?v=aqy9QSbn1to) with a Good Rod in the fourth position using x (multiplication sign), however, CoolTrainer has to work on your save and I only really know about the 7 letter long name method yet.
  34.  
  35. 2) Get specific Pokémon in your party to redirect the code to item 3. They are needed for your code to work. (e.g. http://forums.glitchcity.info/index.php/topic,6638.msg194471.html#msg194471)
  36.  
  37. 3) A modified version of TheZZAZZGlitch's 'jailbreak' trick to turn Pokémon Red into Pong:
  38.  
  39. Prepare the following items from item 1:
  40. Max Repel x99 (optional but recommended)
  41. 8F x(any)
  42. X Accuracy, x97
  43. Burn Heal, x126
  44. Parlyz Heal, x15
  45. HP UP, x15
  46. Ice Heal, x15
  47. Potion, x134
  48. TM34, x20
  49. TM20, x46
  50. Leaf Stone, x52
  51. Great Ball, x201
  52. TM10, x1
  53. TM15, x46
  54. TM21 x46 (if you want to execute program 2 later to get warps and the sign to work)
  55.  
  56. 4) Swap TM20 x46 with TM15 x46, use 8F and jump off a ledge to walk through walls.
  57. 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.
  58.  
  59. 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. Currently, you'll probably need a memory viewer to keep track of what spots have which coordinates. I will make a map that tells you the coordinates of spots.
  60.  
  61. Data:
  62. Raw code:
  63. C3DFDC0F0F0F0F0F0F7B7B0F0F0F0F0F
  64. 0F0F0F0F0F0F0F0F0F7B7B0F0F0F0F0F
  65. 0F0F0F0F0F0F0F0F0F0A0A0F0F0F0F0F
  66. 0F0F0F0F0F0F0C0E0A0A0A0A0A0A0F0F
  67. 0F0F0F0F0F0F10120A7B7B0A02030F0F
  68. 0F0F0F0F0F0F0A7B7B7B797B7B0A0F0F
  69. 0F0F0F0F0F0F74740A7B7B0A74740F0F
  70. 0F0F0F0F0F0F0A0A0A7B7B0A0C0E0F0F
  71. 0F0F0F0F0F0F02030A7B7B0A10120F0F
  72. 0F0F0F0F0F0F0A7B7B7B7B7B7B0A0F0F
  73. 0F0F0F0F0F0F0F0F1D1F1F1E0F0F0F0F
  74. 0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
  75. 0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
  76. 0F01CE002104DC11F9C6CDB500C9010D
  77. 0021D2DC113EDBCDB5003E15EAF1D5C9
  78.  
  79. ASM (Program 1):
  80. jp DCDF
  81. db 0F0F0F0F0F0F7B7B0F0F0F0F0F
  82. 0F0F0F0F0F0F0F0F0F7B7B0F0F0F0F0F
  83. 0F0F0F0F0F0F0F0F0F0A0A0F0F0F0F0F
  84. 0F0F0F0F0F0F0C0E0A0A0A0A0A0A0F0F
  85. 0F0F0F0F0F0F10120A7B7B0A02030F0F
  86. 0F0F0F0F0F0F0A7B7B7B797B7B0A0F0F
  87. 0F0F0F0F0F0F74740A7B7B0A74740F0F
  88. 0F0F0F0F0F0F0A0A0A7B7B0A0C0E0F0F
  89. 0F0F0F0F0F0F02030A7B7B0A10120F0F
  90. 0F0F0F0F0F0F0A7B7B7B7B7B7B0A0F0F
  91. 0F0F0F0F0F0F0F0F1D1F1F1E0F0F0F0F
  92. 0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
  93. 0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
  94. 0F ["Twinleaf Town" 4x4 blocks]
  95. ld bc,000D
  96. ld hl,DCD2
  97. ld de,DB3E
  98. call 00B5
  99. ld a,15
  100. ld (D5F1),a
  101. ret
  102.  
  103. 7) Swap TM10 x1 with TM34 and use 8F to execute your code.
  104.  
  105. 8) Congratulations, program 1 (map layout into Twinleaf Town) is complete.
  106.  
  107. 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.
  108.  
  109. 10) Swap TM21 x46 with TM15 x46, use 8F and jump off a ledge to walk through walls.
  110.  
  111. 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.
  112.  
  113. 12) Write the following data ("Program 2").
  114.  
  115. Raw code:
  116. C380DD05FFFFFFFFFFFFFFFF070B0093
  117. B6A8ADABA4A0A57F93AEB6AD4E85B1A4
  118. B2A77FA0ADA37F85B1A4A4E757040504
  119. 0027050F00760D0300280D100025010B
  120. 002104DD11B0D4CDB500011F00210FDD
  121. 1101CACDB500011100212EDD11AED3CD
  122. B500FA0BC0FEDEC8010600218CDD1106
  123. C0CDB5003E0101030021B6C0C3E03601
  124. 4100213FDD114ADBC3B50092DD12DE87
  125. DEED0078EC01DCD6E577E407E5B3E407
  126. 2347E58397AB97E42713274357E55377
  127. 8BE42707E573E40BE5B797E427334B57
  128. E597E407E5B7E407E59787DCD473E403
  129. E5B3E4072343E57396E43023073BE573
  130. E403E5B3E407234373E306302307DCD6
  131. E553432307E673E507270BE673E527
  132.  
  133. 13) When you finish writing the data (TM34's count should be x0), swap TM21 x46 with TM22 x46 so you begin writing from DE00 onward instead of DD00. Then write the following data.
  134.  
  135. Raw code:
  136. 07E67397E5079757E6B7E527B797FE00
  137. 92DDEC02DCC3C3FE2116DEE67373E507
  138. E673E50BE693E50BE6839B5393E507E6
  139. 63E52B270703E6B3E523477397E40BE5
  140. 376397E69BE5477397E403E5734303E4
  141. 03E543A74373A39FE303E473534BC773
  142. 432303E34702E4925103E593925201E6
  143. B2E52201E671E501215171E401215172
  144. E30221FE0012DEDC14E60B4B479B7B77
  145. 2B1B170BE7BBB7E60F4B839F8F2F6F7F
  146. 7F05E503CFE601E501E60135E533CFE6
  147. 31E531E63105E503CFE601E501E60175
  148. E573CFE601E501E6015F5F4F4F2F2F7F
  149. 7FFE0087DE
  150.  
  151. ASM (Program 2):
  152. jp DD80
  153. db 05FFFFFFFFFFFFFFFF070B [# of Signs, Sign coordinates]
  154. db 0093B6A8ADABA4A0A57 [Custom text]
  155. db 0405040027050F00760D0300280D100025 [Warps]
  156. ld bc,000B
  157. ld hl,DD04
  158. ld de,D4B0
  159. call 00B5
  160. ld bc,001F
  161. ld bc,DD0F
  162. ld de,CA01
  163. call 00B5
  164. ld bc,0011
  165. ld hl,DD2E
  166. ld de,D3AE
  167. call 00B5
  168. ld a,(C00B) [Channel 3 music command position's high byte. It will always be DE when the custom music is playing]
  169. cp a,DE [DE base 16 (222), not de register!]
  170. ret z [Don't load the music again if it is already loaded]
  171. ld bc,0006
  172. ld hl,DD8C
  173. ld de,C006 [Channel 1 music command position's low byte]
  174. call 00B5
  175. ld a,01 [We need to reset music command delay in order to keep all 3 channels in sync]
  176. ld bc,0003
  177. ld hl,C0B6 [Channel 1 music command delay]
  178. jp 36E0 [FillMemory]
  179. ld bc,0041
  180. ld hl,DD3F
  181. ld de,DB4A
  182. jp 00B5
  183. dw DD92 [Start of Twinleaf Town Channel 1's music commands]
  184. dw DE12 [Start of Twinleaf Town Channel 2's music commands]
  185. dw DE87 [Start of Twinleaf Town Channel 3's music commands]
  186. db ED0078EC01DCD6E577E407E5B3E407
  187. 2347E58397AB97E42713274357E55377
  188. 8BE42707E573E40BE5B797E427334B57
  189. E597E407E5B7E407E59787DCD473E403
  190. E5B3E4072343E57396E43023073BE573
  191. E403E5B3E407234373E306302307DCD6
  192. E553432307E673E507270BE673E52707
  193. E67397E5079757E6B7E527B797FE0092
  194. DD [Twinleaf Town Channel 1's music commands]
  195. db EC02DCC3C3FE2116DEE67373E507E6
  196. 73E50BE693E50BE6839B5393E507E663
  197. E52B270703E6B3E523477397E40BE537
  198. 6397E69BE5477397E403E5734303E403
  199. E543A74373A39FE303E473534BC77343
  200. 2303E34702E4925103E593925201E6B2
  201. E52201E671E501215171E401215172E3
  202. 0221FE0012DE [Twinleaf Town Channel 2's music commands]
  203. db DC14E60B4B479B7B772B1B170BE7BB
  204. B7E60F4B839F8F2F6F7F7F05E503CFE6
  205. 01E501E60135E533CFE631E531E63105
  206. E503CFE601E501E60175E573CFE601E5
  207. 01E6015F5F4F4F2F2F7F7FFE0087DE [Twinleaf Town Channel 3's music commands]
  208.  
  209. 14) When you finished writing the data, swap TM22 x46 with TM21 x46 and swap TM10 x1 with TM34 in order to run the code at DD01. Then use 8F to execute your code.
  210.  
  211. 15) The next time you go to "Twinleaf Town", the signs, warps and music should be functionable.
  212.  
  213. Removing Twinleaf Town:
  214. 16) Set up dry underflow (https://www.youtube.com/watch?v=ZyppANEvnh8) in your item storage box, then place one of the j. x0 into item 92, which should be a Boulder Badge (probably the second one you encounter while scrolling down). If you run into long name glitch items you may need to hold down and press B a few times to get past them. This does not change the data you wrote, but will change Pallet Town's script to 00h from 15h, where no arbitrary code is executed upon entering the town.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement