
 include "include_i:lvos.i"

_custom equ $DFF000
DMACON EQU 96
DMACONR EQU 2
CIAB_GAMEPORT1    EQU   (7)   ;gameport 1, pin 6 is fire button
_ciaa EQU $bfe001

start:
  movea.l 4.w,a6
  lea dosname(pc),a1
  moveq.l #0,d0
   jsr _LVOOpenLibrary(a6)
  move.l d0,dosbase
  lea gname(pc),a1
  moveq.l #0,d0
   jsr _LVOOpenLibrary(a6)
  move.l d0,gbase
.checkblitter:
  movea.l gbase(pc),a6
  tst.w $aa(a6)
   beq.b .busy
  btst    #CIAB_GAMEPORT1,_ciaa  ; tasto sinistro del mouse premuto?
   bne.s   .checkblitter   ; se no, cicla
.exit:
  movea.l 4.w,a6
  movea.l dosbase(pc),a1
   jsr _LVOCloseLibrary(a6)
  movea.l gbase(pc),a1
   jsr _LVOCloseLibrary(a6)
 rts

.busy
  move.l dosbase(pc),a6
   jsr _LVOOutput(a6)
  move.l d0,d1
  move.l #busystr,d2
  move.l #dosbase-busystr,d3
   jsr _LVOWrite(a6)
 bra.b .checkblitter

busystr: dc.b "the blitter is busy",10,0
dosbase: ds.l 1
gbase: ds.l 1
gname: dc.b "graphics.library",0
dosname: dc.b "dos.library",0
