*	ZIK DRIVER IN TIMER A  (50 HZ)    V1.5
*	POUR FALCON
*	JUSQU'A 32 VOIES AU DSP (oune pitite optimizassion)
*	50 KHZ  (1,5% CPU TAKEN PER CHANNEL)
*	BY AXEL F. OF MCS     AND
*	SIMPLET OF FATA DESIGN (DSP)


	
COLOR	EQU	1	* 0 = COLOR CPU	1 = NO EFFECT

	OPT	O-,D+

FRQ_DSP		EQU	610697964		* $800000*3579546/49169
OFFSET_VAL		EQU	984
CLK		EQU	1
***************************************************************************

LL	DC.W	0
ZIK	
text
***************************************************************************
**************  MUSIC PLAYER  *********************************************
***************************************************************************
	BRA	INIT
	BRA	MY_134
	BRA	END
	BRA	BRUIT
	DC.B	"FIRST AXEL F.(MCS)'S MUSIC DRIVER FOR FALCON : 16-BIT 50 KHZ  (DSP ROUT BY SIMPLET OF FATAL DESIGN)"
	EVEN

***************************************************************************
**************  MIXAGE DES VOIX  ******************************************
***************************************************************************
MY_134:
	IFEQ	COLOR
	NOT.W	$FFFF8240.W
	NOT.L	$FFFF9800.W
	ENDC
	
	MOVE.W	SR,-(A7)
	MOVE.W	#$2300,SR

	ROR.W	SndTrack_Timer_Cmpt
	BCC.S	SndTrack_Timer_Ret
	BSR.S	SndTrack_IT
	MOVE.B	TIMER_DATA,$FFFFFA1F.W
	MOVE.B	TIMER_CONTROL,$FFFFFA19.W
	MOVE.W	SAMPLE_LENGHT,CODE_SAMPLE_LENGHT

SndTrack_Timer_Ret
	IFEQ	COLOR
	NOT.W	$FFFF8240.W
	NOT.L	$FFFF9800.W
	ENDC
	MOVE.W	(A7)+,SR
	RTE
	
*--------------------------------------------------------------------------
SndTrack_IT
	TST.B	DSP_IN_USE
	BEQ.S	IT_OK
	RTS
	
IT_OK	MOVEM.L	D0-A6,-(A7)
	
	ST	DSP_IN_USE    			* Signale au DSP qu'on veut causer … la routine Soundtracker
	MOVE.B	#$80+$26/2,$FFFFA201.W		* Host User 0, vecteur $26
	
	LEA	$FFFFA204.W,A3
	
	MOVEQ	#0,D0
	MOVE.W	CODE_SAMPLE_LENGHT,D0
	MOVE.L	D0,(A3)
	
	BTST.B	#1,$FFFFA202.W
	BEQ.S	*-6
	
	LEA	PILEVOIE,A5
	MOVE.L	(A5)+,A6
	MOVE.L	A5,VOICE_POINTER
 	
	BSR	PLAY_VOICE_0
	
	MOVE.L	#MY_3FC,$3FC.W
	MOVE.B	#$FF,$FFFFA203.W
	BSET.B	#0,$FFFFA200.W
 	MOVEM.L	(A7)+,D0-A6
 	RTS
*--------------------------------------------------------------------------
MY_3FC:	
	IFEQ	COLOR
	MOVE.W	#$700,$FFFF8240.W
	MOVE.L	#$70000000,$FFFF9800.W
	ENDC
	
.CC	MOVEM.L	D0-A6,-(A7)
	LEA	$FFFFA204.W,A3
	MOVE.L	(A3),D0
	BCLR.B	#0,$FFFFA200.W
	MOVE.W	#$2300,SR
	
.NEXT_V	MOVE.L	VOICE_POINTER,A5
	MOVE.L	(A5)+,A6
	CMP.L	#0,A6
	BEQ.S	NO_MORE_VOICE
	
	MOVE.L	A5,VOICE_POINTER
	
	TST.B	KIND_VOICE(A6)		*SI PAS VOIE SNDTRACK NI VOIE BRUIT
	BEQ.S	.NEXT_V
	
	BSR	PLAY_VOICE
	BMI.S	.NEXT_V
	
	MOVE.L	#MY_3FC,$3FC.W
	MOVE.B	#$FF,$FFFFA203.W
	BSET.B	#0,$FFFFA200.W
 	
DD
 	IFEQ	COLOR
	MOVE.W	#$FFF,$FFFF8240.W
	MOVE.L	#$FFFFFFFF,$FFFF9800.W
	ENDC
 	MOVEM.L	(A7)+,D0-A6
	RTE
*--------------------------------------------------------------------------
NO_MORE_VOICE
	MOVE.L	#0,(A3)
	SF	DSP_IN_USE
	BSR.L	OLD_134
	BRA	DD
*--------------------------------------------------------------------------
PLAY_VOICE_0
	BTST.B	#0,KIND_VOICE(A6)			* VOIE ACTIVE ?
	BEQ.S	NIET_ACTIVE_0
	
	TST.W	LEFT_VOL(A6)				* PANORAMIQUE NUL ?
	BEQ.S	NIET_VOICE_0
	
	MOVE.L	SPL_POINTER(A6),A0
	TST.L	SPL_POINTER(A6)				* VOIE VIDE
	BEQ.S	NIET_VOICE_0

	MOVEQ	#0,D3	
	MOVE.W	PATT_VOL(A6),D3			* .W VOLUME NUL ?
	BNE.S	CHOIX_0
NIET_VOICE_0
	CMP.W	#0,FREQUENCY(A6)
	BNE.S	.AA
	MOVE.W	#1712,FREQUENCY(A6)
.AA	CMP.W	#0,BASE_SPL(A6)
	BNE.S	.BB
	MOVE.W	#8000,BASE_SPL(A6)
.BB	CMP.L	#0,A0
	BNE.S	CHOIX_0
	LEA	RIEN+1,A0
	BRA.S	CHOIX_0
NIET_ACTIVE_0
	MOVE.W	#1712,FREQUENCY(A6)
	MOVE.L	#0,SPL_POINTER(A6)
	LEA	RIEN+1,A0
	BRA.S	CHOIX_0
*--------------------------------------------------------------------------
PLAY_VOICE
	BTST.B	#0,KIND_VOICE(A6)		* VOIE ACTIVE ?
	BEQ.S	NIET_VOICE
	
	TST.W	LEFT_VOL(A6)			* PANORAMIQUE NUL ?
	BEQ.S	NIET_VOICE
	
	MOVE.L	SPL_POINTER(A6),A0		* VOIE VIDE ?
	TST.L	SPL_POINTER(A6)
	BEQ.S	NIET_VOICE
	
	MOVEQ	#0,D3	
	MOVE.W	PATT_VOL(A6),D3			* .W VOLUME NUL ?
	BNE.S	CHOIX
	
NIET_VOICE
	MOVEQ	#-1,D0				* La voie est saut‚e
	RTS
*--------------------------------------------------------------------------
CHOIX:	MOVE.L	#1,(A3)			* DEMANDE UNE NOUVELLE VOIE AU DSP
CHOIX_0	moveq	#0,d0
	moveq	#0,d4
	moveq	#0,d5
	moveq	#0,d6
	*move.b	NBVF,d4			* DIGVOICES
	*lsr.w	#1,d4
	move.b	MASTER_VOL_LEFT,d5
	move.b	MASTER_VOL_RIGHT,d6

	move.b	LEFT_VOL(a6),d0
	mulu.w	d3,d0
	*divu.l	d4,d0
	mulu.l	d5,d0
	move.l	d0,(a3)			* Volume Gauche

	moveq	#0,d0
	move.b	RIGHT_VOL(a6),d0
	mulu.w	d3,d0
	*divu.l	d4,d0
	mulu.l	d5,d0
	move.l	d0,(a3)			* Volume Droit

	move.l	#$800000/8*428/49169,d0
	moveq	#0,d2
	move.w	BASE_SPL(a6),d2
	mulu.l	d2,d1:d0
	move.w	FREQUENCY(a6),d2
	divu.l	d2,d1:d0
	move.l	d0,(a3)			* NOTE

	BTST.B	#0,$FFFFA202.W
	BEQ.S	*-6
	MOVE.L	(A3),D0			* RECOIT LA LONGUEUR A RENVOYER
	
	
.QQ	MOVE.L	D0,D3			* SAUVEGARDE
	MOVE.L	A0,A1			*

	EXT.L	D0
	DIVU.W	#6,D0			; Envoi par paquet de 3
	ADDQ.W	#1,D0			; un de plus car on tombe
	EXT.L	D0			; par forc‚ment pile
	MOVE.L	D0,(A3)			; Nombre de paquets

	SUBQ.W	#1,D0			; pour le dbra
	SUBQ.W	#1,A0			; Cale les samples

	MOVE.W	#$2300,SR
Send_Samples
	MOVE.L	(A0),(A3)
	MOVE.L	3(A0),(A3)
	ADDQ.W	#6,A0
	DBRA	D0,Send_Samples

	TST.L	SPL_POINTER(A6)
	BEQ.S	.RRETT

	MOVE.L	A1,A0
	ADD.L	D3,A0
	
	MOVE.L	A0,SPL_POINTER(A6)	* POSITION COURANTE DANS LE SAMPLE
	MOVE.L	A0,D0
	MOVE.L	LOOP_END(A6),D1		* FIN DU SAMPLE
	CMP.L	D0,D1
	BGE.S	.PARES
	BRA.S	.CALCRESTE
.RRETT	MOVEQ	#0,D0
	RTS

.CALCRESTE
	BTST.B	#2,BITS(A6)
	BNE.S	.UNLOOP
	MOVE.W	#0,FREQUENCY(A6)
	MOVE.L	#0,SPL_POINTER(A6)
