Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .thumb
- .global spikes_rewrite
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .equ rom, 0x08000000
- .equ offset, 0xF00000
- .equ Normal, 0
- .equ Fighting, 1
- .equ Flying, 2
- .equ Poison, 3
- .equ Ground, 4
- .equ Rock, 5
- .equ Bug, 6
- .equ Ghost, 7
- .equ Steel, 8
- .equ Fire, 0xA
- .equ Water, 0xB
- .equ Grass, 0xC
- .equ Electric, 0xD
- .equ Psychic, 0xE
- .equ Ice, 0xF
- .equ Dragon, 0x10
- .equ Dark, 0x11
- .equ Fairy, 23
- .equ Spikes, 0xBF
- .equ Stealth_Rock, 0x1D4
- .equ Toxic_Spikes, 0x1D5
- .equ Sticky_Web, 0x1E1
- .equ Immunity, 0x11
- .equ Levitate, 0x1A
- .equ Magic_Guard, 0xAB
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .org 0x9063FB
- .word main + rom + 1
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .org offset
- .align 1
- main:
- push {r4-r7, lr}
- mov r0, #0
- bl get_battle_side_something @get defender
- mov r4, r0 @r4 is the bank we're using
- mov r1, #0x58 @size_of(battle_struct)
- mul r0, r1
- ldr r1, battle_struct
- add r6, r0, r1 @r6 is the battle_struct
- mov r1, #0xC
- mul r0, r1
- ldr r1, timers
- add r0, r1
- ldrb r0, [r0, #0xA] @spike bits
- mov r1, #0x3F @00WRTTSS
- and r0, r1
- mov r5, r0
- type_checks_start:
- mov r0, r6
- add r0, #0x21
- ldrb r0, [r0]
- mov r1, #0xC @toxic_spikes bits
- mov r2, #0x2F @everything but stealth rock
- mov r3, #0
- type_check_loop_thing:
- cmp r0, #Flying
- bne poison_type_check
- bic r5, r2
- poison_type_check:
- cmp r0, #Poison
- bne steel_type_check
- bic r5, r1
- steel_type_check:
- cmp r0, #Steel
- bne loop_check
- bic r5, r1
- loop_check:
- cmp r3, #1
- beq ability_check
- add r3, #1
- mov r0, r6
- add r0, #0x22
- ldrb r0, [r0]
- b type_check_loop
- ability_check:
- mov r3, #0xFF
- mov r0, r6
- add r0, #0x20
- ldrb r0, [r0]
- cmp r0, #Magic_Guard
- bne levitate_check
- bic r5, r3
- levitate_check:
- cmp r0, #Levitate
- bne immunity_check
- bic r5, r2
- immunity_check:
- cmp r0, #Immunity
- bne sticky_web_check
- bic r5, r1
- sticky_web_check:
- mov r0, r5
- mov r1, #0x20
- and r0, r1
- cmp r0, #0
- beq toxic_spikes_check
- ldr r0, sticky_web_battle_script_pointer
- bl battle_script_push
- toxic_spikes_check:
- mov r0, r5
- mov r1, #0xC
- and r0, r1
- cmp r0, #0
- beq stealth_rock_check
- cmp r0, #8 @badly poisoned
- bne normal_poison
- mov r0, #6 @toxic
- b store_effect
- normal_poison:
- mov r0, #2 @poison
- store_effect:
- ldr r1, effect
- strb r0, [r1]
- ldr r0, toxic_spikes_battle_script_pointer
- bl battle_script_push
- b stealth_rock_check
- get_badly_poisoned_battle_script:
- mov r0, #6 @toxic
- b store_effect
- stealth_rock_check:
- mov r0, r5
- mov r1, #0x10
- and r0, r1
- cmp r0, #0
- beq spikes_check
- mov r2, r6
- mov r0, #0 @used for the loop
- add r3, #0x21
- ldrb r2, [r3, #1] @r2 is one of the types
- ldrb r3, [r3] @and there's the other
- mov r1, #8 @normal damage
- check_type_resistance:
- cmp r2, #Fighting
- beq reduce_stealth_rock_damage
- cmp r2, #Flying
- beq increase_stealth_rock_damage
- cmp r2, #Ground
- beq reduce_stealth_rock_damage
- cmp r2, #Bug
- beq increase_stealth_rock_damage
- cmp r2, #Fire
- beq increase_stealth_rock_damage
- cmp r2, #Ice
- beq increase_stealth_rock_damage
- b stealth_rock_loop
- reduce_stealth_rock_damage:
- lsl r1, #1 @makes the denominator bigger, therefore the result will be small (20/10)
- b stealth_rock_loop
- increase_stealth_rock_damage:
- lsr r1, #1 @makes the denominator smaller, making a big result (20/2)
- stealth_rock_loop:
- add r0, #1
- mov r2, r3
- cmp r1, #2
- bne check_type_resistance
- ldrh r0, [r6, #0x2C] @hp
- bl div
- ldr r1, damage
- cmp r0, #0
- bne store_stealth_damage
- mov r0, #1
- store_stealth_damage:
- str r0, [r1]
- ldr r0, stealth_rock_battle_script_pointer
- bl battle_script_push
- spikes_check:
- mov r0, r5
- mov r1, #3
- and r0, r1
- cmp r0, #0
- beq assembly_end
- cmp r0, #1
- bne spikes_2
- mov r1, #8
- spikes_2:
- cmp r0, #2
- bne spikes_3
- mov r1, #6
- spikes_3:
- cmp r0, #3
- bne spikes_div
- mov r1, #4
- spikes_div:
- ldrh r0, [r6, #0x2C]
- bl div
- cmp r0, #0
- bne store_spikes_damage
- mov r0, #1
- store_spikes_damage:
- ldr r1, damage
- str r0, [r1]
- ldr r0, spikes_battle_script_pointer
- bl battle_script_push
- assembly_end:
- ldr r0, return_pointer
- bl battle_script_push
- pop {r4-r7, pc}
- .align 2
- timers: .word 0x02023DE4
- battle_struct: .word 0x02023BE4
- movescr_cursor: .word 0x02023D74
- damage: .word 0x02023D50
- effect: .word 0x02023E85
- sticky_web_battle_script_pointer: .word sticky_web_battle_script + rom
- toxic_spikes_battle_script_pointer: .word toxic_spikes_battle_script + rom
- stealth_rock_battle_script_pointer: .word stealth_rock_battle_script + rom
- spikes_battle_script_pointer: .word spikes_battle_script + rom
- return_pointer: .word return + rom
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .align 2
- battle_script_push:
- ldr r1, bs_push
- bx r1
- .align 2
- bs_push: .word 0x08017520
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .align 2
- get_battle_side_something:
- ldr r1, battle_side_something
- bx r1
- .align 2
- battle_side_something: .word 0x08016E24
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- spikes_battle_script: @text at 0x083FC0C6
- .byte 0xFA
- .word 0x0203C020, 0x083FC036 @text
- .byte 0x28 @goto
- .word damage_and_msg + rom
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- stealth_rock_battle_script:
- @stuff here, the pointer to the text is 08257be5 i think
- .byte 0xFA
- .word 0x0203C020, 0x08257BE5 @text
- .byte 0x28 @goto
- .word damage_and_msg + rom
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- toxic_spikes_battle_script:
- .byte 0x16, 0xF, 0x12 @seteffecttarget, resultmessage, waitmessage
- .hword 0x0040
- .byte 0x3C @return
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- sticky_web_battle_script: @text at 08257C02
- @text first
- .byte 0xFA
- .word 0x0203C020, 0x08257C02
- .byte 0x10
- .hword 0x0184
- .byte 0x12
- .hword 0x0040
- .byte 0x2E @setbyte
- .word 0x02023E85
- .byte 0x18, 0xF, 0x12
- .hword 0x0040
- .byte 0x3C
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- damage_and_msg:
- .byte 0x5C, 0, 0x3A, 0xB, 0, 0xC, 0 @hp stuff
- .byte 0x10
- .hword 0x0184
- .byte 0x12 @waitmessage
- .hword 0x0040
- .byte 0x3C @return
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- return:
- .byte 0x3C
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement