	
	;this version is only sd card bootable	
	
;*********************************************************************
;* static memory map
;*********************************************************************	
	
;		base	d0000000	offset		comment
;		bytes	words	
;				
;frame buffer 0	176400	88200	d0000000		(16+360+16)*225
;frame buffer 1	176400	88200	d0015888		(16+360+16)*225
;font 8x8	7552	3776	d002b110		
;font 2 8x8	7552	3776	d002bfd0		
;font 16x16	30720	15360	d002ce90		
;player		126720	63360	d0030a90		
;enemy1		126720	63360	d0040210		
;bullets	148458	74229	d004f990		
;hud		6624	3312	d0061b85		
;title image	112640	56320	d0062875		
;gameover image	165600	82800	d0070475		
;won image	165600	82800	d00847e5		
;map 1		131072	65536	d0098b55		level 1
;map 1 data 2	131072	65536	d00a8b55		
;map 1 anim lut	2048	1024	d00b8b55		
;map 1 enemys	2048	1024	d00b8f55		
;map 2		131072	65536	d00b9355		level 2
;map 2 data 2	131072	65536	d00c9355		
;map 2 anim lut	2048	1024	d00d9355		
;map 2 enemys	2048	1024	d00d9755		
;map 3		131072	65536	d00d9b55		level 3
;map 3 data 2	131072	65536	d00e9b55		
;map 3 anim lut	2048	1024	d00f9b55		
;map 3 enemys	2048	1024	d00f9f55		
;map T		131072	65536	d00fa355		intro tile map
;map T data 2	131072	65536	d010a355		
;map T anim lut	2048	1024	d011a355		
;map T enemys	2048	1024	d011a755		
;map 4		131072	65536	d011ab55		level 4
;map 4 data 2	131072	65536	d012ab55		
;map 4 anim lut	2048	1024	d013ab55		
;map 4 enemys	2048	1024	d013af55		
;map 5		131072	65536	d013b355		level 5
;map 5 data 2	131072	65536	d014b355		
;map 5 anim lut	2048	1024	d015b355		
;map 5 enemys	2048	1024	d015b755		
;tile set 1	220968	110484	d015bb55		tile set 1
;tile set 1 lut	1520	760	d0176ae9		lut for tile set 1,2,3
;tile set 2	220968	110484	d0176de1		tile set 2
;tile set 3	220968	110484	d0191d75		tile set 3
;tile set 4	302126	151063	d01acd09		tile set 4
;tile set 4 lut	2080	1040	d01d1b20		lut for tile set 4
;title mod	122878	61439	d01d1f30		
;level s1 mod	77546	38773	d01e0f2f		
;level s2 mod	408160	204080	d01ea6a4		
;sfx explosion	63726	31863	d021c3d4		
;sfx shot	25926	12963	d022404b		


	.def	globalFrameBuffer0	$d0000000
	.def	globalFrameBuffer1	$d0015888
	.def	globalFont8x8		$d002b110
	.def	globalFontTwo8x8	$d002bfd0
	.def	globalFont16x16         $d002ce90
	.def	globalPlayer		$d0030a90
	.def	globalEnemy1		$d0040210
	.def	globalBullets		$d004f990
	.def	globalHud		$d0061b85
	.def	globalTitleImage	$d0062875
	.def	globalGameOverImage	$d0070475
	.def	globalWonImage		$d00847e5
	.def	globalMap1		$d0098b55
	.def	globalMap1Ctrl		$d00a8b55
	.def	globalMap1Anim		$d00b8b55
	.def	globalMap1Enemys	$d00b8f55
	.def	globalMap2		$d00b9355
	.def	globalMap2Ctrl		$d00c9355
	.def	globalMap2Anim		$d00d9355
	.def	globalMap2Enemys	$d00d9755
	.def	globalMap3		$d00d9b55
	.def	globalMap3Ctrl		$d00e9b55
	.def	globalMap3Anim		$d00f9b55
	.def	globalMap3Enemys	$d00f9f55
	.def	globalMapT		$d00fa355
	.def	globalMapTCtrl		$d010a355
	.def	globalMapTAnim		$d011a355
	.def	globalMapTEnemys	$d011a755
	.def	globalMap4		$d011ab55
	.def	globalMap4Ctrl		$d012ab55
	.def	globalMap4Anim		$d013ab55
	.def	globalMap4Enemys	$d013af55
	.def	globalMap5		$d013b355
	.def	globalMap5Ctrl		$d014b355
	.def	globalMap5Anim		$d015b355
	.def	globalMap5Enemys	$d015b755
	.def	globalTileSet1          $d015bb55
	.def	globalTileSet1Lut       $d0176ae9
	.def	globalTileSet2          $d0176de1
	.def	globalTileSet3          $d0191d75
	.def	globalTileSet4          $d01acd09
	.def	globalTileSet4Lut       $d01d1b20
	.def	globalTitleMod		$d01d1f30
	.def	globalLevelS1Mod	$d01e0f2f
	.def	globalLevelS2Mod	$d01ea6a4
	.def	globalSfxExplosion	$d021c3d4
	.def	globalSfxShot		$d022404b

	
