**
** ©1991 Cords Maker V1.0
**
** Coded by Raistlin of Dragon Masters
**
** Please send bug reports to:-
**				Leon Skeldon,
**				55 Chester Road,
**				Poynton,
**				Cheshire.
**				Sk12 1Qu
**
** See the doc file for more information.
**

	opt c-

	include	source:include/hardware.i		; Harware equates

	section	Scrolling,code		; Use public memory

	lea	$dff000,a5		; Address of DMA in a5

	move.l	4,a6			; A6=Exec base
	lea	gfxname,a1		; address of lib name in a1
	moveq.l	#0,d0			; Any version
	jsr	-552(a6)		; Open the lib
	move.l	d0,gfxbase		; Save base address of gfx lib
	beq	error2			; Quit if error found

	move.l	#204800,d0		; allocate 200K
	move.l	#0,d1			; Any
	jsr	-198(a6)		; AllocMem
	move.l	d0,Buffer		; Save pointer to memory
	beq	error1			; Quit if error
	move.l	d0,BufferP		; Save 2nd pointer to memory

	jsr	-132(a6)		; Forbid

	
****************************************************************************
;		Load the bitplane pointers
****************************************************************************
	move.l	#Screen,d0		; D0=Address of the screen

	move.w	d0,bpl1+2		; Load the bpl pointers
	swap	d0
	move.w	d0,bph1+2
	swap	d0
	add.l	#60*256,d0
	move.w	d0,bpl2+2
	swap	d0
	move.w	d0,bph2+2
	swap	d0
	add.l	#60*256,d0
	move.w	d0,bpl3+2
	swap	d0
	move.w	d0,bph3+2
	swap	d0
	add.l	#60*256,d0
	move.w	d0,bpl4+2
	swap	d0
	move.w	d0,bph4+2
	swap	d0
	add.l	#60*256,d0
	move.w	d0,bpl5+2
	swap	d0
	move.w	d0,bph5+2


****************************************************************************
;		Let The Coder Know Who Wrote This Utility!!!!!
****************************************************************************
RaistPrint
	move.l	Buffer,a0		; A0=Pointer to buffer
	move.b	#';',(a0)+
	move.b	#' ',(a0)+
	move.b	#'R',(a0)+
	move.b	#'a',(a0)+
	move.b	#'i',(a0)+
	move.b	#'s',(a0)+
	move.b	#'t',(a0)+
	move.b	#'l',(a0)+
	move.b	#'i',(a0)+
	move.b	#'n',(a0)+
	move.b	#' ',(a0)+
	move.b	#$27,(a0)+
	move.b	#'9',(a0)+
	move.b	#'1',(a0)+
	move.b	#$0a,(a0)+
	move.l	a0,BufferP		; Save the pointer to buffer




****************************************************************************
;	       Blit Some Bobs Ready To Move Later
****************************************************************************
; First Blit Dragon Logo 1
; Get The Background gfx
Dragon1a
	move.l	#0,d0			; Clear d0
	move.l	#0,d1			; Clear d1
	move.w	Xcord,d0		; D0=X offset
	move.w	Ycord,d1		; D1=Y offset
	mulu	#60,d1			; Convert Y offset into correct format
	divu	#16,d0			; Convert X offset into shoft & words
	lsl.w	#1,d0			; Turn words to bytes
	add.w	d0,d1			; Add the X offset to the Y offset
	swap	d0			; Get shift value
	lsl.w	#4,d0			; 8+4=12
	lsl.w	#8,d0			; Put shift onto 4 MSB
	move.w	d1,LastXY1		; Save the XY offset
	move.l	#4,d3			; D3=Number of bitplanes-1

	lea	Screen,a1		; A1=Address of screen
	add.l	d1,a1			; Add the offset to bob destination
	lea	Back1,a4		; A4=Address of store background data
.Loopy1
	move.w	#42,Amodulo		; 60-18
	move.w	#$0,Dmodulo		; No D modulo
	move.w	#%100111110000,d5	; D5=Bltcon0
	move.w	#(31*64)+9,d7		; D7=Bltsize
	bsr	AD_Blit			; Do the blit
	add.l	#256*60,a1		; Get to next screen plane
	add.l	#31*18,a4		; Point to next dest address
	dbra	d3,.Loopy1		; Keep blitting

