* MouseCrash by E.Hambuch
* V0.0 18.5.90
* Demo, darf nicht veraendert werden !
* Linken:  BLINK MouseCrash.o Samp.o TO MouseCrash CHIP
  include 'exec.i'
  include 'intuition.i'
  include 'startup.i'
_main:
  lea intname,a1               ;Libs oeffnen
  CALLEXEC OldOpenLibrary
  move.l d0,_IntBase
  beq ende
  lea windowstr,a0             ;Fenster
  CALLINT OpenWindow
  move.l d0,Window
  beq closeint
  move.l d0,a0
  move.l 86(a0),MsgPort       ;Window->MsgPort
  lea IntStr5,a1              ;Interrupt fuer Vertikal-Blank
  moveq #5,d0                 ;einfuegen
  CALLEXEC AddIntServer
  lea IntStr7,a1              ;Und Interrupt fuer Kanal 0 setzen
  moveq #7,d0
  jsr _LVOSetIntVector(A6)
  move.w #$0001,$dff096       ;Sound DMA abschalten
forever: move.l MsgPort,a0    ;auf Nachricht warten
  CALLEXEC WaitPort
  move.l MsgPort,a0
  jsr _LVOGetMsg(a6)
  move.l d0,a1
  jsr _LVOReplyMsg(a6)
  lea IntStr5,a1               ;Interrups entfernen
  moveq #5,d0
  jsr _LVORemIntServer(a6)
  move.w #$0001,$dff096               ;Sound DMA aus
  move.w #%00000000010000000,$dff09a  ;Kanal 0-Interrupt abschalten
closewin:                             ;alles schliessen
  move.l Window,a0
  CALLINT CloseWindow
closeint:
  move.l _IntBase,a1
  CALLEXEC CloseLibrary
ende: rts
Interrupt5:                         ;Interrupt-Routine
  movem.l d0/a0/a4,-(sp)
  btst #6,$bfe001
  bne endint5
  lea $dff000,a4
  move.w #%0000000010000000,$09a(a4)
  lea SoundData,a0
  addq.l #4,a0
  move.w #$0001,$96(a4)
  move.l (a0)+,d0
  lsr.l #1,d0
  move.w d0,$0a4(a4)
  move.w (a0)+,$0a6(a4)
  move.l a0,$0a0(a4)
  move.w #64,$0a8(a4)
  move.w #$780,$09c(a4)
  move.b #2,Status
  move.w #%1000000010000000,$09a(a4)
  move.w #$8001,$096(a4)
endint5: movem.l (sp)+,d0/a0/a4
  rts
Interrupt7:
  movem.l d0,-(sp)
  move.w $dff01e,d0
  and.w #$780,d0
  move.w d0,$dff09c
  subq.b #1,Status
  bne.s endint7
  move.w #$0001,$dff096
  move.w #%0000000010000000,$dff09a
endint7: movem.l (sp)+,d0
  rts
intname: INTNAME
segptr:    dc.l 0
_IntBase:  dc.l 0
Window:    dc.l 0
MsgPort:   dc.l 0
Status:    dc.w 0
windowstr:
  dc.w 0,0,310,10
  dc.b 0,1
  dc.l CLOSEWINDOW
  dc.l WINDOWDEPTH!WINDOWDRAG!WINDOWCLOSE
  dc.l 0,0,Titel,0,0
  dc.w 0,0,0,0,WBENCHSCREEN
IntStr5:
  dc.l 0,0
  dc.b 2,0
  dc.l IntName5
  dc.l 0,Interrupt5
IntStr7:
  dc.l 0,0
  dc.b 2,127
  dc.l IntName7
  dc.l 0,Interrupt7
IntName5: dc.b 'MC-Mouse-Interrupt',0
IntName7: dc.b 'MC-Sound-Interrupt',0
Titel: dc.b 'MouseCrash V0.0 by E.Hambuch',0
  xref SoundData
; Fuer eigenes File SAMP.o:
; SAMP-File (erzeugt mit Playsample) mit HexDump in Quellcode wandeln
; An Anfang:   DATA CHIP
;           SoundData:
;             xdef SoundData
; An Ende:    END
  END
