.gba
.open "zm.gba","ShineSparkImprovements.gba",0x8000000

;Standing
.org 0x80086D8
	ldr r0,=300137Ch
	
.org 0x80086E4
	ldrh r0,[r4,16h]
	cmp r0,0h
	bne 8008724h
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq 8008724h
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq 8008724h
	ldr r0,=300137Ch
	ldrh r1,[r0]
	mov r0,0C0h
	and r0,r1
	cmp r0,80h
	beq StandingDown
	mov r2,20h
	cmp r0,40h
	bne StandingNormal
	mov r2,40h
StandingNormal:
	ldrh r0,[r4,14h]
	sub r0,r0,r2
	strh r0,[r4,14h]
StandingDown:
	mov r0,21h
	b 8008816h
	.pool
	.fill 0x4
	
;Turning
.org 0x8008840
	ldr r0,=300137Ch
	
.org 0x800884C
	ldrh r0,[r4,16h]
	cmp r0,0h
	bne 800888Ch
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq 800888Ch
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq 800888Ch
	ldr r0,=300137Ch
	ldrh r1,[r0]
	mov r0,0C0h
	and r0,r1
	cmp r0,80h
	beq TurningDown
	mov r2,20h
	cmp r0,40h
	bne TurningNormal
	mov r2,40h
TurningNormal:
	ldrh r0,[r4,14h]
	sub r0,r0,r2
	strh r0,[r4,14h]
TurningDown:
	mov r0,21h
	b 80088F2h
	.pool
	.fill 0x4
	
;Crouching
.org 0x8008960
	ldr r0,=300137Ch
	
.org 0x800896C
	ldrh r0,[r4,16h]
	cmp r0,0h
	bne 80089ACh
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq 80089ACh
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq 80089ACh
	ldr r0,=300137Ch
	ldrh r1,[r0]
	mov r0,0C0h
	and r0,r1
	cmp r0,80h
	beq CrouchingDown
	mov r2,20h
	cmp r0,40h
	bne CrouchingNormal
	mov r2,40h
CrouchingNormal:
	ldrh r0,[r4,14h]
	sub r0,r0,r2
	strh r0,[r4,14h]
CrouchingDown:
	mov r0,21h
	b 8008B0Ch
	.pool
	.fill 0x4

;CrouchingAndTurning
.org 0x8008B18
	ldr r0,=300137Ch
	
.org 0x8008B24
	ldrh r0,[r4,16h]
	cmp r0,0h
	bne 8008B64h
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq 8008B64h
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq 8008B64h
	ldr r0,=300137Ch
	ldrh r1,[r0]
	mov r0,0C0h
	and r0,r1
	cmp r0,80h
	beq CrouchingAndTurningDown
	mov r2,20h
	cmp r0,40h
	bne CrouchingAndTurningNormal
	mov r2,40h
CrouchingAndTurningNormal:
	ldrh r0,[r4,14h]
	sub r0,r0,r2
	strh r0,[r4,14h]
CrouchingAndTurningDown:
	mov r0,21h
	b 8008C1Eh
	.pool
	.fill 0x4

;Morphball
.org 0x800926A
	ldrh r0,[r4,16h]
	cmp r0,0h
	bne 80092B8h
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq 80092B8h
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq 80092B8h
	ldr r0,=3001530h
	ldrb r1,[r0,0Fh]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq MorphballDown
	ldr r0,=300137Ch
	ldrh r1,[r0]
	mov r0,80h
	and r0,r1
	cmp r0,0h
	bne MorphballDown
	ldrh r0,[r4,14h]
	sub r0,40h
	strh r0,[r4,14h]
MorphballDown:
	mov r0,25h
	b 80093ACh
	.pool
	.fill 0xC
	
;JumpingOrFallingInMorphball
.org 0x8009530
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,40h
	and r0,r1
	cmp r0,0h
	beq ContinueChecks
	
.org 0x800953C
	ldr r0,=823A554h
	
.org 0x800954C
	bne ContinueChecks
	mov r0,78h
	bl 8002A18h
	mov r0,0Fh
	strb r0,[r4,9h]
	mov r0,8h
	b 80095FCh
ContinueChecks:
	ldr r0,=300137Ch
	ldrh r1,[r0,4h]
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq NoShineSpark
	ldrb r0,[r4,8h]
	cmp r0,0h
	beq NoShineSpark
	mov r0,25h
	b 80095FCh
NoShineSpark:
	ldrb r0,[r4,4h]
	cmp r0,0h
	bne 800959Ch
	ldr r0,=300137Ch
	ldrh r0,[r0]
	mov r1,1h
	and r1,r0
	cmp r1,0h
	bne 80095A8h
	mov r2,18h
	ldsh r0,[r4,r2]
	cmp r0,0h
	ble 80095A8h
	strh r1,[r4,18h]
	b 80095A8h
	.pool
	
.org 0x8009E4C
	nop
	nop
	nop
	
.close