;*********************************************************************
;* defines
;*********************************************************************
	
;*********************************************************************	
; includes
;*********************************************************************	

	.incdir	"F:\git\goldmomo_endlos\assembler_files\ucore\"
	.include "boot_level_sdHeader.s"
	.include "include\ucore.i"
	.include "include\ucore_ctrl.i"
	
;***********************************************************************
;* loader
;***********************************************************************	

	;video off at sd card load
	
	movei	r1,0				;video off
	dexti	>UcVideoRHCountWVideoOn
	movei	r0,UcVideoRHCountWVideoOn
	nop
	st	r0,r1
	
	;clear frame buffers
	
	movei	r2,0
	dexti	$d0
	movei	r3,0		;r3:r2 = $d000 0000
	
	dexti	>efill8
	movei	r4,efill8
	gpci	r7,2
	jmpi	r4,0
	dexti	$56		;delay slot
	movei	r0,$21		;delay slot
	movei	r1,0		;delay slot
	nop			;delay slot

	;!! emulator special (set read only spaces) !!
	
	; movei	r0,0	;select read only start low
	; dexti	>globalTiles
	; movei	r1,globalTiles
	; setssr	r0,3
	; setssr	r1,7
	
	; movei	r0,1	;select read only start high
	; dexti	>>>globalTiles
	; movei	r1,>>globalTiles
	; setssr	r0,3
	; setssr	r1,7
	
	; movei	r0,2	;select read only stop low
	; dexti	>globalMap1
	; movei	r1,globalMap1
	; setssr	r0,3
	; setssr	r1,7
	
	; movei	r0,3	;select read only  stop high
	; dexti	>>>globalMap1
	; movei	r1,>>globalMap1
	; setssr	r0,3
	; setssr	r1,7
	
	; movei	r0,4	;push 
	; movei	r1,1
	; setssr	r0,3
	; setssr	r1,7
	
	;read sdcard to s/sdram
	
	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	r0,$10
	movei	r1,$02
	moveih	r0,$b1
	moveih	r1,$d0		;r1:r0 = $d002 b110 (dest start)
	
	movei	r6,sdCardReadBlocks
	nop
	moveih	r6,>sdCardReadBlocks
	
	gpci	r7,2		;
	jmpi	r6,0
	movei	r4,$ff		;16384 blocks-1	delay slot
	nop			;delay slot
	moveih	r4,$2f		;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)
	
	dexti	>setupVideo
	movei	r0,setupVideo
	gpci	r7,2		;next 4 + X
	jmpi	r0,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;setup audio
	
	dexti	>initAudio
	movei	r0,initAudio
	gpci	r7,2		;next 4 + X
	jmpi	r0,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;setup irq vector
	
	dexti	>irq
	movei	r0,irq	
	nop
	setssr	r0,2
	
	;setup irq msk
	
	movei	r0,UcIrqMsk
	movei	r1,$6			;enable audio irq and timer 2
	moveih	r0,>UcIrqMsk
	nop
	st	r0,r1			;
	
	;set audio dac counter = 2 (96/3 = 32KHz)
	
	movei	r6,UcAudioDACBase
	nop
	moveih	r6,>UcAudioDACBase
	movei	r1,$2
	movei	r0,0
	moveih	r1,$2	;address 2
	
	stinc	r6,r0	;dac left high = 0
	nop
	stinc	r6,r0	;dac left low = 0
	nop
	stinc	r6,r0	;dac right high = 0
	nop
	stinc	r6,r0	;dac right low = 0	
	nop
	st	r6,r1	;dac address/ctrl = $0201	;dac counter = 2
			
	;enable irqs
	
	sei
		
	;intro
		