; Blit The Bob
	lea	Logo1,a1		; A1=Address of bob to blit
	lea	Mask1,a2		; A2=Address of mask
	lea	Back1,a3		; A3=Address of saved background data
	lea	Screen,a4		; A4=Address of screen
	add.l	d1,a4			; Add the bob offset
	move.l	#4,d3			; D3=Number of bitplanes-1
.Loopy2
	move.w	#-2,AModulo		; Actual bob size-Bltsize
	move.w	#42,Dmodulo		; 60-18
	move.w	#%111111110010,d5	; D5=ABCD blit
	or.w	d0,d5			; Add the shift value
	move.w	#$0,d6			; D6=Bltcon0 value (cleared)
	or.w	d0,d6			; Add the shift value
	move.w	#(31*64)+9,d7		; D7=Bltsize
	bsr	ABCD_Blit		; Do the blit
	add.l	#31*16,a1		; Get to next bob plane
	add.l	#31*18,a3		; Get to next saved data plane
	add.l	#256*60,a4		; Get to next screen plane
	dbra	d3,.Loopy2		; Keep blitting





****************************************************************************
; 		Set-up the DMA
****************************************************************************
DMA
.Wait1	btst	#0,vposr(a5)
	bne	.Wait1
.Wait2	cmpi.b	#55,vhposr(a5)
	bne	.Wait2
	move.w	#$20,dmacon(a5)		; Disable sprites
	move.l	#Copperlist,cop1lch(a5)	; Load my copper list
	move.w	#$0,copjmp1(a5)		; Run my copper list




****************************************************************************
;		The Main Branching Routine
****************************************************************************
MouseWait
	cmpi.b	#255,vhposr(a5)		; Wait vbl
	bne	MouseWait

	bsr	CheckRMB		; Test the RMB
	bsr	TestJoystick		; Test the joystick state
	bsr	TestKeys		; Test for key presses
	bsr	MoveBob			; Move the bob to next co-ordinate
	bsr	DisplayCords		; Display the co-ordinates

	btst	#6,$bfe001		; Test LMB
	bne	MouseWait



****************************************************************************
;		Clean-up the system ready to leave
****************************************************************************
Clean_Up
	move.w	#$8e30,dmacon(a5)	; Enable sprites
	move.l	gfxbase,a1
	move.l	38(a1),cop1lch(a5)	; System copper list
	move.w	#$0,copjmp1(a5)		; Run the system copper
	move.l	4,a6			; Exec base
	jsr	-138(a6)		; Permit

; Work out the length of the file name to save
	move.l	Buffer,d0		; D0=Start of cord table
	move.l	BufferP,d2		; D2=End of cord table
	sub.l	d0,d2			; Work out length of file
	move.l	d2,d7			; Put file length in safe register
		
; Open A File To Save The Cords To
; I don't check to make sure the lib exists (lets just hope!!)
	lea	dosname,a1		
	moveq.l	#0,d0			; Any version
	jsr	-552(a6)		; Open library
	move.l	d0,dosbase		; Save base address
	move.l	d0,a6			; A6=dos base
	move.l	#FileName,d1		; D1=Pointer to file name
	move.l	#1006,d2		; File access mode (new)
	jsr	-30(a6)			; Open the destination file
	move.l	d0,filehd		; Save the file handle
	
	move.l	d0,d1			; D1=Handle
	move.l	Buffer,d2		; D2=Buffer address
	move.l	d7,d3			; D3=Length of file
	jsr	-48(a6)			; Write to the file

	move.l	filehd,d1		; D1=File handle
	jsr	-36(a6)			; Close the file

; Now free the memory
	move.l	4,a6			; A6=Exec base
	move.l	Buffer,a1		; A1=Pointer to memory to free
	move.l	#204800,d0		; Free 200K
	jsr	-210(a6)		; Free memory
error2	move.l	4,a6			; A6=Exec base
	move.l	gfxbase,a1		; address of gfx lib in a1
	jsr	-408(a6)		; Close the lib
	jsr	-138(a6)		; Permit	
error1	rts				; End the program







****************************************************************************
;		Test The State Of The Joystick
****************************************************************************
TestJoystick
	move.w	$dff00c,d0	; Move JOY1DAT into D0
	btst	#1,d0		; Test bit no. 1
	bne	right		; Set? If so, joystick right
	btst	#9,d0		; Test bit no. 9
	bne	left		; Set? If so, joystick left

	move.w	d0,d1		; copy D0 to D1
	lsr.w	#1,d1		; Move Y1 & X1 to pos of Y0 & X0
	eor.w	d0,d1		; Exclusive OR: Y1 EOR X1 & Y0 EOR X0
	btst	#0,d1		; Test result of X1 EOR X0
	bne	back		; Equal 1? If so, joystick backward
	btst	#8,d1		; Test result of Y1 EOR Y0
	bne	forward		; Equal 1? If so, joystick forward
	bra	Fire		; test for fire if the joystick wasn't moved


right	
	move.w	Speed,d0		; D0=Speed value
	add.w	d0,Xcord		; Increment X offset
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord
	rts
left	
	move.w	Speed,d0		; D0=Speed value
	sub.w	d0,Xcord		; Decrement X offset
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord

	rts
back	
	move.w	Speed,d0		; D0=Speed value
	add.w	d0,Ycord		; Increment Y offset 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord

	rts
forward	
	move.w	Speed,d0		; D0=Speed value
	sub.w	d0,Ycord		; Decrement Y offset 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord

	rts

Fire
	btst	#7,$bfe001		; Test Fire button
	beq	SetFire

	and.b	#1,FireF		; Has fire button been released?
	beq	.Nope
	move.b	#0,FireF		; Reset the fire flag
	bra	WorkOutCords		; And work out the co-ordinates
.Nope	rts
SetFire
	move.b	#1,FireF		; Set the fire flag
	rts


****************************************************************************
;  The Routine Checks For Key Presses.  Note That I Check For A Release
;  Code Rather Than A Press Code.  This Stops Me Getting Multiple Key
;  Presses Because The User Can't Release The Key In 1/50th Of A Second!
****************************************************************************
TestKeys
; This Small Routine Converts The Key Press
init	move.l	#0,d0			; Clear d0
	move.b	$bfec01,d0		; D0=Key value
	not	d0			; Invert it
	ror.b	#1,d0			; And divide it by 1

; First lets check for a change in the plotting mode
; Remember that I'm checking for a key release so I add $80 to
; Thee values shown in the Hardware Reference Manual
F1	cmpi.b	#$d0,d0			; Check for F1
	bne	F2			; If F1 aint pressed try F2
	move.b	#1,Mode			; Set mode 1 
	move.w	#$000,ModeCol+2		; Mode colour=black
	rts				; Return
F2	cmpi.b	#$d1,d0			; Check for F2
	bne	Cursors			; Check for a cursor key press
	move.b	#2,Mode			; Set mode 2
	move.w	#$070,ModeCol+2		; Mode colour=dark green
	rts				; Return

; This section tests for a cursor key press
; (Used to detect fine movement)
Cursors
.UP	cmpi.b	#$cc,d0			; Was 'UP' pressed?
	bne	.Left			; If not try left
	sub.w	#1,YCord		; If up pressed, decrement Y cord
	move.b	#$0,$bfec01		; Clear the key buffer. 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord
	rts				; & return	
.Left	cmpi.b	#$ce,d0			; Was 'LEFT' pressed?
	bne	.Down			; If not try down
	add.w	#1,XCord		; If left pressed, inrement X cord
	move.b	#$0,$bfec01		; Clear the key buffer. 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord
	rts				; & Return
.Down	cmpi.b	#$cd,d0			; Was 'DOWN' pressed?
	bne	.Right			; If not try right
	add.w	#1,YCord		; If down pressed, increment Y cord
	move.b	#$0,$bfec01		; Clear the key buffer. 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord
	rts				; And return
.Right	cmpi.b	#$cf,d0			; Was 'RIGHT' pressed?
	bne	.Speed			; Try a speed value
	sub.w	#1,XCord		; If right pressed, decrement X cord
	move.b	#$0,$bfec01		; Clear the key buffer. 
	cmpi.b	#2,Mode			; Are we in mode 2?
	beq	WorkOutCords		; If so plot the cord
	rts				; And return 
