	
	;this version is only sd card bootable	
	
;*********************************************************************
;* defines
;*********************************************************************

	.def	picDataRAM	$d0000000
	
	.def	uLow         	0
	.def	uHigh         	1
	.def	vLow         	2
	.def	vHigh         	3
	.def	suLow        	4
	.def	suHigh        	5
	.def	svLow        	6
	.def	svHigh        	7
	.def	duLow        	8
	.def	duHigh        	9
	.def	dvLow        	10
	.def	dvHigh        	11
	
	.def	cOffsetX	0
	.def	cOffsetY        1
	.def	cCenterX        2
	.def	cCenterY        3
	.def	cAngle          4
	.def	cZoom	        5
	.def	cosycLow	6
	.def	cosycHigh	7
	.def	cosxcLow 	8
	.def	cosxcHigh	9
	.def	sinycLow	10
	.def	sinycHigh	11
	.def	sinxcLow	12
	.def	sinxcHigh	13
	
	
;*********************************************************************	
; includes
;*********************************************************************	

	.incdir	"F:\git\goldmomo_endlos\assembler_files\ucore\"
	.include "boot_level_sdHeader.s"
	.include "include\ucore.i"
	.include "include\ucore_ctrl.i"
	
;***********************************************************************
;* loader
;***********************************************************************	

	;read sdcard to sram
	
	movei	r0,startBlock
	nop
	moveih	r0,>startBlock
	nop
	rqldi	r0,0	;low
	rqldi	r0,1	;high
	nop
	ld	r2
	ld	r3
	
	addi	r2,64	;64 blocks offset (ucore code/data)
	addtqi	r3,r3,0
	
	;read blocks

	movei	r1,$00
	movei	r0,$00
	moveih	r1,$f0		;r1:r0 = $f000 0000 (dest start)
	
	movei	r6,sdCardReadBlocks
	nop
	moveih	r6,>sdCardReadBlocks
	
	gpci	r7,2		;
	jmpi	r6,0
	movei	r4,$02		;2048+3 blocks-1	delay slot
	nop			;delay slot
	moveih	r4,$4		;delay slot
	nop			;delay slot
	
;***********************************************************************
;* real code
;***********************************************************************	
	
	;reset PS2 buffer
	
	gpci	r7,2	;next 4 + X
	br	PS2Reset
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
		
	;setup video (360x225)
	
	gpci	r7,2		;next 4 + X
	br	setupVideo
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;setup irq vector
	
	dexti	>irq
	movei	r0,irq	
	nop
	setssr	r0,2
	
	;init fps timer 2
	
	dexti	>UcTimer2LowValue
	movei	r2,UcTimer2LowValue
		
	dexti	$c7		;0658 c749 = 1 Hz
	movei	r0,$49
	dexti	$06
	movei	r1,$58
		
	stinc	r2,r0		;low
	movei	r0,5		;start with auto reloead
	stinc	r2,r1		;high		(timer will reload value after next hit)
	nop
	stinc	r2,r0		;write config	
	
	;enable irq mask
	
	movei	r0,UcIrqMsk
	movei	r1,$2			;enable timer 2
	moveih	r0,>UcIrqMsk
	nop
	st	r0,r1	
	
	;enable irqs
	
	sei
	
;***********************************************************************
;* main loop
;***********************************************************************	
		
loop	
	;test switches to skip vblank wait
	
	dexti	>UcRSwichtWLedG
	movei	r0,UcRSwichtWLedG
	nop
	rqldi	r0,0
	nop
	nop
	ld	r0
	nop
	extri	r0,0	;SW 0?
	brts	skipVBlank
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;wait vpos (930)

	gpci	r7,2	;next 4 + X
	br	waitVPos
	movei	r0,$a1	;delay slot
	nop		;delay slot
	moveih	r0,$3	;delay slot
	nop		;delay slot
	
skipVBlank	
	
	;switchFrames

	gpci	r7,2	;next 4 + X
	br	switchFrames
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;set display address to video
	
	movei	r0,displayFrame	
	movei	r1,UcVideoMEMStartAdrLow
	movei	r2,UcVideoMEMLatch
	moveih	r0,>displayFrame
	moveih	r1,>UcVideoMEMStartAdrLow	;low memstart
	moveih	r2,>UcVideoMEMLatch		;latch out
	
	rqldi	r0,1
	rqldi	r0,0
	nop
	ld	r3
	ld	r4
	
	st	r1,r3
	addi	r1,1
	nop
	st	r1,r4
	st	r2,r7		;latch out
	
	;process ps2 keys
	
	gpci	r7,2		;next 4 + X
	br	PS2Process
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;testKeys
	
	gpci	r7,2
	br	testKeys
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;calcValues
	
	gpci	r7,2
	br	calcValues
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;***********************************************************************
	;* per screen
	;***********************************************************************
	
	dexti	>objectValues	
	movei	r2,objectValues	;u, v, su, sv, ...
	nop
	
	;set du
	
	rqldi	r2,duLow
	rqldi	r2,duHigh
	nop
	ld	r0
	ld	r1
	
	movei	r6,l2dduHigh
	nop
	setssr	r6,5		;write sel
	setssr	r1,6		;write data
	
	movei	r6,l2dduLow
	nop
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
	
	;set dv
	
	rqldi	r2,dvLow
	rqldi	r2,dvHigh
	nop
	ld	r0
	ld	r1
	
	movei	r6,l2ddvHigh
	nop
	setssr	r6,5		;write sel
	setssr	r1,6		;write data
	
	movei	r6,l2ddvLow
	nop
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
				
	;set xmask, ymask, xwidth, adr

	movei	r6,l2dxmask
	dexti	1	
	movei	r0,$ff		;xmask
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
	
	movei	r6,l2dymask
	dexti	1	
	movei	r0,$ff		;ymask
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
	
	movei	r6,l2dxwidth
	dexti	2	
	movei	r0,$00		;xwidth
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
	
	movei	r1,$00
	movei	r0,$00
	moveih	r1,$f0		;r1:r0 = $f000 0000 (source)
	
	movei	r6,l2dsadrLow
	nop
	setssr	r6,5		;write sel
	setssr	r0,6		;write data
	
	movei	r6,l2dsadrHigh
	nop
	setssr	r6,5		;write sel
	setssr	r1,6		;write data
	
	;
	
	movei	r3,0		;y
	
