blurose

b2w2 fairy type complete

Jul 24th, 2022 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 21.94 KB | None | 0 0
  1. /*
  2.  * follow the parts of the meromero tutorial where you edit the narcs.  keep the edited ones on standby.
  3.  *
  4.  * run extract.bat
  5.  * run decompress.bat
  6.  * run makefairytype.bat
  7.  *
  8.  * open rom in tinke and "Change file" all of:
  9.  *  overlay 167
  10.  *  overlay 168
  11.  *  overlay 207
  12.  *  overlay 255
  13.  *  overlay 265
  14.  *  arm9
  15.  *  the narcs that you edited from the tutorial
  16.  *
  17.  * save rom--should be all set.  fairy type becomes type 17.
  18.  * from there:
  19.  *  make struggle type 18 and that should be good to get it typeless (i believe it used to be type 17 to get the typeless advantage).
  20.  */
  21.  
  22. // initializations
  23.  
  24. .nds
  25. .thumb
  26.  
  27. // configs
  28. MEROMERO_SUMMARY_SCREEN_FIX equ 0
  29. BLU_SUMMARY_SCREEN_FIX equ 1
  30. BLU_PC_SCREEN_FIX equ 1
  31.  
  32. BLACK2 equ 0
  33.  
  34.  
  35. // defines
  36. TYPE_NORMAL equ 0
  37. TYPE_FIGHTING equ 1
  38. TYPE_FLYING equ 2
  39. TYPE_POISON equ 3
  40. TYPE_GROUND equ 4
  41. TYPE_ROCK equ 5
  42. TYPE_BUG equ 6
  43. TYPE_GHOST equ 7
  44. TYPE_STEEL equ 8
  45. TYPE_FIRE equ 9
  46. TYPE_WATER equ 10
  47. TYPE_GRASS equ 11
  48. TYPE_ELECTRIC equ 12
  49. TYPE_PSYCHIC equ 13
  50. TYPE_ICE equ 14
  51. TYPE_DRAGON equ 15
  52. TYPE_DARK equ 16
  53. TYPE_FAIRY equ 17
  54. NUM_OF_TYPES equ 18
  55.  
  56. START_OF_NEW_TAGS equ 0x20 // god damn it
  57.  
  58. //.expfunc rgb555(red, green, blue), (red & 0x1F) | ((green & 0x1F) << 5) | ((blue & 0x1F) << 10)
  59. //.expfunc rgb(red, green, blue), rgb555(red / 8, green / 8, blue / 8)
  60.  
  61.  
  62. // notice of configurations
  63. .notice "Building for " + (BLACK2 == 1 ? "Black" : "White") + " 2."
  64.  
  65. .if (MEROMERO_SUMMARY_SCREEN_FIX == 1 && BLU_SUMMARY_SCREEN_FIX == 1)
  66. .error "Both MeroMero's summary screen fix and Blu's summary screen fix are enabled.  Aborting."
  67. .endif
  68.  
  69. .notice "Building with " + (BLU_SUMMARY_SCREEN_FIX == 1 ? "Blu's" : (MEROMERO_SUMMARY_SCREEN_FIX == 1 ? "MeroMero's" : "no")) + " summary screen fix and " + (BLU_PC_SCREEN_FIX == 1 ? "Blu's" : "no") + " PC screen fix."
  70. .notice "If these are not the desired settings, edit the \"configs\" at the beginning of the fairy.s file.  Building..."
  71.  
  72. // code
  73.  
  74.  
  75. // relative offsets are the same so loading address should not matter
  76. //.if BLACK2 == 1
  77. //.open "filesys/overlay/overlay_0255.bin", "overlay_0255.bin", 0x021BB700
  78. //.else
  79. .open "filesys/overlay/overlay_0255.bin", "overlay_0255.bin", 0x021BB740
  80. //.endif
  81.  
  82. // gotta get 0xA268 (where gfx info for fairy type is loaded) to be the old end of the structure, 0xA5BC.  expand structure to be 0xA700
  83.  
  84. .org 0x021C2A50 // increase allocation
  85.  
  86. .if BLU_PC_SCREEN_FIX == 1
  87. .word 0xA700
  88. .else
  89. .word 0xA5BC
  90. .endif
  91.  
  92.  
  93. .org 0x021D0846 // load in fairy gfx
  94. .if BLU_PC_SCREEN_FIX == 1
  95. cmp r4, NUM_OF_TYPES
  96. .else
  97. cmp r4, NUM_OF_TYPES-1
  98. .endif
  99.  
  100. .org 0x021D09AC // move type gfx tracker whatever to end of old structure
  101. .if BLU_PC_SCREEN_FIX == 1
  102. .word 0xA5BC
  103. .else
  104. .word 0xA268
  105. .endif
  106.  
  107.  
  108. // put a read breakpoint at 0x02271558 (0x022672F0+0xA268).  need to find where the old one is
  109. // 021cf578 - A0DC from 226747C ends up being 2271558.  need to make this A430 under the right circumstances (if A0DC would have been A268-A2AC)
  110.  
  111.  
  112. // starting index below
  113. .org 0x021D0A00
  114. .if BLU_PC_SCREEN_FIX == 1
  115. add r1, #START_OF_NEW_TAGS
  116. .else
  117. add r1, #0x20
  118. .endif
  119.  
  120. .org 0x021D0A0A
  121. .if BLU_PC_SCREEN_FIX == 1
  122. cmp r4, NUM_OF_TYPES
  123. .else
  124. cmp r4, NUM_OF_TYPES-1
  125. .endif
  126.  
  127.  
  128. .if BLU_PC_SCREEN_FIX == 1
  129. .org 0x021CF574
  130. bl (patch_load_fairy_from_elsewhere + (BLACK2 == 1 ? 0x40 : 0))
  131. .else
  132. ldr r1, [pc, #0x2c]  ; +0 = 0b 49
  133. ldr r0, [pc, #0x30]  ; +2 = 0c 48
  134. .endif
  135.  
  136.  
  137. // starting index below
  138. .org 0x021BF2F0
  139. .if BLU_PC_SCREEN_FIX == 1
  140. mov r4, #START_OF_NEW_TAGS
  141. .else
  142. mov r4, #0x20
  143. .endif
  144.  
  145. .org 0x021BF300 // deletes when moving to a blank spot with the rest of the sprites
  146. .if BLU_PC_SCREEN_FIX == 1
  147. cmp r4, #(START_OF_NEW_TAGS + NUM_OF_TYPES)
  148. .else
  149. cmp r4, #(0x20 + NUM_OF_TYPES-1)
  150. .endif
  151.  
  152.  
  153. .org 0x021D0A6E // starting index below
  154. .if BLU_PC_SCREEN_FIX == 1
  155. mov r4, #START_OF_NEW_TAGS
  156. .else
  157. mov r4, #0x20
  158. .endif
  159.  
  160.  
  161. .org 0x021D0A7E // deletes when swapping to a new mon
  162. .if BLU_PC_SCREEN_FIX == 1
  163. cmp r4, #(START_OF_NEW_TAGS + NUM_OF_TYPES)
  164. .else
  165. cmp r4, #(0x20 + NUM_OF_TYPES-1)
  166. .endif
  167.  
  168.  
  169. .org 0x021D0A22 // move the type tags
  170. .if BLU_PC_SCREEN_FIX == 1
  171. add r7, #START_OF_NEW_TAGS
  172. .else
  173. add r7, #0x20
  174. .endif
  175.  
  176.  
  177. .org 0x021D0A4A // move the type tags here too?
  178. .if BLU_PC_SCREEN_FIX == 1
  179. add r4, #START_OF_NEW_TAGS
  180. .else
  181. add r4, #0x20
  182. .endif
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192. // me when i write too much asm in the name of fixing things that are not broken:
  193.  
  194. // this is the 0x81 loop deallocator--does everything for the summary screen.  works without patch
  195. //.org 0x021CF4D2
  196. //.if BLU_PC_SCREEN_FIX == 1
  197. //bl patch_load_fairy_from_elsewhere_r7
  198. //.else
  199. //lsl r0, r4, #2
  200. //add r0, r5, r0
  201. //.endif
  202.  
  203.  
  204. //// new:
  205. //.org 0x021CF51C // 0x81 loop that works?
  206. //.if BLU_PC_SCREEN_FIX == 1
  207. //.word 0xA5DC
  208. //.else
  209. //.word 0xA0DC
  210. //.endif
  211.  
  212.  
  213.  
  214. //.org 0x021CF7DC
  215. //.if BLU_PC_SCREEN_FIX == 1
  216. //bl patch_load_fairy_from_elsewhere_r1
  217. //.else
  218. //add r2, r5, r1
  219. //ldr r1, [pc, #0xa0]  ; +0 = 28 49
  220. //.endif
  221.  
  222. //.org 0x021CF880 // 0x60 loop that does not work
  223. //.if BLU_PC_SCREEN_FIX == 1
  224. //.word 0xA5DC
  225. //.else
  226. //.word 0xA0DC
  227. //.endif
  228.  
  229.  
  230. //.org 0x021CF5A4 // called once each thing i believe
  231. //.if BLU_PC_SCREEN_FIX == 1
  232. //.word 0xA5DC
  233. //.else
  234. //.word 0xA0DC
  235. //.endif
  236.  
  237.  
  238.  
  239. .close
  240.  
  241.  
  242. .if BLACK2 == 1
  243. .open "filesys/overlay/overlay_0265.bin", "overlay_0265.bin", 0x021998C0
  244. .else
  245. .open "filesys/overlay/overlay_0265.bin", "overlay_0265.bin", 0x02199900
  246. .endif
  247.  
  248. .org BLACK2 == 1 ? 0x02199F74 : 0x02199FB4
  249.  
  250. .word type_to_loaded_gfx_hof // adjust this to go behind where it already is.
  251.  
  252.  
  253. .org BLACK2 == 1 ? 0x0219B8C8 : 0x0219B908
  254.  
  255. type_to_loaded_gfx_hof:
  256. /* TYPE_NORMAL   */ .word 0x2D
  257. /* TYPE_FIGHTING */ .word 0x26
  258. /* TYPE_FLYING   */ .word 0x28
  259. /* TYPE_POISON   */ .word 0x2E
  260. /* TYPE_GROUND   */ .word 0x2B
  261. /* TYPE_ROCK     */ .word 0x30
  262. /* TYPE_BUG      */ .word 0x22
  263. /* TYPE_GHOST    */ .word 0x29
  264. /* TYPE_STEEL    */ .word 0x31
  265. /* TYPE_FIRE     */ .word 0x27
  266. /* TYPE_WATER    */ .word 0x32
  267. /* TYPE_GRASS    */ .word 0x2A
  268. /* TYPE_ELECTRIC */ .word 0x25
  269. /* TYPE_PSYCHIC  */ .word 0x2F
  270. /* TYPE_ICE      */ .word 0x2C
  271. /* TYPE_DRAGON   */ .word 0x24
  272. /* TYPE_DARK     */ .word 0x23
  273. /* TYPE_FAIRY    */ .word 0x2D // fairy loads the normal spa
  274.  
  275. // unsure yet
  276. .orga 0x21DC
  277. .word 4
  278.  
  279. .orga 0x221C // fairy pal 9 is the new pal, but actually loading anything causes a hardware crash for some reason.  it literally loads and frees immediately too, so not sure what is going on.
  280. .word 0
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288. // 915A of structure is u16 type.  used to index the above table.  r5 is structure pointer.  the load does not seem to take anything unusual
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. .close
  298.  
  299. // BLACK2 should not need a separate config here because relative offsets are the same.
  300. .open "filesys/overlay/overlay_0207.bin", "overlay_0207.bin", 0x021B2FC0
  301.  
  302. .if BLU_SUMMARY_SCREEN_FIX == 1
  303.  
  304. // rewrite 0x130 to be 0x264, the end of the old structure, reserving quite a bit of new space for the new substructure as well.  also double heap memory allocated, just in case.
  305.  
  306. .org 0x021B5110 // double heap for summary screen
  307.     lsl r2, #0x11
  308.  
  309. .org 0x021B511A // structure clearing
  310.     mov r1, #0xB0
  311.  
  312. .org 0x021B5126 // structure allocation
  313.     mov r2, #0xB0
  314.  
  315. .org 0x021B3A5A // make loop run one more time for fairy type
  316.     cmp r4, #NUM_OF_TYPES
  317.  
  318.  
  319.  
  320. .org 0x021B3A32 // used to subtract 1A0 to 130, now we want to get 1A0 to 264
  321.     add r0, #(0x264 - 0x1A0) // will restore and get everything properly
  322.  
  323. .org 0x021B6BF0 // 0x130 -> 0x264
  324.     add r1, r6, r0
  325.     mov r0, #(0x264 >> 2)
  326.     lsl r0, #2
  327.     ldr r0, [r1, r0]
  328.  
  329. .org 0x021B6C5C // var_7C is not even used the rest of the function, we do not have to rewrite to it or grab from it
  330.     mov r0, #(0x264 >> 2)
  331.     lsl r0, #2
  332.     add r5, sp, #0x24
  333.     nop // one extra instruction pog
  334.     //ldr r0, [sp, #0x1C]
  335.     //add r5, sp, #0x24
  336.     //add r0, #0xD0
  337.     //str r0, [sp, #0x1C]
  338.  
  339.  
  340.  
  341.  
  342. .org 0x021B8EE0 // second type from the other one
  343.     mov r0, #(0x264 >> 2)
  344.     lsl r0, #2
  345.     //mov r0, #0xAF
  346.     //add r0, #0x81
  347.  
  348.  
  349.  
  350. .else
  351.  
  352. .org 0x021B5110
  353.     lsl r2, #0x10
  354.  
  355. .org 0x021B511A
  356.     mov r1, #0x99
  357.  
  358. .org 0x021B5126
  359.     mov r2, #0x99
  360.  
  361. .org 0x021B3A5A
  362.     cmp r4, #NUM_OF_TYPES-1
  363.  
  364.  
  365.  
  366. .org 0x021B3A32
  367.     sub r0, #0x70
  368.  
  369. .org 0x021B6BF0
  370.     add r1, r6, r0
  371.     mov r0, #(0x130 >> 4)
  372.     lsl r0, #4
  373.     ldr r0, [r1, r0]
  374.  
  375. .org 0x021B6C5C
  376.     ldr r0, [sp, #0x1C]
  377.     add r5, sp, #0x24
  378.     add r0, #0xD0
  379.     str r0, [sp, #0x1C]
  380.  
  381.  
  382.  
  383.  
  384. .org 0x021B8EE0
  385.     mov r0, #0xAF
  386.     add r0, #0x81
  387.  
  388. .endif
  389.  
  390. .if MEROMERO_SUMMARY_SCREEN_FIX == 1
  391.  
  392. .org 0x021B6BE0
  393.     ldr r1, =patch_1 | 1
  394.     bx r1
  395.  
  396. .pool
  397.  
  398. .org 0x021B6BF0
  399.     ldr r1, =patch_2 | 1
  400.     bx r1
  401.  
  402. .pool
  403.  
  404. .org 0x021B8E68
  405.     ldr r1, =patch_3 | 1
  406.     bx r1
  407.  
  408. .pool
  409.  
  410. .org 0x021B8E78
  411.     ldr r1, =patch_4 | 1
  412.     bx r1
  413.  
  414. .pool
  415.  
  416. .org 0x021BA848
  417.     ldr r1, =patch_5 | 1
  418.     bx r1
  419.  
  420. .pool
  421.  
  422. .else // MEROMERO_SUMMARY_SCREEN_FIX != 1
  423.  
  424. .org 0x021B6BE0 // patch 1
  425.     ldr  r0, [sp, #0x18]  ; +0 = 06 98
  426.     mov  r1, #0xaf        ; +2 = af 21
  427.     mov  r2, #0           ; +4 = 00 22
  428.     mov  r4, #0xaf        ; +6 = af 24
  429.  
  430. .if BLU_SUMMARY_SCREEN_FIX != 1 // type 2 normal summary screen
  431. .org 0x021B6BF0 // patch 2
  432.     add  r1, r6, r0    ; +0 = 31 18
  433.     mov  r0, #0xaf     ; +2 = af 20
  434.     add  r0, #0x81     ; +4 = 81 30
  435.     ldr  r0, [r1, r0]  ; +6 = 08 58
  436. .endif
  437.  
  438. .org 0x021B8E68 // patch 3
  439.     add  r5, r0, #0  ; +0 = 05 1c
  440.     add  r0, r4, #0  ; +2 = 20 1c
  441.     mov  r1, #0xaf   ; +4 = af 21
  442.     mov  r2, #0      ; +6 = 00 22
  443.  
  444. .org 0x021B8E78 // patch 4
  445.     lsl  r0, r5, #2  ; +0 = a8 00
  446.     add  r1, r6, r0  ; +2 = 31 18
  447. .if BLU_SUMMARY_SCREEN_FIX != 1
  448.     mov  r0, #0xaf   ; +4 = af 20
  449.     add  r0, #0x81   ; +6 = 81 30
  450. .else
  451.     mov r0, #(0x264 >> 2)
  452.     lsl r0, #2
  453. .endif
  454.  
  455. .org 0x021BA848 // this one fixes moves
  456.     lsl  r0, r6, #2  ; +0 = b0 00
  457.     add  r1, r5, r0  ; +2 = 29 18
  458. .if BLU_SUMMARY_SCREEN_FIX != 1
  459.     mov  r0, #0x13   ; +4 = 13 20
  460.     lsl  r0, r0, #4  ; +6 = 00 01
  461. .else
  462.     mov r0, #(0x264 >> 2)
  463.     lsl r0, #2
  464. .endif
  465.  
  466. .endif
  467.  
  468. .close
  469.  
  470.  
  471. // BLACK2 should not need a separate config here because relative offsets are the same.
  472. .open "filesys/overlay/overlay_0168.bin", "overlay_0168.bin", 0x021DDAA0
  473.  
  474. .org 0x021F38E8
  475.  
  476. .word 572 // new nclr file in a011, colors written below.  only written to if extracted accordingly
  477.  
  478. .close
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490. .create "overlay_0167.bin", (0x02199780 - ((BLACK2 == 1) ? 0x40 : 0)) // adjusted load location for type chart, originally use 02199900
  491.  
  492. .area 0x180, 0xFF
  493.  
  494.  
  495. // 4 is normal effectiveness, 2 is not very effective, 8 is super effective, 0 has no effect
  496. // go down to the attacker type then over to the defender type
  497.  
  498. type_effectiveness_table: // u8 [NUM_OF_TYPES][NUM_OF_TYPES] // [attack][defend] grabs effectiveness
  499.  
  500. //             atk \ def  NORMAL,  FIGHT, FLYING, POISON, GROUND,   ROCK,    BUG,  GHOST,  STEEL,   FIRE,  WATER,  GRASS,ELECTRC,PSYCHIC,    ICE, DRAGON,   DARK,  FAIRY
  501. .byte /* TYPE_NORMAL   */      4,      4,      4,      4,      4,      2,      4,      0,      2,      4,      4,      4,      4,      4,      4,      4,      4,      4
  502. .byte /* TYPE_FIGHTING */      8,      4,      2,      2,      4,      8,      2,      0,      8,      4,      4,      4,      4,      2,      8,      4,      8,      2
  503. .byte /* TYPE_FLYING   */      4,      8,      4,      4,      4,      2,      8,      4,      2,      4,      4,      8,      2,      4,      4,      4,      4,      4
  504. .byte /* TYPE_POISON   */      4,      4,      4,      2,      2,      2,      4,      2,      0,      4,      4,      8,      4,      4,      4,      4,      4,      8
  505. .byte /* TYPE_GROUND   */      4,      4,      0,      8,      4,      8,      2,      4,      8,      8,      4,      2,      8,      4,      4,      4,      4,      4
  506. .byte /* TYPE_ROCK     */      4,      2,      8,      4,      2,      4,      8,      4,      2,      8,      4,      4,      4,      4,      8,      4,      4,      4
  507. .byte /* TYPE_BUG      */      4,      2,      2,      2,      4,      4,      4,      2,      2,      2,      4,      8,      4,      8,      4,      4,      8,      2
  508. .byte /* TYPE_GHOST    */      0,      4,      4,      4,      4,      4,      4,      8,      4,      4,      4,      4,      4,      8,      4,      4,      2,      4
  509. .byte /* TYPE_STEEL    */      4,      4,      4,      4,      4,      8,      4,      4,      2,      2,      2,      4,      2,      4,      8,      4,      4,      8
  510. .byte /* TYPE_FIRE     */      4,      4,      4,      4,      4,      2,      8,      4,      8,      2,      2,      8,      4,      4,      8,      2,      4,      4
  511. .byte /* TYPE_WATER    */      4,      4,      4,      4,      8,      8,      4,      4,      4,      8,      2,      2,      4,      4,      4,      2,      4,      4
  512. .byte /* TYPE_GRASS    */      4,      4,      2,      2,      8,      8,      2,      4,      2,      2,      8,      2,      4,      4,      4,      2,      4,      4
  513. .byte /* TYPE_ELECTRIC */      4,      4,      2,      4,      0,      4,      4,      4,      4,      4,      8,      2,      2,      4,      4,      2,      4,      4
  514. .byte /* TYPE_PSYCHIC  */      4,      8,      4,      8,      4,      4,      4,      2,      2,      4,      4,      4,      4,      4,      4,      4,      4,      4
  515. .byte /* TYPE_ICE      */      4,      4,      8,      4,      8,      4,      4,      4,      2,      2,      2,      8,      4,      4,      4,      8,      4,      4
  516. .byte /* TYPE_DRAGON   */      4,      4,      4,      4,      4,      4,      4,      4,      2,      4,      4,      4,      4,      4,      4,      8,      4,      0
  517. .byte /* TYPE_DARK     */      4,      2,      4,      4,      4,      4,      4,      8,      4,      4,      4,      4,      4,      8,      4,      4,      4,      2
  518. .byte /* TYPE_FAIRY    */      4,      8,      4,      2,      4,      4,      4,      4,      2,      2,      4,      4,      4,      4,      4,      8,      8,      4
  519.  
  520. .endarea
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. .org (0x02199900 - ((BLACK2 == 1) ? 0x40 : 0))
  533.  
  534. .incbin "filesys/overlay/overlay_0167.bin" // import the old overlay at the same address, but new beginning at 0x180 of the file
  535.  
  536. // repoint
  537. .orga 0x23A6C
  538. .word type_effectiveness_table
  539.  
  540. .orga 0x23BA4
  541. .word type_effectiveness_table
  542.  
  543. // code rewrites
  544. .orga 0xC312
  545. .byte NUM_OF_TYPES, 0x2A, 0x08, 0xDA
  546.  
  547. .orga 0x11226
  548. .byte NUM_OF_TYPES, 0x28, 0x02, 0xDB
  549.  
  550. .orga 0x21884
  551. .byte NUM_OF_TYPES
  552.  
  553. .orga 0x21896
  554. .byte NUM_OF_TYPES
  555.  
  556. .orga 0x218A2
  557. .byte NUM_OF_TYPES, 0x29, 0x06, 0xDB
  558. .byte NUM_OF_TYPES, 0x28, 0x01, 0xDB
  559.  
  560. .orga 0x218B4
  561. .byte NUM_OF_TYPES, 0x28, 0x00, 0xDB
  562.  
  563. .orga 0x218DA
  564. .byte NUM_OF_TYPES, 0x2C, 0x0E, 0xDA
  565.  
  566. .orga 0x23A20
  567. .byte NUM_OF_TYPES, 0x28, 0x01, 0xDA
  568. .byte NUM_OF_TYPES, 0x29, 0x01, 0xDB
  569.  
  570. .orga 0x23A2C
  571. .byte NUM_OF_TYPES, 0x22, 0x42, 0x43
  572.  
  573. .orga 0x23B98
  574. .byte NUM_OF_TYPES
  575.  
  576. .orga 0x260E2
  577. .byte NUM_OF_TYPES, 0x2E, 0x1E, 0xDA
  578.  
  579. .orga 0x306F0
  580. .byte NUM_OF_TYPES, 0x2C, 0x3C, 0xDA
  581.  
  582. .orga 0x306F6
  583. .byte NUM_OF_TYPES
  584.  
  585. .close
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. .open "filesys/arm9.bin", "arm9.bin", 0x02004000
  599.  
  600. // type pal table selection - make pal grab from pal 2 and not 0
  601. .orga ((BLACK2 == 1) ? 0x8E09D : 0x8E0C9)
  602. .byte 2
  603.  
  604. .if MEROMERO_SUMMARY_SCREEN_FIX == 1
  605.  
  606. /*
  607.  *
  608.  * brief:  if incoming type is fairy, set it to 0 to prevent it from displaying fucked up.
  609.  * somewhere, type is added to 0x22 to get the right index in the narc
  610.  *
  611.  * patch_1 and patch_2 are type1 and type2 of the function at 021B6B14
  612.  * patch_3 and patch_4 are type1 and type2 of the function at 021B8D90
  613.  * patch_5 also grabs pal from the one function?
  614.  *
  615.  * all of these have the type multiplied by 4 (shifted left 2).  what does it load then?  find out:
  616.  * patch_5 is specifically for moves.
  617.  * patch_1 and patch_2 appear to be for the type as displayed in the main page
  618.  * patch_3 and patch_4 fix the types when they move to the bottom screen
  619.  *
  620.  */
  621.  
  622. .org 0x02093BF0
  623.  
  624. ret_1 equ BLACK2 == 1 ? 0x021B6BA9 : 0x021B6BE9
  625. ret_2 equ BLACK2 == 1 ? 0x021B6BB9 : 0x021B6BF9
  626. ret_5 equ BLACK2 == 1 ? 0x021BA811 : 0x021BA851
  627. ret_3 equ BLACK2 == 1 ? 0x021B8E31 : 0x021B8E71
  628. ret_4 equ BLACK2 == 1 ? 0x021B8E43 : 0x021B8E83
  629.  
  630. patch_1:
  631.     cmp  r5, #TYPE_FAIRY  ; +0 = 11 2d
  632.     blt  @@default        ; +2 = 00 db
  633.     mov  r5, #0           ; +4 = 00 25
  634. @@default:
  635.     ldr  r0, [sp, #0x18]  ; +6 = 06 98
  636.     mov  r1, #0xaf        ; +8 = af 21
  637.     mov  r2, #0           ; +10 = 00 22
  638.     mov  r4, #0xaf        ; +12 = af 24
  639.     ldr  r7, =ret_1       ; +14 = 13 4f
  640.     bx   r7               ; +16 = 38 47
  641.  
  642.  
  643. patch_2:
  644.     cmp  r7, #TYPE_FAIRY  ; +0 = 11 2f
  645.     blt  @@default        ; +2 = 00 db
  646.     mov  r7, #0           ; +4 = 00 27
  647. @@default:
  648.     add  r1, r6, r0       ; +6 = 31 18
  649.     mov  r0, #0xaf        ; +8 = af 20
  650.     add  r0, #0x81        ; +10 = 81 30
  651.     ldr  r0, [r1, r0]     ; +12 = 08 58
  652.     ldr  r1, =ret_2       ; +14 = 0f 49
  653.     bx   r1               ; +16 = 08 47
  654.  
  655.  
  656. patch_5:
  657.     cmp  r6, #TYPE_FAIRY  ; +0 = 11 2e
  658.     blt  @@default        ; +2 = 00 db
  659.     mov  r6, #0           ; +4 = 00 26
  660. @@default:
  661.     lsl  r0, r6, #2       ; +6 = b0 00
  662.     add  r1, r5, r0       ; +8 = 29 18
  663.     mov  r0, #0x13        ; +10 = 13 20
  664.     lsl  r0, r0, #4       ; +12 = 00 01
  665.     ldr  r5, =ret_5       ; +14 = 0c 4d
  666.     bx   r5               ; +16 = 28 47
  667.  
  668.  
  669. patch_3:
  670.     add  r5, r0, #0       ; +0 = 05 1c
  671.     cmp  r5, #TYPE_FAIRY  ; +2 = 11 2d
  672.     blt  @@default        ; +4 = 00 db
  673.     mov  r5, #0           ; +6 = 00 25
  674. @@default:
  675.     add  r0, r4, #0       ; +8 = 20 1c
  676.     mov  r1, #0xaf        ; +10 = af 21
  677.     mov  r2, #0           ; +12 = 00 22
  678.     ldr  r4, =ret_3       ; +14 = 08 4c
  679.     bx   r4               ; +16 = 20 47
  680.  
  681.  
  682. patch_4:
  683.     cmp  r7, #TYPE_FAIRY  ; +0 = 11 2f
  684.     blt  @@default        ; +2 = 00 db
  685.     mov  r7, #0           ; +4 = 00 27
  686. @@default:
  687.     lsl  r0, r5, #2       ; +6 = a8 00
  688.     add  r1, r6, r0       ; +8 = 31 18
  689.     mov  r0, #0xaf        ; +10 = af 20
  690.     add  r0, #0x81        ; +12 = 81 30
  691.     ldr  r0, [r1, r0]     ; +14 = 08 58
  692.     ldr  r1, =ret_4       ; +16 = 04 49
  693.     bx   r1               ; +18 = 08 47
  694.  
  695. .pool
  696.  
  697. .elseif BLU_PC_SCREEN_FIX == 1
  698.  
  699. .org 0x02093BF0
  700.  
  701. /*
  702.  *
  703.  * brief:
  704.  *
  705.  * basically sub_21CF55C handles a bunch of gfx and there is like a substructure within the bigger structure that starts at like 0x18C of the bigger structure.
  706.  * in there, there is an 0xA0DC--and this A0DC is the offset that loads what we want, corresponds to A268 under the right circumstances (when loading the types).
  707.  * so i can create a little somewhat hacky workaround that does not involve expanding the inner structure but detects if it is loading within A268-A2AC of the overall structure,
  708.  * and redirect it to load from A5BC instead.
  709.  *
  710.  * r4 is overall structure.
  711.  *
  712.  * needs to return offset in r1 and 9E94 in r0
  713.  *
  714.  */
  715.  
  716. patch_load_fairy_from_elsewhere:
  717. push {r2-r3, lr}
  718. ldr r1, =0xA0DC
  719. add r2, r1
  720. sub r2, r4
  721. ldr r3, =(0xA268/*-0x18C*/)
  722. cmp r2, r3
  723. blt @@keep_r1_A0DC
  724. ldr r3, =(0xA2AC/*-0x18C*/)
  725. cmp r2, r3
  726. bhi @@keep_r1_A0DC
  727.  
  728. ldr r1, =(0xA5BC-0x18C)//0xA430
  729.  
  730. @@keep_r1_A0DC:
  731. ldr r0, =0x9E94
  732. pop {r2-r3, pc}
  733.  
  734.  
  735. //// r1, r2 free
  736. //patch_load_fairy_from_elsewhere_r7:
  737. //ldr r7, =0xA0DC
  738. //lsl r0, r4, #2
  739. //add r0, r7, r0
  740. //ldr r1, =(0xA268-0x18C)
  741. //cmp r0, r1
  742. //blt @@keep_r7_A0DC
  743. //ldr r1, =(0xA2AC-0x18C)
  744. //cmp r0, r1
  745. //bhi @@keep_r7_A0DC
  746. //
  747. //ldr r7, =(0xA5BC-0x18C)//0xA430
  748. //
  749. //@@keep_r7_A0DC:
  750. //lsl r0, r4, #2
  751. //add r0, r5, r0
  752. //bx lr
  753. //
  754. //
  755. //// r2, r3 free
  756. //patch_load_fairy_from_elsewhere_r1:
  757. //ldr r2, =0xA0DC
  758. //add r1, r2
  759. //ldr r2, =(0xA268-0x18C)
  760. //cmp r1, r2
  761. //blt @@keep_r1_A0DC
  762. //ldr r2, =(0xA2AC-0x18C)
  763. //cmp r1, r2
  764. //bhi @@keep_r1_A0DC
  765. //
  766. //ldr r1, =(0xA5BC-0x18C)//0xA430
  767. //b @@return
  768. //
  769. //@@keep_r1_A0DC:
  770. //ldr r1, =0xA0DC
  771. //@@return:
  772. //bx lr
  773.  
  774. .pool
  775.  
  776. .endif
  777.  
  778. .close
  779.  
  780.  
  781.  
  782. // repoint overlay 167 to load properly from new location
  783.  
  784. .open "filesys/y9.bin", 0
  785.  
  786. .org (167 * 0x20 + 4)
  787.  
  788. .word (0x02199780 - ((BLACK2 == 1) ? 0x40 : 0))
  789. .word filesize("overlay_0167.bin")
  790.  
  791. .close
  792.  
  793.  
  794. .notice "All done!"
  795.  
  796.  
  797.  
  798.  
  799.  
  800. // random notes and ramblings section.  a little crazy
  801.  
  802.  
  803.  
  804. /*
  805.  * patch_* notes as taken from the rom with the working patch:
  806.  *
  807.  *           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  808.  * patch_1:
  809.  * 02093BF0  11 2D 00 DB 00 25 06 98 AF 21 00 22 AF 24 13 4F
  810.  * 02093C00  38 47
  811.  *
  812.  * patch_2:
  813.  *                 11 2F 00 DB 00 27 31 18 AF 20 81 30 08 58
  814.  * 02093C10  0F 49 08 47
  815.  *
  816.  * patch_5:
  817.  *                       11 2E 00 DB 00 26 B0 00 29 18 13 20
  818.  * 02093C20  00 01 0C 4D 28 47
  819.  *
  820.  * patch_3:
  821.  *                             05 1C 11 2D 00 DB 00 25 20 1C
  822.  * 02093C30  AF 21 00 22 08 4C 20 47
  823.  *
  824.  * patch_4:
  825.  *                                   11 2F 00 DB 00 27 A8 00
  826.  * 02093C40  31 18 AF 20 81 30 08 58 04 49 08 47
  827.  *
  828.  * .pool:
  829.  *                                               E9 6B 1B 02
  830.  * 02093C50  F9 6B 1B 02 51 A8 1B 02 71 8E 1B 02 83 8E 1B 02
  831.  */
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840. /*
  841.  *
  842.  * the fairy type persists in pc screen for some reason!
  843.  * 021BF0AE - grabs type 1 and type 2 from current mon in pc.  stores at r4+C and r4+D respectively
  844.  * 021D0A8A of sub_21D0A68 - reads type 1 and type 2 as r1 and r2 for sub_21D0A1C -
  845.  *
  846.  *
  847.  *
  848.  * new idea:  reroute all of A0DC
  849.  *
  850.  * 021CF4CC is called when exiting
  851.  * 021CF7DE is called when coming in
  852.  * i think i just need hooks on both of these.
  853.  *
  854.  */
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870. /*
  871.  *
  872.  * serperior - grass dragon - loads 0x10 and 0x14
  873.  * infernape - fire fight - 0xE 0x6
  874.  * metagross - steel psychic - 0xD 0x12
  875.  * braviary - normal flying - 0x5 0x7
  876.  * gyarados - water flying - 0xF 0x7
  877.  * type+5 is fed in.  does not work necessarily tho
  878.  *
  879.  */
  880.  
  881.  
  882. /*
  883.  * 022572E0 + type*4 + 0x130 = type+5 to load
  884.  * CpuFill8 - writes 0s to the place?
  885.  * 021B3A52 actually fills it out--needs more space?  nah, we hacking this shit.  fuck memory shenanigans
  886.  *
  887.  * can we hotswap nitrofs references real time?  something like that?
  888.  *
  889.  * (ptr at (ptr at 214197C)+0x10C) + 0x40*(type+5)
  890.  */
  891.  
Add Comment
Please, Sign In to add comment