.Speed
	cmpi.b	#1,d0			; Is it a 1?
	blt	Space			; Try space
	cmpi.b	#9,d0			; Is it a 9?
	bgt	Space			; Try Space
	and.l	#$0000000f,d0		; Mask out unwanted bits
	move.b	d0,Speed+1		; Must be 1-9 to enter 
					; new speed value
Space	cmpi.b	#$40,d0			; Space?
	bne	NoKey
	bra	WorkOutCords
NoKey	rts				; No key was pressed


****************************************************************************
;   This Is The Routine That Actually Works Out The Co-Ordinates & Turns
;   Them Into ASCII Ready To Save To The Cords File
****************************************************************************
WorkOutCords
	move.l	BufferP,a0		; A0=Buffer pointer
	move.b	#$09,(a0)+		; Tabulation
	move.b	#'d',(A0)+		; Set-up 
	move.b	#'c',(a0)+		; The DC.W
	move.b	#'.',(a0)+		
	move.b	#'w',(a0)+
	move.b	#$09,(a0)+		; Tabulation
	move.b	#'$',(a0)+		; $ sign
**********************
* Convert The X Cord *
**********************
	move.w	XCord,d0
	move.w	d0,d1			; d0=copy of cords
	move.l	#3,d5			; d5=Number of nibbles in word-1
next1		
	move.w	d0,d1			; D1=Copy of cords
	lsr.w	#4,d1			; 4+8=12
	lsr.w	#8,d1			; Put number to change in 4 LSB
	cmpi.b	#9,d1			; Is it a 0-9?
	bgt	A_F1			; If its A_F branch to the A_F routine
	add.b	#$30,d1			; Else add $30 to get ascii code
	move.b	d1,(a0)+		; enter assci code into Buffer
	lsl.w	#4,d0			; get next number to convert
	dbra	d5,next1		; Convert next number
	bra	DoYCord
A_F1
	add.b	#$37,d1			; Else add $37 to get ascii code
	move.b	d1,(a0)+		; enter assci code into Buffer
	lsl.w	#4,d0			; get next number to convert
	dbra	d5,next1		; Convert next number


**********************
* Convert The Y Cord *
**********************
DoYCord
	move.w	YCord,d0		
	move.b	#',',(a0)+		; Insert a comma
	move.b	#'$',(a0)+		; Insert a $ sign (Hex notation)
	move.w	d0,d1			; d0=copy of cords
	move.l	#3,d5			; d5=Number of nibbles in word-1
next2	
	move.w	d0,d1			; D1=Copy of cords
	lsr.w	#4,d1			; 4+8=12
	lsr.w	#8,d1			; Put number to change in 4 LSB
	cmpi.b	#9,d1			; Is it a 0-9?
	bgt	A_F2			; If its A_F branch to the A_F routine
	add.b	#$30,d1			; Else add $30 to get ascii code
	move.b	d1,(a0)+		; enter assci code into Buffer
	lsl.w	#4,d0			; get next number to convert
	dbra	d5,next2		; Convert next number
	bra	Done_Cords
A_F2
	add.b	#$37,d1			; Else add $37 to get ascii code
	move.b	d1,(a0)+		; enter assci code into Buffer
	lsl.w	#4,d0			; get next number to convert
	dbra	d5,next2		; Convert next number

Done_Cords
	move.b	#$0a,(a0)+		; Insert a character return
	move.l	a0,BufferP		; Save the buffer pointer
	rts



****************************************************************************
;   This Routine Checks The RMB & Inserts A Control Code If Pressed
****************************************************************************
; If the use is uing control codes in his/her cords tables (ie a pause code)
; than when the bob is where he/she wants it he/she (this is getting boring!)
; presses RMB & a 'CONTROL CODE' is entered into the cords table at that
; position.  Then all you have to do is use:-  FIND...CONTROL CODE in Genam
; & when it gets to this position you enter the pause code
CheckRMB
	btst	#$a,$dff016		; Test RMB
	bne	Release?		; See if its been released
	move.b	#1,RMBF			; Set the RMB flag
	rts				; & return
