*
* Dugeon Master
* (c) 1987, FTL
* (s) 2016, Brutal Deluxe Software
*

         mx	%00
	rel
	dsk	INTERRUPTS.L
	lst	off

	use	INTERRUPTS.X

	use	4/Misc.Macs
	use	4/Qd.Macs
	use	4/Util.Macs
	
L090000  SEP   #$30
         LDA   $C023
         AND   #$20
         BNE   L09000B
         SEC
         RTL

L09000B  LDA   #$00
         STAL  L03013E
         STAL  L03013F
         LDA   #$20
         TRB   $C032
         CLC
         RTL

         REP   #$30
L09001E  ADRL  $00000000
         DW    $0001
         DW    $A55A
         REP   #$30
         LDA   #$0001
         STAL  $FFFFFF
         LDA   #$0000
         STAL  L030132
         LDAL  L030052
         INC
         STAL  L030052
         CMPL  L030054
         BCC   L09004C
         LDA   #$0001
         STAL  L03001C
L09004C  SEP   #$30
         RTL

         REP   #$30
L090051  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EA
         TCS
         CLC
         LDA   #L09001E
         ADC   #$000E
         STA   $EC
         LDA   #^L09001E
         ADC   #$0000
         STA   $EE
         CLC
         LDA   #L09001E
         ADC   #$0004
         STA   [$EC]
         LDY   #$0002
         LDA   #^L09001E
         ADC   #$0000
         SEP   #$30
         STA   [$EC],Y
         REP   #$30
         LDA   #L09001E
         LDX   #^L09001E
         STX   $F4
         STA   $F2
         PHA
         PEI   $F4
         PEI   $F2
         _SetHeartBeat
         BCS   L0900A0
         LDA   #$0000
L0900A0  STAL  L030002
         _GetIRQEnable
         BCS   L0900B0
         LDA   #$0000
L0900B0  STAL  L030002
         PLA
         STA   L030134
         PHA
         PEA   $0005
         _IntSource
         BCS   L0900C8
         LDA   #$0000
L0900C8  STAL  L030002
         PLA
         PHX
         PHA
         PEA   $000E
         _GetVector
         BCS   L0900DE
         LDA   #$0000
L0900DE  STAL  L030002
         PLA
         PLX
         STX   L03013C
         STA   L03013A
         LDA   #L082F68
         LDX   #^L082F68
         STX   $F4
         STA   $F2
         PHA
         PEA   $000E
         PEI   $F4
         PEI   $F2
         _SetVector
         BCS   L090108
         LDA   #$0000
L090108  STAL  L030002
         PEA   $0004
         _IntSource
         BCS   L09011B
         LDA   #$0000
L09011B  STAL  L030002
         PLA
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

L090128  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F0
         TCS
         LDA   #L09001E
         LDX   #^L09001E
         STX   $F4
         STA   $F2
         PHA
         PEI   $F4
         PEI   $F2
         _DelHeartBeat
         BCS   L09014E
         LDA   #$0000
L09014E  STAL  L030002
         PEA   $0005
         _IntSource
         BCS   L090161
         LDA   #$0000
L090161  STAL  L030002
         PEA   $000E
         LDX   L03013C
         LDA   L03013A
         PHX
         PHA
         _SetVector
         BCS   L09017C
         LDA   #$0000
L09017C  STAL  L030002
         PLA
         LDA   L030134
         AND   #$0020
         TAY
         BEQ   L09019F
         PHA
         PEA   $0004
         _IntSource
         BCS   L09019A
         LDA   #$0000
L09019A  STAL  L030002
         PLA
L09019F  TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0901A7  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDA   #$0001
         STAL  L030132
L0901B9  LDAL  L030132
         BNE   L0901B9
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0901C7  CLC
         RTL

L0901C9  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EE
         TCS
         PHA
         _GetIRQEnable
         BCS   L0901E1
         LDA   #$0000
L0901E1  STAL  L030002
         PLA
         STA   $F0
         PHA
         PEA   $000B
         _IntSource
         BCS   L0901F8
         LDA   #$0000
L0901F8  STAL  L030002
         PLA
         PHX
         PHA
         PEA   $0012
         _GetVector
         BCS   L09020E
         LDA   #$0000