yloop	
	;set u (x)
	
	rqldi	r2,uLow
	rqldi	r2,uHigh
	movei	r6,l2duHigh
	ld	r0
	ld	r1
	
	movei	r5,l2duLow
	setssr	r6,5		;write sel
	setssr	r1,6		;write data
	setssr	r5,5		;write sel
	setssr	r0,6		;write data

	;set v 
	
	rqldi	r2,vLow
	rqldi	r2,vHigh
	nop
	ld	r0
	ld	r1
	
	movei	r6,l2dvHigh
	movei	r5,l2dvLow
	setssr	r6,5		;write sel
	setssr	r1,6		;write data
	setssr	r5,5		;write sel
	setssr	r0,6		;write data
	
	;v += sv;
	
	rqldi	r2,vLow
	rqldi	r2,vHigh
	rqldi	r2,svLow
	ld	r0		;vLow
	ld	r1		;vHigh
	ld	r5		;svLow
	rqldi	r2,svHigh
	nop
	nop
	ld	r6		;svHigh
	
	add	r0,r0,r5
	addt	r1,r1,r6
	ssto	vLow
	stwo	r2,r0
	ssto	vHigh
	stwo	r2,r1
		
	;u = +su
	
	rqldi	r2,uLow
	rqldi	r2,uHigh
	rqldi	r2,suLow
	ld	r0		;uLow
	ld	r1		;uHigh
	ld	r5		;suLow
	rqldi	r2,suHigh
	nop
	nop
	ld	r6		;suHigh
	
	add	r0,r0,r5
	addt	r1,r1,r6
	ssto	uLow
	stwo	r2,r0
	ssto	uHigh
	stwo	r2,r1
	
	;push pipeline (after du,dv)
	
	exl2den
	exl2den
	exl2den
	
	;draw scanline
	
	;movei	r5,picDataRAM		;destination 
       ; movei	r6,>>picDataRAM
        ;moveih	r5,>picDataRAM
        ;moveih	r6,>>>picDataRAM
	
	movei	r1,drawFrame
	nop
	moveih	r1,>drawFrame
	nop
	rqldi	r1,1	;low
	rqldi	r1,0	;high
	nop
	ld	r5
	ld	r6
	
	
	or	r0,r3,r3	;r0 = y
	dexti	1
	muli	r0,$68		;r0 = r0 * 360
	gmulhi	r1		;r1 (high part)

	gpci	r7,2
	br	drawScanLine24
	movei	r4,14		;15 * 24 = 360 pixel	delay slot
	add	r5,r5,r0	;dest + y		;delay slot
	addt	r6,r6,r1	;high partnop		;delay slot
	nop			;delay slot

	;
	
	cmpeqi	r3,224
	brtc	yloop
	addi	r3,1		;y++ delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
		
	;draw stats
	
	dexti	>fps
	movei	r0,fps
	nop
	rqldi	r0,0
	nop
	nop
	ld	r0
	nop
	push	r0

	gpci	r7,2		;next 4 + X
	br	drawTextFormated
	movei	r0,textStats	;delay slot
	movei	r1,1		;delay slot
	moveih	r0,>textStats	;delay slot
	movei	r2,1		;delay slot
	
	rqpop
	
	;increment frameCounter
	
	dexti	>frameCounter
	movei	r0,frameCounter
	nop
	rqldi	r0,0
	nop
	nop
	ld	r1
	nop
	addi	r1,1
	nop
	st	r0,r1
	
	;.stop

	;
		
	br	loop	
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;*********************************************************************
;* functions
;*********************************************************************	
	
	.include	"components\sdCardLoader.s"
	.include	"components\ps2keyboard.s"	
	.include	"components\drawText.s"
	.include	"components\drawChar1Bit.s"
	
;***********************************************************************
;* irq code start
;***********************************************************************
	
irq
	cli
	
	;save all register
	
	epushsadrl
	epushsadrh
	push	r0
	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	push	r6
	push	r7
	
	;check type of irq
	
	dexti	>UcIrqMemory
	movei	r0,UcIrqMemory
	nop
	rqldi	r0,0
	nop
	nop
	ld	r0		;memory
	nop
	extri	r0,1		;timer 2
	gpci	r7,2		
	brts	irqTimer2	
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	
	;restore all used register and go back
	
	rqpop		
	rqpop	
	rqpop	
	pop	r7
	pop	r6
	pop	r5
	
	rqpop		
	rqpop	
	rqpop	
	pop	r4
	pop	r3
	pop	r2
	
	rqpop		
	rqpop
	rqpop
	pop	r1
        pop	r0
	epopsadrh
	
	rqpop
	rti
	nop		;delay slot
	epopsadrl	;delay slot
	nop		;delay slot
	sei		;delay slot	
	
;***********************************************************************
;* irq timer 2
;***********************************************************************
		
irqTimer2

	push	r0
	push	r7
	
	;do something
	
	dexti	>frameCounter
	movei	r0,frameCounter
	movei	r3,0
	rqldi	r0,0
	dexti	>fps
	movei	r1,fps
	ld	r2	;counter
	st	r0,r3	;clear counter
	st	r1,r2	;store to fps
	
	;clear irq 2 timer
	
	dexti	>UcIrqMemory
	movei	r0,UcIrqMemory
	nop
	rqldi	r0,0
	nop
	movei	r1,2		;timer 2
	ld	r2		;memory
	nop
	bic	r2,r2,r1
	nop
	st	r0,r2		;
	
	;back
	
	rqpop
	nop
	nop
	pop	r7
	
	rqpop
	jmpi	r7,0
	nop		;delay slot
	pop	r0	;delay slot
	nop		;delay slot
	nop		;delay slot	
	
