
WaitBlitter	macro
.wait\@	btst.b	#6,$002(a6)
	bne.s	.wait\@
	endm

LMB	macro
.lmb\@	btst.b	#6,$bfe001.l
	bne.s	.lmb\@
	endm

RMB	macro
.rmb\@	btst.b	#2,$016(a6)
	bne.s	.rmb\@
	endm

;IN : d0.l  linenumber
WaitLine_def	macro
WaitLine
	lsl.l	#8,d0		;numero di linea << 8
	lea.l	$004(a6),a0
.aspetta
	MOVE.L	(a0),D1		;prendo linea corrente
	AND.L	#$1ff00,D1	;maschero
	CMP.L	d0,D1		;sono arrivato ???
	bne.s	.aspetta	;se no aspetto
.aspetta2
	move.l	(a0),d1		;riprendo linea
	and.l	#$1ff00,d1	;rimaschero
	cmp.l	d0,d1		;sono ancora nella stesa linea ???
	beq.s	.aspetta2	;se si aspetto di uscire

	rts
	endm

WaitVB	macro
	movem.l	d0-d1/a0,-(sp)	;registri usati in WaitLine
	move.l	#$12d,d0	;aspetto linea 300
	bsr	WaitLine	;chiamo procedura
	movem.l	(sp)+,d0-d1/a0	;a posto i registri
	endm

Wait50	macro
	move.w	d0,-(sp)
	move.w	#\1,d0
.loop\@	WaitVB
	dbra	d0,.loop\@
	move.w	(sp)+,d0
	endm


slmb	macro		;special lmb, colora lo schermo nell'attesa
.loop\@	move.w	#$a00,$dff180
	move.w	#$aaa,$dff180
	btst.b	#6,$bfe001
	bne.s	.loop\@
	endm

srmb	macro		;special rmb, colora lo schermo nell'attesa
.loop\@	move.w	#$a0,$dff180
	move.w	#$aaa,$dff180
	btst.b	#2,$dff016
	bne.s	.loop\@
	endm

saveall	macro
	movem.l	d0-d7/a0-a6,-(sp)
	endm
restoreall	macro
	movem.l	(sp)+,d0-d7/a0-a6
	endm

DisableAGA	macro
	move.w	#0,$dff1fc
	move.w	#$c00,$dff106
	move.w	#$11,$dff10c
	endm

COLOR0	macro
	move.w	#\1,$dff180
	endm

;Prese direttamente da  exec/types.i  del SAS/C 6.56
**
** Structure Building Macros
**
STRUCTURE   MACRO		; structure name, initial offset
\1	    ;SET     0
SOFFSET     SET     \2
	    ENDM

BYTE	    MACRO		; byte (8 bits)
\1	    EQU     SOFFSET
	    DS.B    1
SOFFSET     SET     SOFFSET+1
	    ENDM

WORD	    MACRO		; word (16 bits)
\1	    EQU     SOFFSET
	    DS.W    1
SOFFSET     SET     SOFFSET+2
	    ENDM

LONG	    MACRO		; long (32 bits)
\1	    EQU     SOFFSET
	    DS.L    1
SOFFSET     SET     SOFFSET+4
	    ENDM

LABEL	    MACRO		; Define a label without bumping the offset
\1	    EQU     SOFFSET
	    ENDM

