--------------------------------------------------------------------------
     SamplePlay+Source ... Created for UGA PD in 1989 By Brian Postma
--------------------------------------------------------------------------
start:	lea		buffer,a1
	subq.l		#2,d0		;Command Line Empty
	blt		quit		;Yes ??
copy:	move.b		(a0)+,(a1)+	;Copy Commandline
	dbra		d0,copy
	clr.b		(a1)		;End with 0->filename
	lea		dosname,a1	;Library Name
	move.l		4,a6		;Execbase
	jsr		-408(a6)	;Open Library
	move.l		d0,dosbase
	move.l		dosbase,a6
	move.l		#buffer,d1	;FileName
	move.l		#2,d2		;Read
	jsr		-84(a6)		;GetLock
	move.l		d0,handle	;LockHandle
	beq		quit		;File Found ??
	move.l		dosbase,a6
	move.l		#block,d2	;Fileinfo block
	move.l		handle,d1	;LockHandle
	jsr		-102(a6)	;Examine
	beq		quit		;Error ?
	lea		block,a0
	move.l		124(a0),length	;Fetch length from fileinfo
	move.l		dosbase,a6
	move.l		handle,d1
	jsr		-90(a6)		;UnLock
	move.l		4,a6		;Execbase
	move.l		length,d0	;Length of file
	move.l		#2,d1		;ChipMem
	jsr		-198(a6)	;AllocMem
	move.l		d0,memblock	;Pointer to memory
	beq		quit		;Error
	move.l		dosbase,a6
	move.l		#1005,d2	;Mode=OLDFILE
	move.l		#buffer,d1	;FileName
	jsr		-30(a6)		;Open
	move.l		d0,handle	;FileHandle
	beq		quit2		;Error ??
	move.l		handle,d1	;FileHandle
	move.l		length,d3	;FileLength
	move.l		memblock,d2	;Buffer
	jsr		-42(a6)		;Read
	move.l		handle,d1	;FileHandle
	jsr		-36(a6)		;Close
	move.l		memblock,$dff0a0;Pointer to Sample
	move.l		length,d0	;Length
	lsr.l		#1,d0		;Divide by 2->Length in Words
	move.w		d0,$dff0a4	;Length Sample in words
	move.w		#$1ac,$dff0a6	;Replay Rate
	move.w		#64,$dff0a8	;Volume
	move.w		#$8001,$dff096	;Audio DMA for Voice1 on
wait:	btst		#6,$bfe001	;MouseButton Pressed
	bne		wait		;No ??
	move.w		#$1,$dff096	;Audio DMA for Voice1 off
quit2:	move.l		memblock,a1	;Memory Pointer
	move.l		length,d0	;Length in bytes
	move.l		4,a6		;Execbase
	jsr		-210(a6)	;Freemem
quit:	clr.l		d0
	rts
; Some Vars
dosbase:dc.l		0
length:	dc.l		0		;FileLength
handle:	dc.l		0		;FileHandle
memblock:dc.l		0
buffer:	blk.b		128,0		;Command Line Buffer
block:	blk.b		256,0		;FileInfoBlock buffer
dosname:dc.b		"dos.library",0	;Name of doslibrary
--------------------------------------------------------------------------
How does this work:
Load the source from this disk with Seka (type 'r<CR>' and 'SamplePlay',
extension .S is not necessary). Type 'a' followed by 2 times RETURN to
assemble the program and type 'wo<CR>' to save the executable object file
to disk. If you have a version 2.0 or higher from seka, you will also be
asked for 'MODE', just press return here.
To execute program type 'SAMPLEPLAY filename' from the CLI. The program
will now load, load the sample named 'filename' and starts playing it.
Press the left mouse button to quit.

This program demonstrates in fact 3 things:
-How to use commandlines from assembler.
-How to use the dos functions:Lock,UnLock,Examine,Read,Write,Close.
-How to play a digitized sound.

Have fun with it.

For questions, complaints, remarks:

Brian Postma
J.v.Hartenstraat 51
7576VX Oldenzaal (NL)
05410-14763