;******************************
;*
;* drawScanLine24
;*
;* r4 	pixel count / 24 - 1
;* r5 	dest low
;* r6 	dest high
;*
;* note: you have to setup l2dData before 	

drawScanLine24

	push	r0
	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	push	r6
	push	r7
	
	;per 24 pixel (dest)
	
scanloop	
	exl2den
	exl2denerqld	
	exl2denerqld    
	exl2denerqld    
	exl2denerqld 
	exl2denerqld	
	exl2denerqld    
	exl2denerqld    
	exl2denerqld 
	exl2denerqld	
	exl2denerqld    
	exl2denerqld    
	exl2denerqld  
	exl2denerqld	
	exl2denerqld    
	exl2denerqld    
	exl2denerqld  	
	exl2denerqld	
	exl2denerqld    
	exl2denerqld  
	exl2denerqld    
	exl2denerqld	
	exl2denerqld    
	exl2denerqld 	
	exl2derqld    
	esadr	r6,r5
	addi	r5,8
	addtqi	r6,r6,0
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	est	r0,0
	est	r1,1
	est	r2,2
	est	r3,3
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	est	r0,4
	est	r1,5
	est	r2,6
	est	r3,7
	esadr	r6,r5
	addi	r5,8
	addtqi	r6,r6,0
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	est	r0,0
	est	r1,1
	est	r2,2
	est	r3,3
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	est	r0,4
	est	r1,5
	est	r2,6
	est	r3,7
	esadr	r6,r5
	addi	r5,8
	addtqi	r6,r6,0
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	est	r0,0
	est	r1,1
	est	r2,2
	est	r3,3
	eld	r0
	eld	r1
	eld	r2
	eld	r3
	subi	r4,1
	brts	scanloop
	est	r0,4		;delay slot
	est	r1,5            ;delay slot
	est	r2,6           ;delay slot
	est	r3,7            ;delay slot
	
	;
	
	rqpop	
	rqpop
	rqpop
	pop	r7
	pop	r6
	pop	r5
	rqpop	
	rqpop
	rqpop
	pop	r4
	pop	r3
	pop	r2

	rqpop	
	rqpop
	jmpi	r7,0
	pop	r1		;delay slot
	pop	r0		;delay slot
	nop			;delay slot
	nop			;delay slot
	
;******************************
;*
;* testKeys
;* 	

testKeys	
	
	push	r7
	
	dexti	>variableValues
	movei	r6,variableValues	;source
		
	;check key A
	
	movei	r0,$1c		;a?
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	
	cmpeqi	r0,0
	brts	notAPressed
	rqldi	r6,cAngle	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
		
	nop
	addi	r0,1
	ssto	cAngle
	stwo	r6,r0
		
notAPressed	

	;check key S
	
	movei	r0,$1b		;s?
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notSPressed
	rqldi	r6,cAngle	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	subi	r0,1
	ssto	cAngle
	stwo	r6,r0
		
notSPressed	

	;check key D
	
	movei	r0,$23		;d?
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notDPressed
	rqldi	r6,cZoom	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	addi	r0,1
	ssto	cZoom
	stwo	r6,r0
		
notDPressed	

	;check key F
	
	movei	r0,$2b		;f?
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notFPressed
	rqldi	r6,cZoom	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	subi	r0,1
	ssto	cZoom
	stwo	r6,r0
		
notFPressed	

	
	;left arrow
	
	movei	r0,$fb		;l
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notLAPressed
	rqldi	r6,cCenterX	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	addi	r0,1
	ssto	cCenterX
	stwo	r6,r0
		
notLAPressed	

	;right arrow
	
	dexti	1
	movei	r0,$04		;r
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notRAPressed
	rqldi	r6,cCenterX	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	subi	r0,1
	ssto	cCenterX
	stwo	r6,r0
		
notRAPressed	

	;up arrow
	
	dexti	1
	movei	r0,$05		;u
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notUAPressed
	rqldi	r6,cCenterY	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	addi	r0,1
	ssto	cCenterY
	stwo	r6,r0
		
notUAPressed	

	;down arrow
	
	dexti	1
	movei	r0,$02		;d
	gpci	r7,2
	br	PS2TestKey
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;dump
	
	cmpeqi	r0,0
	brts	notDAPressed
	rqldi	r6,cCenterY	;delay slot
	nop                     ;delay slot
	nop                     ;delay slot
	ld	r0              ;delay slot
	
	nop
	subi	r0,1
	ssto	cCenterY
	stwo	r6,r0
		
notDAPressed

	rqpop
	nop
	nop
	pop	r7
	nop

	jmpi	r7,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

;******************************
;* waitVPos
;*
;* r0 pos
;* 

waitVPos	
	
	push	r1
	push	r2
	
	dexti	>UcVideoRVCountWHSYNC
	movei	r1,UcVideoRVCountWHSYNC	;vcount
	nop
		
waitV	
	rqldi	r1,0
	nop
	nop
	ld	r2	;get vcount
	nop
	cmpeq	r0,r2
	brtc	waitV
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

	rqpop
	rqpop
	jmpi	r7,0
	pop	r2	;delay slot
	pop	r1     	;delay slot
	nop		;delay slot
	nop		;delay slot
	
;******************************
;*
;* calcValues
;*
	
