Advertisement
M4n0z

Extra Scripts for BlipBlopMenu 2 or TimOS for Pokemon Red and Blue EN via Arbitrary Code Execution

Dec 17th, 2024 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. BBM2 Extras - Compatible with EN Red and Blue ONLY
  4.  
  5.  
  6. Description
  7.  
  8. Extra scripts for BlipBlopMenu 2 or TimOS. After installation TimOS scripts are incresed by five having the following effects:
  9.  
  10. #+1 ItemGiver: It gives any item, based on the selected internal ID.
  11. #+2 MonGiver: It gives any pokemon, based on the selected pokedex ID.
  12. #+3 MonEncounter: It encounters any pokemon, based on the selected pokedex ID.
  13. #+4 TrainerEncounter: It encounters any trainer, based on the selected pokedex ID.
  14. #+5 PokeDuplicator: It duplicates the pokemon in the first party slot to the second party slot.
  15.  
  16.  
  17. Prerequirements
  18. - TimoVM's gen 1 ACE setup with a clean TimOS installation from:
  19.  https://glitchcity.wiki/wiki/Guides:SRAM_Glitch_ACE_Setups_(EN)
  20.  
  21. - BlipBlopMenu 2 (optional):
  22.  https://pastebin.com/H7v1fP2s
  23.  
  24.  
  25. Instructions
  26. 1)  - Installation on actual hardware or emulator: You can use TimoVM's NicknameConverter and NicknameWriter from the given page.
  27.     - Installation on emulator with debugging features: Just copy and paste the HEX code into address $d8b4.
  28. 2) Run the code from NicknameWriter.
  29. 3) Verify new scripts are intalled and work correctly.
  30.  
  31. Warning! Scripts are stored in addresses $c8c3-$c975 inside TimOS region.
  32. Make sure you are not using this area before installation!
  33.  
  34.  
  35.  
  36. Code:
  37.  
  38. 21 e9 c6 46 3e 05 86 77 11 c2  
  39. c7 1c 1c 05 20 fb 0e 0a 21 d5  
  40. d8 cd b5 00 0e b3 11 c3 c8 c3  
  41. b5 00 db c8 24 c9 2e c9 3b c9  
  42. 5d c9 ea 97 cf cd 57 2d a7 fa  
  43. 96 cf c9 21 09 c4 11 6d cd cd  
  44. 29 38 2b 36 7f c9 cd 0f 19 3e  
  45. ff cd c3 c8 c0 f5 ea 1e d1 cd  
  46. cf 2f cd ce c8 3e 63 cd c3 c8  
  47. c1 20 e5 4f cd 2e 3e 18 df cd  
  48. 0f 19 3e 97 cd c3 c8 28 01 c9  
  49. 11 1e d1 12 06 10 21 f9 4f cd  
  50. d6 35 1a f5 cd 9e 2f cd ce c8  
  51. 3e 64 cd c3 c8 c1 20 d9 c9 cd  
  52. fc c8 c0 4f cd 48 3e 18 f6 cd  
  53. fc c8 c0 ea 2e cd fa 1e d1 c3  
  54. da 32 cd 0f 19 3e 2f cd c3 c8  
  55. c0 ea 31 d0 f5 cd 9e 35 cd ce  
  56. c8 f1 c6 c8 ea 1e d1 3e 01 cd  
  57. c3 c8 20 e0 18 d5 21 64 d1 2a  
  58. 77 01 2c 00 11 97 d1 2e 6b cd  
  59. b5 00 11 b5 d2 21 c0 d2 c3 29  
  60. 38  
  61.  
  62. Total Bytes: 221
  63.  
  64.  
  65.  
  66.  
  67.  
  68. Source is compiled with RGBDS
  69.  
  70. */
  71.  
  72.  
  73. SECTION "BlipBlopMenu2ExtrasRB", ROM0
  74.  
  75. start:
  76.  
  77. ; ----------- Installer payload ------------
  78.  
  79. ; increse no of scripts by 5
  80. ld hl, $c6e9
  81. ld b, [hl]
  82. ld a, $05
  83. add a, [hl]
  84. ld [hl], a
  85.  
  86. ; write pointers to the correct position
  87. ld de, $c7c2        ; destination - script #1
  88. .pointerloop
  89. inc e
  90. inc e
  91. dec b
  92. jr nz, .pointerloop
  93.  
  94. ; Copy pointers
  95. ld c, 10            ; 10 bytes: b = 0 from previous operation
  96. ld hl, $d8d5        ; origin
  97. call $00b5          ; CopyData
  98.  
  99. ; Copy payloads
  100. ld c, $b3           ; 179 bytes
  101. ld de, $c8c3        ; destination
  102. jp $00b5            ; CopyData
  103.  
  104.  
  105. ; ----------- Payload pointers ------------
  106.  
  107. db $db, $c8, $24, $c9, $2e, $c9, $3b, $c9, $5d, $c9
  108.  
  109.  
  110. selector:           ; 11 bytes - common function
  111. ld [$cf97], a       ; wMaxItemQuantity write
  112. call $2d57          ; DisplayChooseQuantityMenu
  113. and a, a            ; if a is 0, z flag is set
  114. ld a, [$cf96]       ; wItemQuantity read
  115. ret
  116.  
  117. copyname:           ; 13 bytes - common function
  118. ld hl, $c409        ; destination
  119. ld de, $cd6d        ; origin - wNameBuffer
  120. call $3829          ; CopyString
  121. dec hl
  122. ld [hl], $7f        ; blank last name byte
  123. ret
  124.  
  125. itemgiver:          ; 33 bytes
  126. call $190f          ; ClearScreen
  127. ld a, 255           ; total item IDs
  128. call $c8c3          ; .selector
  129. ret nz              ; if B pressed, then ret
  130. push af
  131. ld [$d11e], a       ; wPokedexNum
  132. call $2fcf          ; GetItemName
  133. call $c8ce          ; .copyname
  134. ld a, 99
  135. call $c8c3          ; .selector
  136. pop bc
  137. jr nz, itemgiver    ; if B pressed go to the beginning, ln0
  138. ld c, a             ; bc = id, quantity
  139. call $3e2e          ; GiveItem
  140. jr itemgiver        ; jp to start, ln0
  141.  
  142. pokecommon:         ; 41 bytes - common function
  143. call $190f          ; ClearScreen
  144. ld a, 151           ; total species IDs
  145. call $c8c3          ; .selector
  146. jr z, .continue     ; if B pressed, then ret
  147. ret
  148. .continue
  149. ld de, $d11e        ; wPokedexNum
  150. ld [de], a          ; pokemon id is stored in wPokedexNum
  151. ld b, $10           ; select bank 16
  152. ld hl, $4ff9        ; PokedexToIndex
  153. call $35d6          ; Bankswitch
  154. ld a, [de]          ; wPokedexNum
  155. push af
  156. call $2f9e          ; GetMonName
  157. call $c8ce          ; .copyname
  158. ld a, 100
  159. call $c8c3          ; .selector
  160. pop bc
  161. jr nz, pokecommon       ; if B pressed go to the beginning, ln0
  162. ret
  163.  
  164. dexgiver:           ; 10 bytes
  165. call $c8fc          ; .pokecommon
  166. ret nz
  167. ld c, a             ; bc = id, level
  168. call $3e48          ; GivePokemon
  169. jr dexgiver         ; jp to start, ln0
  170.  
  171.  
  172. letsgetwild:        ; 5 bytes
  173. call $c8fc          ; .pokecommon
  174. ret nz
  175. encounter:          ; 9 bytes - common function
  176. ld [$cd2e], a       ; wEnemyMonAttackMod - [wCurEnemyLevel]/[wTrainerNo]
  177. ld a, [$d11e]       ; wPokedexNum - pokemon/trainer id
  178. jp $32da            ; InitBattleEnemyParameters+$03
  179.  
  180.  
  181. hitrainer:          ; 34 bytes
  182. call $190f          ; ClearScreen
  183. ld a, 47            ; total encounter IDs
  184. call $c8c3          ; .selector
  185. ret nz              ; if B pressed, then ret
  186. ld [$d031], a       ; wTrainerClass
  187. push af
  188. call $359e          ; GetTrainerName
  189. call $c8ce          ; .copyname
  190. pop af
  191. add a, $c8
  192. ld [$d11e], a       ; id is stored in wNamedObjectIndex
  193. ld a, 01
  194. call $c8c3          ; .selector
  195. jr nz, hitrainer    ; if B pressed go to the beginning, ln0
  196. jr encounter
  197.  
  198.  
  199. duplicator:         ; 25 bytes
  200. ; transfer pokemon id
  201. ld hl, $d164        ; poke 1 id
  202. ld a, [hli]
  203. ld [hl], a          ; hl = $d165
  204. ; transfer pokemon data
  205. ld bc, $002c        ; poke data length
  206. ld de, $d197        ; poke 2 data
  207. ld l, $6b           ; poke 1 data
  208. call $00b5          ; CopyData
  209. ; transfer pokemon nickname
  210. ld de, $d2b5        ; poke 1 nickname
  211. ld hl, $d2c0        ; poke 2 nickname
  212. jp $3829            ; CopyString
  213.  
  214.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement