
;EXPERIMENTAL DONT LOAD/USE

;*********************************************************************	
; includes
;*********************************************************************	

	.incdir	"F:\git\goldmomo_endlos\assembler_files\ucore\"
	.include "include\ucore_ctrl.i"

;*********************************************************************	
; sd header is placed here
;*********************************************************************	

	.include "boot_level_sdHeader.s"

;*********************************************************************
;* start at address 32 here
;*********************************************************************

start	
	;setup irq vector
	
	movei	r0,irq
	nop
	moveih	r0,>irq
	nop
	setssr	r0,2

	;setup video (720x450)
	
	gpci	r7,2		;next 4 + X
	br	setupVideo
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;clear screen
	
	movei	r2,$00	;destination 
	movei	r3,$00
	moveih	r2,$00
	moveih	r3,$f0	;p(0,0) = f000 0000
	
	gpci	r7,2	;next 4 + X
	br	memset
	movei	r1,$33	; count		delay slot	
	movei	r0,$00	; value		delay slot
	moveih	r1,$9e	; count		delay slot
	nop		;		delay slot
	
	;copy sample into sram

	movei	r4,$e4
	movei	r2,>>sampleData
	moveih	r4,$6
	moveih	r2,>>>sampleData
	gpci	r7,2	;next 4 + X
	br	iToECopy
	movei	r0,sampleDataIRAM	;delay slot	
	movei	r1,sampleData		;delay slot
	moveih	r0,>sampleDataIRAM	;delay slot
	moveih	r1,>sampleData		;delay slot	
	
	;draw header
	
	gpci	r7,2		;next 4 + X
	br	drawTextFormated
	movei	r0,textHeader	;delay slot
	movei	r1,0		;delay slot
	moveih	r0,>textHeader	;delay slot
	movei	r2,0		;delay slot
	
	;setup audio
	
	gpci	r7,2		;next 4 + X
	br	initAudio
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
		
	;setup audio irq
	
	movei	r0,UcIrqMsk
	movei	r1,$4			;enable audio irq
	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
	
	;draw sample
	
	;******************************
;*
;* drawPixel
;* 
;* r0 	 	x
;* r1		y (wasted)
;* r2		low screen adr (wasted) 
;* r3		high screen adr (wasted)
;* r4		pixel value	
;* r5		screen width (wasted)
;*

	
	movei	r6,0		;x counter
	movei	r7,0		;byte counter
drawLoop

	movei	r4,sampleData
	movei	r5,>>sampleData
	moveih	r4,>sampleData
	moveih	r5,>>>sampleData	;data

	lsrqi	r0,r7,1
	esadr	r5,r4
	erqld	r0
	eld	r1
	extri	r0,0
	swptc	r1,r1
	movei	r0,225
	extb	r1,r1	;signed
	nop
	sub	r1,r0,r1
	nop
	
	
	push	r7
	
	;draw pixel
	
	movei	r4,$e0
	movei	r3,0
	movei	r2,0
	moveih	r3,$f0		;screen address $f0000000
	gpci	r7,2
	br	drawPixel
	movei	r5,$d0		;	delay slot
	or	r0,r6,r6	;x	delay slot
	moveih	r4,$7f		;value	delay slot
	moveih	r5,2		;720 screen width

	rqpop
	nop
	nop
	pop	r7
	nop
	addi	r7,5
	
	;
	movei	r0,$cf
	nop
	moveih	r0,2
	nop
	cmpeq	r6,r0
	brtc	drawLoop
	addi	r6,1		;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	;enable irqs
	
	sei
	
	;
		
end	;push leds off
	
	movei	r7,UcRSwichtWLedG
	movei	r6,$0
	moveih	r7,>UcRSwichtWLedG
	nop
	st	r7,r6	

	br	end
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	

	
;***********************************************************************
;* irq code start
;***********************************************************************
	
irq
	cli
	
	;save all register
	
	push	r0
	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	push	r6
	push	r7
		
	;irq begin
	
	;push leds on
	
	movei	r0,UcRSwichtWLedG
	movei	r1,$ff
	moveih	r0,>UcRSwichtWLedG
	moveih	r1,$ff
	nop
	st	r0,r1	
		
	
	;copy 96 values from channel	

	movei	r7,channel0
	gpci	r5,2
	br	channelBufferdCopy
	movei	r0,95			;value count samples
	movei	r6,channel0Buffer	;out buffer
	moveih	r7,>channel0		;data struct
	moveih	r6,>channel0Buffer
	
	;push dac data
	
	movei	r1,channel0Buffer
	movei	r0,95			;95 values to DAC
	moveih	r1,>channel0Buffer	;source data
	
fillDACBuffer

	movei	r6,UcAudioDACBase	;optimize me out of loop
	rqldi	r1,0			
	moveih	r6,>UcAudioDACBase
	movei	r3,0			;zero
	ld	r4			;dac value
	nop
	
	stinc	r6,r4	;dac left high = value
	movei	r7,$1
	stinc	r6,r3	;dac left low = 0
	moveih	r7,$1
	stinc	r6,r4	;dac right high = value
	
	subi	r0,1
	brts	fillDACBuffer
	stinc	r6,r3	;delay slot 	dac right low = 0						
	addi	r1,1	;next bufferd value
	st	r6,r7	;delay slot 	dac address/ctrl = $0101	;ctrl = enable audio
	nop		;delay slot
	
	;clear stored audio irq
	
	movei	r7,UcIrqMemory
	movei	r0,4
	moveih	r7,>UcIrqMemory
	nop
	st	r7,r0	
	
	;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	
	rti
	pop	r1	;delay slot
	pop	r0	;delay slot
	nop		;delay slot
	sei		;delay slot
	
sampleOffset	word	$0000
sampleAdd	word	$0100	
	

	
;*********************************************************************
;* functions
;*********************************************************************

	.include	"components\i2c.s"
	.include	"components\drawText.s"

;******************************
;*
;* initAudio
;*
;* return
;*
;* r0 = 0 (PASS)
;*

initAudio	

	push	r7
	
	movei	r6,audioDefault	
	movei	r5,2			;y cursor	
	moveih	r6,>audioDefault
	nop
	
initAudioI2CWriteLoop
	
	rqldi	r6,0
	rqldi	r6,1
	nop
	ld	r2		;address
	ld	r3		;data
	
	cmpeqi	r2,$ff		;stop at sentinel ($ff)
	brts	initAudioI2CWriteFinish
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	
	gpci	r7,2		;next 4 + X
	br	i2cWM8731WriteWord	;r2 = address;	r3 = data; return r0 = result
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	push	r0	;result
	push	r2	;address
	push	r3	;value
	
	gpci	r7,2			;next 4 + X
	br	drawTextFormated	;r0 = text; r1 = cursor x; r2 = cursor y	
	movei	r0,i2cSetupString	;delay slot
	movei	r1,0			;x = 0		delay slot
	moveih	r0,>i2cSetupString	;delay slot
	movei	r2,2;or	r2,r5,r5		;y = y + 2	delay slot
	
	rqpop
	rqpop
	rqpop
	pop	r3
	pop	r2
	pop	r0
		
	br	initAudioI2CWriteLoop
	addi	r6,2		;next lut address	delay slot
	addi	r5,1		;next y counter		delay slot
	nop			;delay slot
	nop			;delay slot

	movei	r0,0
	
initAudioI2CWriteFinish	
	
	rqpop
	nop
	nop
	pop	r7
	nop
	
	jmpi	r7,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;******************************
;*
;* i2cWM8731WriteWord
;*
;* r2 = address
;* r3 = data
;* 
;* return:
;*
;* r0 = result
;*

i2cWM8731WriteWord

	push	r1
	push	r6
	push	r7
	
	;start
	
	gpci	r7,2	;next 4 + X
	br	i2cSendStart
	movei	r6,UcI2CSoftPortBCtrl		;delay slot
	nop					;delay slot
	moveih	r6,>UcI2CSoftPortBCtrl		;I2C ports b	;delay slot
	nop					;delay slot
	
	;write id
	
	gpci	r7,2	;next 4 + X
	br	i2cSend8WACK
	movei	r1,$34		;WRITE			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	cmpeqi	r0,0
	brtc	i2cSend8WACKFailsWr
	movei	r0,$ff		;delay slot
	nop			;delay slot
	moveih	r0,$01		;delay slot
	nop			;delay slot
	
	;write address
	
	add	r1,r2,r2	;adr*2
	extri	r3,8
	addtqi	r1,r1,0		;+ bit8 of data
	
	gpci	r7,2	;next 4 + X
	br	i2cSend8WACK
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	cmpeqi	r0,0
	brtc	i2cSend8WACKFailsWr
	movei	r0,$ff		;delay slot
	nop			;delay slot
	moveih	r0,$02		;delay slot
	nop			;delay slot
		
	;write data low

	gpci	r7,2	;next 4 + X
	br	i2cSend8WACK
	or	r1,r3,r3	;WRITE		;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	cmpeqi	r0,0
	brtc	i2cSend8WACKFailsWr
	movei	r0,$ff		;delay slot
	nop			;delay slot
	moveih	r0,$04		;delay slot
	nop			;delay slot
	
	;finished without fail
	
	movei	r0,0		;all fine
	
	;stop
	
i2cSend8WACKFailsWr

	gpci	r7,2	;next 4 + X
	br	i2cSendStop
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
	gpci	r7,2	;next 4 + X
	br	i2cWaitHalfPeriode
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	gpci	r7,2	;next 4 + X
	br	i2cWaitHalfPeriode
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	gpci	r7,2	;next 4 + X
	br	i2cWaitHalfPeriode
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	gpci	r7,2	;next 4 + X
	br	i2cWaitHalfPeriode
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot	
	
	
	rqpop
	rqpop
	rqpop
	pop	r7
	pop	r6
	pop	r1

	jmpi	r7,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot	

;******************************
;*
;* drawChar
;* 
;* r0 	 	value
;* r1		x 	
;* r2		y
;*
;* trash r0

drawChar	

	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	push	r6
	
	;destination base (sram base 0)
	
	muli	r1,8
	
	movei	r4,$00	;destination 
	movei	r5,$00
	moveih	r4,$00
	moveih	r5,$f0	;p(0,0) = f000 0000
	
	add	r4,r4,r1
	addtqi	r5,r5,0
	
	movei	r1,$00
	nop
	moveih	r1,$2d	;720*16
	nop
	
	mul	r1,r1,r2;*y
	gmulhi	r2
	
	add	r4,r4,r1
	addt	r5,r5,r2
		
	;font source
	
	movei	r2,$68	;source 
	movei	r3,$01
	moveih	r2,$50
	moveih	r3,$e0	;p(0,0) = e001 5068
	
	muli	r0,8		;value * 8
	nop
	add	r2,r2,r0	;source 
	addtqi	r3,r3,0		;

	;

	movei	r0,15		;16 [y]
dcYloop	
	
	movei	r1,7		;8 [x]
dcXloop
	esadr	r3,r2
	erqldi	0
	eld	r6
	nop
	
	extri	r6,15
	brts	dcNoTransp
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	nop		;delay slot
	
	movei	r6,0
	
dcNoTransp	
	
		
	esadr	r5,r4
	est	r6,0
	
	subi	r1,1		;x-
	brts	dcXloop
	addi	r4,1		;delay slot
	addtqi	r5,r5,0		;delay slot
	addi	r2,1		;delay slot
	addtqi	r3,r3,0		;delay slot
	
	;
		
	movei	r1,$c8
	nop
	moveih	r1,$2		;r1 = 720-8
	nop
	
	add	r4,r4,r1	;dest + 720-8
	addtqi	r5,r5,0		;
	
	movei	r1,$e8
	nop
	moveih	r1,$2		;r1 = 752-8
	nop	
	
	subi	r0,1		;y-
	brts	dcYloop
	add	r2,r2,r1	;source + 752-8		delay slot
	addtqi	r3,r3,0		;			delay slot
	nop			;delay slot
	nop			;delay slot
	
	;
	
	rqpop
	rqpop
	rqpop
	pop	r6
	pop	r5
	pop	r4
	
	rqpop
	nop
	nop
	pop	r3
	
	
	rqpop
	rqpop
	jmpi	r7,0
	pop	r2	;delay slot
	pop	r1	;delay slot
	nop		;delay slot
	nop		;delay slot

;******************************
;*
;* r0 	 	value
;* r1		count-1 (8 words))
;* r3:r2	dest
;
memset

