- 82
- Posts
- 6
- Years
- California
- Seen May 20, 2020
Trying to teach myself assembly. I know for a fact some syntax is wrong. I'm writing this on mobile so don't hate me lol
With that said, I know these won't work. I haven't tested them but no way my first try works.
I've made 3 small routines. They are all ai scripting commands(think like adding commands to bsp but a different table).
Routine 1 - Addition
Usage: If the ai has mega launcher, calculate the added damage so it can decide what really is the most powerful move.
push r0-r4, lr
ldr r2 .abilityloc
Ldr r2 .doublebattlecheck @battle type ram
ldrb r2 [r2 #0x4] @get battle type data
Cmp r2, #0x01 @is it double battle?
Bne abilitycheck @no? Skip slot check
Slotcheck:
Ldr r2 .userdata @load battle data
Ldr r3 .userbank @load slot number
Ldr r4, #0x74 @load first opponent ability
Mul r3, r3, r4 @if second opponent, double 74
Add r2, r2, r3
Abilitycheck:
cmp r2, # @check megalauncher and others
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
b Return
GetBasePower:
ldr r0 =(base power ram) @need to find ram offset
mov r1 #0x5
div r1, r0, r1 @get 20% of base power
add r0, r0, r1 @add 20% to base power
ldr r1 =(base power ram)
strh r0 @store new base power
Return:
pop r0-r4, pc
.word .abilityloc 0x02023C54
.word .userdata 0x02023BE4
.word .userbank 0x02023D6B
Routine 2 + 3 branch with link
Usage: Jump to address to run a script function but come back when done. Makes scripting more modular. Requires 1 function to end with branch start and the called function to end with branch end.
arugments 'curroffset'(word) 'jumptoffset'(word)
branch with link start
push r0-r2, lr
ldr r0, .AICursor
ldr r1, [r0]
ldr r1, [r0, #0x1] @curroffset
ldr r2, [r0, #0x2] @jumpoffset
str r1 =(Blfreeram) @curroffset
b r2 @jumpoffset
pop r0-r2, pc
@@@@@@@@@@@@@
branch with link finish
push r0, lr
ldr r0 =(BLrfreeram)
b r0
pop r0, pc
With that said, I know these won't work. I haven't tested them but no way my first try works.
I've made 3 small routines. They are all ai scripting commands(think like adding commands to bsp but a different table).
Routine 1 - Addition
Usage: If the ai has mega launcher, calculate the added damage so it can decide what really is the most powerful move.
Spoiler:
push r0-r4, lr
ldr r2 .abilityloc
Ldr r2 .doublebattlecheck @battle type ram
ldrb r2 [r2 #0x4] @get battle type data
Cmp r2, #0x01 @is it double battle?
Bne abilitycheck @no? Skip slot check
Slotcheck:
Ldr r2 .userdata @load battle data
Ldr r3 .userbank @load slot number
Ldr r4, #0x74 @load first opponent ability
Mul r3, r3, r4 @if second opponent, double 74
Add r2, r2, r3
Abilitycheck:
cmp r2, # @check megalauncher and others
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
cmp r2, #
beq GetBasePower
b Return
GetBasePower:
ldr r0 =(base power ram) @need to find ram offset
mov r1 #0x5
div r1, r0, r1 @get 20% of base power
add r0, r0, r1 @add 20% to base power
ldr r1 =(base power ram)
strh r0 @store new base power
Return:
pop r0-r4, pc
.word .abilityloc 0x02023C54
.word .userdata 0x02023BE4
.word .userbank 0x02023D6B
Routine 2 + 3 branch with link
Usage: Jump to address to run a script function but come back when done. Makes scripting more modular. Requires 1 function to end with branch start and the called function to end with branch end.
Spoiler:
arugments 'curroffset'(word) 'jumptoffset'(word)
branch with link start
push r0-r2, lr
ldr r0, .AICursor
ldr r1, [r0]
ldr r1, [r0, #0x1] @curroffset
ldr r2, [r0, #0x2] @jumpoffset
str r1 =(Blfreeram) @curroffset
b r2 @jumpoffset
pop r0-r2, pc
@@@@@@@@@@@@@
branch with link finish
push r0, lr
ldr r0 =(BLrfreeram)
b r0
pop r0, pc
Last edited: