
	incdir	"Includes:"
	include	"misc/DeliPlayer.i"

;
;
	SECTION Player,Code
;
;

	PLAYERHEADER PlayerTagArray

	dc.b '$VER: Fred player module V1.1 (30 Mar 92)',0
	even

PlayerTagArray
	dc.l	DTP_PlayerVersion,1
	dc.l	DTP_PlayerName,PName
	dc.l	DTP_Creator,CName
	dc.l	DTP_Check2,Chk
	dc.l	DTP_Interrupt,Int
	dc.l	DTP_InitPlayer,InitPlay
	dc.l	DTP_EndPlayer,EndPlay
	dc.l	DTP_InitSound,InitSnd
	dc.l	DTP_EndSound,RemSnd
	dc.l	DTP_PrevSong,PrevSub
	dc.l	DTP_NextSong,NextSub
	dc.l	TAG_DONE

*-----------------------------------------------------------------------*
;
; Player/Creatorname und lokale Daten

PName	dc.b 'Fred',0
CName	dc.b 'JC & Fred,',10
	dc.b 'adapted by Delirium',0
	even
fr_data		dc.l 0

*-----------------------------------------------------------------------*
;
;Interrupt für Replay

Int
	movem.l	d0-d7/a0-a6,-(sp)
	move.l	fr_data(pc),a0
	jsr	4(a0)	 			; DudelDiDum
	movem.l	(sp)+,d0-d7/a0-a6
	rts

*-----------------------------------------------------------------------*
;
; Testet auf Fred-Modul

Chk						; Fred ?
	move.l	dtg_ChkData(a5),a0
	moveq	#-1,d0				; Modul nicht erkannt (default)
	cmpi.w	#$4efa,$0(a0)
	bne.s	ChkEnd
	cmpi.w	#$4efa,$4(a0)
	bne.s	ChkEnd
	cmpi.w	#$4efa,$8(a0)
	bne.s	ChkEnd
	cmpi.w	#$4efa,$c(a0)
	bne.s	ChkEnd
	moveq	#0,d0				; Modul erkannt
ChkEnd
	rts

*-----------------------------------------------------------------------*

; Init Player

InitPlay
	moveq	#0,d0
	move.l	dtg_GetListData(a5),a0		; Function
	jsr	(a0)
	move.l	a0,fr_data

	clr.w	dtg_SndNum(a5)			; first Subsong

	move.l	dtg_AudioAlloc(a5),a0		; Function
	jsr	(a0)				; returncode is already set !
	rts

*-----------------------------------------------------------------------*
;
; End Player

EndPlay
	move.l	dtg_AudioFree(a5),a0		; Function
	jsr	(a0)
	rts

*-----------------------------------------------------------------------*

; Init Sound

InitSnd
	move.l	a5,-(sp)
	moveq	#0,d0
	move.w	dtg_SndNum(a5),d0		; SoundNum
	move.l	fr_data(pc),a0
	jsr	(a0)				; Init Sound
	move.l	(sp)+,a5
	rts

*-----------------------------------------------------------------------*
;
; Remove Sound

RemSnd
	move.l	a5,-(sp)
	moveq	#0,d1
	move.l	fr_data(pc),a0
	jsr	8(a0)				; End Sound
	move.l	(sp)+,a5
	rts

*-----------------------------------------------------------------------*
;
; Previous SubSong

PrevSub
	tst.w	dtg_SndNum(a5)
	beq.s	PrevSubEnd
	move.l	dtg_StopInt(a5),a0
	jsr	(a0)
	bsr	RemSnd
	subq.w	#1,dtg_SndNum(a5)		; Vorheriger Sound
	bsr	InitSnd
	move.l	dtg_StartInt(a5),a0
	jsr	(a0)
PrevSubEnd
	rts
	
*-----------------------------------------------------------------------*
;
; Next SubSong

NextSub
	move.l	dtg_StopInt(a5),a0
	jsr	(a0)
	bsr	RemSnd
	addq.w	#1,dtg_SndNum(a5)		; Nächster Sound
	bsr	InitSnd
	move.l	dtg_StartInt(a5),a0
	jsr	(a0)
NextSubEnd
	rts

*-----------------------------------------------------------------------*