.PARES	MOVEQ	#0,D0
	RTS

.UNLOOP	MOVE.L	SPL_POINTER(A6),D0
	MOVE.L	LOOP_END(A6),D1
	SUB.L	D1,D0
	MOVE.L	LOOP_BEGIN(A6),SPL_POINTER(A6)
	ADD.L	D0,SPL_POINTER(A6)
.YET	MOVE.L	SPL_POINTER(A6),D1
	MOVE.L	LOOP_END(A6),D2
	CMP.L	D2,D1
	BGE.S	.RECAL
	MOVEQ	#0,D0
	RTS
.RECAL	
	SUB.L	LOOP_BEGIN(A6),D1
	SUB.L	LOOP_BEGIN(A6),D2
	SUB.L	D2,D1
	MOVE.L	LOOP_BEGIN(A6),SPL_POINTER(A6)
	ADD.L	D1,SPL_POINTER(A6)
	BRA.S	.YET
***************************************************************************
******  TRAITEMENT DES PATTERNS  ******************************************
***************************************************************************
OLD_134:
	LEA	TICK,A0
	ADDQ.W	#1,(A0)
	MOVE.W	(A0),D0
	CMP.W	SPEED,D0
	BLO.S	.sor
	MOVE.W	#0,(A0)
	
	ADDQ.W	#1,INPATT
	
	BSR.S	SONG1
	
	BSR	TREAT_VOICE

	LEA	INPATT,A0
	CMP.W	#63,(A0)		*LENCURPATT
	BNE.S	.ros
	
	MOVE.W	#0,TICK
	
.ros	LEA	BREAK,A0
	CMP.B	#0,(A0)
	BEQ.S	.SRO
	
	CMP.B	#1,(A0)			* PATT_BREAK
	BEQ.S	.PB
					* SINON POS_JUMP
	MOVE.B	#0,(A0)
	MOVEQ	#0,D0
	LEA	BREAKPOS,A0
	MOVE.W	(A0),D0
	MOVE.W	#0,(A0)
	SUBQ.W	#1,D0
	MOVE.W	#-1,INPATT
	BSR	RESET_INPATT2		* METTRE INPATT2 A 0
	BSR.S	sng3			* (REFAIRE LA ROUTINE)
	RTS

.PB	MOVE.B	#0,(A0)
	MOVEQ	#0,D0
	LEA	BREAKPOS,A0
	MOVE.W	(A0),D0
	MOVE.W	#0,(A0)
	SUBQ.W	#1,D0
	MOVE.W	D0,INPATT
					* RECHERCHER INPATT2
	BSR.S	sng2			
.SRO	RTS

.sor	BSR	EFFECT
	BRA.S	.ros
*--------------------------------------------------------------------------	
SONG1	CMP.W	#64,INPATT		* LENCURPATT
	BEQ.S	sng1
	RTS
sng1	MOVE.W	#0,INPATT
	BSR	RESET_INPATT2
sng2	MOVEM.L	RIEN,D0-D3
	MOVE.W	CURPOS,D0
sng3	MOVE.W	CURLEN,D1
	SUBQ.W	#1,D1
	CMP.W	D0,D1
	BEQ.S	finsong
	ADDQ.W	#1,D0
LLOP	MOVE.W	D0,CURPOS

	MOVEQ	#0,D0
	MOVEQ	#0,D3
	MOVE.W	CURPOS,D0
	MOVE.L	ADDCURSEQ,A0
	MOVE.W	(A0,D0.W*2),D3
	CMP.W	#-1,D3
	BEQ.S	sng1
	MOVE.W	D3,CURPATT

	BSR.S	PATT_TRACK
	RTS
finsong 
	MOVE.W	CURLOP,D0
	BRA	LLOP
*--------------------------------------------------------------------------	
*	D3 = No PATT DESIRE
PATT_TRACK:
	MOVE.L	ADDMOD,A0
	MOVE.L	S_DEBPATT(A0),A0
	MULU	LEN_ONE_PATT,D3
	LEA	(A0,D3.L),A0
	
	MOVE.L	A0,ADDCURPATT
	MOVE.W	(A0)+,LENCURPATT
	LEA	PILEVOIE,A1
	MOVE.L	ADDMOD,A5
	MOVE.L	S_DEBTABTRACK(A5),A5
	MOVE.W	NBVOICE,D0
	
.MM	MOVE.L	(A1)+,A3
	MOVEQ	#0,D1
	MOVE.W	(A0)+,D1
	MOVE.W	D1,NBCURTRACK(A3)
	MOVE.L	(A5,D1.L*4),A4
	MOVE.W	(A4)+,LENCURTRACK(A3)
	MOVE.L	A4,ADDCURTRACK(A3)
	MOVE.L	A4,INPATT2(A3)
	MOVE.W	#0,EMPTY_LINE(A3)
	DBF	D0,.MM
	RTS
***************************************************************************
EFFECT	LEA	VOICE0,A1
	BSR	OUT_PAT
	LEA	VOICE1,A1
	BSR	OUT_PAT
	LEA	VOICE2,A1
	BSR	OUT_PAT
	LEA	VOICE3,A1
	BSR	OUT_PAT
	LEA	VOICE4,A1
	BSR	OUT_PAT
	LEA	VOICE5,A1
	BSR	OUT_PAT
	LEA	VOICE6,A1
	BSR	OUT_PAT
	LEA	VOICE7,A1
	BSR	OUT_PAT
	LEA	VOICE8,A1
	BSR	OUT_PAT
	LEA	VOICE9,A1
	BSR	OUT_PAT
	LEA	VOICE10,A1
	BSR	OUT_PAT
	LEA	VOICE11,A1
	BSR	OUT_PAT
	LEA	VOICE12,A1
	BSR	OUT_PAT
	LEA	VOICE13,A1
	BSR	OUT_PAT
	LEA	VOICE14,A1
	BSR	OUT_PAT
	LEA	VOICE15,A1
	BSR	OUT_PAT
	LEA	VOICE16,A1
	BSR.S	OUT_PAT
	LEA	VOICE17,A1
	BSR.S	OUT_PAT
	LEA	VOICE18,A1
	BSR.S	OUT_PAT
	LEA	VOICE19,A1
	BSR.S	OUT_PAT
	LEA	VOICE20,A1
	BSR.S	OUT_PAT
	LEA	VOICE21,A1
	BSR.S	OUT_PAT
	LEA	VOICE22,A1
	BSR.S	OUT_PAT
	LEA	VOICE23,A1
	BSR.S	OUT_PAT
	LEA	VOICE24,A1
	BSR.S	OUT_PAT
	LEA	VOICE25,A1
	BSR.S	OUT_PAT
	LEA	VOICE26,A1
	BSR.S	OUT_PAT
	LEA	VOICE27,A1
	BSR.S	OUT_PAT
	LEA	VOICE28,A1
	BSR.S	OUT_PAT
	LEA	VOICE29,A1
	BSR.S	OUT_PAT
	LEA	VOICE30,A1
	BSR.S	OUT_PAT
	LEA	VOICE31,A1
	BSR.S	OUT_PAT
	RTS	

OUT_PAT	TST.B	KIND_VOICE(A1)
	BEQ.S	.OK_RTS
	MOVEQ	#0,D0
	MOVE.B	PATT_COMM(A1),D0
	CMP.W	#35,D0
	BGE.S	.OK_RTS
	JSR	([TABLE_EFFECT2,PC,D0.W*4])

	MOVEQ	#0,D0
	MOVE.B	VOL_COMM(A1),D0
	JSR	([TABLE_VOL_EFFECT2,PC,D0.W*4])
.OK_RTS	RTS
***************************************************************************
RESET_INPATT2
	LEA	PILEVOIE,A0
	MOVE.W	NBVOICE,D0
.AA	MOVE.L	(A0)+,A1
	MOVE.L	ADDCURTRACK(A1),INPATT2(A1)
	MOVE.W	#0,EMPTY_LINE(A1)
	DBF	D0,.AA
	RTS
***************************************************************************
RECHERCHE_INPATT2
	LEA	PILEVOIE,A0
	MOVE.W	NBVOICE,D0
	
.AA	MOVE.L	(A0)+,A1
	MOVE.L	ADDCURTRACK(A1),A2
	MOVEQ	#0,D1
	MOVEQ	#0,D5			* D5 = EMPTY_LINE
	
.BB	CMP.W	INPATT,D1
	BEQ.S	.TROUV

	CMP.W	#0,D5
	BEQ.S	.CC
	SUBQ.W	#1,D5
	BRA.S	.FF
	
.CC	MOVE.B	(A2)+,D2
	MOVE.B	D2,D4
	AND.W	#3,D4
	BEQ.S	.PAS_VIDE
	SUBQ.B	#1,D4
	MOVE.W	D4,D5
	*BRA.S	.FF
	
.PAS_VIDE
	BTST	#2,D2
	BEQ.S	.F1
	MOVE.B	(A2)+,D3		* NOTE
.F1	BTST	#3,D2
	BEQ.S	.F2
	MOVE.B	(A2)+,D3		* INSTRU
.F2	BTST	#4,D2
	BEQ.S	.F3
	MOVE.B	(A2)+,D3		* VOLUME
.F3	BTST	#5,D2
	BEQ.S	.F4
	MOVE.B	(A2)+,D3		* EFFECT
.F4	BTST	#6,D2
	BEQ.S	.F5
	MOVE.B	(A2)+,D3		* PARAM 1
.F5	BTST	#6,D2
	BEQ.S	.FF
	MOVE.B	(A2)+,D3		* PARAM 2

.FF	ADDQ.W	#1,D1
	BRA.S	.BB
	
.TROUV	MOVE.L	A2,INPATT2(A1)
	DBF	D0,.AA
	RTS
***************************************************************************
*************  TRAITEMENT DES VOIES  **************************************
***************************************************************************
TREAT_VOICE
	MOVEQ	#0,D0
	MOVE.L	ADDMOD,A4
	
.BB	LEA	CUR_VOICE,A1
	ADDQ.W	#1,(A1)
	MOVE.W	(A1),D0
	CMP.W	S_NBVOICE(A4),D0
	BEQ.S	.AA
	LEA	PILEVOIE,A1
	MOVE.L	(A1,D0.W*4),A1
	BSR.S	TREAT_ONE_VOICE
	BRA.S	.BB
	
.AA	MOVE.W	#-1,(A1)
	TST.B	PATTDELTIME
	BEQ.S	.NO_PATT_DELAY
	SUBQ.B	#1,PATTDELTIME
	BNE.S	.NO_PATT_DELAY
	SUBQ.W	#1,INPATT
	BSR	RECHERCHE_INPATT2
	
.NO_PATT_DELAY
	RTS
***************************************************************************
TREAT_ONE_VOICE:
	BTST.B	#0,KIND_VOICE(A1)	* SI VOIE SOUNDTRACK (ONLY)
	BEQ	NO_EFFECT
	
	MOVEM.L	RIEN,D0-D3
	
	MOVE.L	#0,PATT_LINE(A1)
	MOVE.W	#0,PATT_LINE+4(A1)
	
	CMP.W	#0,EMPTY_LINE(A1)
	BEQ.S	.HH
	SUBQ.W	#1,EMPTY_LINE(A1)
	BRA.S	.GG
	
	MOVE.W	INPATT,D0
	CMP.W	LENCURTRACK(A1),D0
	BGE.S	.GG
	
.HH	MOVE.L	INPATT2(A1),A0
	CMP.L	#0,A0
	BEQ	VOL_OK
	MOVE.B	(A0)+,D0
	MOVE.B	D0,D1
	AND.B	#3,D1
	BEQ.S	.PAS_VIDE
	MOVE.W	D1,EMPTY_LINE(A1)
	
.PAS_VIDE
	BTST	#2,D0
	BEQ.S	.F1
	MOVE.B	(A0)+,PATT_LINE(A1)		* NOTE
.F1	BTST	#3,D0
	BEQ.S	.F2
	MOVE.B	(A0)+,PATT_LINE+1(A1)		* INSTRU
.F2	BTST	#4,D0
	BEQ.S	.F3
	MOVE.B	(A0)+,PATT_LINE+5(A1)		* VOLUME
.F3	BTST	#5,D0
	BEQ.S	.F4
	MOVE.B	(A0)+,PATT_LINE+2(A1)		* EFFECT
.F4	BTST	#6,D0
	BEQ.S	.F5
	MOVE.B	(A0)+,PATT_LINE+3(A1)		* PARAM 1
.F5	BTST	#7,D0
	BEQ.S	.FF
	MOVE.B	(A0)+,PATT_LINE+4(A1)		* PARAM 2

.FF	LEA	INPATT2(A1),A2
	MOVE.L	A0,(A2)
	
.GG	LEA	PATT_LINE(A1),A0
	CMP.B	#$15,2(A0)
	BEQ.S	DOSETFINETUNE
	CMP.B	#3,2(A0)
	BEQ.S	CHECK_TONE1
	CMP.B	#5,2(A0)
	BEQ.S	CHECK_TONE
	BRA.S	SET_INSTR
DOSETFINETUNE
	BSR	SET_FINE_TUNE
	BRA.S	SET_INSTR
	
CHECK_TONE1
	MOVE.W	VOL1(A1),PATT_VOL(A1)
CHECK_TONE
	MOVE.B	2(A0),PATT_COMM(A1)
	MOVE.W	3(A0),PATT_PARAM(A1)
	BSR	SET_PORTAMENTO_TONE
	RTS
	
SET_INSTR
	MOVE.B	1(A0),D0			* 2 OCTET INSTRUMENT
	BEQ.S	SET_PERIODE
	MOVE.B	D0,PATT_INSTR(A1)
	BSR	INSTR
	
SET_PERIODE
	MOVE.B	(A0),D1				* 1 OCTET NOTE
	BNE.S	GFD
	TST.B	1(A0)				* 2 OCTET INSTRUMENT
	BEQ.S	SET_VOL
	MOVE.W	PATT_NOTE1(A1),FREQUENCY(A1)
	MOVE.B	PATT_NOTE2(A1),D1
GFD	LEA	TABLE_DIGINOTE,A2
	MOVEQ	#0,D0
	MOVE.B	FINE_TUNE(A1),D0		* FINE TUNE
	MOVE.L	(A2,D0.W*4),A2
	MOVE.B	D1,PATT_NOTE2(A1)
	SUBQ.W	#1,D1
	MOVE.W	(A2,D1.L*2),D0
	MOVE.W	D0,FREQUENCY(A1)
	MOVE.W	D0,PATT_NOTE1(A1)
	
DFG	*MOVE.B	2(A0),D0
	*CMP.B	#$1D,D0 			; Notedelay
	*BEQ.S	SET_VOL

	BTST	#2,WAVE_CONTROL(A1)
	BNE.S	VIBNOC
	CLR.B	VIB_POS(A1)
VIBNOC	BTST	#6,WAVE_CONTROL(A1)
	BNE.S	TRENOC
	CLR.B	TREM_POS(A1)
TRENOC	TST.B	1(A0)
	BNE.S	SET_VOL
	MOVEQ	#0,D0
	MOVE.B	PATT_INSTR(A1),D0
	BSR	INSTR2

SET_VOL	MOVEQ	#0,D0
	MOVE.B	5(A0),D0			* 6 OCTET VOLUME
	BEQ.S	TREAT_EFFECT
	CMP.W	#$50,D0
	BGT.S	TREAT_VOLUME
	CMP.B	#$10,D0
	BLT.S	TREAT_EFFECT
	SUB.B	#$10,D0
	LSL.W	#4,D0
	MOVE.W	D0,PATT_VOL(A1)
	MOVE.W	D0,VOL1(A1)
	
TREAT_EFFECT
	MOVEQ	#0,D0
	MOVE.B	2(A0),D0			* EFFECT NUMBER
	CMP.W	#35,D0
	BGE.S	NO_EFFECT
	MOVE.B	D0,PATT_COMM(A1)
	MOVE.W	3(A0),PATT_PARAM(A1)
	JSR	([TABLE_EFFECT,PC,D0.W*4])
NO_EFFECT
	RTS
***************************************************************************
TREAT_VOLUME
	BSR.S	TREAT_VOLUME1
	BRA	TREAT_EFFECT
	
TREAT_VOLUME1
	MOVE.B	D0,D1
	AND.W	#$00F0,D0
	LSR.W	#4,D0
	AND.W	#$000F,D1
	MOVE.B	D0,VOL_COMM(A1)
	MOVE.B	D1,VOL_PARAM(A1)
	JSR	([TABLE_VOL_EFFECT,PC,D0.W*4])
	RTS
*--------------------------------------------------------------------------	
VOL_SLIDE_DOWN
	MOVEQ	#0,D0
	MOVE.B	VOL_PARAM(A1),D0
	BRA	VDO
*--------------------------------------------------------------------------	
VOL_SLIDE_UP
	MOVEQ	#0,D0
	MOVE.B	VOL_PARAM(A1),D0
	BRA	VUP
*--------------------------------------------------------------------------	
FVOL_SLIDE_DOWN
	MOVEQ	#0,D0
	MOVE.B	VOL_PARAM(A1),D0
	BRA	VDO
*--------------------------------------------------------------------------	
FVOL_SLIDE_UP
	MOVEQ	#0,D0
	MOVE.B	VOL_PARAM(A1),D0
	BRA	VUP
***************************************************************************
INSTR:	MOVE.L	S_DEBSPLDATA(A4),A3
	SUBQ.B	#1,D0
	MULU	#LEN_SAMPLE_MGT,D0
	ADD.L	D0,A3
	
	CMP.B	#0,(A0)
	BNE.S	.DS
	CMP.B	#$A,2(A0)
	BNE.S	.DS
	BRA.S	.SD
	
.DS	MOVE.L	DEB_MGT(A3),SPL_POINTER(A1)		* ADD DEBUT
	MOVE.L	DEB_MGT(A3),SPL_BEGIN(A1)		* DANS ADD DEBUT SPL
	MOVE.B	F_TUNE_MGT(A3),FINE_TUNE(A1)		* FINE TUNE
	MOVE.W	VOL_MGT(A3),PATT_VOL(A1)		* VOLUME
	MOVE.W	VOL_MGT(A3),VOL1(A1)
	MOVE.L	LOOP_DEB_MGT(A3),LOOP_BEGIN(A1)		* ADD LOOP DEBUT
	MOVE.L	LOOP_DEB_MGT(A3),LOOP_END(A1)
	MOVE.L	LEN_LOOP_MGT(A3),D0
	ADD.L	D0,LOOP_END(A1)				* FIN LOOP = FIN DU SAMPLE
	MOVE.B	BIT1_MGT+1(A3),BITS(A1)
	MOVE.W	BASE_MGT(A3),BASE_SPL(A1)
	RTS
.SD	MOVE.W	VOL_MGT(A3),PATT_VOL(A1)
	MOVE.W	VOL_MGT(A3),VOL1(A1)
	RTS
