;**************************************************************************
; Assembly example to test the dissidents instype.library.  This library
; makes it easy to manipulate the SAMP InstrumentType byte. SAMP is an IFF
; sampled sound format, and the InstrumentType byte tells what kind of
; sampled sound is being dealt with in musical terms (i.e. the sound of a
; snare drum).
;
; Only run this example from the CLI.
;
; blink startup.o test.o small.lib nodebug to TEST

	SMALLOBJ
	ADDSYM
	OBJFILE	"rad:Test.o"

	;from StartUp.o
	XREF	_SysBase,_DOSBase,_stdout

	;from small.lib
	XREF	_LVOWrite,_LVOOpenLibrary,_LVOCloseLibrary

	;for instype.library
_LVOGetInsType		equ	-30
_LVOGetInsString	equ	-36


	XDEF	_main
_main:
	;--- Open the dissidents instype.library
		movea.l	_SysBase,a6
		moveq		#0,d0
		lea		InsName,a1
		jsr		_LVOOpenLibrary(a6)
		move.l	d0,d1
		bne.s		gotIt
		;--- ERROR: Can't open the instype.library
		lea		CantOpen,a0
		bsr.s		WriteStr
		bra.s		outt
	;--- Let the user choose the desired InstrumentType
gotIt	movea.l	d0,a6
		suba.l	a1,a1			;open on WB screen
		jsr		_LVOGetInsType(a6)
		move.l	d0,d1
		bpl.s		gotTT
		;--- ERROR: I'm too lazy to explain
		lea		ErrorLib,a0
		bra.s		doprt
	;--- Now just get a string that represents the InstrumentType and print it
gotTT	jsr		_LVOGetInsString(a6)
		movea.l	d0,a0
doprt	bsr.s		WriteStr
	;---Close the instype.library and exit
		movea.l	a6,a1
		movea.l	_SysBase,a6
		jsr		_LVOCloseLibrary(a6)
outt	moveq		#0,d0
		rts

WriteStr:
		movem.l	d2/d3/a6,-(sp)
		suba.w	#200,sp
		move.l	_stdout,d1
		beq.s		WB
		move.l	sp,a1
enss	move.b	(a0)+,(a1)+
		bne.s		enss
		move.b	#10,-1(a1)
		move.l	a1,d3
		move.l	sp,d2
		sub.l		d2,d3
		movea.l	_DOSBase,a6
		jsr		_LVOWrite(a6)
WB		adda.w	#200,sp
		movem.l	(sp)+,d2/d3/a6
		rts

CantOpen	dc.b	'Can',$27,'t open the dissidents '
InsName	dc.b	'instype.library',0
ErrorLib	dc.b	'Error in obtaining InstrumentType',0