clearLoop

	esadr	r3,r2
	est	r0,0
	est	r0,1
	est	r0,2
	est	r0,3
	est	r0,4
	est	r0,5
	est	r0,6
	est	r0,7
	subi	r1,1
	brts	clearLoop
	addi	r2,8	;delay slot
	addtqi	r3,r3,0	;delay slot
	nop		;delay slot
	nop		;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				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	$0080	;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	$0170	;21 HLOADSTOP					360+8				180+8
	word	$001e	;22 VLOADSTART 					31-1				31-1
	word	$03a2	;23 VLOADSTOP 					931-1				931-1
	word	$0002	;24 VLOADNEXT					2				4
	word	$0000	;25 MEM_STARTADR_store low			$0000				$0000
	word	$f000	;26 MEM_STARTADR_store high			$f000				$f000
	word	$0000	;27 MEM_LINEOFFSET_store low			$0000				$0000
	word	$0000	;28 MEM_LINEOFFSET_store high			$0000				$0000
	word	$0002	;29 MEM_MODE_store 				2				2 (X1R5G5B5X1R5G5B5)
	word	$0000	;2a LATCH MEM_STARTADR/LINEOFFSET/MODE		X				X
	

audioDefault
	
	;
				;A =  8 7654 3210
	.data   $9,$0000	;9 =  0 0000 0000 	(inactivate interface)
	.data	$0,$0097	;0 =  0 1001 0111	;left line in mute
	.data	$1,$0097	;1 =  0 1001 0111	;right line in mute
	.data	$2,$0079	;2 =  0 0111 1001	;+6db left out
	.data	$3,$0079	;3 =  0 0111 1001	;0db right out
	.data	$4,$0012	;4 =  0 0001 0010	;0=0 mic boost off;
							;1=1 enable line input mute
							;2=1 line input to adc
							;3=0 disable bypass
							;4=1 DAC select
							;5=0 side tone disable
							;76=0 -6db sidetone						
	.data	$5,$0000	;5 =  0 0000 0000	;DAC soft Mute off, no Filer
	.data	$6,$0067	;6 =  0 0110 0111 	;DAC Power, Output Power, Device Power on
	.data	$7,$0009	;7 =  0 0000 1001 	;left justified, 24 bit
	.data	$8,$001e	;8 =  0 0001 1110	;0=0 normal mode
							;1=1 bosr (384/192)
							;5432=0111 96khz
							;78=00 no clk dividing	
	.data   $9,$0001	;9 =  0 0000 0001 	(activate interface)
	.data	$ff,$0000	;stop
	
		
textHeader	

	.string		"I2C Sound push sample test"
	word	0

i2cSetupString
	.string		"i2c write value %x to address %x result %x"
	word	0
	
textReaded
	.space	32
	


;******************************
;*
;* channelBufferdCopy
;*
;* r0 = counter
;* r5 = return address !!
;* r6 = channel out buffer
;* r7 = channel struct
;*
	
channelBufferdCopy	

	push	r1
	push	r2
	push	r3
	push	r4
	push	r5
	
	rqldi	r7,channelCurrentPositionHigh
	rqldi	r7,channelRepeatStart
	rqldi	r7,channelRepeatLength
	ld	r1		;pos high
	ld	r2		;repeat start
	ld	r3		;repeat length
	
	rqldi	r7,channelSampleAdrLow
	rqldi	r7,channelSampleAdrHigh
	add	r3,r3,r2	;rep start + rep length
	ld	r4		;sample adr low
	ld	r5		;sample adr high
	nop
	esadr	r5,r4		;sample addr
	
smpLoop	
	
	rqldi	r7,channelLength
	cmplo	r1,r3		;pos high < (rep start + rep length)
	movets	r1,r1,r2	;pos high = pos high TS else rep start , dont remove fractal part
	ld	r4		;channel length
	nop
	cmplo	r1,r4		;pos high < channel length
	brtc	smpFinish
	movei	r4,0				;delay slot	value = 0
	rqldi	r7,channelCurrentPositionLow	;delay slot
	rqldi	r7,channelIncrement		;delay slot
	nop					;delay slot
	
	ld	r5		;pos low
	ld	r4		;increment
	nop			;?
	
	erqldb	r1		;take some cycles to get data
	
	add	r5,r5,r4	;pos + incremnt 
	addtqi	r1,r1,0	
	rqldi	r7,channelVolume
	add	r5,r5,r4	;pos + increment
	addtqi	r1,r1,0
	ld	r4		;volume
	
	ssto	channelCurrentPositionLow
	stwo	r7,r5		;store low back
		
	extri	r5,0		;is even address?	
	eld	r5		;value
	nop
	swptc	r5,r5		;swap bytes
	
