         nam   ACIAPAK
         ttl   os9 device driver    

* Disassembled 98/08/23 20:33:33 by Disasm v1.6 (C) 1988 by RML

         ifp1
         use   defsfile
         use   scfdefs
         endc

tylg     set   Drivr+Objct   
atrv     set   ReEnt+rev
rev      set   $01

         mod   eom,name,tylg,atrv,start,size

u0000    rmb   1
u0001    rmb   2
u0003    rmb   1
u0004    rmb   1
u0005    rmb   1
u0006    rmb   3
u0009    rmb   2
u000B    rmb   1
u000C    rmb   1
u000D    rmb   1
u000E    rmb   1
u000F    rmb   1
u0010    rmb   6
u0016    rmb   7
u001D    rmb   1
u001E    rmb   1
u001F    rmb   1
u0020    rmb   1
u0021    rmb   1
u0022    rmb   1
u0023    rmb   1
u0024    rmb   1
u0025    rmb   2
u0027    rmb   1
u0028    rmb   1
u0029    rmb   1
u002A    rmb   1
u002B    rmb   3
u002E    rmb   34
u0050    rmb   46
u007E    rmb   2
u0080    rmb   18
u0092    rmb   28
u00AE    rmb   1
u00AF    rmb   81
size     equ   .
         fcb   READ.+WRITE.

name     fcs   /ACIAPAK/
         fcb   $0C 

start    lbra  Init
         lbra  Read
         lbra  Write
         lbra  GetStat
         lbra  SetStat
         lbra  Term

L0028    fcb   $00,$80,$0a

Init     ldx   u0001,u
         stb   $01,x
         ldd   <IT.COL,y		get col/row bytes
         std   <u002A,u
         ldd   <IT.PAR,y		get parity/baud bytes
         lbsr  L01B4
         ldd   u0001,u
         addd  #$0001
         leax  >L0028,pcr
         leay  >L023E,pcr
         os9   F$IRQ    
         bcs   L006D
         pshs  cc
         orcc  #IntMasks
         lda   >$FF23
         anda  #$FC
         sta   >$FF23
         lda   >$FF22
         lda   <u0092
         ora   #$01
         sta   <u0092
         sta   >$FF92
         puls  cc
         lda   #$03
         sta   >$FF7F
         clrb  
L006D    rts   
L006E    orcc  #IntMasks
         lda   ,x
         lda   ,x
         lda   $01,x
         ldb   $01,x
         ldb   $01,x
         bmi   L00E0
         lda   #$02
         sta   <u0022,u
         clra  
         andb  #$60
         std   <u0023,u
         clrb  
         std   <u001D,u
         std   <u0020,u
         sta   <u001F,u
         std   <u0025,u
         andcc #^IntMasks
         rts   
L0097    bsr   L00E4
Read     lda   <u0023,u
         ble   L00B1
         ldb   <u001F,u
         cmpb  #$0A
         bhi   L00B1
         ldb   u000F,u
         orb   #$80
         stb   <u0023,u
         ldb   #$05
         lbsr  L0370
L00B1    tst   <u0025,u
         bne   L00E0
         ldb   <u001E,u
         leax  <u002E,u
         orcc  #IntMasks
         cmpb  <u001D,u
         beq   L0097
         abx   
         lda   ,x
         dec   <u001F,u
         incb  
         cmpb  #$4F
         bls   L00CF
         clrb  
L00CF    stb   <u001E,u
         ldb   u000E,u
         beq   L0143
         stb   <$3A,y
         clr   u000E,u
         comb  
         ldb   #$F4
         bra   L0144
L00E0    comb  
         ldb   #$F6
         rts   
L00E4    pshs  x,b,a
         lda   u0004,u
         sta   u0005,u
         andcc #^IntMasks
         ldx   #$0000
         os9   F$Sleep  
         ldx   <u0050
         ldb   <$19,x
         beq   L00FD
         cmpb  #$03
         bls   L0113
L00FD    clra  
         lda   $0C,x
         bita  #$02
         bne   L0113
         ldb   #$DC
         lda   u000E,u
         bita  #$20
         bne   L010E
         puls  pc,x,b,a
L010E    inc   <$3F,y
         clr   u000E,u
L0113    leas  $06,s
         coma  
         rts   
L0117    bsr   L00E4
Write    leax  <u007E,u
         ldb   <u0020,u
         abx   
         sta   ,x
         incb  
         cmpb  #$81
         bls   L0128
         clrb  
L0128    orcc  #IntMasks
         cmpb  <u0021,u
         beq   L0117
         stb   <u0020,u
         lda   <u0022,u
         beq   L0143
         anda  #$FD
         sta   <u0022,u
         bne   L0143
         ldb   #$05
         lbsr  L0370
L0143    clrb  
L0144    andcc #^IntMasks
         rts   
GetStat  ldx   $06,y
         cmpa  #$01
         bne   L0156
         ldb   <u001F,u
         beq   L00E0
         stb   $02,x
L0154    clrb  
         rts   
L0156    cmpa  #$06
         beq   L0154
         cmpa  #$26
         beq   L0169
         cmpa  #$28
         bne   L0176
         ldd   <u0028,u
         std   $06,x
         bra   L0154
L0169    clra  
         ldb   <u002A,u
         std   $04,x
         ldb   <u002B,u
         std   $06,x
         bra   L0154
L0176    comb  
         ldb   #$D0
         rts   
SetStat  ldx   $06,y
         cmpa  #$1A
         bne   L0197
         lda   $05,y
         ldb   $05,x
         orcc  #IntMasks
         tst   <u001F,u
         bne   L0190
         std   <u0025,u
         bra   L0143
L0190    andcc #^IntMasks
         os9   F$Send   
         clrb  
         rts   
L0197    cmpa  #$29
         beq   L01DF
         cmpa  #$2A
         beq   L01EF
         cmpa  #$1B
         bne   L01AE
         lda   $05,y
         cmpa  <u0025,u
         bne   L0154
         clr   <u0025,u
         rts   
L01AE    cmpa  #$28
         bne   L0176
         ldd   $06,x
L01B4    std   <u0028,u
         andb  #$E0
         pshs  b
         ldb   <u0029,u
         andb  #$07
         leax  <L01D7,pcr
         ldb   b,x
         orb   ,s+
         anda  #$E0
         sta   u0006,u
         ldx   u0001,u
         lda   $02,x
         anda  #$1F
         ora   u0006,u
         std   $02,x
         bra   L020C
L01D7    fdb   $1316,$1718,$1a1c,$1e1f
L01DF    ldb   #$09
         lda   $07,x
         cmpa  #$01
         bne   L020C
         orcc  #IntMasks
         lbsr  L0370
         lbra  L006E
L01EF    lda   $07,x
         bne   L020C
         ldb   #$0B
         lda   <u0028,u
         bita  #$10
         beq   L01FD
L01FC    clrb  
L01FD    pshs  b
L01FF    bsr   L0211
         bcs   L01FF
         puls  b
         orcc  #IntMasks
         lbsr  L0370
         andcc #^IntMasks
L020C    clrb  
         rts   
L020E    lbsr  L00E4
L0211    ldb   <u0020,u
         orcc  #IntMasks
         cmpb  <u0021,u
         bne   L020E
         rts   

Term     ldx   <u0050
         lda   ,x
         sta   u0004,u
         sta   u0003,u
         bsr   L01FC
         lda   <u0092
         anda  #$FE
         sta   <u0092
         sta   >$FF92
         ldx   #$0000
         os9   F$IRQ    
         clrb  
         rts   
L0237    ldb   >$FF92
         orb   <u00AF
         bra   L0240
