;...................................
;: (c) 1993 Rebellion Software Ltd :
;: Hand coded by R.C.Dibley - 1993 :
;:.................................:

; The new system for point transformations and so forth.
; This is the CPU section - GPU stuff is in new.gas.  

;========================================
;         INCLUDES OF EQUATES
;========================================

.include 'jaguar.inc'
.include 'blit.inc'
.include 'memdefs.inc'
.include 'msg.inc'

;========================================
;	MACRO DEFINITIONS
;========================================


.macro	RunGPU	 program

	st	gpu_int.w
.ntc\~:	movea.w	#gpusem,a0
	tst.l	(a0)
	bne.b	.ntc\~
	addq.l	#1,(a0)			; note addq.l to a known zero is same effect as move.l #1, 
					; but 2 bytes (not 6) and 20 ticks (not 28)
	bclr	#0,G_CTRL+3		; halt GPU - note +3 to force last byte
	move.l	#G_RAM,G_PC		; set pc to start
	move.l	#\program*GPUM,gpustop
	move.l	#$11,G_CTRL		; start GPU

.endm

;=======================

.macro	waitgpu
;	movea.w	#gpusem,a0
.wait\~:stop	#$2000
	tst.l	(a0)
	bne.b	.wait\~
.endm

;=======================

.macro	border colour,override
.iif Borders=1, move.l #b_\colour,BORD1
.iif \?override&!Borders, move.l #b_\colour,BORD1
.endm

;============================================================

.text

Draw::
	move.l	#collide_table+4,collide_table	; initalise pointer for collision data
	border	0;,1
	RunGPU	13
	waitgpu
	border	-1;,1
dk::	tst.l	blitsem.w
	bmi.b	.ok
	illegal
.ok:	clr.l	blitsem.w
	rts

;========================= End of drawing system

.include 'animate.s'
;.include 'blitmap.s'