***************************************************************************
INSTR2	MOVE.L	S_DEBSPLDATA(A4),A3
	SUBQ.B	#1,D0
	MULU	#LEN_SAMPLE_MGT,D0
	ADD.L	D0,A3
	
	MOVE.L	DEB_MGT(A3),SPL_POINTER(A1)		* ADD DEBUT
	MOVE.L	DEB_MGT(A3),SPL_BEGIN(A1)		* DANS ADD DEBUT SPL
	MOVE.B	F_TUNE_MGT(A3),FINE_TUNE(A1)		* FINE TUNE
	MOVE.L	LOOP_DEB_MGT(A3),LOOP_BEGIN(A1)		* ADD LOOP DEBUT
	MOVE.L	LOOP_DEB_MGT(A3),LOOP_END(A1)
	MOVE.L	LEN_LOOP_MGT(A3),D0
	ADD.L	D0,LOOP_END(A1)				* FIN LOOP = FIN DU SAMPLE
	MOVE.B	BIT1_MGT+1(A3),BITS(A1)
	MOVE.W	BASE_MGT(A3),BASE_SPL(A1)
	RTS
***************************************************************************
ARPEGGIO
	TST.B	PATT_COMM(A1)
	BNE	NO_EFFECT

	MOVEQ	#0,D0
	MOVEQ	#0,D1
	MOVE.W	TICK,D0
	MOVE.W	PATT_PARAM(A1),D1
	BEQ	NO_EFFECT
	
	TST.B	PATT_PARAM(A1)
	BEQ.S	.NO_XTEND
	LEA	Arpeggio_Table2,A2
	LEA	Arpeggio_Table,A3
	MOVE.L	A3,D1
	SUB.L	A2,D1
	ADD.W	D1,D0
	
.NO_XTEND
	MOVE.B	Arpeggio_Table(PC,D0.W),D0
	BEQ.S	.ARP_NOP

	SUBQ.W	#4,D0	
	LSR.W	D0,D1
	AND.W	#$F,D1
	
	ADD.B	PATT_NOTE2(A1),D1
	SUBQ.W	#1,D1
	MOVEQ	#0,D0
	MOVE.B	FINE_TUNE(A1),D0
	LEA	TABLE_DIGINOTE,A2
	MOVE.L	(A2,D0.W*4),A2
	MOVE.W	(A2,D1.W*2),FREQUENCY(A1)
	RTS
	
.ARP_NOP
	MOVE.W	PATT_NOTE1(A1),FREQUENCY(A1)
	RTS
*--------------------------------------------------------------------------
Arpeggio_Table
	DC.B	0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4
	DC.B	8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0
	DC.B	4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8
	DC.B	0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4,8,0,4
	
Arpeggio_Table2
	DC.B	0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4
	DC.B	8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12
	DC.B	16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0
	DC.B	4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8,12,16,0,4,8
***************************************************************************
PORTAMENTO_UP
	TST.W	FREQUENCY(A1)
	BEQ	VOL_OK
	MOVEQ	#0,D0
	MOVE.W	PATT_PARAM(A1),D0
	SUB.W	D0,FREQUENCY(A1)
	SUB.W	D0,PATT_NOTE1(A1)
	MOVE.W	FREQUENCY(A1),D0
	CMP.W	#$20,D0
	BPL.S	ZERO2
	MOVE.W	#$20,FREQUENCY(A1)
	MOVE.W	#$20,PATT_NOTE1(A1)
ZERO1	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
ZERO2	RTS
***************************************************************************
PORTAMENTO_DOWN
	TST.W	FREQUENCY(A1)
	BEQ	VOL_OK
	MOVEQ	#0,D0
	MOVE.W	PATT_PARAM(A1),D0
	ADD.W	D0,FREQUENCY(A1)
	ADD.W	D0,PATT_NOTE1(A1)
	MOVE.W	FREQUENCY(A1),D0
	CMP.W	#6848,D0
	BMI	ZERO2
	MOVE.W	#6848,FREQUENCY(A1)
	MOVE.W	#6848,PATT_NOTE1(A1)
	BRA.S	ZERO1
***************************************************************************
SET_PORTAMENTO_TONE
	MOVE.B	(A0),D2
	BEQ	VOL_OK
	MOVEQ	#0,D0
	SUBQ.B	#1,D2
	MOVE.B	FINE_TUNE(A1),D0
	LEA	TABLE_DIGINOTE,A2
	MOVE.L	(A2,D0.W*4),A2
	MOVE.W	(A2,D2.W*2),D2

	MOVE.W	D2,WANTED_PERIOD(A1)
	MOVE.W	PATT_NOTE1(A1),D0
	MOVE.B	#0,TONE_PORT_DIR(A1)
	CMP.W	D0,D2
	BEQ.S	.CLEARTONEPORTA
	BGE	VOL_OK
	MOVE.B	#1,TONE_PORT_DIR(A1)
	RTS
.CLEARTONEPORTA
	MOVE.W	#0,WANTED_PERIOD(A1)
	RTS
***************************************************************************
PORTAMENTO_TONE
	TST.W	FREQUENCY(A1)
	BEQ	VOL_OK
	MOVE.W	PATT_PARAM(A1),D0
	BEQ.S	TONEPORTNOCHANGE
	MOVE.W	D0,TONE_PORT_SPD(A1)
	MOVE.W	#0,PATT_PARAM(A1)
TONEPORTNOCHANGE
	TST.W	WANTED_PERIOD(A1)
	BEQ	VOL_OK
	MOVE.W	TONE_PORT_SPD(A1),D0
	TST.B	TONE_PORT_DIR(A1)
	BNE.S	.TONEPORTAUP
.TONEPORTADOWN
	ADD.W	D0,FREQUENCY(A1)
	ADD.W	D0,PATT_NOTE1(A1)
	MOVE.W	WANTED_PERIOD(A1),D0
	CMP.W	FREQUENCY(A1),D0
	BGT.S	.TONEPORTASETPER
	MOVE.W	WANTED_PERIOD(A1),FREQUENCY(A1)
	MOVE.W	#0,WANTED_PERIOD(A1)
	BRA.S	.TONEPORTASETPER

.TONEPORTAUP
	SUB.W	D0,FREQUENCY(A1)
	SUB.W	D0,PATT_NOTE1(A1)
	MOVE.W	WANTED_PERIOD(A1),D0
	CMP.W	FREQUENCY(A1),D0
	BLT.S	.TONEPORTASETPER
	MOVE.W	WANTED_PERIOD(A1),FREQUENCY(A1)
	MOVE.W	#0,WANTED_PERIOD(A1)

.TONEPORTASETPER
	MOVE.W	FREQUENCY(A1),D2
	MOVE.B	GLISS_FUNK(A1),D0
	AND.B	#$0F,D0
	BEQ.S	.GLISSKIP
	MOVEQ	#0,D0
	MOVE.B	FINE_TUNE(A1),D0
	LEA	TABLE_DIGINOTE,A2
	MOVE.L	(A2,D0.W*4),A2
	MOVEQ	#0,D0
.GLISSLOOP
	CMP.W	(A2,D0.W),D2
	BHS.S	.GLISSFOUND
	ADDQ.W	#2,D0
	CMP.W	#96*2,D0
	BLO.S	.GLISSLOOP
	MOVE.L	#95*2,D0
.GLISSFOUND
	MOVE.W	(A2,D0.W),D2
.GLISSKIP
	MOVE.W	D2,FREQUENCY(A1) 			; Set period
	MOVE.W	D2,PATT_NOTE1(A1)
	RTS
***************************************************************************
VIBRATO	
	MOVE.B	PATT_PARAM+1(A1),D0
	BEQ.S	VIBRATO2
	MOVE.B	VIB_COMM(A1),D2
	AND.B	#$0F,D0
	BEQ.S	.VIBSKIP
	AND.B	#$F0,D2
	OR.B	D0,D2
.VIBSKIP
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$F0,D0
	BEQ.S	.VIBSKIP2
	AND.B	#$0F,D2
	OR.B	D0,D2
.VIBSKIP2
	MOVE.B	D2,VIB_COMM(A1)
VIBRATO2
	MOVE.B	VIB_POS(A1),D0
	LEA	SINUS,A5
	LSR.W	#2,D0
	AND.W	#$001F,D0
	MOVEQ	#0,D2
	MOVE.B	WAVE_CONTROL(A1),D2
	AND.B	#$03,D2
	BEQ.S	.VIB_SINE
	LSL.B	#3,D0
	CMP.B	#1,D2
	BEQ.S	.VIB_RAMPDOWN
	MOVE.B	#255,D2
	BRA.S	.VIB_SET
.VIB_RAMPDOWN
	TST.B	VIB_POS(A1)
	BPL.S	.VIB_RAMPDOWN2
	MOVE.B	#255,D2
	SUB.B	D0,D2
	BRA.S	.VIB_SET
.VIB_RAMPDOWN2
	MOVE.B	D0,D2
	BRA.S	.VIB_SET
.VIB_SINE
	MOVE.B	0(A5,D0.W),D2
.VIB_SET
	MOVE.B	VIB_COMM(A1),D0
	AND.W	#15,D0
	MULU	D0,D2
	LSR.W	#7,D2
	MOVE.W	PATT_NOTE1(A1),D0			* PERIODE
	TST.B	VIB_POS(A1)
	BMI.S	.VIBRATONEG
	ADD.W	D2,D0
	BRA.S	.VIBRATO3
.VIBRATONEG
	SUB.W	D2,D0
.VIBRATO3
	MOVE.W	D0,FREQUENCY(A1)				* PERIODE
	MOVE.B	VIB_COMM(A1),D0
	LSR.W	#2,D0
	AND.W	#$003C,D0
	ADD.B	D0,VIB_POS(A1)
	RTS
***************************************************************************
PORT_SLID
	BSR	TONEPORTNOCHANGE
	BRA	VOLUME_SLIDE