introStart	
	
	;show intro
	
	dexti	>introScreen
	movei	r0,introScreen
	gpci	r7,2
	jmpi	r0,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
		
	;reset lives
	
	dexti	>resetLives
	movei	r0,resetLives
	gpci	r7,2
	jmpi	r0,0
	dexti	>playerData	;delay slot
	movei	r0,playerData	;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;ingame  loop
	
	movei	r4,0		;current level
		
inGameLoop

	;get current level

	dexti	>levels
	movei	r0,levels
	nop
	rqld	r0,r4
	addi	r4,1		;set next level
	nop
	ld	r6		;level data
	
	;init level
	
	dexti	>initLevel
	movei	r0,initLevel
	gpci	r7,2	;
	jmpi	r0,0		
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;play level
	
	dexti	>playLevel
	movei	r0,playLevel
	gpci	r7,2	;
	jmpi	r0,0		
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;is game over ??
	
	cmpeqi	r0,lvGameOver
	brts	gameOver
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;else set next level if there is one
	
	cmpeqi	r4,levelCount	;
	brtc	inGameLoop
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;----------- you have won! -----------
		
	dexti	>youHaveWon
	movei	r2,youHaveWon
	gpci	r7,2
	jmpi	r2,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot	
		
	br	introStart
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;-----------  you are dead -----------
	
gameOver

	;dexti	>youLoose
	;movei	r2,youLoose
	;gpci	r7,2
	;jmpi	r2,0
	;nop			;delay slot
	;nop			;delay slot
	;nop			;delay slot
	;nop			;delay slot

	br	introStart
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;*********************************************************************
;* draw char switch
;*********************************************************************		
	
;******************************
;*	
;* drawChar
;*
		
drawChar

	push	r6
	push	r7
	
	dexti	>drawCharFunction
	movei	r6,drawCharFunction
	nop
	rqldi	r6,0
	nop
	nop
	ld	r6
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	rqpop
	rqpop
	nop
	pop	r7
	pop	r6
	
	jmpi	r7,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

;******************************
;*	
;* setCharDrawer
;*
;* r0 = fontAddress (low)
;* r1 = fontAddress (high)
;* r2 = drawFunction
;*
	
setCharDrawer

	push	r3
	
	dexti	>fontAddress
	movei	r3,fontAddress
	nop
	stinc	r3,r1
	nop
	st	r3,r0
	
	dexti	>drawCharFunction
	movei	r3,drawCharFunction
	nop
	st	r3,r2
	
	rqpop
	jmpi	r7,0
	nop			;delay slot
	pop	r3		;delay slot
	nop			;delay slot
	nop			;delay slot
		
	
drawCharFunction	word	drawChar8x8	
	
