Code:
ldrh r5,Activator
ldrh r4,Done
@convert to thumb
add r2,pc,#1
bx r2
.thumb
@[Text to Item] = r5
ldr r1, text
ldrh r2,[r1]
cmp r2,r5
bne End
strh r4,[r1]
add r1,#2
mov r5,#0x0
mov r0,#0xC
mov r2,#0xF
loop:
ldrb r3,[r1]
add r1,#1
cmp r3,#0x3A
blt number
add r3,#9
number:
and r3,r2
lsl r3,r0
add r5,r3
sub r0,#0x4
bpl loop
@[Item Address] = r2
ldr r2, Map
ldr r4, =0x10
lsl r4, #0x8
sub r4, #0x1
maploop:
ldrh r3, [r2]
cmp r3, r5
beq Move
notreplace:
add r2, #0x2 @add 2 to the map address, thus going to the next spot
sub r4, #0x1 @subtract 1 from r5, this is howmany times the loop repeats
bpl maploop
b End
@[Calculations..]
Move:
ldr r1,Corner@r1 X coordinate
ldr r5,Corner@r5 Y coordinate
ldr r3, Map
sub r2, r3
mov r3,#0x20
lsl r3,#8
lsr r2,#1
mov r4,#2
lsl r4,#7
mov r0,#0
@Box Number
Div1:
cmp r2,r4
blt Add1
sub r2,r4
add r0,#1
b Div1
Add1:
mov r4,r0
mov r0,#0
@Row number
Div2:
cmp r4,#4
blt Next
sub r4,#4
add r0,#1
b Div2
Next:
@r0 holds row number
@r4 holds box number
@r2 holds slot number
mul r0,r3
lsl r0, #4
add r5,r0
mul r4,r3
lsl r4,#4
add r1,r4
mov r0,#0
Div3:
cmp r2,#16
blt Finish
sub r2,#16
add r0,#1
b Div3
Finish:
mul r0,r3
add r5,r0
mul r2,r3
add r1,r2
ldr r0,Pointer
ldr r0,[r0]
ldrh r2,=0x548
sub r0,r2
str r1,[r0]
str r5,[r0,#8]
End:
bx lr
.arm
Map:
.long 0x021E3124
text:
.long 0x022AF136
Pointer:
.long 0x21C6DEC
Corner:
.long 0x00020FD7
Activator:
.ascii "zn"
Done:
.ascii "$$"
Compiled code (1.0)