***************************************************************************
VIB_SLID
	BSR.S	VIBRATO2
	BRA	VOLUME_SLIDE
***************************************************************************
TREMOLO
	MOVEQ	#0,D0
	MOVEQ	#0,D2
	MOVE.B	PATT_PARAM+1(A1),D0
	BEQ.S	.TREMOLO2
	MOVE.B	TREM_COMM(A1),D2
	AND.B	#$0F,D0
	BEQ.S	.TRESKIP
	AND.B	#$F0,D2
	OR.B	D0,D2
.TRESKIP
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$F0,D0
	BEQ.S	.TRESKIP2
	AND.B	#$0F,D2
	OR.B	D0,D2
.TRESKIP2
	MOVE.B	D2,TREM_COMM(A1)
.TREMOLO2
	MOVE.B	TREM_POS(A1),D0
	LEA	SINUS,A5
	LSR.W	#2,D0
	AND.W	#$001F,D0
	MOVEQ	#0,D2
	MOVE.B	WAVE_CONTROL(A1),D2
	*LSR.B	#4,D2	????
	AND.B	#$03,D2
	BEQ.S	.TRE_SINE
	LSL.B	#3,D0
	CMP.B	#1,D2
	BEQ.S	.TRE_RAMPDOWN
	MOVE.B	#255,D2
	BRA.S	.TRE_SET
.TRE_RAMPDOWN
	TST.B	VIB_POS(A1)
	BPL.S	.TRE_RAMPDOWN2
	MOVE.B	#255,D2
	SUB.B	D0,D2
	BRA.S	.TRE_SET
.TRE_RAMPDOWN2
	MOVE.B	D0,D2
	BRA.S	.TRE_SET
.TRE_SINE
	MOVE.B	0(A5,D0.W),D2
.TRE_SET
	MOVE.B	TREM_COMM(A1),D0
	AND.W	#15,D0
	MULU	D0,D2
	LSR.W	#2,D2		* #6 ????
	MOVEQ	#0,D0
	MOVE.B	PATT_VOL(A1),D0		* VOLUME
	TST.B	TREM_POS(A1)
	BMI.S	.TREMOLONEG
	ADD.W	D2,D0
	BRA.S	.TREMOLO3
.TREMOLONEG
	SUB.W	D2,D0
.TREMOLO3
	BPL.S	.TREMOLOSKIP
	MOVEQ	#0,D0
.TREMOLOSKIP
	CMP.W	#$40,D0			* A ADAPTER  $10 -> $50
	BLS.S	.TREMOLOK
	MOVE.W	#$40,D0
.TREMOLOK
	MOVE.W	D0,22(A1)		*??
	MOVE.B	TREM_COMM(A1),D0
	LSR.W	#2,D0
	AND.W	#$3C,D0
	ADD.B	D0,TREM_POS(A1)
	RTS
***************************************************************************
SAMPLEOFFSET
	TST.L	SPL_POINTER(A1)
	BEQ	VOL_OK
	
	MOVEQ	#0,D0
	MOVE.W	PATT_PARAM(A1),D0
	BEQ.S	.NONEW
	MOVE.W	#0,PATT_PARAM(A1)
	MOVE.B	#0,PATT_COMM(A1)
	
	MOVE.W	D0,SPL_OFFSET(A1)
.NONEW	MOVE.W	SPL_OFFSET(A1),D0
	LSL.L	#8,D0
	ADD.L	D0,SPL_POINTER(A1)
	MOVE.L	SPL_POINTER(A1),D0
	MOVE.L	LOOP_END(A1),D1
	CMP.L	D0,D1
	BLT.S	.NOOK
	RTS
.NOOK	MOVE.L	SPL_BEGIN(A1),SPL_POINTER(A1)
	RTS
***************************************************************************
VOLUME_SLIDE
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM(A1),D0
	BEQ.S	VOL_DOWN
VUP	LSL.W	#4,D0
	ADD.W	D0,PATT_VOL(A1)
	CMP.W	#$400,PATT_VOL(A1)
	BMI.S	VOL_OK
	MOVE.W	#$400,PATT_VOL(A1)
	RTS
VOL_DOWN
	MOVE.B	PATT_PARAM+1(A1),D0
VDO	LSL.W	#4,D0
	SUB.W	D0,PATT_VOL(A1)
	BPL.S	VOL_OK
	MOVE.W	#0,PATT_VOL(A1)
	RTS
***************************************************************************
POS_JUMP
	MOVE.B	#2,BREAK			* A REFAIRE
	MOVE.W	PATT_PARAM(A1),BREAKPOS
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
***************************************************************************
SET_VOLUME
	MOVE.W	PATT_PARAM(A1),PATT_VOL(A1)
	MOVE.W	PATT_PARAM(A1),VOL1(A1)
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	CMP.W	#$400,PATT_VOL(A1)
	BMI.S	VOL_OK
	MOVE.W	#$400,PATT_VOL(A1)
	MOVE.W	#$400,VOL1(A1)
VOL_OK	RTS
***************************************************************************
PATT_BREAK
	MOVE.B	#1,BREAK
	MOVE.W	PATT_PARAM(A1),D0
	
	CMP.B	#63,D0
	BLE.S	.JPP
	MOVEQ	#0,D0
	
.JPP	MOVE.B	D0,BREAKPOS			* A REFAIRE
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
***************************************************************************
SET_SPEED:
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	BEQ.S	SET_TEMPO
	CMP.W	#$1F,D0
	BGT.S	SET_TEMPO
	MOVE.W	#0,TICK
	LEA	SPEED,A2
	MOVE.W	D0,(A2)
	TST.W	(A2)
	BNE.S	SET_TEMPO
	MOVE.W	#1,(A2)

SET_TEMPO:
	MOVE.B	PATT_PARAM(A1),D0
SET_T2	CMP.B	#0,D0
	BEQ.S	.ZZ
	CMP.B	#$FF,D0
	BEQ.S	.ZZ
	MOVE.B	D0,TEMPO
	SUB.B	#32,D0
.JK	LEA	Simplet_Tempo_Table,A2
	MOVE.W	 (A2,D0.W*4),SAMPLE_LENGHT
	MOVE.B	2(A2,D0.W*4),TIMER_CONTROL
	MOVE.B	3(A2,D0.W*4),TIMER_DATA
.ZZ	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
***************************************************************************
FINE_PORT_UP
	TST.W	TICK
	BNE	VOL_OK
	LEA 	LOWMASK,A2
	MOVE.B	#$0F,(A2)
PORTAUP MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	(A2),D0
	MOVE.B	#$FF,(A2)
	SUB.W	D0,FREQUENCY(A1)
	MOVE.W	FREQUENCY(A1),D0
	CMP.W	#$20,D0
	BPL	VOL_OK
	MOVE.W	#$20,FREQUENCY(A1)
	RTS
***************************************************************************
FINE_PORT_DOWN
	TST.W	TICK
	BNE	VOL_OK
	LEA 	LOWMASK,A2
	MOVE.B	#$0F,(A2)
PORTADOWN
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	(A2),D0
	MOVE.B	#$FF,(A2)
	ADD.W	D0,FREQUENCY(A1)
	MOVE.W	FREQUENCY(A1),D0
	AND.W	#$0FFF,D0
	CMP.W	#6848,D0
	BMI	VOL_OK
	MOVE.W	#6848,FREQUENCY(A1)
	RTS
**********************************************************************
SET_GLISSANDO_CONTROL
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$F0,GLISS_FUNK(A1)
	OR.B	D0,GLISS_FUNK(A1)
	RTS
**********************************************************************
SET_VIBRATO_CONTROL
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$F0,WAVE_CONTROL(A1)
	OR.B	D0,WAVE_CONTROL(A1)
	RTS
***************************************************************************
SET_FINE_TUNE
	MOVE.B	PATT_PARAM+1(A1),FINE_TUNE(A1)
	RTS
***************************************************************************
JUMP_LOOP
	TST.B	TICK
	BNE	VOL_OK
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$0F,D0
	BEQ.S	.SETLOOP
	LEA	LOOP_COUNT,A2
 	TST.B	(A2)
	BEQ.S	.JUMPCNT
	SUBQ.B	#1,(A2)
	BEQ	VOL_OK
.JMPLOOP
	MOVEQ	#0,D0
	MOVE.B	PATT_LOOP_POS,D0
	MOVE.W	D0,INPATT			* A REFAIRE
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
.JUMPCNT
	MOVE.B	D0,LOOP_COUNT
	BRA.S	.JMPLOOP
.SETLOOP
	MOVE.W	INPATT,PATT_LOOP_POS
	RTS
***************************************************************************
SET_TREMOLO_CONTROL
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$0F,D0
	LSL.B	#4,D0
	AND.B	#$0F,WAVE_CONTROL(A1)
	OR.B	D0,WAVE_CONTROL(A1)
	RTS
***************************************************************************
SET_PAN
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$0F,D0
	LEA	TAB_PAN,A2
	MOVE.W	(A2,D0.W*2),LEFT_VOL(A1)
	RTS
***************************************************************************
FINE_PAN
	MOVE.B	PATT_PARAM+1(A1),D0
	MOVE.B	#-1,D1
	SUB.B	D0,D1
	MOVE.B	D1,LEFT_VOL(A1)
	MOVE.B	D0,RIGHT_VOL(A1)
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
***************************************************************************
RETRIG_NOTE
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	BEQ	VOL_OK
	MOVEQ	#0,D1
	MOVE.W	TICK,D1
	BNE.S	.RTNSKP
	TST.W	PATT_NOTE1(A1)
	BNE	VOL_OK
.RTNSKP	DIVU	D0,D1
	SWAP	D1
	TST.W	D1
	BNE	VOL_OK
	MOVE.W	PATT_NOTE1(A1),FREQUENCY(A1)
	MOVE.L	SPL_BEGIN(A1),SPL_POINTER(A1)			* ADD DEBUT SPL
	RTS