;*********************************************************************
;* functions
;*********************************************************************	
	
	;standard
	
	.include	"components\drawText.s"
	.include	"components\sdCardLoader.s"
	.include	"components\ps2keyboard.s"		
	
	;i2c
	
	.include	"components\i2c.s"
	
	;mod and audio
	
	.include	"components\audioChannel.s"
	.include	"components\modSample.s"
	.include	"components\modPattern.s"
	.include	"components\audioPeriode.s"
	.include	"components\mod.s"
	.include	"components\modEffects.s"
	.include	"components\modEEffects.s"
	
	;local
		
	.include	"Sheriff\hudFunctions.s"	
	.include	"Sheriff\drawFunctions.s"
	.include	"Sheriff\bulletFunctions.s"
	.include	"Sheriff\playerFunctions.s"
	.include	"Sheriff\enemyFunctions.s"
	.include	"Sheriff\mapFunctions.s"
	.include	"Sheriff\counters.s"
	.include	"Sheriff\special.s"
	.include	"Sheriff\drawChar.s"		
	.include	"Sheriff\levelFunctions.s"
	.include	"Sheriff\prologFunctions.s"
	.include	"Sheriff\introFunctions.s"
	.include	"Sheriff\audioFunctions.s"
			               

;******************************
;*
;* testKeys
;* 	

testKeys	
	
	;prolog

	push	r0
	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	push	r6
	push	r7
	
	;
	
	dexti	>PS2TestKey
	movei	r6,PS2TestKey
	
	movei	r4,0		;ESOURL
		
	;enter
	
	movei	r0,$5A		;enter
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

	muli	r0,32
	nop
	or	r4,r4,r0	;	
		
	;space
	
	movei	r0,$29		;space
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

	muli	r0,16
	nop
	or	r4,r4,r0	;	
		
	;left arrow
	
	movei	r0,$fb		;l	($6b + 144 (extended))
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot

	or	r4,r4,r0	;

	;right arrow
	
	dexti	1
	movei	r0,$04		;r
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	muli	r0,2
	nop
	or	r4,r4,r0	;
		

	;up arrow
	
	dexti	1
	movei	r0,$05		;u
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	muli	r0,8
	nop
	or	r4,r4,r0	;
			
	;down arrow
	
	dexti	1
	movei	r0,$02		;d
	gpci	r7,2
	jmpi	r6,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	muli	r0,4
	nop
	or	r4,r4,r0	;
		
	;

	dexti	>OURL
	movei	r0,OURL
	nop
	st	r0,r4		;save ourl
		
	;epilog
	
	rqpop
	rqpop
	rqpop
	poparqp	r7
	poparqp	r6
	poparqp	r5
	poparqp	r4
	poparqp	r3
	pop	r2
	pop	r1
	pop	r0
	
	jmpi	r7,0
	nop		;delay slot
	nop		;delay slot	
	nop		;delay slot
	nop		;delay slot

;******************************
;*
;* efill8
;*
;* r0	 = count - 1
;* r1 	 = value to fill
;* r3:r2 = dest address
;*
	
efill8	
	
clearFBLoop
	esadr	r3,r2	;destination
	est	r1,0
	est	r1,1
	est	r1,2
	est	r1,3
	est	r1,4
	est	r1,5
	subi	r0,1
	brts	clearFBLoop
	addi	r2,8            ;delay slot
	addtqi	r3,r3,0         ;delay slot	
	est	r1,6		;delay slot
	est	r1,7            ;delay slot

	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				
	
	word	$0001	;10 VIDEO_ON					1				
	word	$0097	;11 HSYNC (D = 11 .. 0)				152-1				
	word	$017f	;12 HSTART (D = 11 .. 0)			384-1				
	word	$017d	;13 HMEMSTART (D = 11 .. 0)			382-1				
	word	$071f	;14 HSTOP (D = 11 .. 0)				1824-1				
	word	$076f	;15 HTOTAL (D = 11 .. 0)			1904-1				
	word	$0002	;16 VSYNC (D = 10 .. 0)				3-1				
	word	$001e	;17 VSTART (D = 10 .. 0)			31-1				
	word	$03a2	;18 VSTOP  (D = 10 .. 0)			931-1				
	word	$03a3	;19 VTOTAL  (D = 10 .. 0)			932-1				
	word	$0000	;1a LC ADDER LOW				$0000				
	word	$0040	;1b LC ADDER HIGH				$0080				
	word	$0000	;1c LC ADDER LATCH				X				
	word	$0000	;1d LC START (10 .. 0) Pixeloffset		$0000				
	word	$0000	;1e						X				
	word	$0000	;1f						X				
	word	$0008	;20 HLOADSTART 					8				
	word	$00bc	;21 HLOADSTOP					360+8				
	word	$001e	;22 VLOADSTART 					31-1				
	word	$03a2	;23 VLOADSTOP 					931-1				
	word	$0004	;24 VLOADNEXT					2				
	word	$0010	;25 MEM_STARTADR_store low			16				
	word	$d000	;26 MEM_STARTADR_store high			$f000				
	word	$0020	;27 MEMLowINEOFFSET_store low			16+16				
	word	$0000	;28 MEMLowINEOFFSET_store high			$0000				
	word	$0003	;29 MEM_MODE_store 				2 (X4R4G4B4*2)
	word	$0000	;2a LATCH MEM_STARTADR/LINEOFFSET/MODE		X				
	