smpFinish
	
	subi	r0,1
	extb	r5,r5		;signed extend from byte to word
	brts	smpLoop
	muls	r5,r5,r4	;value * volume			delay slot
        nop     		;				delay slot
	stinc	r6,r5    	;*channelbuffer++ = value	delay slot
	nop			;				delay slot
	
	ssto	channelCurrentPositionHigh
	stwo	r7,r1		;store high back
	
	rqpop	
	rqpop	
	rqpop
	pop	r5
	pop	r4
	pop	r3
	
	rqpop
	rqpop
	jmpi	r5,0		;return via r5!
	pop	r2		;				delay slot
	pop	r1		;				delay slot
	nop			;				delay slot
	nop			;				delay slot
	
;******************************
;* iToECopy
;*
;* r0 source
;* r2:r1	dest
;* r4 count - 1 
;* 
;* waste r0 .. r4
;*	

iToECopy

	
iToECopyLoop
	
	rqldi	r0,0
	addi	r0,1
	subi	r4,1
	ld	r3
	brts	iToECopyLoop
	esadr	r2,r1		;delay slot
	est	r3,0		;delay slot
	addi	r1,1		;delay slot
	addtqi	r2,r2,0		;delay slot
	
	jmpi	r7,0
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	
;******************************
;*
;* udiv16
;* 
;* r0 	 	divident
;* r1		divisor
;*
;* return
;*
;* r2		qoutient
;* r3		remainder
;*
;* needs 34 cycles
;*
	
udiv16	
	udivinit	15
	udivsdd		r0
	udivsdv		r1
	
	movei	r0,3	;(3+1)*4 = 16
	cli		;disable irq
udiv16Loop	
	subi	r0,1
	brts	udiv16Loop
	udivstep	;delay slot	!!!! note udivstep is not irq save, so use cli/sei lock
	udivstep        ;delay slot
	udivstep        ;delay slot
	udivstep        ;delay slot

	jmpi	r7,0
	nop			;delay slot
	udivgq		r2	;delay slot		get qoutient
	udivgr		r3	;delay slot		get remainder
	sei			;delay slot		enable irqs	
	
;******************************
;*
;* drawPixel
;* 
;* r0 	 	x
;* r1		y (wasted)
;* r2		low screen adr (wasted) 
;* r3		high screen adr (wasted)
;* r4		pixel value	
;* r5		screen width (wasted)
;*

drawPixel
	
	
	nop
	mul	r1,r1,r5	;y*width
	gmulhi	r5			
	add	r2,r2,r1	
	addt	r3,r3,r5
	add	r2,r2,r0
	jmpi	r7,0
	addtqi	r3,r3,0		;delay slot
	nop			;delay slot
	esadr	r3,r2		;delay slot
	est	r4,0		;delay slot
	
;*********************************************************************
;* data
;*********************************************************************

	.incdir	"F:\git\goldmomo_endlos\sfx"

	.def	channelRepeatStart		0
	.def	channelRepeatLength		1
	.def	channelIncrement		2
	.def	channelVolume			3	
	.def	channelLength			4
	.def	channelCurrentPositionLow	5
	.def	channelCurrentPositionHigh	6
	.def	channelSampleAdrLow		7
	.def	channelSampleAdrHigh		8
	.def	channelStructSize		9
	
channel0
	
	word	3372				;channelRepeatStart		
	word	158                             ;channelRepeatLength		
	word	$3fff                           ;channelIncrement		
	word	63                              ;channelVolume			
	word	3530                            ;channelLength			
	word	0	;fractation             ;channelCurrentPositionLow	
	word	0	;position               ;channelCurrentPositionHigh	
	word	$f1a0                     	;channelSampleAdrLow		
	word	$f004                    	;channelSampleAdrHigh		

channel0Buffer

	.space	96

	
sampleDataIRAM
	
	.incbin	"sample_length_3530_repeatStart_3372_repeatLength_158"
	
		
	.def	sampleData	$f004f1a0
	.def	sampleLength	1765