;
; DUMP v1.1
;
; September 8, 1999
; Anders Eriksson
; ae@atari.org
;
; main.s


ttpfile:	equ	1					;1=take commandline 0=use internal

	section	text

begin:
		include	'init.s'				;init and check for commandlines
		include	'loader.s'				;load module
		include	'modtype.s'				;check moduletype




		move.l	#songname_text,textadr			;Songname:
		bsr.w	print					;

		move.l	filebuffer,textadr			;print songname
		bsr.w	print					;

		move.l	#newrow_text,textadr			;new row
		bsr.w	print					;
	
		move.l	#filename_text,textadr			;Filename:
		bsr.w	print					;
	
		move.l	filename,textadr			;print filename
		bsr.w	print					;

		move.l	#newrow_text,textadr			;new row
		bsr.w	print					;

		move.l	#channels_text,textadr			;Number of channels: #
		bsr.w	print					;
	
		tst.w	surround				;Surround: Yes/No
		beq.s	.nosurr					;
		move.w	#"On",surr_text+10			;
		bra.s	.surrdone				;
.nosurr:	move.l	#"Off ",surr_text+10			;
.surrdone:	move.l	#surr_text,textadr			;
		bsr.w	print					;

		tst.w	interpolation				;Interpol: Yes/No
		beq.s	.nointer				;
		move.w	#"On",inter_text+10			;
		bra.s	.interdone				;
.nointer:	move.l	#"Off ",inter_text+10			;
.interdone:	move.l	#inter_text,textadr			;
		bsr.w	print					;




		move.l	#dspmod_begin,super_rout		;start module
		bsr.w	supexec					;

		bsr.w	waitkey					;playing

		move.l	#dspmod_end,super_rout			;stop module
		bsr.w	supexec					;



		include	'exit.s'				;exit
		include	'dspmod.s'				;moduleplayer routines
		include	'loader.s'				;fileloader routines



; subroutines


supexec:	move.l	super_rout,-(sp)			;supexec()
		move.w	#$26,-(sp)				;
		trap	#14					;
		addq.l	#6,sp					;
		rts						;


waitkey:	move.w	#7,-(sp)				;wait for keypress
		trap	#1					;
		addq.l	#2,sp					;
		rts						;


print:		tst.w	quiet
		bne.s	.no
		move.l	textadr,-(sp)				;
		move.w	#9,-(sp)				;print tos text
		trap	#1					;input: move.l #mytextadr,textadr
		addq.l	#6,sp					;
.no:		rts



		section	data


	ifeq	ttpfile
fixedname:	dc.b	'd:\temp\mod.mod',0			;internal filename
		even
	endc



title_text:	dc.b	'DUMP v1.1',13,10			;title
		dc.b	'Press any key to stop',13,10,13,10,0	;
		even

songname_text:	dc.b	'Songname: ',0				;Songname:
		even						;

filename_text:	dc.b	'Filename: ',0				;Filename:
		even						;

inter_text:	dc.b	'Interpol:     ',13,10,0		;Interpol:
		even

surr_text:	dc.b	'Surround:     ',13,10,0		;Surround:
		even

newrow_text:	dc.b	13,10,0					;new row
		even

channels_text:	dc.b	'Channels:  ',13,10,0
		even





		section	bss

;commandline parameters
quiet:		ds.w	1					;0=print 1=silent
surround:	ds.w	1
interpolation:	ds.w	1


super_rout:	ds.l	1					;supexec routine
textadr:	ds.l	1					;text to print

save_dta:	ds.l	1					;old dta
dta:		ds.l	11					;new dta

dma_pointer:	ds.l	1					;pointer to 8000 bytes stram buffer

filelength:	ds.l	1					;filelength
filebuffer:	ds.l	1					;filebuffer address
filename:	ds.l	1					;filename address
filenumber:	ds.w	1					;filenumber
