.text

.align 2

.thumb

.thumb_func

.global levelball

main:

ldr r0, pokeindex

ldrh r0, [r0]

mov r1, #0x24

mul r0,r1

ldr r1, pokedextable

add r1, r0, r1

add r1, r1, #0xE

ldrh r1, [r1] \\r1 now contains the weight in kg-1

ldr r2, stattable

ldr r0, pokeindex

ldrh r0, [r0]

mov r4, #0x1C

mul r0, r4

add r2, r2, r0

ldrb r2, [r2] \\r2 loads the catchrate of the poke

cmp r1, #0x1000

bhi plusforty

cmp r1, #0xBB8

bhi plusthirty

cmp r1, #0x7D0

bhi plustwenty

cmp r2, #20 \\checks to see if catchrate <20 (hence 0 chance)

bhi minustwenty

mov r4, #0

b ender

plusforty:

mov r0, #0x0

add r0, r2, #40

mov r1, r2

b 0x081E4018

mov r3, r0 \\integer stored in r3

mov r0, #0x0

add r0, r2, #40

mov r1, r2

b 0x081E4684 \\remainder stored in r0

b intdivision

plusthirty:

mov r0, #0x0

add r0, r2, #30

mov r1, r2

b 0x081E4018

mov r3, r0

mov r0, #0x0

add r0, r2, #30

mov r1, r2

b 0x081E4684

b intdivision

plustwenty:

mov r0, #0x0

add r0, r2, #20

mov r1, r2

b 0x081E4018

mov r3, r0

mov r0, #0x0

add r0, r2, #20

mov r1, r2

b 0x081E4684

b intdivision

minustwenty:

mov r0, #0x0

sub r0, r2, #20

mov r1, r2

b 0x081E4018

mov r3, r0

mov r0, #0x0

sub r0, r2, #20

mov r1, r2

b 0x081E4684

b intdivision

intdivision

mov r4, #0

mov r1, #10

mul r0, r1

mov r1, r2 \\This load 10x the remainder to give an integer when divided

b 0x081E4018 \\divides 10x remainder by C, always <10 due to math laws

mul r3, r1

add r4, r0, r3 \\adds the remainder and whole together

b ender

ender:

ldr r0, catchratecalcfunction

mov pc, r0

.align 2

pokeindex: .word 0x0202077E

pokedextable: .word 0x08735100

stattable: .word 0x08722600

catchratecalcfunction: .word 0x0802d62a