Each pattern is 0x200 bytes (#512)

difference between characters 0x228C

difference between patterns 0x228

Adresses:
Town owner


021D6DDC = 1st pattern town owner 1st character

immediately after each pattern is the information for that pattern


-----------------------------------------------------

021D9068 = 1st pattern town owner 2nd character

021DB2F4 = 1st pattern town owner 3rd character

021DD580 = 1st pattern town owner 4th character





For town owner, ALL patterns are stored, even ones for their other characters



Other visitors:


021D0390 = first visitor first pattern

021D261C = second visitor first pattern

021D48A8 = third visitor first pattern
---------------------------------------------------------------


Code directions:

type znX Y Z into the chat


x is the player to copy from

0 town owner char 1
1 town owner char 2
2 town owner char 3
3 town owner char 4
4 visitor 1
5 visitor 2
6 visitor 3

y is the pattern to copy

0-7

Z is the pattern slot to store it in (for you)

0-7
--------------------------------------------------------------


@Pattern copy ASM routine:
@Text to copy
@this version allows you to type without sending the message


@Convert to thumb
add r2,pc,#1            
bx r2
.thumb

ldrh r2,=0x2424
ldrh r1,=0x6E7A

ldr r5,TextPointer
ldr r5,[r5]
ldrh r0,=0x3C16
ldrh r3,[r5,r0]
cmp r3,r1
bne Exit
add r5,r0
strh r2,[r5]

ldr r0,char2
ldr r1,VisitorPattern
ldrb r0,[r0]
cmp r0,#0
bgt Online
ldr r0,char1
ldrb r0,[r0]
ldr r1,OwnerPattern
Online:

@r1 holds your pattern
ldrh r2,chardiff
mul r0,r2
add r1,r0

@get X r0
ldrb r0,[r5,#2]
sub r0,#0x30
bpl Valid
b Exit
Valid:
cmp r0,#3
bgt StealFromVisitor
ldr r3,OwnerPattern
b ChoosePattern

StealFromVisitor:
cmp r0,#6
bgt Exit
sub r0,#3
ldr r3,VisitorPattern

ChoosePattern:
mul r0,r2
add r3,r0

@r1 holds stealer's pattern
@r3 holds victim's pattern

ldrb r0,[r5,#4]
sub r0,#0x30
bpl Valid1
b Exit
Valid1:
cmp r0,#7
bgt Exit
mov r4,#0x22
lsl r4,#4
add r4,#8
mul r0,r4
add r3,r0

@r1 holds stealers pattern
@r3 holds victims pattern


ldrb r0,[r5,#6]
sub r0,#0x30
bpl Valid2
b Exit
Valid2:
cmp r0,#7
bgt Exit
mul r0,r4
add r1,r0

mov r4,#0x22
lsl r4,#4
add r4,#0x4
Steal:
ldr r2,[r3,r4]
str r2,[r1,r4]
sub r4,#4
bpl Steal

Exit:bx lr



.arm
TextPointer:
.long 0x21CAF6C
OwnerPattern:
.long 0x21D6DDC
VisitorPattern:
.long 0x21CE104
char1:
.long 0x21D02EC
char2:
.long 0x21CBD48
chardiff:
.short 0x228C




-------------------------------------------

@Different version
@coordinates determine what item you're standing on
@basically if you're on a pattern,
@you can copy it


@Convert to thumb
add r2,pc,#1            
bx r2
.thumb

ldr r1,CoordinatesPointer

ldr r1,[r1]
cmp r1,#0

@Check if you're at the games menu or some place that clears the address in the pointer

beq Exit

mov r2,#0xA9
lsl r2,#3
sub r1,r2
ldr r3,[r1] @r3 now holds X coordinates
lsr r3,#0xD


ldr r2,[r1,#8] @r2 now holds y coordinate
lsr r2,#0xD



OutdoorsCheck:

cmp r3,#0x10 @check if you're before the map
blt Exit
cmp r3,#0x50 @check if you're after the map
bgt Exit


cmp r2,#0x10 @check if you're before the map
blt Exit
cmp r2,#0x50 @check if you're after the map
bgt Exit



@subtract #0x10 so you end up with the Row/Column number
sub r3,#0x10
sub r2,#0x10

@r2 holds column
@r3 holds row

BeginDivision:
mov r0,#0xF
mov r4,#0xF


@-----------My routine
Divide1:
and r0,r3,r0
lsr r3,#4


@-----------My routine
Divide2:
and r4,r2,r4
lsr r2,#4

Finish:
@r3 holds y box multiply by #0x200
@r2 holds x box multiply by #0x800
@r0 holds column multiply by #0x2
@r4 holds row  multiply by #0x20

lsl r0,#1   @multiply by #2
lsl r4,#5   @multiply by #32
lsl r3,#9   @multiply by #512
lsl r2,#0xB @multiply by #2048


@add to the map to get the space you're on

AddSlot:
add r0,r4
add r0,r2
add r0,r3



@Load item from that space
ldr r1,Map
ldrh r5,[r1,r0]

@Check if the item is a pattern, if not end the code
cmp r5,#0xA7 
blt Exit
cmp r5,#0xC6
bgt Exit

sub r5,#0xA7

mov r0,#0

@determine which player that pattern belongs to
@and which pattern number it is
Loop:
cmp r5,#8
blt Done
sub r5,#8
add r0,#1
b Loop

Done:
ldrh r2,Chardiff
mul r0,r2
mov r3,#0x22
lsl r3,#4
add r3,#8
mul r5,r3

@r5 holds pattern number
@r0 holds player number

ldr r3,TownOwner
add r3,r5
add r3,r0
@r3 holds pattern address

ldr r1,Char2
ldr r4,VisitorPattern
ldrb r1,[r1]

cmp r1,#0
bgt Visiting
ldr r1,Char1
ldrb r1,[r1]
ldr r4,TownOwner

Visiting:
mul r1,r2
add r4,r1
mov r1,#0x22
lsl r1,#4
add r1,#8

mov r0,#0x22
lsl r0,#4
add r0,#0x4


Copy:  @completely copy the pattern and information
ldr r2,[r3,r0]
str r2,[r4,r0]
sub r0,#4
bpl Copy

Exit:
bx lr

.arm
CoordinatesPointer:
.long 0x21C6DEC
Map:
.long 0x21E3124
TownOwner:
.long 0x21D6DDC
VisitorPattern:
.long 0x21CE104
Char2:
.long 0x21CBD48
Char1:
.long 0x21D02EC
Chardiff:
.short 0x228C