calcValues	

	push	r7
	
	dexti	>variableValues
	movei	r5,variableValues	;source
	
	dexti	>objectValues
	movei	r6,objectValues		;dest
	
	;get sin,cos form angle
	
	dexti	$1
	movei	r2,$ff
	rqldi	r5,cAngle
	dexti	>sinTable
	movei	r1,sinTable
	ld	r0		;angle
	nop
	and	r0,r0,r2	;only 0..511
	nop
	rqld	r1,r0		;sinTable[r]
	addi	r0,128
	nop
	ld	r4		;r4 = sin
	rqld	r1,r0		;sinTable[r+128]
	rqldi	r5,cZoom
	nop
	ld	r3		;r3 = cos
	ld	r2		;r2 = zoom
	
	;multiply with zoom
	
	nop
	muls	r0,r4,r2	;sin * zoom	
	gmulhi	r4		;get upper part r4 = ssin (high)
	muls	r1,r3,r2	;cos * zoom
	gmulhi	r3		;get upper part r3 = scos (high)
		
	;asr 8	r4:r0	r3:r1

	lsri	r0,8
	lsri	r1,8
	dexti	$20		;*$100 =  10 0000 [000] = 
	mulqi	r2,r4,0		;r4 = AAAA AAAA BBBB BBBB ->  BBBB BBBB 0000 0000
	nop
	or	r0,r0,r2
	dexti	$20
	mulqi	r2,r3,0
	nop
	or	r1,r1,r2
	asri	r4,8
	asri	r3,8
		
	;store su,sv,du,dv
		
	ssto	duLow
	stwo	r6,r0		;du = ssin
	ssto	duHigh
	stwo	r6,r4	
	
	ssto	dvLow
	stwo	r6,r1		;dv = scos
	ssto	dvHigh
	stwo	r6,r3

	
	ssto	suLow
	stwo	r6,r1		;su = scos
	ssto	suHigh
	stwo	r6,r3	
	
	movei	r7,0
	movei	r2,0
	
	sub	r7,r7,r0
	subt	r2,r2,r4	
	
	ssto	svLow
	stwo	r6,r7		;sv = -ssin
	ssto	svHigh
	stwo	r6,r2
	
	;calculate offset for center position
	;

	;scos = r3:r1
	;ssin = r4:r0
	
	;Int32 cosy = (Int32)((ncos * centerY));
	
	push	r0
	push	r1
	push	r3
	push	r4
	
	
	gpci	r7,2
	br	muls32x16	;r4:r3 = r1:r0 * r2
	rqldi	r5,cCenterY	
	or	r0,r1,r1	;r0 = cos low
	or	r1,r3,r3	;r1 = cos high
	ld	r2		;r2 = centerY
	ssto	cosycLow
	stwo	r5,r3
	ssto	cosycHigh
	stwo	r5,r4
	
	;dump
	;.stop
	
	rqpop
	rqpop
	rqpop
	pop	r4
	pop	r3
	pop	r1
	rqpop
	nop
	nop
	pop	r0
	nop
	
	
	
		
        ;Int32 cosx = (Int32)((ncos * centerX));
	
	push	r0
	push	r1
	push	r3
	push	r4
	
	gpci	r7,2
	br	muls32x16	;r4:r3 = r1:r0 * r2
	rqldi	r5,cCenterX	
	or	r0,r1,r1	;r0 = cos low
	or	r1,r3,r3	;r1 = cos high
	ld	r2		;r2 = centerX
	ssto	cosxcLow
	stwo	r5,r3
	ssto	cosxcHigh
	stwo	r5,r4
	
	;dump
	;.stop
	
	rqpop
	rqpop
	rqpop
	pop	r4
	pop	r3
	pop	r1
	rqpop
	nop
	nop
	pop	r0
	nop
	
        ;Int32 siny = (Int32)((nsin * centerY));
	
	push	r0
	push	r1
	push	r3
	push	r4
	
	gpci	r7,2
	br	muls32x16	;r4:r3 = r1:r0 * r2
	rqldi	r5,cCenterY	
	or	r0,r0,r0	;r0 = sin low
	or	r1,r4,r4	;r1 = sin high
	ld	r2		;r2 = centerY
	ssto	sinycLow
	stwo	r5,r3
	ssto	sinycHigh
	stwo	r5,r4
	
	
	
	rqpop
	rqpop
	rqpop
	pop	r4
	pop	r3
	pop	r1
	rqpop
	nop
	nop
	pop	r0
	nop
	
        ;Int32 sinx = (Int32)((nsin * centerX));
	
	push	r0
	push	r1
	push	r3
	push	r4
	
	gpci	r7,2
	br	muls32x16	;r4:r3 = r1:r0 * r2
	rqldi	r5,cCenterX	
	or	r0,r0,r0	;r0 = sin low
	or	r1,r4,r4	;r1 = sin high
	ld	r2		;r2 = centerX
	ssto	sinxcLow
	stwo	r5,r3
	ssto	sinxcHigh
	stwo	r5,r4
	
	rqpop
	rqpop
	rqpop
	pop	r4
	pop	r3
	pop	r1
	rqpop
	nop
	nop
	pop	r0
	nop

        ;u = (UInt32)(((cosyc + sinxc)) + (offsetTextX << 16));
	
	rqldi	r5,cosycHigh
	rqldi	r5,cosycLow
	rqldi	r5,sinxcHigh
	ld	r0		
	ld	r1		;cosyc = r0:r1
	ld	r2
	rqldi	r5,sinxcLow
	rqldi	r5,cOffsetX
	nop
	ld	r3		;sinxc  = r2:r3
	ld	r4		;offset = r4
	
	;dump
	;.stop
	
	add	r1,r1,r3
	addt	r0,r0,r2	;cosyc + sinxc
	nop
	add	r0,r0,r4	;+ offset X
	
	;set u
	
	ssto	uLow
	stwo	r6,r1
	ssto	uHigh
	stwo	r6,r0
	
	;v = (UInt32)(((cosx - siny)) + (offsetTextY << 16));
	
	rqldi	r5,cosxcHigh
	rqldi	r5,cosxcLow
	rqldi	r5,sinycHigh
	ld	r0		
	ld	r1		;cosxc = r0:r1
	ld	r2
	rqldi	r5,sinycLow
	rqldi	r5,cOffsetY
	nop
	ld	r3		;sinyc  = r2:r3
	ld	r4		;offset = r4
	
	sub	r1,r1,r3
	subt	r0,r0,r2	;cosyc + sinxc
	nop
	add	r0,r0,r4	;+ offset Y
	
	;set u
		
	ssto	vLow
	stwo	r6,r1
	ssto	vHigh
	stwo	r6,r0
	
	;
	
	rqpop
	nop
	nop
	pop	r7
	nop
	
	
	jmpi	r7,0
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot

;******************************
;*
;* r4:r3 = r1:r0 * r2
;*
	
muls32x16	

	nop
	mul	r3,r0,r2
	gmulhi	r4
	mul	r1,r1,r2
	movei	r2,0
	add	r4,r4,r1
	jmpi	r7,0
	sub	r0,r2,r0
	nop
	add	r4,r4,r0	
	nop
	
;******************************
;* switchFrames
;*

switchFrames

	push	r0
	push	r1
	push	r2
	push	r3
	push	r4
	push	r5

	movei	r0,displayFrame
	movei	r1,drawFrame
	moveih	r0,>displayFrame	
	moveih	r1,>drawFrame
	
	rqldi	r0,0
	rqldi	r0,1
	nop
	ld	r2
	ld	r3
	
	rqldi	r1,0
	rqldi	r1,1
	nop
	ld	r4
	ld	r5

	st	r0,r4
	addi	r0,1
	nop
	st	r0,r5
	
	st	r1,r2
	addi	r1,1
	nop
	st	r1,r3
	
	rqpop
	rqpop
	rqpop
	pop	r5
	pop	r4
	pop	r3
	
	rqpop
	rqpop
	rqpop
	pop	r2
	pop	r1
	pop	r0
	
	jmpi	r7,0
	nop		;delay slot
	nop	     	;delay slot
	nop		;delay slot
	nop		;delay slot		
	
;******************************
;*
;* setupVideo
;*

setupVideo

	
	movei	r0,videoDefault		;source
	movei	r1,UcTimer2Ctrl		;dest-1
	moveih	r0,>videoDefault
	moveih	r1,>UcTimer2Ctrl			
	movei	r2,26			;27-1
	
setupVideoLoop

	rqldi	r0,0
	addi	r0,1
	addi	r1,1
	ld	r3
	subi	r2,1
	brts	setupVideoLoop
	st	r1,r3	;delay slot
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
		
	jmpi	r7,0
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot	
	
;*********************************************************************
;* data
;*********************************************************************
	
videoDefault		;AD NAME					NEW				DEFAULT
	
	word	$0001	;10 VIDEO_ON					1				1 (ON)
	word	$0097	;11 HSYNC (D = 11 .. 0)				152-1				152-1
	word	$017f	;12 HSTART (D = 11 .. 0)			384-1				384-1
	word	$017d	;13 HMEMSTART (D = 11 .. 0)			382-1				382-1
	word	$071f	;14 HSTOP (D = 11 .. 0)				1824-1				1824-1
	word	$076f	;15 HTOTAL (D = 11 .. 0)			1904-1				1904-1
	word	$0002	;16 VSYNC (D = 10 .. 0)				3-1				3-1
	word	$001e	;17 VSTART (D = 10 .. 0)			31-1				31-1
	word	$03a2	;18 VSTOP  (D = 10 .. 0)			931-1				931-1
	word	$03a3	;19 VTOTAL  (D = 10 .. 0)			932-1				932-1
	word	$0000	;1a LC ADDER LOW				$0000				$0000
	word	$0040	;1b LC ADDER HIGH				$0080				$0040	
	word	$0000	;1c LC ADDER LATCH				X				X
	word	$0000	;1d LC START (10 .. 0) Pixeloffset		$0000				$0000	
	word	$0000	;1e						X				X
	word	$0000	;1f						X				X
	word	$0008	;20 HLOADSTART 					8				8
	word	$00bc	;21 HLOADSTOP					360+8				180+8
	word	$001e	;22 VLOADSTART 					31-1				31-1
	word	$03a2	;23 VLOADSTOP 					931-1				931-1
	word	$0004	;24 VLOADNEXT					2				4
	word	$0000	;25 MEM_STARTADR_store low			$0000				$0000
	word	$d000	;26 MEM_STARTADR_store high			$f000				$f000
	word	$0000	;27 MEMLowINEOFFSET_store low			$0000				$0000
	word	$0000	;28 MEMLowINEOFFSET_store high			$0000				$0000
	word	$0002	;29 MEM_MODE_store 				2				2 (X1R5G5B5X1R5G5B5)
	word	$0000	;2a LATCH MEM_STARTADR/LINEOFFSET/MODE		X				X
		
;**********************************************	

textStats

	.stringz	"FPS %u"
	
fps		word	0
frameCounter	word	0

;**********************************************	

objectValues
	
	word	0	;uLow         	0		
	word	0	;uHigh         	1
	word	0	;vLow         	2		
	word	0	;vHigh         	3
	word	0	;suLow        	4		
	word	0	;suHigh        	5
	word	32767	;svLow        	6		
	word	0	;svHigh        	7
	word	32767	;duLow        	8		
	word	0	;duHigh        	9
	word	0	;dvLow        	10		
	word	0	;dvHigh        	11
	
variableValues	
	
	word	267	;offset X
	word	250	;offset Y
	word	-180	;center X
	word	-112	;center Y
	word	0	;angle
	word	$0100	;zoom	
	word	0	;cosyc 	low
	word	0	;	high
	word	0	;cosxc 	low 
	word	0	;     	high
	word	0	;sinyc 	low
	word	0	;    	high
	word	0	;sinxc 	low
	word	0	;     	high
	