Release?
	and.b	#1,RMBF			; Was RMBF set?
	cmpi.b	#0,RMBF			; If not exit
	beq	NoRMB
	move.b	#0,RMBF			; Else reset RMB flag
	move.l	BufferP,a0		; A0=Pointer to Buffer
	move.b	#'C',(a0)+		; Insert the word
	move.b	#'O',(a0)+		; CONTROL CODE
	move.b	#'N',(a0)+
	move.b	#'T',(a0)+
	move.b	#'R',(a0)+
	move.b	#'O',(a0)+
	move.b	#'L',(a0)+	
	move.b	#' ',(a0)+
	move.b	#'C',(a0)+
	move.b	#'O',(a0)+
	move.b	#'D',(a0)+
	move.b	#'E',(a0)+
	move.b	#$0a,(a0)+		; Insert character return
	move.l	a0,BufferP		; Save the buffer pointer
NoRMB	rts				; And return


****************************************************************************
;     This Routine Displays The Co-Ordinates In The Bottom Left Corner
****************************************************************************
*Note: Don't get confused between the two different X & Y cords in this 
*section.  Remember that I need X & Y offsets to position the actual
*co-ordinates value in the bottom left corner!! (understand?)
; First of all display the X co-ordinate
DisplayCords
	move.w	XCord,d0		; D0=X cord value
	move.w	#0,d2			; D2=Offset

; Work out the number to display
	move.l	#0,d1			; Clear d1
	move.l	#3,d3			; D3=Number of cords to blit
.Loopy
	move.w	d0,d1			; D1=X cord value
	lsr.w	#4,d1			; 4+8=12
	lsr.w	#8,d1			; Get number to display in 4 LSB
	lsl.w	#1,d1			; Multipply by 2 to get pos in font

	lsl.w	#4,d0			; D0=Next number to blit
	
	lea	Font,a1			; A1=Address of font
	add.w	d1,a1			; Add the font offset
	lea	Screen+14400,a4		; A4=Address of screen+Y offset
	add.w	d2,a4			; Add the X offset

	move.w	#30,Amodulo		; 32-2
	move.w	#58,DModulo		; 60-2
	move.w	#%100111110000,d5	; A-D blit
	move.w	#(12*64)+1,d7		; 12 * 16
	bsr	AD_Blit			; Blit the co-ordinate

	add.w	#2,d2			; Get to next X cord to blit to
	dbra	d3,.Loopy		; Blit all 3 co-ordinates

**********************************
* Next display the Y co-ordinate *
**********************************
	move.w	YCord,d0		; D0=Y cord value
	move.w	#12,d2			; D2=Offset (12 bytes along)

; Work out the number to display
	move.l	#0,d1			; Clear d1
	move.l	#3,d3			; D3=Number of cords to blit-1
.Loopy2
	move.w	d0,d1			; D1=Y cord value
	lsr.w	#4,d1			; 4+8=12
	lsr.w	#8,d1			; Get number to display in 4 LSB
	lsl.w	#1,d1			; Multipply by 2 to get pos in font

	lsl.w	#4,d0			; D0=Next number to blit
	
	lea	Font,a1			; A1=Address of font
	add.w	d1,a1			; Add the font offset
	lea	Screen+14400,a4		; A4=Address of screen+Y offset
	add.w	d2,a4			; Add the X offset

	move.w	#30,Amodulo		; 32-2
	move.w	#58,DModulo		; 60-2
	move.w	#%100111110000,d5	; A-D blit
	move.w	#(12*64)+1,d7		; 12 * 16
	bsr	AD_Blit			; Blit the co-ordinate

	add.w	#2,d2			; Get to next X cord to blit to
	dbra	d3,.Loopy2		; Blit all 3 co-ordinates
	rts


****************************************************************************
* 			Actual Bob Movement Routine 			   *
****************************************************************************
; Replace the background
MoveBob
	lea	Back1,a1		; A1=Address of saved background data
	lea	Screen,a4		; A4=Address of screen
	add.w	LastXY1,a4		; Add the bob offset
	move.l	#4,d0			; D0=Number of bitplanes-1
