; **************************************************************************
; *                                                                        *
; *                           EXAMPLE.NPLAYLIB                             *
; *             an example source for writing NPlay libraries              *
; *             modelled after the ProTracker.NPlayLib source              *
; *                                                                        *
; *                             by Necrologic                              *
; *                                                                        *
; **************************************************************************

init	lea	req(pc),a0	;return request routine address
	moveq	#42,d0		;return OK signal
	rts

req	cmp.l	#42,d1		;test D1 to see what command is requested
	beq.w	st		;call NP_PLAY
	cmp.l	#43,d1
	beq.w	stp		;call NP_STOP
	cmp.l	#44,d1
	beq.B	ver		;call NP_VERSION
	cmp.l	#45,d1
	beq.B	title		;call NP_TITLE
	cmp.l	#46,d1
	beq.w	m_init		;call NP_INIT
	cmp.l	#47,d1
	beq.B	id		;call NP_ID
error	moveq	#-1,d0		;unsupported command requested!
	rts

ver	lea	vertxt(pc),a0	;return pointer to version info
	moveq	#0,d0		;D0=0 so all's OK
	rts
vertxt	dc.b	"ProTracker.nplaylib (v2.1b) v1.0 (21 Aug 1992)",0
	even

title	lea	titletx(pc),a0	;return pointer to nplaylib title
	moveq	#0,d0		;(used in the main requester)
	rts
titletx	dc.b	"Now playing ProTracker module",10
	dc.b	"(using protracker.nplaylib)",0
	even

id	lea	idtxt(pc),a0	;return pointer to ID string
	moveq	#0,d0		;(used by ID file editors)
	rts
idtxt	dc.w	1,1080		;ID no, keyword offset
	dc.b	"M.K.nplay:protracker.nplaylib",0 ;keyword, libname
	even			;must be word-aligned
	dc.w	-1		;end of string marker

m_init	moveq	#0,d0		;protracker needs no initialization,
	rts			;so do nothing

st	movem.l	d1-d7/a1-a6,-(sp)	;must preserve registers!
	move.l	a0,-(sp)
	bsr.s	SetCIAInt
	move.l	(sp)+,a0
	bsr.b	mt_init
	st	mt_Enable
	movem.l	(sp)+,d1-d7/a1-a6
	moveq	#0,d0
	rts

stp	movem.l	d1-d7/a0-a6,-(sp)
	bsr.b	mt_end
	bsr.b	ResetCIAInt
	movem.l	(sp)+,d1-d7/a0-a6
	moveq	#0,d0
	rts

*** Insert ProTracker CIA playroutine here

