.gba
.open "zm.gba","ShineSparkBonk.gba",0x8000000

.org 0x80074EA
	ldr r5,=30013D4h
	ldr r6,=30013F4h
	ldr r7,=3001414h
	bl FreeSpaceA

.org 0x8007524
	.pool

.org 0x8009CA4
	bl FreeSpaceB
	
.org 0x8043DF0	;Crocomire AI unused
FreeSpaceA:
	lsl r0,r0,18h
	lsr r4,r0,18h
	ldr r2,=30013C4h	;Unused Ram
	cmp r4,22h
	beq Spark
	cmp r4,23h
	beq Bonk
	cmp r4,26h
	beq Spark
	cmp r4,27h
	bne NothingAtAll
Bonk:
	mov r1,0h
	strh r1,[r2,2h]	;x
	strh r1,[r2,4h]	;y
	b NothingAtAll
Spark:
	ldrh r1,[r5,12h]	;x
	strh r1,[r2,2h]	;x
	ldrh r1,[r5,14h]	;y
	strh r1,[r2,4h]	;y
NothingAtAll:
	bx r14
	.pool
	
FreeSpaceB:
	mov r4,r0
	ldr r2,=30013C4h	;Unused Ram
	ldrb r0,[r4]
	cmp r0,0h
	beq Upwards
	ldrh r0,[r4,12h]
	ldrh r1,[r2,2h]
	cmp r0,r1
	bne Upwards
	mov r0,0h
	strh r0,[r4,16h]
Upwards:
	ldrb r0,[r4]
	cmp r0,1h
	beq UpdateValues
	ldrh r0,[r4,14h]
	ldrh r1,[r2,4h]
	cmp r0,r1
	bne UpdateValues
	mov r0,0h
	strh r0,[r4,18h]	
UpdateValues:
	ldrh r0,[r4,12h]
	strh r0,[r2,2h]
	ldrh r0,[r4,14h]
	strh r0,[r2,4h]
ReturnToSparkFunction:
	mov r1,0h
	bx r14
	.pool
	
	.close