L023E    ldb   <u00AF
L0240    andb  #$FE
         stb   <u00AF
         ldx   u0001,u
         sta   <u0027,u
         tfr   a,b
         andb  #$60
         cmpb  <u0024,u
         beq   L028C
         tfr   b,a
         eorb  <u0024,u
         sta   <u0024,u
         lda   <u0027,u
         bitb  #$20
         beq   L027F
         bita  #$20
         beq   L027F
         lda   <u0028,u
         bita  #$10
         beq   L02DF
         ldx   <u0016,u
         beq   L0279
L0271    inc   <$3F,x
         ldx   <$3D,x
         bne   L0271
L0279    lda   #$20
         bsr   L02E9
         bra   L02D4
L027F    bitb  #$40
         beq   L02DF
         bita  #$40
         lbne  L03A2
         lbra  L0391
L028C    bita  #$08
         bne   L02EE
         bita  #$10
         beq   L02DF
         lda   <u0023,u
         bpl   L02A9
         anda  #$7F
         sta   ,x
         eora  u000F,u
         sta   <u0023,u
         lda   <u0022,u
         bne   L02CF
         bra   L02DF
L02A9    leay  <u007E,u
         ldb   <u0021,u
         cmpb  <u0020,u
         beq   L02C7
         clra  
         lda   d,y
         incb  
         cmpb  #$81
         bls   L02BD
         clrb  
L02BD    stb   <u0021,u
         sta   ,x
         cmpb  <u0020,u
         bne   L02D4
L02C7    lda   <u0022,u
         ora   #$02
         sta   <u0022,u
L02CF    ldb   #$09
         lbsr  L0372
L02D4    ldb   #$01
         lda   u0005,u
L02D8    beq   L02DF
         clr   u0005,u
L02DC    os9   F$Send   
L02DF    ldx   u0001,u
         lda   $01,x
         lbmi  L0237
         clrb  
         rts   
L02E9    ora   u000E,u
         sta   u000E,u
         rts   
L02EE    bita  #$07
         beq   L0302
         tfr   a,b
         tst   ,x
         anda  #$07
         bsr   L02E9
         lda   $02,x
         sta   $01,x
         sta   $02,x
         bra   L02DF
L0302    lda   ,x
         beq   L031D
         cmpa  u000B,u
         beq   L0380
         cmpa  u000C,u
         beq   L0384
         cmpa  u000D,u
         beq   L0378
         cmpa  u000F,u
         beq   L0391
         cmpa  <u0010,u
         lbeq  L03A2
L031D    leax  <u002E,u
         ldb   <u001D,u
         abx   
         sta   ,x
         incb  
         cmpb  #$4F
         bls   L032C
         clrb  
L032C    cmpb  <u001E,u
         bne   L0337
         lda   #$04
         bsr   L02E9
         bra   L02D4
L0337    stb   <u001D,u
         inc   <u001F,u
         tst   <u0025,u
         beq   L034A
         ldd   <u0025,u
         clr   <u0025,u
         bra   L02DC
L034A    lda   <u0010,u
         beq   L02D4
         ldb   <u001F,u
         cmpb  #$46
         lbcs  L02D4
         ldb   <u0023,u
         lbne  L02D4
         anda  #$7F
         sta   <u0010,u
         ora   #$80
         sta   <u0023,u
         ldb   #$05
         bsr   L0370
         lbra  L02D4
L0370    ldx   u0001,u
L0372    orb   u0006,u
         stb   $02,x
         clrb  
         rts   
L0378    ldx   u0009,u
         beq   L031D
         sta   $08,x
         bra   L031D
L0380    ldb   #$03
         bra   L0386
L0384    ldb   #$02
L0386    pshs  a
         lda   u0003,u
         lbsr  L02D8
         puls  a
         bra   L031D
L0391    lda   <u0022,u
         anda  #$FE
         sta   <u0022,u
         bne   L039F
         ldb   #$05
         bsr   L0372
L039F    lbra  L02DF
L03A2    lda   <u0022,u
         bne   L03AB
         ldb   #$09
         bsr   L0372
L03AB    ora   #$01
         sta   <u0022,u
         bra   L039F
         emod
eom      equ   *
