.gba
.open "zm.gba","fastvaria.gba",0x8000000

.definelabel freespace,0x8770000

.org 0x08007674
	bne	 0x800767A

.org 0x8007678
	nop

.org 0x80076CC
	.word	fastvaria

.org 0x800767C
	mov		r15,r0


.org freespace
fastvaria:
	ldr     r0,=0x3001530
    ldrb    r0,[r0,13h]       
    cmp     r0,0             
    beq     @@nometroid          
    mov     r5,0x1  
	ldr		r0,=0x8007684
	mov		r15,r0
@@nometroid:
	mov     r0,r4  
    add     r0,0x5B
    strb    r5,[r0]
	cmp		r5,0x0
	bne		@@underwater

	ldr     r0,=0x3001530
    ldrb    r0,[r0,0xF]
	mov		r1,0x10
	and		r0,r1
    cmp     r0,0             
    bne     @@hasvaria          
	ldr		r0,=0x8007684
	mov		r15,r0

@@underwater:
	ldr     r0,=0x3001530
    ldrb    r0,[r0,13h]       
    cmp     r0,0             
    beq     @@underwaternometroid          
    add     r5,0x1  
	ldr		r0,=0x8007684
	mov		r15,r0
@@underwaternometroid:
	ldr     r0,=0x3001530
    ldrb    r0,[r0,0xF]
	mov		r1,0x10
	and		r0,r1
    cmp     r0,0             
    bne     @@underwaterhasvaria          
	ldr		r0,=0x8007684
	mov		r15,r0

@@hasvaria:
	mov     r0,r4              ;
	add     r0,0x5E             ;
    mov     r1,0xa              ;} [XAcceleration] = 0xC
    strh    r1,[r0]            ;
    mov     r3,r4              ;
    add     r3,0x60             ;
    mov     r0,0x78             ; [MaxXVelocity] = 0x90
    strh    r0,[r3]            ;
    mov     r2,r4              ;
    add     r2,0x6A             ;
    mov     r0,0x50             ; [InAirMaxVelocity] = 50h
    strh    r0,[r2]            ;
    mov     r0,r4              ;
    add     r0,0x68             ; [InAirAcceleration] = 8h
    strh    r1,[r0]            ;
    mov     r1,r4              ;
    add     r1,0x6C             ;
    mov     r0,0x30             ;} [MaxMorphXSpeedInAir] = 30h
    strh    r0,[r1]            ;
    sub     r1,0xa             ;
    mov     r0,0x6              ;} [YAcceleration] = 6h
    strh    r0,[r1]            ;
    add     r1,0x2              ;
    mov     r0,0xC0            ;} [30015EC] = C0h
    strh    r0,[r1]            ;
    add     r1,0x2              ;
    mov     r0,0x80             ;} [MaxYVelocity] = 80h
    strh    r0,[r1]            ;
    ldrb    r0,[r6,0x5]         ;
    cmp     r0,0x0              ;} If SpeedBoostingFlag != 0:
    beq     @@return           ;
    mov     r0,0xA0            ;
    strh    r0,[r2]            ;} [MaxXVelocity] = A0
    strh    r0,[r3]            ; [InAirMaxXVelocity] = A0
	b		@@return

@@underwaterhasvaria:
	add     r0,0x3              ;
    mov     r2,0x5              ;} [XAcceleration] = 4h
    strh    r2,[r0]            ;
    mov     r1,r4              ;
    add     r1,0x60             ;|
    mov     r0,0x40             ;} [MaxXVelocity] = 30h
    strh    r0,[r1]            ;
    add     r1,0x0A             ;
    mov     r0,0x24             ;} [InAirMaxVelocity] = 20h
    strh    r0,[r1]            ;
    mov     r0,r4              ;
    add     r0,0x68             ;} [InAirAcceleration] = 4h
    strh    r2,[r0]            ;
    add     r1,0x2              ;
    mov     r0,0x1C             ;} [midair morph veloc x cap] = 18h
    strh    r0,[r1]            ;
    sub     r1,0x0A             ;
    mov     r0,0x5              ;} [YDeceleration] = 5h
    strh    r0,[r1]            ;
    mov     r0,r4              ;
    add     r0,0x64             ;} [y velocity cap] = 28h
    mov     r1,0x28             ;|
    strh    r1,[r0]            ;
    add     r0,0x2              ;
    strh    r1,[r0]            ;} [y velocity cap] = 28h
    ldrb    r0,[r6,0x5]         ;
    cmp     r0,0x0              ;} If [SpeedBoostingFlag] != 0:
    beq     @@return           ;
    mov     r0,0x0              ;
    strb    r0,[r6,0x5]         ;} Set [SpeedBoostingFlag] = 0
    b       @@return           ;















@@return:
	ldr		r0,=0x08007714
	mov		r15,r0

.pool
.close