
MemfPublic_MemfClear EQU $10001
CIAB_PORTREG_A EQU $BFD000
CIAB_INTERRUPT_CONTROLREG EQU $BFDD00
CIAA_PORTREG_A EQU $BFE001
CIAA_INTERRUPT_CONTROLREG EQU $BFED01
Long_Custom EQU $DFF000
_custom EQU $DFF000
INTENA EQU $9A
INTREQ EQU $9C
MaxIntSgnd EQU $7FFFFFFF
 MC68020

romtag: illegal 
 
L_0_2:  dc.l romtag
L_0_6:  dc.l endtag
  dc.b $01,$27 ;.'
  dc.b 8,"P"
L_0_E:  dc.l ciaresource_T
L_0_12:  dc.l cia39110392_T
L_0_16:  dc.l init_routine

ciaresource_T:  dc.b "cia.resource",0,0
ciaaresource_T:  dc.b "ciaa.resource",0
ciabresource_T:  dc.b "ciab.resource",0
cia39110392_T:  dc.b "cia 39.1 (10.3.92)",13,10,0,0
  ds.w 1

;cia  LVO $fffa -6  AddICRVector()
;cia  LVO $fff4 -12  RemICRVector()
;cia  LVO $ffee -18  AbleICR()
;cia  LVO $ffe8 -24  SetICR()

JumpTAB1:  dc.w $FFFF
L_0_5E: dc.w JL_0_302-(JumpTAB1)
L_0_60: dc.w JL_0_36A-(JumpTAB1)
L_0_62: dc.w JL_0_2CC-(JumpTAB1)
L_0_64: dc.w JL_0_25A-(JumpTAB1)
  dc.w $FFFF

init_routine:  movem.l A2-A3,-(A7)
  moveq.l #$20,D0
  move.l #MemfPublic_MemfClear,D1
   jsr -$C6(A6)
  movea.l D0,A3
   bsr.w JL_0_100
  move.l A2,$4(A3)
  moveq.l #$00,D0
  moveq.l #$03,D1
  movem.l D0-D1/A2,$8(A3)
  bset D0,$86(A2)
  move.l #CIAA_PORTREG_A,$22(A2)
  move.l A6,$7C(A2)
  move.w #$0008,$26(A2)
  move.l #AJL_0_136,$12(A1)
  moveq.l #$03,D0
   jsr -$A8(A6)
  lea ciaaresource_T(PC),A0
   bsr.b JL_0_F0
   bsr.b JL_0_100
  move.l A2,(A3)
  lea CIAB_PORTREG_A,A0
  move.l A0,$22(A2)
  move.l A6,$7C(A2)
  moveq.l #-$40,D0
  or.b D0,$200(A0)
  or.b D0,(A0)
  move.w #$2000,$26(A2)
  move.l #AJL_0_1DC,$12(A1)
  moveq.l #$0D,D0
   jsr -$A8(A6)
  lea ciabresource_T(PC),A0
   bsr.b JL_0_F0
  movem.l (A7)+,A2-A3
 rtS 
 
JL_0_F0:  move.l A0,$A(A1)
  move.l A0,$A(A2)
  movea.l A2,A1
   jsr -$1E6(A6)
 rtS 
 
JL_0_100:  lea JumpTAB1(PC),A0
  suba.l A1,A1
  suba.l A2,A2
  moveq.l #$11,D0
  rol.l #3,D0
   jsr -$54(A6)
  movea.l D0,A2
  move.b #$8,$8(A2)
  clr.b $9(A2)
  lea $2A(A2),A1
  move.b #$2,$8(A1)
  move.b #$78,$9(A1)
  move.l A2,$E(A1)
  move.l A3,$80(A2)
 rtS 
 
AJL_0_136:  movem.l D2/A2,-(A7)
  movea.l A1,A2
JL_0_13C:  bclr #$0,$87(A2)
   beq.b JL_0_150
  movea.l $80(A2),A1
  movem.l $18(A1),A1/A5