***************************************************************************
VOLUME_FINE_UP
	TST.W	TICK
	BNE	VOL_OK
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$F,D0
	BRA	VUP
**********************************************************************
VOLUME_FINE_DOWN
	TST.W	TICK
	BNE	VOL_OK
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	AND.B	#$0F,D0
	BRA	VDO
**********************************************************************
NOTE_CUTE
	MOVEQ	#0,D0
	MOVE.W	PATT_PARAM(A1),D0
	CMP.W	TICK,D0
	BNE	VOL_OK
	MOVE.W	#0,PATT_VOL(A1)
	RTS
**********************************************************************
NOTE_DELAY
	MOVEQ	#0,D0
	MOVE.L	D0,2(A1)
	MOVE.W	PATT_PARAM(A1),D0
	CMP.W	TICK,D0
	BNE	VOL_OK
	MOVE.L	SPL_BEGIN(A1),SPL_POINTER(A1)
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
***************************************************************************
PATTERN_DELAY
	TST.W	TICK
	BNE	VOL_OK
	MOVEQ	#0,D0
	MOVE.B	PATT_PARAM+1(A1),D0
	ADDQ.B	#1,D0
	LEA	PATTDELTIME,A2
	MOVE.B	D0,PATTDELTIME
	RTS
***************************************************************************
SET_STEREO
	MOVE.W	PATT_PARAM(A1),LEFT_VOL(A1)
	MOVE.B	#0,PATT_COMM(A1)
	MOVE.W	#0,PATT_PARAM(A1)
	RTS
*************************************************************************
FUNK_IT						* A REFAIRE
	TST.B	TICK
	BNE	VOL_OK
	MOVE.B	3(A0),D0
	AND.B	#$0F,D0
	LSL.B	#4,D0
	AND.B	#$0F,55(A1)
	OR.B	D0,55(A1)
	TST.B	D0
	BEQ	VOL_OK
UPDATE_FUNK
	MOVEQ	#0,D0
	MOVE.B	55(A1),D0
	LSR.B	#4,D0
	BEQ.S	.FUNKEND
	LEA	FUNK_TABLE,A2
	MOVE.B	(A2,D0.W),D0
	ADD.B	D0,56(A1)
	BTST	#7,56(A1)
	BEQ.S	.FUNKEND
	CLR.B	56(A1)
	MOVE.L	10(A1),D0			* FIN DU SAMPLE
	MOVE.L	14(A1),A2
	ADDQ.L	#1,A2
	CMP.L	D0,A2
	BLO.S	.FUNKOK
	MOVE.L	10(A1),A2
.FUNKOK	MOVE.L	A2,14(A1)
	MOVEQ	#-1,D0
	SUB.B	(A2),D0
	MOVE.B	D0,(A2)
.FUNKEND	RTS
**************  POUR ARRETER LE PLAYER  *********************************
END:	MOVE.W	SR,-(A7)
	MOVE.W	#$2700,SR
	MOVE.B	#$80+$28/2,$FFFFA201.W	* Host User 1, vecteur $28 STOP
	MOVE.L	#$0A00A00,$FFFF8800.W
	MOVE.L	#$0900900,$FFFF8800.W
	MOVE.L	#$0800800,$FFFF8800.W
	MOVE.L	#0,$FFFF8900.W
	MOVE.L	#0,$FFFFA204.W
	BSR	RESTORE
	MOVE.W	(A7)+,SR
	RTS
*************************************************************************
*	D0 = EQUIVALENCE D'UNE LIGNE PATTERN
*	D1 = VOIE UTILISE
BRUIT
	MOVEM.L	D0-A6,-(A7)
	LEA	VOICE0,A1
	MULU	#66,D1
	ADD.W	D1,A1
	MOVE.L	D0,LIGNE
	MOVE.B	#0,26(A1)
	BSR	TREAT_ONE_VOICE
	MOVE.B	#1,26(A1)			* VOICE IS BUSY
	MOVEM.L (A7)+,D0-A6
	RTS
*************  INITIALISATION ET RELOGEMENT  *****************************
*************          DU PLAYER             *****************************
INIT:	MOVEM.L	D0-A6,-(A7)

	LEA	NO_MUS,A1
	MOVE.W	D0,(A1)
	
	MOVE.L	A0,A1
	MOVE.L	A1,ADDMOD
	
	MOVEQ	#0,D1
	MOVE.W	RELOGE,D1
	CMP.W	#1,D1
	BEQ	DEJA

Init_Sound
* Stoppe la lecture DMA au cas o—...
		clr.b	$ffff8901.w

* DAC sur piste 0 (quartet fort)
		move.b	#$0f,$ffff8920.w

* Source DSP-Xmit sur Horloge Interne 25.175 MHz, DSP connect‚ (Enable)
* Source DMA-Play sur Horloge Interne 25.175 MHz
		move.w	#%10010001,$ffff8930.w

* Destinations DAC, DMA-Record et External OutPut
* connect‚es … Source DSP-Xmit, Handshaking On
* Destination DSP-Rec connect‚e sur DMA-Play, DSP connect‚ (Enable)
		move.w	#%0010001000010011,$ffff8932.w

* Fr‚quence 49169 Hz
		move.b	#1,$ffff8935.w

* Programme DSP
	move.w	#113,-(sp)		; DSP_RequestUniqueAbility
	trap	#14			; XBios
	addq.l	#2,sp

	move.w	d0,-(sp)		; No Ability
	move.l	#(DSP_End-DSP_Code)/3,-(sp)		; Longueur en Mots DSP
	pea.l	DSP_Code		; Adresse du code binaire
	move.w	#109,-(sp)		; Dsp_ExecProg
	trap	#14			; XBios
	lea.l	12(sp),sp


Connect	move.l	#87654321,$ffffa204.w
	moveq.l	#0,d0

Conct_Get
	btst.b	#0,$ffffa202.w
	bne.s	DSP_Test
	addq.l	#1,d0
	cmp.l	#100000,d0
	beq.s	DSP_Error
	bra.s	Conct_Get

DSP_Test
	move.l	$ffffa204.w,d0
	cmp.l	#12345678,d0
	beq.s	DSP_Ok

DSP_Error
	moveq.l	#-1,d0
	
DSP_Ok
	MOVE.L	ADDMOD,A1
	MOVE.L	A1,A0			* RELOGE
	MOVE.L	A1,D1
	ADD.L	D1,S_DEBMUS(A1)
	ADD.L	D1,S_DEBSPLDATA(A1)
	ADD.L	D1,S_DEBSEQ(A1)
	ADD.L	D1,S_DEBPATT(A1)
	ADD.L	D1,S_DEBTABTRACK(A1)
	ADD.L	D1,S_DEBSPL(A1)
	
	MOVE.W	S_NBVOICE(A1),D0	* CALCUL LA LONGUEUR D'1 PATT
	LEA	NBVOICE,A0
	MOVE.W	D0,(A0)
	SUBQ.W	#1,(A0)
	
	ADD.W	D0,D0			* EN FONCTION DU NOMBRE DE VOIES
	ADD.W	#2,D0
	LEA	LEN_ONE_PATT,A2
	MOVE.W	D0,(A2)
	
	MOVE.W	S_NBVOICE(A1),D0	* CALCUL LA LONGUEUR D'UNE MUS
	ADD.W	D0,D0			* EN FONCTION DU NB DE VOIES
	ADD.W	#I_MASTERVOL_MUS,D0
	LEA	LEN_ONE_MUS,A2
	MOVE.W	D0,(A2)
	
	MOVE.L	S_DEBMUS(A1),A2
	MOVE.W	S_NBMUS(A1),D0
.AA	ADD.L	D1,ADDDEB_MUS(A2)
	ADD.W	#TOTAL_MUS,A2
	SUBQ.W	#1,D0
	BNE.S	.AA

	MOVE.L	S_DEBTABTRACK(A1),A2
	MOVE.W	S_NBTRK(A1),D0
.BB	ADD.L	D1,(A2)+
	SUBQ.W	#1,D0
	BNE.S	.BB
	
	MOVE.L	S_DEBSPLDATA(A1),A2
	MOVE.W	S_NBSPL(A1),D0
.CC	ADD.L	D1,DEB_MGT(A2)
	ADD.L	D1,LOOP_DEB_MGT(A2)
	ADD.W	#LEN_SAMPLE_MGT,A2
	SUBQ.W	#1,D0
	BNE.S	.CC

	LEA	TABLE_DIGINOTE,A2
	LEA	DIGINOTE1,A3
	MOVEQ	#15,D1
.ULP	MOVE.L	A3,(A2)+
	ADD.W	#192,A3
	DBF	D1,.ULP
	
REPLACE_SAMPLE					* POUR UNE MEILLEUR	
	MOVE.L	S_DEBSPLDATA(A1),A2		* GESTION DE BOUCLE
	MOVE.W	S_NBSPL(A1),D0
	SUBQ.W	#1,D0
	MOVEQ	#0,D1
	MOVEQ	#0,D2
	
.AA	CMP.L	#0,LEN_MGT(A2)
	BEQ.S	.GG
	MOVE.W	LEN_BUF_MGT(A2),D2
	ADD.L	D2,D1
.GG	ADD.W	#LEN_SAMPLE_MGT,A2
	SUBQ.W	#1,D0
	BNE.S	.AA
	
	MOVE.W	S_NBSPL(A1),D0
	
