.gba
.open "zm.gba","LoadBeamGraphics.gba",0x8000000

.org 0x8007D6A
	bl ChargeBeamGraphics

.org 0x800CCC6
	bl 804F924h

.org 0x801BAF0
	nop
	nop

.org 0x804F2C4
	bl BeamProcess

.org 0x804F924
	push r14

.org 0x804F670
ChargeBeamGraphics:
	push r14
	ldr r0,=3001530h
	ldrb r1,[r0,12h]
	cmp r1,2h
	bne NotBeamPistole
	mov r0,5h
	b EndCheck
NotBeamPistole:
	ldrb r1,[r0,0Dh]
	mov r0,8h
	and r0,r1
	cmp r0,0h
	beq NotPlasma
	lsr r0,r0,1h
	b EndCheck
NotPlasma:
	mov r0,4h
	and r0,r1
	cmp r0,0h
	beq NotWave
	sub r0,r0,1h
	b EndCheck
NotWave:
	mov r0,2h
	and r0,r1
	cmp r0,0h
	beq NotIce
	b EndCheck
NotIce:
	mov r0,1h
	and r0,r1
	cmp r0,0h
	beq NotLong
	b EndCheck
NotLong:
	mov r0,0h
EndCheck:
	push r2,r3
	bl LoadBeamGraphics
	pop r2,r3
	ldrb r0,[r3,5h]
	cmp r0,4Fh
	b ReturnToCode
	
BeamProcess:
	push r14
	ldrb r0,[r4,0Fh]
	bl LoadBeamGraphics
	ldrb r0,[r4,0Fh]
	lsl r0,r0,2h
ReturnToCode:
	pop r1
	bx r1
	
LoadBeamGraphics:
	push    r14              
	ldr     r3,=3001530h     
	ldrb    r3,[r3,0Dh]      
	cmp     r0,3h
	beq			LoadWave
	cmp     r0,4h
	beq			LoadPlasma
	cmp     r0,5h
	beq			ZeroSuitPistole
	cmp     r0,9h
	beq			LoadWave
	cmp     r0,0Ah
	beq			LoadPlasma
	cmp     r0,0Bh	
	beq			ZeroSuitPistole
	b				LoadPartTwo
ZeroSuitPistole:
	ldr     r0,=40000D4h 
	ldr     r1,=832B078h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r1,=80000080h
	str     r1,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832B278h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832B478h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832B678h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	bl      80538E8h     
	mov     r0,50h           
	b       Return			     
LoadPlasma:                 
	ldr     r0,=40000D4h 
	ldr     r1,=8329ED4h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832A0D4h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832A2D4h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=832A4D4h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	mov     r0,40h           
	b       PlasmaWaveIceCheck
LoadWave:      
	ldr     r0,=40000D4h 
	ldr     r1,=8328F34h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8329134h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8329334h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8329534h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	mov     r0,30h           
PlasmaWaveIceCheck:
	mov     r1,2h            
	and     r3,r1            
	cmp     r3,0h            
	bne     PlasmaWaveIce    
	b       Return			     
PlasmaWaveIce:
	mov     r0,20h           
	b       Return
LoadPartTwo:
	cmp     r0,0h
	beq			LoadNormal
	cmp     r0,1h
	beq			LoadLong
	cmp     r0,2h
	beq			LoadIce
	cmp     r0,6h
	beq			LoadNormal
	cmp     r0,7h
	beq			LoadLong
	cmp     r0,8h
	beq			LoadIce
	b ReturnEnd
LoadIce:      
	ldr     r0,=40000D4h 
	ldr     r1,=8328500h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8328700h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8328900h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8328B00h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	mov     r0,20h           
	b       Return			     
LoadLong:      
	ldr     r0,=40000D4h 
	ldr     r1,=8327B90h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8327D90h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8327F90h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=8328190h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	mov     r0,10h           
	b       Return			     
LoadNormal:
	ldr     r0,=40000D4h 
	ldr     r1,=83271A8h 
	str     r1,[r0]          
	ldr     r1,=6011000h 
	str     r1,[r0,4h]       
	ldr     r2,=80000100h
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=83273A8h 
	str     r1,[r0]          
	ldr     r1,=6011400h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=83275A8h 
	str     r1,[r0]          
	ldr     r1,=6011800h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r1,[r0,8h]       
	ldr     r1,=83277A8h 
	str     r1,[r0]          
	ldr     r1,=6011C00h 
	str     r1,[r0,4h]       
	str     r2,[r0,8h]       
	ldr     r0,[r0,8h]       
	mov     r0,0h            
Return:
	ldr     r2,=40000D4h 
	lsl     r0,r0,1h         
	ldr     r1,=83270E8h 
	add     r0,r0,r1         
	str     r0,[r2]          
	ldr     r0,=5000240h 
	str     r0,[r2,4h]       
	ldr     r0,=80000006h
	str     r0,[r2,8h]       
	ldr     r0,[r2,8h]
ReturnEnd:
	pop     r0               
	bx      r0      

.pool
.close	