L_0_14E:   jsr (A5)
JL_0_150:  move.w sr,D0
  ori.w #$700,sr
  move.b CIAA_INTERRUPT_CONTROLREG,D2
  bclr #$7,D2
  or.b $29(A2),D2
  move.b D2,$29(A2)
  and.b $28(A2),D2
  move.b D2,$84(A2)
   beq.b JL_0_19E
  eor.b D2,$29(A2)
  move.w D0,sr
  movea.l $7C(A2),A6
  lea Long_Custom,A0
  lsr.b #1,D2
   bcs.b JL_0_1A8
JL_0_186:  lsr.b #1,D2
   bcs.b JL_0_1B2
   beq.b JL_0_13C
JL_0_18C:  lsr.b #1,D2
   bcs.b JL_0_1BC
   beq.b JL_0_13C
JL_0_192:  lsr.b #1,D2
   bcs.b JL_0_1C6
   beq.b JL_0_13C
JL_0_198:  lsr.b #1,D2
   bcs.b JL_0_1D0
 bra.b JL_0_13C
 
JL_0_19E:  move.w D0,sr
  movem.l (A7)+,D2/A2
  moveq.l #$00,D0
 rtS 
 
JL_0_1A8:  movem.l $40(A2),A1/A5
L_0_1AE:   jsr (A5)
 bra.b JL_0_186
 
JL_0_1B2:  movem.l $4C(A2),A1/A5
L_0_1B8:   jsr (A5)
 bra.b JL_0_18C
 
JL_0_1BC:  movem.l $58(A2),A1/A5
L_0_1C2:   jsr (A5)
 bra.b JL_0_192
 
JL_0_1C6:  movem.l $64(A2),A1/A5
L_0_1CC:   jsr (A5)
 bra.b JL_0_198
 
JL_0_1D0:  movem.l $70(A2),A1/A5
L_0_1D6:   jsr (A5)
 bra.w JL_0_13C
 
AJL_0_1DC:  movem.l D2/A2,-(A7)
  move.b CIAB_INTERRUPT_CONTROLREG,D2
  bclr #$7,D2
  or.b $29(A1),D2
  move.b D2,$29(A1)
  and.b $28(A1),D2
   beq.b JL_0_220
  move.b D2,$84(A1)
  movea.l A1,A2
  eor.b D2,$29(A2)
  lsr.b #1,D2
   bcs.b JL_0_228
JL_0_206:  lsr.b #1,D2
   bcs.b JL_0_232
   beq.b JL_0_21C
JL_0_20C:  lsr.b #1,D2
   bcs.b JL_0_23C
   beq.b JL_0_21C
JL_0_212:  lsr.b #1,D2
   bcs.b JL_0_246
   beq.b JL_0_21C
JL_0_218:  lsr.b #1,D2
   bcs.b JL_0_250
JL_0_21C:  clr.b $84(A2)
JL_0_220:  movem.l (A7)+,D2/A2
  moveq.l #$00,D0
 rtS 
 
JL_0_228:  movem.l $40(A2),A1/A5
L_0_22E:   jsr (A5)
 bra.b JL_0_206
 
JL_0_232:  movem.l $4C(A2),A1/A5
L_0_238:   jsr (A5)
 bra.b JL_0_20C
 
JL_0_23C:  movem.l $58(A2),A1/A5
L_0_242:   jsr (A5)
 bra.b JL_0_212
 
JL_0_246:  movem.l $64(A2),A1/A5
L_0_24C:   jsr (A5)
 bra.b JL_0_218
 
JL_0_250:  movem.l $70(A2),A1/A5
L_0_256:   jsr (A5)
 bra.b JL_0_21C
 
JL_0_25A:  movea.l $7C(A6),A0
  move.w #$4000,_custom+INTENA
  addq.b #1,$126(A0)
  movea.l $22(A6),A0
  move.b $D00(A0),D1
  bclr #$7,D1
  or.b D1,$29(A6)
  moveq.l #$00,D1
  move.b $29(A6),D1
  or.b $84(A6),D1
  tst.b D0
   beq.b JL_0_29E
  bclr #$7,D0
   bne.b JL_0_29A
  not.b D0
  and.b D0,$29(A6)
  and.b D0,$84(A6)
 bra.b JL_0_29E
 
