本帖最后由 jiangzhengwenjz 于 2015-10-14 12:16 编辑
字节变更均在源码注释中
效果见下图(仍有小bug 但我实在没动力了。。)部分是jambo51的源码
- .thumb
- /*0x82a26 - 04 49 08 47
- 0x82a38 - XX+1 XX XX 08
- 0x7F760 - 00 00*/
- str r0, [sp]
- ldr r0, .opponent_slot
- add r1, r4, #0
- add r2, r6, #0
- mov r3, #0x20
- ldr r4, .pokemon_make_3
- bl linker_4
- mov r1, #0
- mov r2, #0
- loop_1:
- mov r4, #0x64
- ldr r0, .party_slot
- add r0, #0x56
- mul r4, r1
- add r0, r0, r4
- ldrh r0, [r0]
- cmp r0, #0
- bne add_1
- increment:
- add r1, #1
- cmp r1, #6
- bne loop_1
- cmp r2, #2
- blt back_1
- ldr r1, .offset
- ldr r2, .save_block_1
- ldr r2, [r2]
- ldrb r3, [r2, #4] @bank
- lsl r3, r3, #2
- add r1, r1, r3
- ldr r1, [r1]
- ldrb r3, [r2, #5] @map
- lsl r3, r3, #2
- add r1, r1, r3
- ldr r1, [r1]
- ldr r1, [r1]
- ldr r3, [r1, #0x10]
- ldr r2, .tileset_table
- cmp r3, r2
- bne back_1
- bl get_block_id
- mov r2, #0
- loop_2:
- mov r1, pc
- add r1, #0x92
- lsl r3, r2, #2
- add r1, r1, r3
- ldrh r3, [r1]
- cmp r0, r3
- beq calculation
- ldr r1, .end
- cmp r1, r3
- beq back_1
- add r2, #1
- b loop_2
- add_1:
- add r2, #1
- b increment
- back_1:
- mov r0, #0
- ldr r1, .battle_flag
- str r0, [r1]
- back_2:
- add sp, sp, #0x10
- pop {r4-r6, pc}
- get_block_id:
- push {lr}
- ldr r0, .npc_state
- ldrh r1, [r0, #0x12] @Y
- ldrh r0, [r0, #0x10] @X
- ldr r4, .getter
- bl linker_4
- pop {pc}
- calculation:
- ldrb r4, [r1, #2]
- cmp r4, #0x63
- bhi doubletwo
- bl random
- mov r1, #0x64
- bl mod_func
- doublethree:
- add r1, r4, #0
- cmp r0, r1
- bge back_1
- double:
- mov r0, #1
- ldr r1, .battle_flag
- str r0, [r1]
- ldr r4, .rand_grass
- bl linker_4
- ldr r1, [r7, #4]
- lsl r0, r0, #2
- add r0, r0, r1
- ldrh r4, [r0, #2]
- ldr r1, .generate
- bl linker_1
- add r6, r0, #0
- bl random
- mov r1, #0x19
- bl mod_func
- str r0, [sp]
- ldr r0, .opponent_slot
- add r0, #0x64
- add r1, r4, #0
- add r2, r6, #0
- mov r3, #0x20
- ldr r4, .pokemon_make_3
- bl linker_4
- b back_2
- doubletwo:
- mov r0, #0
- b doublethree
- mod_func:
- ldr r3, .mod_addr
- bx r3
- random:
- ldr r2, .rand
- bx r2
- linker_1:
- bx r1
- linker_4:
- bx r4
- .word 0x0005000A
- .word 0x0005000B
- .word 0x0005000C
- .word 0x0005000D
- .hword 0xFEFE
- .align 2
- .opponent_slot: .word 0x0202402C
- .pokemon_make_3: .word 0x0803DD99
- .party_slot: .word 0x02024284
- .battle_flag: .word 0x02022B4C
- .offset: .word 0x083526A8
- .save_block_1: .word 0x03005008
- .tileset_table: .word 0x082D4A94
- .npc_state: .word 0x02036E38
- .getter: .word 0x08058E49
- .end: .word 0x0000FEFE
- .mod_addr: .word 0x081E4685
- .rand: .word 0x08044EC9
- .rand_grass: .word 0x0808274D
- .generate: .word 0x080828F9
复制代码- .thumb
- .align 2
- /*0x16824 - 00 48 00 47 JJ+1 JJ JJ 08*/
- cmp r3, #5
- beq .L_1
- mov r0, #1
- and r3, r0
- cmp r3, #0
- bne .L_0
- .L_1:
- ldr r0, =0x801682D
- bx r0
- .L_0:
- ldr r0, =0x801682D
- add r0, #0x42
- bx r0
复制代码- .thumb
- /*替换ROM中所有的1D 1E 0A 08为下面代码的指针(+1),注意先替换,再写入本源码!!!!!!*/
- ldr r1, .battle_flag
- ldr r1, [r1]
- cmp r1, #5
- bne normal
- ldr r1, .struct
- mov r2, #0x58
- lsl r2, r2, #1
- add r2, r1, r2
- ldrh r1, [r1, #0x28]
- ldrh r2, [r2, #0x28]
- mul r1, r2
- cmp r1, #0
- bne two_mon
- normal:
- ldr r1, .pokeball
- bx r1
- two_mon:
- push {r4, lr}
- mov r0, #0
- mov r1, #2
- mov r2, pc
- add r2, #0xC
- ldr r3, .bag_print
- ldr r4, .texter
- bl jump
- pop {r4, pc}
- jump:
- bx r4
- .word 0xAD0B2302
- .word 0x90087E0F
- .word 0x5B078C10
- .word 0x0D3BBC08
- .word 0x0BAB03A4
- .word 0x094D0337
- .word 0x3CA701B5
- .hword 0x00FF
- .align 2
- .battle_flag: .word 0x2022B4C
- .pokeball: .word 0x80A1E1D
- .struct: .word 0x2023C3C
- .bag_print: .word 0x810a1f9
- .texter: .word 0x08108E71
复制代码- .thumb
- .align 2
- /*21d46 - 00 47
- 21d94 - ZZ+1 ZZ ZZ 08*/
- ldr r0, =0x2022b4c
- ldr r0, [r0]
- cmp r0, #5
- beq double
- audio:
- ldr r0, =0x137
- ldr r1, =0x80722A1
- bl jump
- ldr r1, =0x8021D4B
- jump:
- bx r1
- double:
- ldr r0, =0x2023C3C
- mov r1, #0x58
- lsl r1, r1, #1
- add r1, r0, r1
- ldrh r0, [r0, #0x28]
- ldrh r1, [r1, #0x28]
- add r0, r0, r1
- cmp r0, #0
- beq audio
- ldr r1, =0x8021D4B
- add r1, #8
- bx r1
复制代码- .thumb
- .align 2
- /*0x2D44C - 30 47
- 0x2D480 - MM+1 MM MM 08
- 0x2D812 - 00 00
- 0x2D858 - 00 00
- 0x2D8A6 - 00 00
- 0x2D8F4 - 01 1C
- 0x2DF36 - 08 1C
- 0x2DE58 - 00 00
- 0x2DE84 - 00 00
- 0x2DEA4 - 00 00
- 0x2DEC2 - 04 1C
- 0x2D874 - 6C 3D 02 02
- 0x2D94C - 6C 3D 02 02
- 0x2DF64 - 6C 3D 02 02
- 0x2DF04 - 6C 3D 02 02*/
- ldr r6, =0x2022b4c
- ldr r6, [r6]
- cmp r6, #5
- bne normal
- ldr r6, =0x2023C3C
- ldrh r6, [r6, #0x28]
- cmp r6, #0
- bne case_1
- case_2:
- mov r0, #3
- b back
- case_1:
- mov r0, #1
- b back
- normal:
- mov r1, #1
- eor r0, r1
- back:
- ldr r6, =0x2023D6C
- ldr r1, =0x802d451
- bx r1
复制代码- .thumb
- .align 2
- /*0x2d95c - 00 48 00 47 NN+1 NN NN 08*/
- push {r4, r5, lr}
- ldr r4, =0x0202402C
- ldr r0, =0x02023D6C
- ldrb r0, [r0]
- lsr r0, r0, #1
- mov r1, #0x64
- mul r0, r1
- add r0, r0, r4
- add r4, r0, #0
- mov r1, #0xb
- ldr r2, =0x0802D965
- bx r2
复制代码- .thumb
- .align 2
- /*0x2d9de - 00 47
- 0x2da00 - UU+1 UU UU 08*/
- ldr r0, =0x0202402C
- ldr r1, =0x02023D6C
- ldrb r1, [r1]
- lsr r1, r1, #1
- mov r2, #0x64
- mul r1, r2
- add r0, r1, r0
- mov r1, #0xb
- ldr r2, =0x0802D9E1
- bx r2
复制代码- .thumb
- .align 2
- /*0xEF5F8 - 10 47
- 0xEF680 - QQ+1 QQ QQ 08*/
- ldr r2, =0x02037F1B
- ldr r0, =0x02022B4C
- ldr r0, [r0]
- cmp r0, #5
- bne normal
- ldr r0, =0x02023C3C
- mov r1, #0x58
- lsl r1, r1, #1
- add r1, r0, r1
- ldrh r1, [r1, #0x28]
- cmp r1, #0
- beq normal
- mov r1, #3
- strb r1, [r2]
- normal:
- mov r8, r2
- ldr r0, =0x080EF5FB
- bx r0
复制代码 第一个源码写入后会出现1表格,是0A 00 05 00 0B 00 05 00 0C 00 05 00..... 05即概率 |