Nav apraksta

save_block_jpan.s 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. .align 2
  2. .thumb
  3. /*cc left in first block
  4. 70 +70+70+108 = 258 in people block
  5. 8*70 + 820 = BA0 from box block
  6. grand total of EC4 wasted space (9/10 of block wasted)
  7. saved c000 to c0cc at first block (0x0)
  8. saved c0cc to c324 at fifth block (0x4)
  9. saved c324 to cec4 at 14th block (0xd)*/
  10. /*at 080D9EDC, in the save routine, place a branch to this (in r0)*/
  11. /*in pre-patched Fire Red, d9ef0*/
  12. .global load_hijack
  13. load_hijack: ldr r1, [r4]
  14. mov r3, #0xff
  15. lsl r3, r3, #0x4
  16. add r3, r3, r1
  17. ldrh r0, [r3, #0x4]
  18. cmp r0, #0x0
  19. beq first_cc_load
  20. cmp r0, #0x4
  21. beq middle_load
  22. cmp r0, #0xd
  23. beq last_load
  24. load_ender: cmp r5, #0xd
  25. ble next_loop_iter
  26. mov r0, #0x1
  27. pop {r3}
  28. mov r8, r3
  29. pop {r4-r7}
  30. pop {r1}
  31. bx r1
  32. first_cc_load: mov r1, #0xcc
  33. ldr r2, c0c8_addr
  34. b load_loop
  35. middle_load: mov r1, #0x96
  36. lsl r1, r1, #0x2
  37. ldr r2, c320_addr
  38. b load_loop
  39. last_load: mov r1, #0xba
  40. lsl r1, r1, #0x4
  41. ldr r2, cec0_addr
  42. load_loop: sub r3, #0x4
  43. ldr r0, [r3]
  44. str r0, [r2]
  45. sub r2, #0x4
  46. sub r1, #0x4
  47. cmp r1, #0x0
  48. bne load_loop
  49. b load_ender
  50. .hword 0x0000
  51. c0c8_addr: .word 0x0203c0c8
  52. c320_addr: .word 0x0203c320
  53. cec0_addr: .word 0x0203cec0
  54. next_loop_iter: ldr r0, game_load_ret_addr
  55. bx r0
  56. game_load_ret_addr: .word 0x080D9E71
  57. /*d9e85 for pre-patched*/
  58. .word 0xffffffff
  59. /*for the Save routine, we hijack before the save on Flash routine
  60. that is located at 080d991e. Change there for bx r7, and at 80D995C
  61. place pointer to this*/
  62. /*in pre-patched version is d9932 and d9970*/
  63. .global store_hijack
  64. store_hijack: mov r7, #0xff
  65. lsl r7, r7, #0x4
  66. add r7, r1, r7
  67. strh r0, [r7,#0x6]
  68. ldrh r6, [r7, #0x4]
  69. cmp r6, #0x0
  70. beq first_store
  71. cmp r6, #0x4
  72. beq middle_store
  73. cmp r6, #0xd
  74. beq last_store
  75. .hword 0x0000
  76. store_ender: ldr r0, game_store_ret_addr
  77. bx r0
  78. game_store_ret_addr: .word 0x080D9923
  79. /*in pre-patched return is d9937*/
  80. first_store: mov r3, #0xcc
  81. ldr r2, c0c8_addr_2
  82. b store_loop
  83. middle_store: mov r3, #0x96
  84. lsl r3, r3, #0x2
  85. ldr r2, c320_addr_2
  86. b store_loop
  87. last_store: mov r3, #0xba
  88. lsl r3, r3, #0x4
  89. ldr r2, cec0_addr_2
  90. store_loop: sub r7, #0x4
  91. ldr r0, [r2]
  92. str r0, [r7]
  93. sub r2, #0x4
  94. sub r3, #0x4
  95. cmp r3, #0x0
  96. bne store_loop
  97. b store_ender
  98. c0c8_addr_2: .word 0x0203c0c8
  99. c320_addr_2: .word 0x0203c320
  100. cec0_addr_2: .word 0x0203cec0