JL_0_29A:  or.b D0,$29(A6)
JL_0_29E:  move.b $28(A6),D0
  and.b $29(A6),D0
   beq.b JL_0_2B6
  move.w $26(A6),D0
  or.w #-$8000,D0
  move.w D0,_custom+INTREQ
JL_0_2B6:  movea.l $7C(A6),A0
  subq.b #1,$126(A0)
   bge.b JL_0_2C8
  move.w #$C000,_custom+INTENA
JL_0_2C8:  move.l D1,D0
 rtS 
 
JL_0_2CC:  movea.l $7C(A6),A0
  move.w #$4000,_custom+INTENA
  addq.b #1,$126(A0)
  movea.l $22(A6),A0
  move.b D0,$D00(A0)
  moveq.l #$00,D1
  move.b $28(A6),D1
  tst.b D0
   beq.b JL_0_29E
  bclr #$7,D0
   bne.b JL_0_2FC
  not.b D0
  and.b D0,$28(A6)
 bra.b JL_0_29E
 
JL_0_2FC:  or.b D0,$28(A6)
 bra.b JL_0_29E
 
JL_0_302:  moveq.l #$00,D1
  move.b D0,D1
  mulu #$C,D1
  movea.l $7C(A6),A0
  move.w #$4000,_custom+INTENA
  addq.b #1,$126(A0)
  lea $40(A6,D1.W),A0
  move.l $8(A0),D1
   bne.b JL_0_354
JL_0_324:  move.l A1,$8(A0)
  move.l $12(A1),$4(A0)
  move.l $E(A1),(A0)
  bset D0,$85(A6)
  move.w #$0080,D1
   bsr.b JL_0_3AC
JL_0_33C:  movea.l $7C(A6),A0
  subq.b #1,$126(A0)
   bge.b JL_0_34E
  move.w #$C000,_custom+INTENA
JL_0_34E: rtS 
 
JL_0_350:  move.l D1,D0
 bra.b JL_0_33C
 
JL_0_354:  btst D0,$86(A6)
   beq.b JL_0_350
  movem.l D0-D3/A0-A3/A6,-(A7)
   bsr.b JL_0_3B8
   bne.b JL_0_390
   bsr.b JL_0_3D2
  movem.l (A7)+,D0-D3/A0-A3/A6
 bra.b JL_0_324
 
JL_0_36A:  movea.l $7C(A6),A0
  move.w #$4000,_custom+INTENA
  addq.b #1,$126(A0)
   bsr.b JL_0_396
  movem.l D0-D3/A0-A3/A6,-(A7)
   bsr.b JL_0_3B8
  movem.l $8(A1),D0-D1/A6
  cmp.b D1,D3
   ble.b JL_0_390
   bsr.b JL_0_396
   bsr.b JL_0_3D2
JL_0_390:  movem.l (A7)+,D0-D3/A0-A3/A6
 bra.b JL_0_350
 
JL_0_396:  moveq.l #$00,D1
  move.b D0,D1
  mulu #$C,D1
  lea $40(A6,D1.W),A0
  clr.l $8(A0)
  moveq.l #$00,D1
  bclr D0,$85(A6)
JL_0_3AC:  bset D0,D1
  move.w D1,D0
   bsr.w JL_0_2CC
  moveq.l #$00,D0
 rtS 
 
JL_0_3B8:  movea.l $80(A6),A1
  movem.l (A1),A2-A3
  moveq.l #$03,D3
  moveq.l #$40,D2
JL_0_3C4:  exg.l A3,A2
  lsr.b #3,D2
  btst D2,$85(A2)
   dbeq D3,JL_0_3C4
 rtS 
 
JL_0_3D2:  and.b #$1,D2
  movem.l D2-D3/A2,$8(A1)
  clr.b $86(A3)
  clr.b $86(A2)
  bset D2,$86(A2)
  movea.l $14(A1),A0
L_0_3EC: jmp (A0)
 
endtag:   ds.w 1
 End