.Loopy1
	move.w	#0,AModulo		; No A modlo
	move.w	#42,Dmodulo		; 60-18
	move.w	#%100111110000,d5	; Straight A-D blit
	move.w	#(31*64)+9,d7		; Size=31*18
	bsr	AD_Blit			; Restore background
	add.l	#31*18,a1		; Get to next background plane
	add.l	#256*60,a4		; Get to next screen plane
	dbra	d0,.Loopy1

	
	move.l	#0,d1			; Clear d1
	move.l	#0,d2			; Clear d2
	move.w	XCord,d1		; D1=X offset
	move.w	YCord,d2		; D2=Y offset
	mulu	#60,d2			; Turn Y offset into correct format
	divu	#16,d1			; Turn X offset into words & bytes
	lsl.w	#1,d1			; Turn words to bytes
	add.w	d1,d2			; Add X offset to Y offset
	swap	d1			; Get shift value
	lsl.w	#4,d1			; 4+8=12
	lsl.w	#8,d1			; Put shift value into 4 MSB
	
	move.w	d2,LastXY1		; Save the offset
	lea	Screen,a1		; A1=Address of screen
	add.w	d2,a1			; Add the bob offset
	lea	Back1,a4		; A4=Address to save background data
	move.l	#4,d0			; D0=Number of bitplanes-1
.Loopy2
	move.w	#42,Amodulo		; 60-18
	move.w	#0,DModulo		; No D modulo
	move.w	#%100111110000,d5	; Straight A-D blit
	move.w	#(31*64)+9,d7		; Size=31*18
	bsr	AD_Blit			; Save the background
	add.l	#256*60,a1		; Get to next screen plane
	add.l	#31*18,a4		; Next mem locationg to save data
	dbra	d0,.Loopy2	

; Finally blit the bob & return to main routine
; Blit The Bob
	lea	Logo1,a1		; A1=Address of bob to blit
	lea	Mask1,a2		; A2=Address of mask
	lea	Back1,a3		; A3=Address of saved background data
	lea	Screen,a4		; A4=Address of screen
	add.l	d2,a4			; Add the bob offset
	move.l	#4,d3			; D3=Number of bitplanes-1
.Loopy3
	move.w	#-2,AModulo		; Actual bob size-Bltsize
	move.w	#42,Dmodulo		; 60-18
	move.w	#%111111110010,d5	; D5=ABCD blit
	or.w	d1,d5			; Add the shift value
	move.w	#$0,d6			; D6=Bltcon0 value (cleared)
	or.w	d1,d6			; Add the shift value
	move.w	#(31*64)+9,d7		; D7=Bltsize
	bsr	ABCD_Blit		; Do the blit
	add.l	#31*16,a1		; Get to next bob plane
	add.l	#31*18,a3		; Get to next saved data plane
	add.l	#256*60,a4		; Get to next screen plane
	dbra	d3,.Loopy3		; Keep blitting
	rts



****************************************************************************
;	This Section Contains General Blitter Operations 
****************************************************************************
*****************************
* First An A-D Blit Routine *
*****************************
AD_Blit
	bsr	BlitterBusy		; Check the blitters status
	move.l	a1,bltapth(a5)		; A3=Address of Source A
	move.l	a4,bltdpth(a5)		; A4=Address of Destination
	move.w	AModulo,bltamod(a5)	; AModulo=value of A modulo
	move.w	DModulo,bltdmod(a5)	; DModulo=value of D modulo
	move.w	#$ffff,bltafwm(a5)	; No mask
	move.w	#$ffff,bltalwm(a5)	; No mask
	move.w	#$0,bltcon1(a5)		; Clear
	move.w	d5,bltcon0(a5)		; D5=Value of bltcon0
	move.w	d7,bltsize(a5)		; D7=Value of bltsize
	rts	
	
