
CUSTOM	EQU	$DFF000
SERDATR	EQU	$018
SERPER	EQU	$032
INTENA	EQU	$09A
INTREQ	EQU	$09C


* it uses the DOS and EXEC libraries
	incdir	"df1:include/"		where to look

	include	exec/exec_lib.i		I want to call EXEC
	include exec/memory.i
	include	libraries/dos_lib.i	and DOS
	include	libraries/dos.i

* start by opening the DOS library
start	lea	dosname,a1
	moveq	#0,d0			any version
	CALLEXEC OpenLibrary
	tst.l	d0
	beq	quit_fast		quit if cant
	move.l	d0,_DOSBase		save pointer

	MOVE.l	#100000,D0		100,000 bytes 100K
	MOVE.l	#MEMF_CHIP,D1		bottom 512K
	CALLEXEC AllocMem
	tst.l	d0
	beq	quit_fast
	lea	MEMORY_START,a0
	move.l	d0,(a0)

	CALLDOS	Output			Output a string
	move.l	d0,d1			pass handle
	lea	OUT_HANDLE,a0
	move.l	d0,(a0)
	lea	string,a0
	move.l	a0,d2			pass start of data
	move.l	#string_len,d3
	CALLDOS Write

	lea	file1,a0
	move.l	#len1,d0
	bsr	get
	lea	file2,a0
	move.l	#len2,d0
	bsr	get

	BRA	SKIP			JUST TWO FILES	

	lea	file3,a0
	move.l	#len3,d0
	bsr	get	
	lea	file4,a0
	move.l	#len4,d0
	bsr	get
	lea	file5,a0
	move.l	#len5,d0
	bsr	get
	lea	file6,a0
	move.l	#len6,d0
	bsr	get
	lea	file7,a0
	move.l	#len7,d0
	bsr	get
	lea	file8,a0
	move.l	#len8,d0
	bsr	get
SKIP	BRA	QUIT

get	lea	length,a1
	move.l	d0,(a1)
	lea	filel,a1
	move.l	a0,(a1)
	lea	OUT_HANDLE,a0
	move.l	(a0),d1
	lea	filel,a0
	move.l	(a0),d2			pass start of data
	move.l	#16,d3
	CALLDOS Write

	LEA	CUSTOM,A0
	MOVE	#$4000,INTENA(A0)	DISABLE ALL INTERRUPTS
	MOVE	#372,SERPER(A0)		9600 BAUD, 8 BIT (372-9600)
	lea	length,a6
	MOVE.L	(a6),D7			FILE LENGTH
	SUBQ.L	#1,D7			SUITABLE FOR DBRA NOW
	LEA	MEMORY_START,A1
	MOVE.L	(A1),A1			A1 POINTS TO START
	MOVE	#14,D6			BTST NUMBER
	MOVE	SERDATR(A0),D0		TEST FOR REDUNDANT STARTUP DATA
	BTST	D6,D0
	BEQ	FETCH			NO DATA YET
	MOVE	#$0800,INTREQ(A0)	RESET RBF FLAG SO IT SAYS
FETCH	MOVE	SERDATR(A0),D0
	BTST	D6,D0
	BEQ	FETCH			NO DATA YET
	CMPI.B	#$0D,D0
	BNE	FETCH1
	MOVE.B	D0,(A1)+
FETCH1	MOVE	#$0800,INTREQ(A0)	RESET RBF FLAG SO IT SAYS
	DBRA	D7,FETCH
	MOVE	#$C000,INTENA(A0)	PUT INTERRUPTS BACK ON

* open a file
DSAVE	LEA	filel,A0
	move.l	(a0),a0
	MOVE.L	A0,D1
	MOVE.L	#MODE_NEWFILE,D2
	CALLDOS	Open
	tst.l	d0
	beq	quit_fast
	LEA	FILE_HANDLE,A0
	MOVE.L	D0,(A0)			SAVE FILE HANDLE
* SAVE SOME DATA - RANDOMLY SELECTED
	LEA 	FILE_HANDLE,A0
	MOVE.L	(A0),D1
	LEA	MEMORY_START,a0
	MOVE.L	(a0),D2		
	ADDQ.l	#1,D2			bodge, hope it works !	
	lea	length,a6
	MOVE.L	(A6),D3			LENGTH OF FILE
	CALLDOS	Write
	cmpi.l	#-1,d0
	bne	DSAVEOK
	lea	OUT_HANDLE,a0
	move.l	(a0),d1
	lea	disk_err,a0
	move.l	a0,d2
	move.l	#disk_len,d3
	CALLDOS	Write
	bra	quit_fast
* CLOSE THE FILE
DSAVEOK	LEA	FILE_HANDLE,A0
	MOVE.L	(A0),D1
	CALLDOS	Close
	RTS

* finished so close DOS library
QUIT	move.l	_DOSBase,a1
	CALLEXEC CloseLibrary

quit_fast
	rts				amd finish

dosname	DOSNAME				defines dos name

_DOSBase	DC.L	0		space for pointer
FILE_HANDLE	DC.L	0
OUT_HANDLE	DC.L	0
MEMORY_START	DC.L	0
string		DC.B	"TIERTEX TRANSFER PROGRAM",10,13
		DC.B	"(C) 1987 TIERTEX LIMITED",10,13,10,13,10,13
string_len	EQU	*-string
disk_err	DC.B	"*** DISK ERROR ****",10,13
disk_len	EQU	*-disk_err
file1	dc.b	"df1:moving.s",0,0,10,13
file2	dc.b	"df1:footing.s",0,0,0,0,10,13
file3	dc.b	"df1:footing.s",0,0,10,13
file4	dc.b	"df1:mask.s",0,0,0,0,10,13
file5	dc.b	"df1:moving.s",0,0,10,13
file6	dc.b	"df1:screen.s",0,0,10,13
file7	dc.b	"df1:sound.s",0,0,0,10,13
file8	dc.b	"df1:game.s",0,0,0,0,10,13
len1	equ	24330
len2	equ	13333
len3	equ	12694
len4	equ	8305
len5	equ	23400
len6	equ	12237
len7	equ	3773
len8	equ	17373
	even
length	dc.l	0
filel	dc.l	0