;**********************************************	
	
sinTable	;512*1.25

    word    0   	;0
    word    402   	;1
    word    804   ;2
    word    1206   ;3
    word    1608   ;4
    word    2009   ;5
    word    2411   ;6
    word    2811   ;7
    word    3212   ;8
    word    3612   ;9
    word    4011   ;10
    word    4410   ;11
    word    4808   ;12
    word    5205   ;13
    word    5602   ;14
    word    5998   ;15
    word    6393   ;16
    word    6787   ;17
    word    7179   ;18
    word    7571   ;19
    word    7962   ;20
    word    8351   ;21
    word    8740   ;22
    word    9126   ;23
    word    9512   ;24
    word    9896   ;25
    word    10279   ;26
    word    10660   ;27
    word    11039   ;28
    word    11417   ;29
    word    11793   ;30
    word    12167   ;31
    word    12540   ;32
    word    12910   ;33
    word    13279   ;34
    word    13645   ;35
    word    14010   ;36
    word    14372   ;37
    word    14733   ;38
    word    15091   ;39
    word    15446   ;40
    word    15800   ;41
    word    16151   ;42
    word    16500   ;43
    word    16846   ;44
    word    17189   ;45
    word    17531   ;46
    word    17869   ;47
    word    18205   ;48
    word    18538   ;49
    word    18868   ;50
    word    19195   ;51
    word    19520   ;52
    word    19841   ;53
    word    20160   ;54
    word    20475   ;55
    word    20787   ;56
    word    21097   ;57
    word    21403   ;58
    word    21706   ;59
    word    22005   ;60
    word    22302   ;61
    word    22595   ;62
    word    22884   ;63
    word    23170   ;64
    word    23453   ;65
    word    23732   ;66
    word    24007   ;67
    word    24279   ;68
    word    24547   ;69
    word    24812   ;70
    word    25073   ;71
    word    25330   ;72
    word    25583   ;73
    word    25832   ;74
    word    26078   ;75
    word    26319   ;76
    word    26557   ;77
    word    26790   ;78
    word    27020   ;79
    word    27245   ;80
    word    27467   ;81
    word    27684   ;82
    word    27897   ;83
    word    28106   ;84
    word    28310   ;85
    word    28511   ;86
    word    28707   ;87
    word    28898   ;88
    word    29086   ;89
    word    29269   ;90
    word    29447   ;91
    word    29621   ;92
    word    29791   ;93
    word    29956   ;94
    word    30117   ;95
    word    30273   ;96
    word    30425   ;97
    word    30572   ;98
    word    30714   ;99
    word    30852   ;100
    word    30985   ;101
    word    31114   ;102
    word    31237   ;103
    word    31357   ;104
    word    31471   ;105
    word    31581   ;106
    word    31685   ;107
    word    31785   ;108
    word    31881   ;109
    word    31971   ;110
    word    32057   ;111
    word    32138   ;112
    word    32214   ;113
    word    32285   ;114
    word    32351   ;115
    word    32413   ;116
    word    32469   ;117
    word    32521   ;118
    word    32568   ;119
    word    32610   ;120
    word    32647   ;121
    word    32679   ;122
    word    32706   ;123
    word    32728   ;124
    word    32745   ;125
    word    32758   ;126
    word    32765   ;127
    word    32767   ;128
    word    32765   ;129
    word    32758   ;130
    word    32745   ;131
    word    32728   ;132
    word    32706   ;133
    word    32679   ;134
    word    32647   ;135
    word    32610   ;136
    word    32568   ;137
    word    32521   ;138
    word    32469   ;139
    word    32413   ;140
    word    32351   ;141
    word    32285   ;142
    word    32214   ;143
    word    32138   ;144
    word    32057   ;145
    word    31971   ;146
    word    31881   ;147
    word    31785   ;148
    word    31685   ;149
    word    31581   ;150
    word    31471   ;151
    word    31357   ;152
    word    31237   ;153
    word    31114   ;154
    word    30985   ;155
    word    30852   ;156
    word    30714   ;157
    word    30572   ;158
    word    30425   ;159
    word    30273   ;160
    word    30117   ;161
    word    29956   ;162
    word    29791   ;163
    word    29621   ;164
    word    29447   ;165
    word    29269   ;166
    word    29086   ;167
    word    28898   ;168
    word    28707   ;169
    word    28511   ;170
    word    28310   ;171
    word    28106   ;172
    word    27897   ;173
    word    27684   ;174
    word    27467   ;175
    word    27245   ;176
    word    27020   ;177
    word    26790   ;178
    word    26557   ;179
    word    26319   ;180
    word    26078   ;181
    word    25832   ;182
    word    25583   ;183
    word    25330   ;184
    word    25073   ;185
    word    24812   ;186
    word    24547   ;187
    word    24279   ;188
    word    24007   ;189
    word    23732   ;190
    word    23453   ;191
    word    23170   ;192
    word    22884   ;193
    word    22595   ;194
    word    22302   ;195
    word    22005   ;196
    word    21706   ;197
    word    21403   ;198
    word    21097   ;199
    word    20787   ;200
    word    20475   ;201
    word    20160   ;202
    word    19841   ;203
    word    19520   ;204
    word    19195   ;205
    word    18868   ;206
    word    18538   ;207
    word    18205   ;208
    word    17869   ;209
    word    17531   ;210
    word    17189   ;211
    word    16846   ;212
    word    16500   ;213
    word    16151   ;214
    word    15800   ;215
    word    15446   ;216
    word    15091   ;217
    word    14733   ;218
    word    14372   ;219
    word    14010   ;220
    word    13645   ;221
    word    13279   ;222
    word    12910   ;223
    word    12540   ;224
    word    12167   ;225
    word    11793   ;226
    word    11417   ;227
    word    11039   ;228
    word    10660   ;229
    word    10279   ;230
    word    9896   ;231
    word    9512   ;232
    word    9126   ;233
    word    8740   ;234
    word    8351   ;235
    word    7962   ;236
    word    7571   ;237
    word    7179   ;238
    word    6787   ;239
    word    6393   ;240
    word    5998   ;241
    word    5602   ;242
    word    5205   ;243
    word    4808   ;244
    word    4410   ;245
    word    4011   ;246
    word    3612   ;247
    word    3212   ;248
    word    2811   ;249
    word    2411   ;250
    word    2009   ;251
    word    1608   ;252
    word    1206   ;253
    word    804   ;254
    word    402   ;255
    word    0   ;256
    word    -402   ;257
    word    -804   ;258
    word    -1206   ;259
    word    -1608   ;260
    word    -2009   ;261
    word    -2411   ;262
    word    -2811   ;263
    word    -3212   ;264
    word    -3612   ;265
    word    -4011   ;266
    word    -4410   ;267
    word    -4808   ;268
    word    -5205   ;269
    word    -5602   ;270
    word    -5998   ;271
    word    -6393   ;272
    word    -6787   ;273
    word    -7179   ;274
    word    -7571   ;275
    word    -7962   ;276
    word    -8351   ;277
    word    -8740   ;278
    word    -9126   ;279
    word    -9512   ;280
    word    -9896   ;281
    word    -10279   ;282
    word    -10660   ;283
    word    -11039   ;284
    word    -11417   ;285
    word    -11793   ;286
    word    -12167   ;287
    word    -12540   ;288
    word    -12910   ;289
    word    -13279   ;290
    word    -13645   ;291
    word    -14010   ;292
    word    -14372   ;293
    word    -14733   ;294
    word    -15091   ;295
    word    -15446   ;296
    word    -15800   ;297
    word    -16151   ;298
    word    -16500   ;299
    word    -16846   ;300
    word    -17189   ;301
    word    -17531   ;302
    word    -17869   ;303
    word    -18205   ;304
    word    -18538   ;305
    word    -18868   ;306
    word    -19195   ;307
    word    -19520   ;308
    word    -19841   ;309
    word    -20160   ;310
    word    -20475   ;311
    word    -20787   ;312
    word    -21097   ;313
    word    -21403   ;314
    word    -21706   ;315
    word    -22005   ;316
    word    -22302   ;317
    word    -22595   ;318
    word    -22884   ;319
    word    -23170   ;320
    word    -23453   ;321
    word    -23732   ;322
    word    -24007   ;323
    word    -24279   ;324
    word    -24547   ;325
    word    -24812   ;326
    word    -25073   ;327
    word    -25330   ;328
    word    -25583   ;329
    word    -25832   ;330
    word    -26078   ;331
    word    -26319   ;332
    word    -26557   ;333
    word    -26790   ;334
    word    -27020   ;335
    word    -27245   ;336
    word    -27467   ;337
    word    -27684   ;338
    word    -27897   ;339
    word    -28106   ;340
    word    -28310   ;341
    word    -28511   ;342
    word    -28707   ;343
    word    -28898   ;344
    word    -29086   ;345
    word    -29269   ;346
    word    -29447   ;347
    word    -29621   ;348
    word    -29791   ;349
    word    -29956   ;350
    word    -30117   ;351
    word    -30273   ;352
    word    -30425   ;353
    word    -30572   ;354
    word    -30714   ;355
    word    -30852   ;356
    word    -30985   ;357
    word    -31114   ;358
    word    -31237   ;359
    word    -31357   ;360
    word    -31471   ;361
    word    -31581   ;362
    word    -31685   ;363
    word    -31785   ;364
    word    -31881   ;365
    word    -31971   ;366
    word    -32057   ;367
    word    -32138   ;368
    word    -32214   ;369
    word    -32285   ;370
    word    -32351   ;371
    word    -32413   ;372
    word    -32469   ;373
    word    -32521   ;374
    word    -32568   ;375
    word    -32610   ;376
    word    -32647   ;377
    word    -32679   ;378
    word    -32706   ;379
    word    -32728   ;380
    word    -32745   ;381
    word    -32758   ;382
    word    -32765   ;383
    word    -32768   ;384
    word    -32765   ;385
    word    -32758   ;386
    word    -32745   ;387
    word    -32728   ;388
    word    -32706   ;389
    word    -32679   ;390
    word    -32647   ;391
    word    -32610   ;392
    word    -32568   ;393
    word    -32521   ;394
    word    -32469   ;395
    word    -32413   ;396
    word    -32351   ;397
    word    -32285   ;398
    word    -32214   ;399
    word    -32138   ;400
    word    -32057   ;401
    word    -31971   ;402
    word    -31881   ;403
    word    -31785   ;404
    word    -31685   ;405
    word    -31581   ;406
    word    -31471   ;407
    word    -31357   ;408
    word    -31237   ;409
    word    -31114   ;410
    word    -30985   ;411
    word    -30852   ;412
    word    -30714   ;413
    word    -30572   ;414
    word    -30425   ;415
    word    -30273   ;416
    word    -30117   ;417
    word    -29956   ;418
    word    -29791   ;419
    word    -29621   ;420
    word    -29447   ;421
    word    -29269   ;422
    word    -29086   ;423
    word    -28898   ;424
    word    -28707   ;425
    word    -28511   ;426
    word    -28310   ;427
    word    -28106   ;428
    word    -27897   ;429
    word    -27684   ;430
    word    -27467   ;431
    word    -27245   ;432
    word    -27020   ;433
    word    -26790   ;434
    word    -26557   ;435
    word    -26319   ;436
    word    -26078   ;437
    word    -25832   ;438
    word    -25583   ;439
    word    -25330   ;440
    word    -25073   ;441
    word    -24812   ;442
    word    -24547   ;443
    word    -24279   ;444
    word    -24007   ;445
    word    -23732   ;446
    word    -23453   ;447
    word    -23170   ;448
    word    -22884   ;449
    word    -22595   ;450
    word    -22302   ;451
    word    -22005   ;452
    word    -21706   ;453
    word    -21403   ;454
    word    -21097   ;455
    word    -20787   ;456
    word    -20475   ;457
    word    -20160   ;458
    word    -19841   ;459
    word    -19520   ;460
    word    -19195   ;461
    word    -18868   ;462
    word    -18538   ;463
    word    -18205   ;464
    word    -17869   ;465
    word    -17531   ;466
    word    -17189   ;467
    word    -16846   ;468
    word    -16500   ;469
    word    -16151   ;470
    word    -15800   ;471
    word    -15446   ;472
    word    -15091   ;473
    word    -14733   ;474
    word    -14372   ;475
    word    -14010   ;476
    word    -13645   ;477
    word    -13279   ;478
    word    -12910   ;479
    word    -12540   ;480
    word    -12167   ;481
    word    -11793   ;482
    word    -11417   ;483
    word    -11039   ;484
    word    -10660   ;485
    word    -10279   ;486
    word    -9896   ;487
    word    -9512   ;488
    word    -9126   ;489
    word    -8740   ;490
    word    -8351   ;491
    word    -7962   ;492
    word    -7571   ;493
    word    -7179   ;494
    word    -6787   ;495
    word    -6393   ;496
    word    -5998   ;497
    word    -5602   ;498
    word    -5205   ;499
    word    -4808   ;500
    word    -4410   ;501
    word    -4011   ;502
    word    -3612   ;503
    word    -3212   ;504
    word    -2811   ;505
    word    -2411   ;506
    word    -2009   ;507
    word    -1608   ;508
    word    -1206   ;509
    word    -804   ;510
    word    -402   ;511
    word    0   ;512
    word    402   ;513
    word    804   ;514
    word    1206   ;515
    word    1608   ;516
    word    2009   ;517
    word    2411   ;518
    word    2811   ;519
    word    3212   ;520
    word    3612   ;521
    word    4011   ;522
    word    4410   ;523
    word    4808   ;524
    word    5205   ;525
    word    5602   ;526
    word    5998   ;527
    word    6393   ;528
    word    6787   ;529
    word    7179   ;530
    word    7571   ;531
    word    7962   ;532
    word    8351   ;533
    word    8740   ;534
    word    9126   ;535
    word    9512   ;536
    word    9896   ;537
    word    10279   ;538
    word    10660   ;539
    word    11039   ;540
    word    11417   ;541
    word    11793   ;542
    word    12167   ;543
    word    12540   ;544
    word    12910   ;545
    word    13279   ;546
    word    13645   ;547
    word    14010   ;548
    word    14372   ;549
    word    14733   ;550
    word    15091   ;551
    word    15446   ;552
    word    15800   ;553
    word    16151   ;554
    word    16500   ;555
    word    16846   ;556
    word    17189   ;557
    word    17531   ;558
    word    17869   ;559
    word    18205   ;560
    word    18538   ;561
    word    18868   ;562
    word    19195   ;563
    word    19520   ;564
    word    19841   ;565
    word    20160   ;566
    word    20475   ;567
    word    20787   ;568
    word    21097   ;569
    word    21403   ;570
    word    21706   ;571
    word    22005   ;572
    word    22302   ;573
    word    22595   ;574
    word    22884   ;575
    word    23170   ;576
    word    23453   ;577
    word    23732   ;578
    word    24007   ;579
    word    24279   ;580
    word    24547   ;581
    word    24812   ;582
    word    25073   ;583
    word    25330   ;584
    word    25583   ;585
    word    25832   ;586
    word    26078   ;587
    word    26319   ;588
    word    26557   ;589
    word    26790   ;590
    word    27020   ;591
    word    27245   ;592
    word    27467   ;593
    word    27684   ;594
    word    27897   ;595
    word    28106   ;596
    word    28310   ;597
    word    28511   ;598
    word    28707   ;599
    word    28898   ;600
    word    29086   ;601
    word    29269   ;602
    word    29447   ;603
    word    29621   ;604
    word    29791   ;605
    word    29956   ;606
    word    30117   ;607
    word    30273   ;608
    word    30425   ;609
    word    30572   ;610
    word    30714   ;611
    word    30852   ;612
    word    30985   ;613
    word    31114   ;614
    word    31237   ;615
    word    31357   ;616
    word    31471   ;617
    word    31581   ;618
    word    31685   ;619
    word    31785   ;620
    word    31881   ;621
    word    31971   ;622
    word    32057   ;623
    word    32138   ;624
    word    32214   ;625
    word    32285   ;626
    word    32351   ;627
    word    32413   ;628
    word    32469   ;629
    word    32521   ;630
    word    32568   ;631
    word    32610   ;632
    word    32647   ;633
    word    32679   ;634
    word    32706   ;635
    word    32728   ;636
    word    32745   ;637
    word    32758   ;638
    word    32765   ;639	
   
;*********************************************************************
;* font/video related
;*********************************************************************	
   
displayFrame	
	.data	$d000,$0000
	
drawFrame	
	.data	$d013,$c680
	
screenWidth
	word	360	

fontAddress
	.data	$f004,$0000	
		
;*********************************************************************
;* sd data after code segment
;*********************************************************************		
		
	;gfx
		
	.org	16384
	
textureData	
	
	.incdir "F:\git\goldmomo_endlos\gfx"
	.incbin	"earth512x512.dat.raw"
	
fontData
	
	.incdir		"F:\git\goldmomo_endlos\gfx"
	.incbin		"topaz_1bit.dat.raw"			;1504 byte = 752 words (2f0)	
		