L09020E  STAL  L030002
         PLA
         PLX
         STX   L030138
         STA   L030136
         LDA   #L0901C7
         LDX   #^L0901C7
         STX   $F4
         STA   $F2
         PHA
         PEA   $0012
         PEI   $F4
         PEI   $F2
         _SetVector
         BCS   L090238
         LDA   #$0000
L090238  STAL  L030002
         PLA
         LDA   $F0
         AND   #$0004
         TAY
         BEQ   L09025A
         PHA
         PEA   $000A
         _IntSource
         BCS   L090255
         LDA   #$0000
L090255  STAL  L030002
         PLA
L09025A  TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L090262  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00E8
         TCS
         LDA   $FF
         CMP   #$0002
         BEQ   L090279
         LDA   $FF
         STA   L03005A
L090279  PHA
         _HideCursor
         BCS   L090286
         LDA   #$0000
L090286  STAL  L030002
         _GetIRQEnable
         BCS   L090296
         LDA   #$0000
L090296  STAL  L030002
         PLA
         STA   $EA
         PHA
         PEA   $000D
         _IntSource
         BCS   L0902AD
         LDA   #$0000
L0902AD  STAL  L030002
         PLA
         PHX
         PHA
         PEA   $000A
         _GetVector
         BCS   L0902C3
         LDA   #$0000
L0902C3  STAL  L030002
         PLA
         PLX
         STX   $F2
         STA   $F0
         LDA   #L090000
         LDX   #^L090000
         STX   $EE
         STA   $EC
         PHA
         PEA   $000A
         PEI   $EE
         PEI   $EC
         _SetVector
         BCS   L0902EB
         LDA   #$0000
L0902EB  STAL  L030002
         PEA   $0021
         PHA
         PEA   $0021
         _GetSCB
         BCS   L090302
         LDA   #$0000
L090302  STAL  L030002
         PLA
         ORA   #$0040
         PHA
         _SetSCB
         BCS   L090317
         LDA   #$0000
L090317  STAL  L030002
         PEA   $000C
         _IntSource
         BCS   L09032A
         LDA   #$0000
L09032A  STAL  L030002
         PLA
         LDA   L03005A
         BEQ   L09036B
         LDA   L03007E
         BEQ   L09036B
         STZ   L03007E
         JSL   L0901A7
         PEA   $0020
         LDX   L030022
         LDA   L030020
         PHX
         PHA
         LDA   L03003C
         ASL
         ASL
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L058326
         LDX   #^L058326
         JSL   L021F00
         JSL   L0202AB
         PLY
         PLY
         PLY
         PLY
         PLY
L09036B  LDA   #$0001
         STAL  L03013E
L090372  LDAL  L03013E
         BNE   L090372
         JSL   L090436
         LDA   L03005A
         BNE   L0903A7
         LDA   #$0001
         STA   L03007E
         JSL   L0901A7
         PEA   $0020
         LDX   L030022
         LDA   L030020
         PHX
         PHA
         LDX   L030026
         LDA   L030024
         PHX
         PHA
         JSL   L0202AB
         PLY
         PLY
         PLY
         PLY
         PLY
L0903A7  PHA
         PEA   $000D
         _IntSource
         BCS   L0903B7
         LDA   #$0000
L0903B7  STAL  L030002
         PEA   $0021
         PHA
         PEA   $0021
         _GetSCB
         BCS   L0903CE
         LDA   #$0000
L0903CE  STAL  L030002
         PLA
         AND   #$FFBF
         PHA
         _SetSCB
         BCS   L0903E3
         LDA   #$0000
L0903E3  STAL  L030002
         PEA   $000A
         PEI   $F2
         PEI   $F0
         _SetVector
         BCS   L0903FA
         LDA   #$0000
L0903FA  STAL  L030002
         PLA
         LDA   $EA
         AND   #$0002
         TAY
         BEQ   L09041C
         PHA
         PEA   $000C
         _IntSource
         BCS   L090417
         LDA   #$0000
L090417  STAL  L030002
         PLA
L09041C  PHA
         _ShowCursor
         BCS   L090429
         LDA   #$0000
L090429  STAL  L030002
         PLA
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

L090436  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EC
         TCS
         SEP   #$20
         PHB
         LDA   #$E1       ; BANK
         PHA
         PLB
         REP   #$20
         LDA   #$0002
         STA   $F2
         LDX   #$0000
         TXY
