2015-12-10 18:53:30 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF /A2OSX.BOOT/DRV/SSC.I.DRV
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
BUF.SIZE .EQ $20
|
|
|
|
|
BUF.MASK .EQ $1F
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPTmpPtr1 .EQ ZPDRV
|
|
|
|
|
*--------------------------------------
|
2015-12-12 10:13:14 +00:00
|
|
|
|
* see this :
|
|
|
|
|
* http://mirrors.apple2.org.za/apple.cabi.net/Applications/Telcom/SSC.DRIVER/SSC.DRIVER.TXT
|
|
|
|
|
* About False read issue in SSC
|
|
|
|
|
*--------------------------------------
|
2015-12-10 18:53:30 +00:00
|
|
|
|
* SSC/ACIA I/O
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SSC.REG.DIPSW1 .EQ $C081 R
|
|
|
|
|
SSC.REG.DIPSW2 .EQ $C082 R
|
|
|
|
|
SSC.REG.DATA .EQ $C088 R,W
|
|
|
|
|
SSC.REG.RESET .EQ $C089 W
|
|
|
|
|
SSC.REG.STATUS .EQ $C089 R
|
|
|
|
|
SSC.REG.STATUS.IRQ .EQ %10000000
|
|
|
|
|
SSC.REG.STATUS.DSR .EQ %01000000
|
|
|
|
|
SSC.REG.STATUS.DCD .EQ %00100000
|
|
|
|
|
SSC.REG.STATUS.TDRE .EQ %00010000
|
|
|
|
|
SSC.REG.STATUS.RDRF .EQ %00001000
|
|
|
|
|
SSC.REG.STATUS.OE .EQ %00000100
|
|
|
|
|
SSC.REG.STATUS.FE .EQ %00000010
|
|
|
|
|
SSC.REG.STATUS.PE .EQ %00000001
|
|
|
|
|
SSC.REG.CMD .EQ $C08A W
|
|
|
|
|
SSC.REG.CMD.NOP .EQ %00000000
|
|
|
|
|
SSC.REG.CMD.ODDP .EQ %00100000
|
|
|
|
|
SSC.REG.CMD.EVENP .EQ %01100000
|
|
|
|
|
SSC.REG.CMD.MARKP .EQ %10100000
|
|
|
|
|
SSC.REG.CMD.SPACEP .EQ %11100000
|
|
|
|
|
SSC.REG.CMD.ECHO .EQ %00010000
|
|
|
|
|
SSC.REG.CMD.TBRK .EQ %00001100
|
|
|
|
|
SSC.REG.CMD.TE .EQ %00001000
|
|
|
|
|
SSC.REG.CMD.TEIRQ .EQ %00000100
|
|
|
|
|
SSC.REG.CMD.RIRQDIS .EQ %00000010
|
|
|
|
|
SSC.REG.CMD.DTR .EQ %00000001
|
|
|
|
|
SSC.REG.CTL .EQ $C08B W
|
|
|
|
|
SSC.REG.CTL.1S .EQ %00000000
|
|
|
|
|
SSC.REG.CTL.2S .EQ %10000000
|
|
|
|
|
SSC.REG.CTL.8D .EQ %00000000
|
|
|
|
|
SSC.REG.CTL.7D .EQ %00100000
|
|
|
|
|
SSC.REG.CTL.6D .EQ %01000000
|
|
|
|
|
SSC.REG.CTL.5D .EQ %01100000
|
2015-12-13 12:51:05 +00:00
|
|
|
|
SSC.REG.CTL.CLKEXT .EQ %00000000
|
|
|
|
|
SSC.REG.CTL.CLKINT .EQ %00010000
|
2015-12-10 18:53:30 +00:00
|
|
|
|
SSC.REG.CTL.B16EXT .EQ %00000000
|
|
|
|
|
SSC.REG.CTL.B50 .EQ %00000001
|
|
|
|
|
SSC.REG.CTL.B75 .EQ %00000010
|
|
|
|
|
SSC.REG.CTL.B110 .EQ %00000011
|
|
|
|
|
SSC.REG.CTL.B135 .EQ %00000100
|
|
|
|
|
SSC.REG.CTL.B150 .EQ %00000101
|
|
|
|
|
SSC.REG.CTL.B300 .EQ %00000110
|
|
|
|
|
SSC.REG.CTL.B600 .EQ %00000111
|
|
|
|
|
SSC.REG.CTL.B1200 .EQ %00001000
|
|
|
|
|
SSC.REG.CTL.B1800 .EQ %00001001
|
|
|
|
|
SSC.REG.CTL.B2400 .EQ %00001010
|
|
|
|
|
SSC.REG.CTL.B3600 .EQ %00001011
|
|
|
|
|
SSC.REG.CTL.B4800 .EQ %00001100
|
|
|
|
|
SSC.REG.CTL.B7200 .EQ %00001101
|
|
|
|
|
SSC.REG.CTL.B9600 .EQ %00001110
|
|
|
|
|
SSC.REG.CTL.B19200 .EQ %00001111
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp Dev.Detect cld,jmp abs=DRV
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 DRV Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START Code Length
|
|
|
|
|
.DA DEV.HEADER-CS.START Device Header Offset
|
|
|
|
|
.DA DRV.CS.START-CS.START Driver Code Offset
|
|
|
|
|
.DA DRV.CS.END-DRV.CS.START Drv Code Length
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
L.MSG.DETECT .DA MSG.DETECT
|
|
|
|
|
L.MSG.DETECT.OK .DA MSG.DETECT.OK
|
|
|
|
|
L.MSG.DETECT.KO .DA MSG.DETECT.KO
|
|
|
|
|
L.DEV.HEADER.NAME .DA DEV.HEADER.NAME
|
|
|
|
|
.DA 0 End Of Reloc Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Dev.Detect sta hArgs
|
|
|
|
|
>LDYA L.MSG.DETECT
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
stz ZPTmpPtr1
|
|
|
|
|
lda #$C1
|
|
|
|
|
sta ZPTmpPtr1+1
|
|
|
|
|
|
|
|
|
|
.1 ldx #DEVSIG.Length-1
|
|
|
|
|
|
|
|
|
|
.2 ldy DEVSIG.Offset,x
|
|
|
|
|
lda (ZPTmpPtr1),y
|
|
|
|
|
cmp DEVSIG.Value,x
|
|
|
|
|
bne .3
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
bra .4
|
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr1+1 no match, try next slot....
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
cmp #$C8
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.DETECT.KO
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
lda #DEVMGR.ERRNOHW Not Found in any slot, exiting
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.4 lda ZPTmpPtr1+1
|
|
|
|
|
* sta DEVSLOTCn
|
|
|
|
|
and #$0F
|
|
|
|
|
sta DEVSLOT0n
|
|
|
|
|
ora #$30
|
|
|
|
|
sta DEV.HEADER.NAME+4
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
sta DEVSLOTn0
|
2015-12-12 10:13:14 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #SSC.REG.DATA+1
|
|
|
|
|
sta DEV.DATA.BFFF
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2016-10-17 15:47:50 +00:00
|
|
|
|
>PUSHW L.DEV.HEADER.NAME
|
|
|
|
|
>LDYA L.MSG.DETECT.OK
|
2016-11-03 16:27:43 +00:00
|
|
|
|
>SYSCALL CPrintFYA
|
2015-12-10 18:53:30 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
DEVSIG.Offset .HS 05070B0C
|
|
|
|
|
DEVSIG.Value .HS 38180131
|
|
|
|
|
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
|
2016-10-24 15:54:43 +00:00
|
|
|
|
MSG.DETECT >CSTR "Apple SSC (Super Serial Card,//c Serial Port) Driver (IRQ Enabled).\n"
|
|
|
|
|
MSG.DETECT.OK >CSTR "SSC Installed As Device : %S\n"
|
|
|
|
|
MSG.DETECT.KO >CSTR "No SSC Found.\n"
|
2015-12-10 18:53:30 +00:00
|
|
|
|
hArgs .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Device Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEV.HEADER cld
|
|
|
|
|
jmp (DRV.CS.START,x)
|
|
|
|
|
.DA #S.DEV.F.IRQ+S.DEV.F.EVENT+S.DEV.F.COUT+S.DEV.F.CHAR
|
2016-10-24 15:54:43 +00:00
|
|
|
|
DEV.HEADER.NAME >PSTR "COM1" NAME
|
2015-12-10 18:53:30 +00:00
|
|
|
|
.HS 00.00
|
|
|
|
|
.HS 00.00.00.00
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Driver Code
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DRV.CS.START .DA OPEN
|
|
|
|
|
.DA GETEVENT
|
|
|
|
|
.DA COUT
|
|
|
|
|
.DA CLOSE
|
|
|
|
|
.DA GETINFO
|
|
|
|
|
.DA IRQ
|
|
|
|
|
L.DEVINFO .DA DEVINFO
|
|
|
|
|
.DA 0 end or relocation
|
|
|
|
|
*--------------------------------------
|
2015-12-13 12:51:05 +00:00
|
|
|
|
OPEN php
|
|
|
|
|
sei
|
|
|
|
|
ldx DEVSLOTn0
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
stz SSC.REG.RESET,x
|
|
|
|
|
|
|
|
|
|
stz INBUF.PTR
|
|
|
|
|
stz INBUF.CNT
|
|
|
|
|
stz OUTBUF.PTR
|
|
|
|
|
stz OUTBUF.CNT
|
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
lda #SSC.REG.CTL.CLKINT+SSC.REG.CTL.B9600
|
|
|
|
|
sta SSC.REG.CTL,x
|
|
|
|
|
|
|
|
|
|
lda #SSC.REG.CMD.TE+SSC.REG.CMD.DTR
|
2015-12-10 18:53:30 +00:00
|
|
|
|
sta SSC.REG.CMD,x
|
|
|
|
|
|
|
|
|
|
lda SSC.REG.DATA,x discard any garbage byte
|
2015-12-13 12:51:05 +00:00
|
|
|
|
lda SSC.REG.STATUS,x clear any IRQ pending
|
2016-01-04 07:22:57 +00:00
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
GETEVENT php
|
|
|
|
|
sei
|
|
|
|
|
lda INBUF.CNT
|
2015-12-13 12:51:05 +00:00
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
ldx INBUF.PTR
|
|
|
|
|
lda INBUF,x
|
|
|
|
|
|
|
|
|
|
ldy #S.EVT.DATA
|
|
|
|
|
sta (pEvent),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pEvent),y
|
|
|
|
|
|
|
|
|
|
lda #S.EVT.F.KEY
|
|
|
|
|
sta (pEvent)
|
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
txa
|
|
|
|
|
inc
|
|
|
|
|
and #BUF.MASK
|
|
|
|
|
sta INBUF.PTR
|
2015-12-10 18:53:30 +00:00
|
|
|
|
dec INBUF.CNT
|
|
|
|
|
|
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 plp
|
|
|
|
|
lda #0
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
COUT php
|
|
|
|
|
sei
|
2015-12-12 10:13:14 +00:00
|
|
|
|
tay save char in Y
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
lda SSC.REG.STATUS,x
|
2016-01-04 07:22:57 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
bit #SSC.REG.STATUS.DCD+SSC.REG.STATUS.DSR true when 0
|
|
|
|
|
bne .9
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-12 10:13:14 +00:00
|
|
|
|
ldx OUTBUF.CNT Buffer Empty?
|
2015-12-13 12:51:05 +00:00
|
|
|
|
bne .10 not empty, queue char
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
and #SSC.REG.STATUS.TDRE Register Empty ?
|
2015-12-12 10:13:14 +00:00
|
|
|
|
beq .10 not empty, queue char
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-12 10:13:14 +00:00
|
|
|
|
tya yes, write directly to ACIA
|
2015-12-13 12:51:05 +00:00
|
|
|
|
ldx DEV.DATA.BFFF
|
|
|
|
|
sta $BFFF,x
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.10 cpx #BUF.SIZE
|
|
|
|
|
beq .9 Buffer Full!!
|
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
lda OUTBUF.PTR
|
|
|
|
|
clc
|
|
|
|
|
adc OUTBUF.CNT
|
|
|
|
|
and #BUF.MASK
|
|
|
|
|
tax
|
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
tya
|
|
|
|
|
sta OUTBUF,x
|
|
|
|
|
|
|
|
|
|
inc OUTBUF.CNT
|
|
|
|
|
|
2016-01-04 07:22:57 +00:00
|
|
|
|
* ldx DEVSLOTn0
|
2015-12-13 12:51:05 +00:00
|
|
|
|
lda #SSC.REG.CMD.TEIRQ+SSC.REG.CMD.DTR
|
|
|
|
|
sta SSC.REG.CMD,x
|
2015-12-10 18:53:30 +00:00
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 plp
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CLOSE php
|
|
|
|
|
sei
|
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
stz SSC.REG.RESET,x
|
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
GETINFO >LDYA L.DEVINFO
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* IRQ Handler
|
|
|
|
|
* on exit, CC if handled
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IRQ ldx DEVSLOTn0
|
|
|
|
|
lda SSC.REG.STATUS,x IRQ from this device ?
|
2016-01-04 07:22:57 +00:00
|
|
|
|
* bpl .9 no, exit !!!!Applewin bug #308!!!!
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
bit #SSC.REG.STATUS.RDRF incoming char?
|
2015-12-10 18:53:30 +00:00
|
|
|
|
beq .1
|
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
*------------ IRQ In
|
|
|
|
|
|
|
|
|
|
ldy SSC.REG.DATA,x read data to clear IRQ
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
lda INBUF.CNT
|
|
|
|
|
cmp #BUF.SIZE
|
2015-12-13 12:51:05 +00:00
|
|
|
|
beq .8 buffer full, discard
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
adc INBUF.PTR
|
|
|
|
|
and #BUF.MASK
|
2015-12-13 12:51:05 +00:00
|
|
|
|
tax
|
|
|
|
|
tya get back data
|
|
|
|
|
sta INBUF,x
|
2016-01-04 07:22:57 +00:00
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
inc INBUF.CNT
|
2016-01-04 07:22:57 +00:00
|
|
|
|
bra IRQ start over if
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
*------------ IRQ Out
|
|
|
|
|
|
|
|
|
|
.1 bit #SSC.REG.STATUS.TDRE
|
|
|
|
|
beq .2 no transmit, no recieve, CTS changed!
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
|
|
|
|
lda OUTBUF.CNT something to transmit ?
|
2015-12-13 12:51:05 +00:00
|
|
|
|
beq .11 no, disable IRQ and exit
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
ldx OUTBUF.PTR
|
|
|
|
|
lda OUTBUF,x
|
|
|
|
|
ldy DEV.DATA.BFFF
|
|
|
|
|
sta $BFFF,y
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
dec OUTBUF.CNT
|
|
|
|
|
txa get back OUTBUF.PTR
|
|
|
|
|
inc
|
|
|
|
|
and #BUF.MASK
|
|
|
|
|
sta OUTBUF.PTR
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-12-10 18:53:30 +00:00
|
|
|
|
|
2015-12-13 12:51:05 +00:00
|
|
|
|
.11 lda #SSC.REG.CMD.TE+SSC.REG.CMD.DTR
|
|
|
|
|
sta SSC.REG.CMD,x
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
*------------ IRQ CTS High
|
|
|
|
|
|
|
|
|
|
.2
|
|
|
|
|
|
2015-12-10 18:53:30 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DRV.CS.END
|
|
|
|
|
DEVSLOT0n .BS 1
|
|
|
|
|
*DEVSLOTCn .BS 1
|
2015-12-12 10:13:14 +00:00
|
|
|
|
DEV.DATA.BFFF .BS 1
|
2015-12-10 18:53:30 +00:00
|
|
|
|
DEVSLOTn0 .BS 1
|
|
|
|
|
INBUF.PTR .BS 1
|
|
|
|
|
INBUF.CNT .BS 1
|
|
|
|
|
OUTBUF.PTR .BS 1
|
|
|
|
|
OUTBUF.CNT .BS 1
|
|
|
|
|
INBUF .BS BUF.SIZE
|
|
|
|
|
OUTBUF .BS BUF.SIZE
|
|
|
|
|
DEVINFO .DA #S.DEVINFO.TYPE.CHAR
|
|
|
|
|
.DA #0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE DRV/SSC.DRV.I.S
|
|
|
|
|
ASM
|