.BOUCLE	CMP.L	#0,LEN_MGT(A2)
	BEQ.S	.FIN
	
	MOVE.W	LEN_BUF_MGT(A2),D3
	MOVE.L	LEN_FIN_MGT(A2),D2
	BEQ.S	.BB
	
	MOVE.L	LOOP_DEB_MGT(A2),A3	* DEPLACE FIN DU SAMPLE
	ADD.L	LEN_LOOP_MGT(A2),A3
	ADD.L	D2,A3
	MOVE.L	A3,A4
	ADD.L	D1,A4
	ADD.W	D3,A4
.CC	MOVE.B	-(A3),-(A4)
	SUBQ.L	#1,D2
	BNE.S	.CC

.BB	MOVE.L	LOOP_DEB_MGT(A2),A3	* DEPLACE DEBUT DU SAMPLE
	ADD.L	LEN_LOOP_MGT(A2),A3
	MOVE.L	A3,D2
	SUB.L	DEB_MGT(A2),D2
	MOVE.L	A3,A4
	ADD.L	D1,A4
	MOVE.L	A4,A5
.DD	MOVE.B	-(A3),-(A4)
	SUBQ.L	#1,D2
	BNE.S	.DD
	
	ADD.L	D1,DEB_MGT(A2)
	ADD.L	D1,LOOP_DEB_MGT(A2)
	
	BTST.B	#2,BIT1_MGT+1(A2)	* ON S'OCCUPE DE L'EVENTUEL BOUCLE
	BEQ.S	.PAS_BOUCLE
	MOVE.L	LOOP_DEB_MGT(A2),A3
	MOVE.W	LEN_BUF_MGT(A2),D2
.EE	MOVE.B	(A3)+,(A5)+
	SUBQ.W	#1,D2
	BNE.S	.EE
	BRA.S	.FIN2
	
.PAS_BOUCLE
	MOVE.L	LOOP_DEB_MGT(A2),A3
	MOVE.W	LEN_BUF_MGT(A2),D2
.FF	MOVE.B	#0,(A5)+
	SUBQ.W	#1,D2
	BNE.S	.FF
	
.FIN2	MOVE.W	LEN_BUF_MGT(A2),D2
	SUB.L	D2,D1
.FIN	SUB.W	#LEN_SAMPLE_MGT,A2
	SUBQ.W	#1,D0
	BNE	.BOUCLE
		
	
						
TEST_DAC
	MOVE.W	SR,-(A7)
	MOVE.W	#$2700,SR
	BSR	STORE
	BSR	REINIT_TEMPO
	
	MOVE.B	TIMER_DATA,$FFFFFA1F.W
	MOVE.B	TIMER_CONTROL,$FFFFFA19.W
	BCLR	#3,$FFFFFA17.W
	BSET	#5,$FFFFFA07.W
	BSET	#5,$FFFFFA13.W
	MOVE.L	#NULL,$134.W		
	MOVE.W	(A7)+,SR	

DEJA	MOVE.W	NO_MUS,D0
	CMP.W	S_NBMUS(A1),D0		* PREPARE LA MUSIQUE
	BGE	FIN_INIT		* D0 = No MUSIQUE
	
	MOVEQ	#0,D0
	MOVEQ	#0,D1
	LEA	CURMUS,A0		* RECHERCHE L'ADD_DEB 
	MOVE.B	D0,(A0)			* DE LA MUS COURANTE
	MOVE.W	LEN_ONE_MUS,D1		* PUIS RECHERCHE L'ADD_DEB
	MULU	D1,D0			* DE LA SEQ COURANTE
	MOVE.L	S_DEBMUS(A1),A2
	ADD.L	D0,A2
	LEA	ADDCURSEQ,A0
	MOVE.L	ADDDEB_MUS(A2),(A0)
	
	LEA	CURPOS,A0
	MOVE.W	#0,(A0)
	
	LEA	MASTER_VOL_LEFT,A0
	MOVE.W	I_MASTERVOL_MUS(A2),(A0)
	LEA	SPEED,A0
	MOVE.B	I_SPEED_MUS(A2),1(A0)
	LEA	TEMPO,A0
	MOVE.B	I_TEMPO_MUS(A2),1(A0)
	
	LEA	CURLEN,A0
	MOVE.W	LEN_MUS(A2),(A0)
	ADDQ.W	#1,(A0)
	LEA	CURLOP,A0
	MOVE.W	RESTART_MUS(A2),(A0)
	
	MOVEQ	#0,D0
	MOVEQ	#0,D1
	MOVE.L	ADDCURSEQ,A0		* RECHERCHE L'ADD_DEB
	MOVE.W	(A0),D0			* DE LA PATT COURANTE
	LEA	CURPATT,A0
	MOVE.W	D0,(A0)
	MOVE.W	LEN_ONE_PATT,D1
	MULU	D1,D0
	MOVE.L	S_DEBPATT(A1),A0
	ADD.L	D0,A0
	LEA	ADDCURPATT,A3
	MOVE.L	A0,(A3)
	
	LEA	LENCURPATT,A3
	MOVE.W	(A0)+,(A3)
	LEA	PILEVOIE,A3
	MOVE.L	S_DEBTABTRACK(A1),A5
	MOVE.W	S_NBVOICE(A1),D0
	LEA	I_VOL_MUS(A2),A1
	
.MM	MOVE.L	(A3)+,A4
	MOVEQ	#0,D1
	MOVE.W	(A0)+,D1
	MOVE.W	D1,NBCURTRACK(A4)
	MOVE.L	(A5,D1.L*4),A6
	MOVE.W	(A6)+,LENCURTRACK(A4)
	MOVE.L	A6,ADDCURTRACK(A4)
	MOVE.L	A6,INPATT2(A4)
	MOVE.W	(A1)+,LEFT_VOL(A4)
	BSET.B	#0,KIND_VOICE(A4)
	MOVE.W	#0,EMPTY_LINE(A4)
	SUBQ.W	#1,D0
	BNE.S	.MM
	
	LEA	INPATT,A0
	MOVE.W	#0,(A0)
	
FIN_INIT
	MOVEM.L	(A7)+,D0-A6
	RTS
***********************************************************************
NULL	RTE
***********************************************************************
REINIT_TEMPO
	MOVE.B	#125,TEMPO
	MOVE.W	#6,SPEED
	MOVE.W	#0,TICK
	MOVE.B	#5,TIMER_CONTROL
	MOVE.B	#192,TIMER_DATA
	MOVE.W	#984,CODE_SAMPLE_LENGHT
	MOVE.W	#984,SAMPLE_LENGHT
	RTS
***********************************************************************
STORE	LEA	SAVE_REGISTER,A0
	MOVE.L	$134.W,(A0)+
	MOVE.L	$110.W,(A0)+
	MOVE.L	$FFFFFA06.W,(A0)+
	MOVE.L	$FFFFFA12.W,(A0)+
	MOVE.L	$FFFFFA16.W,(A0)+
	MOVE.B	$FFFFFA19.W,(A0)+
	MOVE.B	$FFFFFA1F.W,(A0)+
	MOVE.B	$FFFFFA25.W,(A0)+
	RTS
RESTORE LEA	SAVE_REGISTER,A0
	MOVE.L	(A0)+,$134.W
	MOVE.L	(A0)+,$110.W
	MOVE.L	(A0)+,$FFFFFA06.W
	MOVE.L	(A0)+,$FFFFFA12.W
	MOVE.L	(A0)+,$FFFFFA16.W
	MOVE.B	(A0)+,$FFFFFA19.W
	MOVE.B	(A0)+,$FFFFFA1F.W
	MOVE.B	(A0)+,$FFFFFA25.W
	RTS
*************************************************************************
***********  VARIABLES ET TABLES  ***************************************
*************************************************************************
INPATT		DC.W	0
DIGVOICES	DC.W	0
BREAK		DC.W	0
LOWMASK		DC.W	0
PATTDELTIME	DC.W	0
PATTDELTIME2	DC.W	0
AD		DC.W	3
		
BREAKPOS	DC.W	0

ADDMOD		DC.L	0
RELOGE		DC.W	0		* SI = 1 ALORS DEJA RELOGE
ADDCURSEQ	DC.L	0		* ADDRESSE DE LA SEQ COURANTE
ADDCURPATT	DC.L	0		*		 PATT
LENCURPATT	DC.W	0		* LONGUEUR (ROW) DE LA PATT COURANTE
CURPATT		DC.W	0		* PATTERN COURANTE
CURPOS		DC.W	0		* POINTEUR DANS LA SEQ COURANTE
CURMUS		DC.W	0		* MUSIQUE COURANTE
CURLEN		DC.W	0		* LEN_MUS
CURLOP		DC.W	0		* RESTART_MUS
LEN_ONE_PATT	DC.W	0		* LONGUEUR D'UNE PATT
LEN_ONE_MUS	DC.W	0		* LONGUEUR D'UNE MUS
TEMPO		DC.W	6
SPEED		DC.W	6
TICK		DC.W	0
TIMER_CONTROL	DC.W	0
TIMER_DATA	DC.W	0
NBVOICE		DC.W	0
CODE_SAMPLE_LENGHT	DC.W	0
SAMPLE_LENGHT		DC.W	0
MASTER_VOL_LEFT		DC.B	0	
MASTER_VOL_RIGHT	DC.B	0

PATT_LOOP_POS	DC.W	0
LOOP_COUNT	DC.W	0
VOICE_POINTER	DC.L	0
DSP_IN_USE	DC.W	0
CUR_VOICE	DC.W	-1

PERIODE		DC.L	0
LIGNE		DC.L	0
*--------------------------------------------------------------------------
		RSRESET				* Musique
NAME_MUS	RS.B	32
ADDDEB_MUS	RS.L	1
LEN_MUS		RS.W	1
RESTART_MUS	RS.W	1
I_SPEED_MUS	RS.B	1
I_TEMPO_MUS	RS.B	1
I_MASTERVOL_MUS RS.W	1
I_VOL_MUS	RS.W	1