L090453  LDA   #$0044
         STA   $F4
L090458  LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         LDAL  $FFFFFF,X
         STA   $34A0,Y
         CLC
         TXA
         ADC   #$00E0
         TAX
         CLC
         TYA
         ADC   #$0140
         TAY
         DEC   $F4
         BEQ   L0905F3
         BRL   L090458
L0905F3  DEC   $F2
         BEQ   L090600
         LDX   #$0070
         LDY   #$00A0
         BRL   L090453
L090600  PLB
         TSC
         CLC
         ADC   #$000E
         TCS
         PLD
         RTL

L090609  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00E8
         TCS
         PHA
         _HideCursor
         BCS   L090621
         LDA   #$0000
L090621  STAL  L030002
         _GetIRQEnable
         BCS   L090631
         LDA   #$0000
L090631  STAL  L030002
         PLA
         STA   $EC
         PHA
         PEA   $000D
         _IntSource
         BCS   L090648
         LDA   #$0000
L090648  STAL  L030002
         PLA
         PHX
         PHA
         PEA   $000A
         _GetVector
         BCS   L09065E
         LDA   #$0000
L09065E  STAL  L030002
         PLA
         PLX
         STX   $F4
         STA   $F2
         LDA   #L090000
         LDX   #^L090000
         STX   $F0
         STA   $EE
         PHA
         PEA   $000A
         PEI   $F0
         PEI   $EE
         _SetVector
         BCS   L090686
         LDA   #$0000
L090686  STAL  L030002
         PEA   $00C7
         PHA
         PEA   $00C7
         _GetSCB
         BCS   L09069D
         LDA   #$0000
L09069D  STAL  L030002
         PLA
         ORA   #$0040
         PHA
         _SetSCB
         BCS   L0906B2
         LDA   #$0000
L0906B2  STAL  L030002
         PEA   $000C
         _IntSource
         BCS   L0906C5
         LDA   #$0000
L0906C5  STAL  L030002
         PLA
         STZ   $EA
         BRA   L0906E1
L0906CE  LDA   #$0001
         STA   L03013E
L0906D4  LDA   L03013E
         BEQ   L0906DB
         BRA   L0906D4
L0906DB  JSL   L090777
         INC   $EA
L0906E1  LDA   $EA
         CMP   #$0007
         BCC   L0906CE
         PHA
         PEA   $000D
         _IntSource
         BCS   L0906F8
         LDA   #$0000
L0906F8  STAL  L030002
         PEA   $00C7
         PHA
         PEA   $00C7
         _GetSCB
         BCS   L09070F
         LDA   #$0000
L09070F  STAL  L030002
         PLA
         AND   #$FFBF
         PHA
         _SetSCB
         BCS   L090724
         LDA   #$0000
L090724  STAL  L030002
         PEA   $000A
         PEI   $F4
         PEI   $F2
         _SetVector
         BCS   L09073B
         LDA   #$0000
L09073B  STAL  L030002
         PLA
         LDA   $EC
         AND   #$0002
         TAY
         BEQ   L09075D
         PHA
         PEA   $000C
         _IntSource
         BCS   L090758
         LDA   #$0000
L090758  STAL  L030002
         PLA
L09075D  PHA
         _ShowCursor
         BCS   L09076A
         LDA   #$0000
L09076A  STAL  L030002
         PLA
         TSC
         CLC
         ADC   #$0012
         TCS
         PLD
         RTL

L090777  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDY   #$001B
         LDX   #$0000
L090788  LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         LDAL  $E18C20,X
         STAL  $E18B80,X
         CLC
         TXA
         ADC   #$00A0
         TAX
         DEY
         BEQ   L090A14
         BRL   L090788
L090A14  LDX   #$009E
L090A17  LDAL  L058D2B,X
         STAL  $E19C60,X
         LDAL  L058DCB,X
         STAL  L058D2B,X
         LDAL  L058E6B,X
         STAL  L058DCB,X
         LDAL  L058F0B,X
         STAL  L058E6B,X
         LDAL  L058FAB,X
         STAL  L058F0B,X
         LDAL  L05904B,X
         STAL  L058FAB,X
         LDAL  L0590EB,X
         STAL  L05904B,X
         DEX
         DEX
         BPL   L090A17
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

