Code:
add r2,pc,#1
bx r2
.thumb
ldr r1,CoordinatesPointer
ldr r1,[r1]
cmp r1,#0
beq Exit
mov r2,#0xA9
lsl r2,#3
neg r2,r2 @r2 now holds negative #0x548
ldr r3,[r1,r2] @r3 now holds X coordinates
lsr r3,#0xC
cmp r3,#0x20 @check if you're before the map
blt Exit
cmp r3,#0xA0 @check if you're after the map
bgt Exit
add r2,#8
ldr r2,[r1,r2] @r2 now holds y coordinate
lsr r2,#0xC
cmp r2,#0x20 @check if you're before the map
blt Exit
cmp r2,#0xA0 @check if you're after the map
bgt Exit
@Divide by 2 and subtract #0x10 so you end up with the Row/Column number
lsr r3,#1
lsr r2,#1
sub r3,#0x10
sub r2,#0x10
@r3 holds column
@r2 holds row
mov r0,#0
mov r4,#0
@Quotient holds Column Box
@Remainder holds Column
Divide1:
cmp r3,#16
blt Divide2
sub r3,#16
add r0,#1
b Divide1
@Quotient holds Row Box
@Remainder holds Row
Divide2:
cmp r2,#16
blt Finish
sub r2,#16
add r4,#1
b Divide2
Finish:
@r0 holds y box multiply by #0x200
@r4 holds x box multiply by #0x800
@r3 holds column multiply by #0x2
@r2 holds row multiply by #0x20
lsl r3,#1
lsl r2,#5
lsl r0,#9
lsl r4,#0xB
ldr r1,Map
@add to the map to get the space you're on
add r1,r4
add r1,r0
add r1,r2
add r1,r3
@[texttoItem] = r5
ldr r4, Text
mov r5,#0x0
mov r0,#0xC
mov r2,#0xF
loop:
ldrb r3,[r4]
add r4,#0x1
cmp r3,#0x3A
blt number
add r3,#0x9
number:
and r3,r2
lsl r3,r0
add r5,r3
sub r0,#0x4
bpl loop
@Store the item in that space
strh r5,[r1]
Exit:
bx lr
.arm
CoordinatesPointer:
.long 0x21C6DEC
Map:
.long 0x21E3124
Text:
.long 0x22AF136