TOTAL_MUS	RS.L	1
*--------------------------------------------------------------------------
		RSRESET				* Entete
S_ENTETE	RS.L	2
S_NBVOICE	RS.W	1
S_NBMUS		RS.W	1
S_NBSEQ		RS.W	1
S_NBPATT	RS.W	1
S_NBTRK		RS.W	1
S_NBSPL		RS.W	1
S_DEBMUS	RS.L	1
S_DEBSPLDATA	RS.L	1
S_DEBSEQ	RS.L	1
S_DEBPATT	RS.L	1
S_DEBTABTRACK	RS.L	1
S_DEBSPL	RS.L	1
S_LENSPL	RS.L	1
S_LEN_BUF_SPL	RS.L	1
S_LEN_DEPACKED_TRACKS	RS.L	1

LEN_S		RS.L	1
*--------------------------------------------------------------------------
	RSRESET					* VOIE IN REPLAY ROUT
FREQUENCY	RS.W	1		* PERIODE OF REPLAY
SPL_POINTER	RS.L	1
SPL_BEGIN	RS.L	1
LOOP_BEGIN	RS.L	1
LOOP_END	RS.L	1
VOL1		RS.W	1
BIT_LOOP	RS.B	1		* LOOP OR NOT
KIND_VOICE	RS.B	1
BUSY		RS.B	1
VOIE_BRUIT	RS.B	1		* ??

PATT_NOTE1	RS.W	1		* (PERIODE)
PATT_NOTE2	RS.B	1		* (LITTERAL)
PATT_INSTR	RS.B	1		*
PATT_COMM	RS.B	1		* LIGNE DANS LA PATT
PATT_VIDE	RS.B	1
PATT_PARAM	RS.W	1		*
PATT_VOL	RS.W	1		*
PATT_LINE	RS.B	6		* LIGNE PATT DECOMPRESSE
INPATT2		RS.L	1		* ADD RELATIVE DANS LA PATT
EMPTY_LINE	RS.W	1		* NB DE LIGNE VIDE RESTANTE

VOL2		RS.B	1
BITS		RS.B	1		* SAMPLE 8/16 BITS
VIB_COMM	RS.B	1
VIB_POS		RS.B	1
SPL_OFFSET	RS.B	1		* .W
TREM_COMM	RS.B	1
TREM_POS	RS.B	1
WAVE_CONTROL	RS.B	1

VOL_COMM	RS.B	1		* VOLUME COMMAND
VOL_PARAM	RS.B	1		* VOLUME PARAMATER

GLISS_FUNK	RS.B	1
FUNK_OFFSET	RS.B	1
WAVE_ST		RS.B	1
FINE_TUNE	RS.B	1
TONE_PORT_DIR	RS.B	1
WANTED_PERIOD	RS.W	1
TONE_PORT_SPD	RS.W	1
NOTE		RS.W	1		* LITTERAL	*.B NORMALEMENT

LEFT_VOL	RS.B	1
RIGHT_VOL	RS.B	1
BASE_SPL	RS.W	1
ADDCURTRACK	RS.L	1
LENCURTRACK	RS.W	1
NBCURTRACK	RS.W	1

VOICE_SIZE	RS.L	1
*--------------------------------------------------------------------------
		RSRESET				* SAMPLE
NAME_MGT	RS.B	32

DEB_MGT		RS.L	1
LEN_MGT		RS.L	1
LOOP_DEB_MGT	RS.L	1
LEN_LOOP_MGT	RS.L	1
LEN_BUF_MGT	RS.W	1
LEN_FIN_MGT	RS.L	1

BASE_MGT	RS.W	1
PANO_MGT	RS.W	1			* PANORAMIQUE
VOL_MGT		RS.W	1
BIT1_MGT	RS.W	1

VIDE_MGT	RS.B	1
F_TUNE_MGT	RS.B	1
NOTE_MGT	RS.B	1
COMMAND_MGT	RS.B	1
PARAM_MGT	RS.W	1
RESERVE_MGT	RS.L	2

LEN_SAMPLE_MGT	RS.B	1
*--------------------------------------------------------------------------
VOICE0		DS.B	VOICE_SIZE
VOICE1		DS.B	VOICE_SIZE
VOICE2		DS.B	VOICE_SIZE
VOICE3		DS.B	VOICE_SIZE
VOICE4		DS.B	VOICE_SIZE
VOICE5		DS.B	VOICE_SIZE
VOICE6		DS.B	VOICE_SIZE
VOICE7		DS.B	VOICE_SIZE
VOICE8		DS.B	VOICE_SIZE
VOICE9		DS.B	VOICE_SIZE
VOICE10		DS.B	VOICE_SIZE
VOICE11		DS.B	VOICE_SIZE
VOICE12		DS.B	VOICE_SIZE
VOICE13		DS.B	VOICE_SIZE
VOICE14		DS.B	VOICE_SIZE
VOICE15		DS.B	VOICE_SIZE
VOICE16		DS.B	VOICE_SIZE
VOICE17		DS.B	VOICE_SIZE
VOICE18		DS.B	VOICE_SIZE
VOICE19		DS.B	VOICE_SIZE
VOICE20		DS.B	VOICE_SIZE
VOICE21		DS.B	VOICE_SIZE
VOICE22		DS.B	VOICE_SIZE
VOICE23		DS.B	VOICE_SIZE
VOICE24		DS.B	VOICE_SIZE
VOICE25		DS.B	VOICE_SIZE
VOICE26		DS.B	VOICE_SIZE
VOICE27		DS.B	VOICE_SIZE
VOICE28		DS.B	VOICE_SIZE
VOICE29		DS.B	VOICE_SIZE
VOICE30		DS.B	VOICE_SIZE
VOICE31		DS.B	VOICE_SIZE

PILEVOIE	DC.L	VOICE0,VOICE1,VOICE2,VOICE3,VOICE4,VOICE5
		DC.L	VOICE6,VOICE7,VOICE8,VOICE9,VOICE10,VOICE11
		DC.L	VOICE12,VOICE13,VOICE14,VOICE15,VOICE16,VOICE17
		DC.L	VOICE18,VOICE19,VOICE20,VOICE21,VOICE22,VOICE23
		DC.L	VOICE24,VOICE25,VOICE26,VOICE27,VOICE28,VOICE29
		DC.L	VOICE30,VOICE31,0

NO_MUS		DC.W	0
SAVE_REGISTER	DCB.L	7
VOLUME_GENERAL	DC.L	0

FUNK_TABLE	DC.B	0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
		EVEN
		
RIEN		DS.L	1024/4

TABLE_EFFECT	DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,SET_PORTAMENTO_TONE
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	FINE_PAN,SAMPLEOFFSET,NO_EFFECT,POS_JUMP
		DC.L	SET_VOLUME,PATT_BREAK,NO_EFFECT,SET_SPEED
		DC.L	NO_EFFECT,FINE_PORT_UP,FINE_PORT_DOWN,SET_GLISSANDO_CONTROL
		DC.L	SET_VIBRATO_CONTROL,SET_FINE_TUNE,JUMP_LOOP,SET_TREMOLO_CONTROL
		DC.L	SET_PAN,RETRIG_NOTE,VOLUME_FINE_UP,VOLUME_FINE_DOWN
		DC.L	NOTE_CUTE,NOTE_DELAY,PATTERN_DELAY,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,SET_STEREO,NO_EFFECT
		
TABLE_EFFECT2	DC.L	ARPEGGIO,PORTAMENTO_UP,PORTAMENTO_DOWN,PORTAMENTO_TONE
		DC.L	VIBRATO,PORT_SLID,VIB_SLID,TREMOLO
		DC.L	NO_EFFECT,NO_EFFECT,VOLUME_SLIDE,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,RETRIG_NOTE,NO_EFFECT,NO_EFFECT
		DC.L	NOTE_CUTE,NOTE_DELAY,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT

TABLE_VOL_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	FVOL_SLIDE_DOWN,FVOL_SLIDE_UP,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
TABLE_VOL_EFFECT2
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,VOL_SLIDE_DOWN,VOL_SLIDE_UP
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		DC.L	NO_EFFECT,NO_EFFECT,NO_EFFECT,NO_EFFECT
		
SINUS		DC.B	$00,$18,$31,$4A,$61,$78,$8B,$A1
		DC.B	$B4,$C5,$D4,$E0,$EB,$F4,$FA,$FD
		DC.B	$FA,$F4,$EB,$E0,$D4,$C5,$B4,$A1
		DC.B	$8B,$78,$61,$4A,$31,$18
		
Simplet_Tempo_Table
		INCBIN	TEMPODSP.TAB

TABLE_DIGINOTE	DC.L	DIGINOTE1,DIGINOTE1,DIGINOTE1,DIGINOTE1
		DC.L	DIGINOTE1,DIGINOTE1,DIGINOTE1,DIGINOTE1
		DC.L	DIGINOTE1,DIGINOTE1,DIGINOTE1,DIGINOTE1
		DC.L	DIGINOTE1,DIGINOTE1,DIGINOTE1,DIGINOTE1
		
DIGINOTE1		INCBIN	PERIOD.TAB

TAB_PAN		dc.w	$ff00
		dc.w	$f010,$e020,$d030,$c040,$b050,$a060,$9070
		dc.w	$8080
		dc.w	$7090,$60a0,$50b0,$40c0,$30d0,$20e0,$00ff

	
SndTrack_Timer_Cmpt
		DC.W	%0001000100010001
*--------------------------------------------------------------------------
DSP_Code		IncBin	HOST_MGT.P56
DSP_End
*--------------------------------------------------------------------------
 TEXT