;*********************************************************************
;* level related data
;*********************************************************************	

	.def	lvPlayerStartPositionX	0
	.def	lvPlayerStartPositionY	1
	.def	lvMapStartPositionX	2
	.def	lvMapStartPositionY	3	
	.def	lvMapAddress		4
	.def	lvNumber		5
	.def	lvNameAddress		6
	.def	lvMusicAddressHigh	7		
	.def	lvMusicAddressLow	8
	
	
	.def	levelCount	5
	
levels	word	level1CData
	word	level2CData
	word	level3CData
	word	level4CData
	word	level5CData
	
	;level 1

level1CData	.data	185,180,-591,-3871
		word	lv1MapData
		word	1		;level 1
		word	lv1Name
		worduc	>>globalLevelS1Mod		
		worduc	globalLevelS1Mod	
		
lv1Name	
	.stringbz "        WARM UP"
	
	;level 2
	
level2CData	.data	185,180,-591,-3871
		word	lv2MapData
		word	2		;level 2
		word	lv2Name
		worduc	>>globalLevelS1Mod		
		worduc	globalLevelS1Mod
		
lv2Name	
	.stringbz "  RUNNING THE GAUNTLET"	
	
	;level 3
	
level3CData	.data	185,180,-64,-3871
		word	lv3MapData
		word	3		;level 3
		word	lv3Name
		worduc	>>globalLevelS1Mod		
		worduc	globalLevelS1Mod
		
lv3Name	
	.stringbz "      THE VILLAGE"	

	;level 4
	
level4CData	.data	185,175,-296,-3871
		word	lv4MapData
		word	4		;level 4
		word	lv4Name
		worduc	>>globalLevelS2Mod		
		worduc	globalLevelS2Mod
		
lv4Name	
	.stringbz "      COMPANY RUN"	

	;level 5
	
level5CData	.data	185,175,-296,-3871
		word	lv5MapData
		word	5		;level 5
		word	lv5Name
		worduc	>>globalLevelS1Mod		
		worduc	globalLevelS1Mod
		
lv5Name	
	.stringbz "      ROUND TABLE"
	
	;--------- INTRO MAP no GAMEPLAY
	
levelTCData	.data	-256,-256,0,0
		word	lvTMapData
		word	99		
		word	lvTName
		worduc	>>globalLevelS1Mod		
		worduc	globalLevelS1Mod
		
lvTName	
	.stringbz "NO NAME"	
		
;*********************************************************************
;* map related data
;*********************************************************************	

lv1MapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet1		
		worduc	globalTileSet1		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMap1
		worduc	globalMap1		;map (background)
		worduc	>>globalMap1Ctrl
		worduc	globalMap1Ctrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMap1Anim	;anim
		worduc	globalMap1Anim	
		worduc	>>globalMap1Enemys	;enemys
		worduc	globalMap1Enemys	
		
lv2MapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet1		
		worduc	globalTileSet1		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMap2
		worduc	globalMap2		;map (background)
		worduc	>>globalMap2Ctrl
		worduc	globalMap2Ctrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMap2Anim	;anim
		worduc	globalMap2Anim	
		worduc	>>globalMap2Enemys	;enemys
		worduc	globalMap2Enemys			
	
lv3MapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet1		
		worduc	globalTileSet1		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMap3
		worduc	globalMap3		;map (background)
		worduc	>>globalMap3Ctrl
		worduc	globalMap3Ctrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMap3Anim	;anim
		worduc	globalMap3Anim	
		worduc	>>globalMap3Enemys	;enemys
		worduc	globalMap3Enemys		

lv4MapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet2		
		worduc	globalTileSet2		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMap4
		worduc	globalMap4		;map (background)
		worduc	>>globalMap4Ctrl
		worduc	globalMap4Ctrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMap4Anim	;anim
		worduc	globalMap4Anim	
		worduc	>>globalMap4Enemys	;enemys
		worduc	globalMap4Enemys	

lv5MapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet3		
		worduc	globalTileSet3		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMap5
		worduc	globalMap5		;map (background)
		worduc	>>globalMap5Ctrl
		worduc	globalMap5Ctrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMap5Anim	;anim
		worduc	globalMap5Anim	
		worduc	>>globalMap5Enemys	;enemys
		worduc	globalMap5Enemys		
		
lvTMapData
		.data	256,256,0,0,392,225	;map width, map height, pos x, pos y, screen width, screen hight
		worduc	>>globalTileSet1		
		worduc	globalTileSet1		;tiles
		worduc	>>globalTileSet1Lut
		worduc	globalTileSet1Lut	;tiles lut (number to offset)
		worduc	>>globalMapT
		worduc	globalMapT		;map (background)
		worduc	>>globalMapTCtrl
		worduc	globalMapTCtrl		;map (ctrl)
		word	mapBobCData		;bob drawing struct
		worduc	>>globalMapTAnim	;anim
		worduc	globalMapTAnim	
		worduc	>>globalMapTEnemys	;enemys
		worduc	globalMapTEnemys	
		
;*********************************************************************
;* bob related temporary data
;*********************************************************************	
	
mapBobCData	.data	0,0,1,16		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	0,0			;sx,sy
		.data	$0000,$0000,341		;source, width
		word	copySolid16xN
		word	0			;flip xy
		.data	0,0,0,0,0		;tmps	
	
playerBobData	.data	188,160,2,32		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	11,44			;sx,sy
		worduc	>>globalPlayer		;source, 
		worduc	globalPlayer
		word	enemySourceWidth	;width
		word	copySolidTransparent16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps
			
enemyBobData	.data	188,160,2,32		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	11,44			;sx,sy
		worduc	>>globalEnemy1		;source, 
		worduc	globalEnemy1
		word	288			;width
		word	copySolidTransparent16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps
			
bulletBobData	.data	100,100,1,16		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	208,37			;sx,sy
		worduc	>>globalBullets		;source, 
		worduc	globalBullets
		word	681			;width
		word	copySolidTransparentWithTest16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps	
  
introBobData	.data	32,0,20,176		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	0,0			;sx,sy
		worduc	>>globalTitleImage	;source, 
		worduc	globalTitleImage
		word	320			;width
		word	copySolidTransparent16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps	

gameOverBobData	
		.data	16,0,23,225		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	0,0			;sx,sy
		worduc	>>globalGameOverImage	;source, 
		worduc	globalGameOverImage
		word	368			;width
		word	copySolid16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps	

wonBobData	
		.data	16,0,23,225		;bob x,y,width16,height
		.data	$0000,$0000,392,225	;dest adr, width, height
		.data	0,0			;sx,sy
		worduc	>>globalWonImage	;source, 
		worduc	globalWonImage
		word	368			;width
		word	copySolid16xN
		word	0			;flip
		.data	0,0,0,0,0		;tmps			
  
;*********************************************************************
;* audio channel data
;*********************************************************************

channel0	
	.space	32	;channel 0
channel1	                    
	.space	32	;channel 1       	
channel2		                              
	.space	32	;channel 2
channel3		                              
	.space	32	;channel 3	
channel4	                          
	.space	32	;channel 4  	
channel5	                            
	.space	32	;channel 5
	
modChannels

	word	channel1
	word	channel2
	word	channel3
	word	channel4
	
;sfxChannels
;
;	word	channel0
;	word	channel5
;	
;	.def	sfxChannelSelectorMask	1
;	
;sfxChannelSelector	
;
;	word	0
	
channel0Buffer
	.space	96

channel1Buffer
	.space	96

channel2Buffer
	.space	96
	
channel3Buffer
	.space	96
		
channel4Buffer
	.space	96

channel5Buffer
	.space	96	
	
	  
;*********************************************************************
;* font/video related
;*********************************************************************	
   
displayFrame	
	worduc	>>globalFrameBuffer0
	worduc	globalFrameBuffer0
	
drawFrame
	worduc	>>globalFrameBuffer1
	worduc	globalFrameBuffer1
	
screenWidth
	word	392	

fontAddress
	worduc	>>globalFont8x8
	worduc	globalFont8x8
	
OURL	word	0	
			
;*********************************************************************
;* sd data after code segment
;*********************************************************************		
		
	;gfx
		
	.org	16384
		
	.incdir		"F:\git\goldmomo_endlos\assembler_files\ucore\Sheriff\gfx"
	.incbin		"font8x8_4444.dat.raw"	
	.incbin		"font2_8x8_4444.dat.raw"		
	.incbin		"font16x16_4444.dat.raw"	
	.incbin		"player_288x220_4444_code2.dat.raw"			
	.incbin		"charEnemy1_code1_288x220_4444.dat.raw"			
	.incbin		"bullets_681x109_4444_code3.dat.raw"		
	.incbin		"hud_144x15_4444.dat.raw"
	.incbin		"title_320x176_4444.dat.raw"
	.incbin		"game_over_368x225_4444.dat.raw"
	.incbin		"won_368x225_4444.dat.raw"
	.incbin		"map1/Background.map.raw"				
	.incbin		"map1/Ctrl.map.raw"						
	.include	"map1/anims.s"					
	.include	"map1/enemys.s"	
	.incbin		"map2/Background.map.raw"				
	.incbin		"map2/Ctrl.map.raw"						
	.include	"map2/anims.s"					
	.include	"map2/enemys.s"	
	.incbin		"map3/Background.map.raw"				
	.incbin		"map3/Ctrl.map.raw"						
	.include	"map3/anims.s"					
	.include	"map3/enemys.s"	
	.incbin		"mapTitle/Background.map.raw"				
	.incbin		"mapTitle/Ctrl.map.raw"					
	.include	"mapTitle/anims.s"					
	.include	"mapTitle/enemys.s"	
	.incbin		"map4/Background.map.raw"				
	.incbin		"map4/Ctrl.map.raw"						
	.include	"map4/anims.s"					
	.include	"map4/enemys.s"	
	.incbin		"map5/Background.map.raw"				
	.incbin		"map5/Ctrl.map.raw"						
	.include	"map5/anims.s"					
	.include	"map5/enemys.s"	
	.incbin		"tiles1_341x324_4444.dat.raw"		
	.include	"map1/tile_lut.s"
	.incbin		"tiles2_341x324_4444.dat.raw"	
	.incbin		"tiles3_341x324_4444.dat.raw"	
	.incbin		"tiles4_341x443_4444.dat.raw"	
	.include	"map6/tile_lut.s"
	.incdir		"F:\git\goldmomo_endlos\assembler_files\ucore\Sheriff\sfx"
	.incbin		"title.mod"	
	.incbin		"level_s1.mod"
	.incbin		"level_s2.mod"
	.incbin		"explosion.raw"
	.incbin		"shot.raw"
	
	