**********************************************
* Now An ABCD Blit Routine For The Cooki-Cut *
**********************************************
ABCD_Blit
	bsr	BlitterBusy		; Check the blitters status
	move.l	a1,bltapth(a5)		; A1=Address of source A
	move.l	a2,bltbpth(a5)		; A2=Address of source B
	move.l	a3,bltcpth(a5)		; A3=Address of source C
	move.l	a4,bltdpth(a5)		; A4=Address of destination
	move.w	Amodulo,bltamod(a5)	; AModulo=Modulo to use
	move.w	#$0,bltbmod(a5)		; No B modulo
	move.w	#$0,bltcmod(a5)		; No C modulo
	move.w	DModulo,bltdmod(a5)	; DModulo=Modulo to use
	move.w	#$ffff,bltafwm(a5)	; No mask
	move.w	#$0000,bltalwm(a5)	; Full mask
	move.w	d5,bltcon0(a5)		; D5=Bltcon0
	move.w	d6,bltcon1(a5)		; D6=Bltcon1
	move.w	d7,bltsize(a5)		; D7=Bltsize
	rts

	
***********
BlitterBusy 
***********
	btst	#14,dmaconr(a5)		; Whats the blitter upto?
	bne	BlitterBusy		; Slave labour!
	rts				; Slobbing around




****************************************************************************
;			THE COPPER LIST
****************************************************************************
	section	copperlist,code_c	; Chip memory
Copperlist	
	dc.w	diwstrt,$2c81		; Window start
	dc.w	diwstop,$2cc1		; Window stop
	dc.w	ddfstrt,$38		; Data fetch start
	dc.w	ddfstop,$d0		; Data fetch stop
	dc.w	bplcon0,%0101001000000000
	dc.w	bplcon1,$0
	dc.w	bpl1mod,20,bpl2mod,20

; The Colours		        
; Color $180 changes acording to the mode we are in.
;      Black=Mode 1
; Dark Green=Mode 2
ModeCol	dc.w	$180,$000,$182,$fff,$184,$000,$186,$044
	dc.w	$188,$066,$18a,$fff,$18c,$a40,$18e,$189
	dc.w	$190,$d63,$192,$98a,$194,$f96,$196,$bac
	dc.w	$198,$7cf,$19a,$fb9,$19c,$ace,$19e,$dcf
	dc.w	$1a0,$000,$1a2,$fff,$1a4,$e00,$1a6,$e30
	dc.w	$1a8,$e60,$1aa,$fff,$1ac,$fc0,$1ae,$ff0
	dc.w	$1b0,$050,$1b2,$fff,$1b4,$070,$1b6,$090
	dc.w	$1b8,$0a0,$1ba,$0b0,$1bc,$f80,$1be,$060

bph1	dc.w	bpl1pth,$0		; The bitplane pointers
bpl1	dc.w	bpl1ptl,$0
bph2	dc.w	bpl2pth,$0
bpl2	dc.w	bpl2ptl,$0
bph3	dc.w	bpl3pth,$0
bpl3	dc.w	bpl3ptl,$0
bph4	dc.w	bpl4pth,$0
bpl4	dc.w	bpl4ptl,$0
bph5	dc.w	bpl5pth,$0
bpl5	dc.w	bpl5ptl,$0

	dc.w	$e201,$fffe
	dc.w	color00,$00f

	dc.w	$ffff,$fffe



****************************************************************************
;			Variables
****************************************************************************
gfxname	dc.b	'graphics.library',0	; Name of libs to load
dosname	dc.b	'dos.library',0		
	even
gfxbase	dc.l	0			; Space for libs address
dosbase	dc.l	0			

AModulo	dc.w	0
DModulo	dc.w	0

BufferP	dc.l	0			; Pointer to buffer
Buffer	dc.l	0			; Pointer to buffer
Length	dc.l	0			; Holds length of file
Filename dc.b	'ram:Table1',0
filehd	dc.l	0

XCord	dc.w	0			; X co-ordinate
YCord	dc.w	0			; Y co-ordinate
LastXY1 dc.w	0			; Last offset 

FireF	dc.b	0			; The fire button flag
RMBF	dc.b	0			; The RMB flag
Mode	dc.b	0			; The plotting mode flag
Speed	dc.w	1			; Speed to move bob

*****************************
* Gfx data for Dragon Logo1 *
*****************************
Logo1	incbin	'source:bitmaps1/Dragon.Logo1
Mask1	incbin	'source:bitmaps1/Dragon.Mask1
Back1	dcb.b	18*31*5,0			; Space for background

screen	dcb.b	256*60*5,$0
Font	incbin	'source:bitmaps1/Font.gfx'

