2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2015-08-05 20:38:05 +00:00
|
|
|
|
.TF /A2OSX.BOOT/DRV/SSC.DRV
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
2015-08-05 20:38:05 +00:00
|
|
|
|
.INB INC/A2OSX.API.I
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
BUF.SIZE .EQ $20
|
|
|
|
|
BUF.MASK .EQ $1F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ZPGoCard .EQ ZPDRV
|
|
|
|
|
ZPTmpPtr1 .EQ ZPDRV+2
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Pascal 1.1 Protocol
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SSC.INIT .EQ $0D
|
|
|
|
|
SSC.READ .EQ $0E
|
|
|
|
|
SSC.WRITE .EQ $0F
|
|
|
|
|
SSC.STATUS .EQ $10
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 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.TDRF .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.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.TE .EQ %00001000
|
|
|
|
|
SSC.REG.CMD.TEIRQ .EQ %00000100
|
|
|
|
|
SSC.REG.CMD.TBRK .EQ %00001100
|
|
|
|
|
SSC.REG.CMD.RIRQDIS .EQ %00000010
|
|
|
|
|
SSC.REG.CMD.DTR .EQ %00000001
|
|
|
|
|
SSC.REG.CTL .EQ $C08B W
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-08-05 20:38:05 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
2015-08-05 20:38:05 +00:00
|
|
|
|
jmp Dev.Detect cld,jmp abs=DRV
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 DRV Layout Version 1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA 0
|
2015-08-05 20:38:05 +00:00
|
|
|
|
.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
|
|
|
|
|
.DA 0 End Of Reloc Table
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-08-05 20:38:05 +00:00
|
|
|
|
Dev.Detect sta hArgs
|
|
|
|
|
>LDYA L.MSG.DETECT
|
|
|
|
|
>SYSCALL SYS.SysScrPPSTRYA
|
|
|
|
|
|
|
|
|
|
stz ZPTmpPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda #$C1
|
|
|
|
|
sta ZPTmpPtr1+1
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.1 ldx #DEVSIG.Length-1
|
|
|
|
|
|
|
|
|
|
.2 ldy DEVSIG.Offset,x
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda (ZPTmpPtr1),y
|
2015-06-03 18:30:57 +00:00
|
|
|
|
cmp DEVSIG.Value,x
|
|
|
|
|
bne .3
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
bra .4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.3 inc ZPTmpPtr1+1 no match, try next slot....
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
cmp #$C8
|
|
|
|
|
bne .1
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda #DEVMGR.ERRNOHW Not Found in any slot, exiting
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.4 lda ZPTmpPtr1+1
|
|
|
|
|
sta DEVSLOTCn
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #$0F
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta DEVSLOT0n
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ora #$30
|
2015-08-05 20:38:05 +00:00
|
|
|
|
sta DEV.HEADER.NAME+4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
sta DEVSLOTn0
|
2015-08-05 20:38:05 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
DEVSIG.Offset .HS 05070B0C
|
|
|
|
|
DEVSIG.Value .HS 38180131
|
|
|
|
|
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
|
|
|
|
|
MSG.DETECT >PSTRING "\nApple Super Serial Card Driver."
|
|
|
|
|
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
|
|
|
|
|
DEV.HEADER.NAME >PSTRING "COM1" NAME
|
|
|
|
|
.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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
OPEN
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* ldy #SSC.INIT
|
|
|
|
|
* jsr GoCard
|
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
|
|
|
|
|
stz SSC.REG.RESET,x
|
|
|
|
|
lda #$1E
|
|
|
|
|
sta SSC.REG.CTL,x
|
|
|
|
|
|
|
|
|
|
stz INBUF.PTR
|
|
|
|
|
stz INBUF.CNT
|
|
|
|
|
stz OUTBUF.PTR
|
|
|
|
|
stz OUTBUF.CNT
|
|
|
|
|
|
|
|
|
|
php
|
|
|
|
|
sei
|
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
lda #SSC.REG.CMD.TEIRQ+SSC.REG.CMD.DTR
|
|
|
|
|
sta SSC.REG.CMD,x
|
|
|
|
|
|
|
|
|
|
lda SSC.REG.STATUS,x clear any IRQ pending
|
|
|
|
|
plp
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-08-05 20:38:05 +00:00
|
|
|
|
GETEVENT php
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sei
|
|
|
|
|
lda INBUF.CNT
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
cpx #BUF.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 stx INBUF.PTR
|
|
|
|
|
dec INBUF.CNT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 plp
|
|
|
|
|
lda #0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-08-05 20:38:05 +00:00
|
|
|
|
COUT php
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sei
|
|
|
|
|
|
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
lda SSC.REG.STATUS,x
|
|
|
|
|
and #SSC.REG.STATUS.DCD+SSC.REG.STATUS.DSR
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
ldx OUTBUF.CNT
|
|
|
|
|
cpx #BUF.SIZE
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
>PULLA
|
|
|
|
|
ldx OUTBUF.PTR
|
|
|
|
|
sta OUTBUF,x
|
|
|
|
|
inx
|
|
|
|
|
cpx #BUF.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 stx OUTBUF.PTR
|
|
|
|
|
inc OUTBUF.CNT
|
|
|
|
|
|
|
|
|
|
plp
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 >PULLA
|
|
|
|
|
plp
|
|
|
|
|
sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CLOSE clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
GETINFO >LDYA L.DEVINFO
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* IRQ Handler
|
|
|
|
|
* on exit, CS if handled
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IRQ cld
|
|
|
|
|
|
|
|
|
|
ldx DEVSLOTn0
|
|
|
|
|
lda SSC.REG.STATUS,x IRQ from this device ?
|
|
|
|
|
* bpl .9 no, exit
|
|
|
|
|
pha save status ...
|
|
|
|
|
and #SSC.REG.STATUS.RDRF incoming char?
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
ldy SSC.REG.DATA,x read data to clear IRQ
|
|
|
|
|
lda INBUF.CNT
|
|
|
|
|
cmp #BUF.SIZE
|
|
|
|
|
beq .1 buffer full, discard
|
|
|
|
|
phy
|
|
|
|
|
clc
|
|
|
|
|
adc INBUF.PTR
|
|
|
|
|
and #BUF.MASK
|
|
|
|
|
tay
|
|
|
|
|
pla get back data
|
|
|
|
|
sta INBUF,y
|
|
|
|
|
inc INBUF.CNT
|
|
|
|
|
|
|
|
|
|
.1 pla get back status
|
|
|
|
|
and #SSC.REG.STATUS.TDRF
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda OUTBUF.CNT something to transmit ?
|
|
|
|
|
beq .8 no, exit
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
adc OUTBUF.PTR
|
|
|
|
|
and #BUF.MASK
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda OUTBUF,Y
|
|
|
|
|
sta SSC.REG.DATA,x
|
|
|
|
|
|
|
|
|
|
dec INBUF.CNT
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PRIVATE
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
GOCARD sta $CFFF Prevent SSC firmware bug
|
|
|
|
|
pha
|
|
|
|
|
stz ZPGoCard
|
|
|
|
|
ldx DEVSLOTCn
|
|
|
|
|
stx ZPGoCard+1
|
|
|
|
|
lda (ZPGoCard),y
|
|
|
|
|
sta ZPGoCard
|
|
|
|
|
ldy DEVSLOTn0
|
|
|
|
|
pla
|
|
|
|
|
jmp (ZPGoCard)
|
|
|
|
|
*--------------------------------------
|
2015-08-05 20:38:05 +00:00
|
|
|
|
DRV.CS.END
|
2015-06-03 18:30:57 +00:00
|
|
|
|
DEVSLOT0n .BS 1
|
|
|
|
|
DEVSLOTCn .BS 1
|
|
|
|
|
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
|
2015-08-05 20:38:05 +00:00
|
|
|
|
DEVINFO .DA #S.DEVINFO.TYPE.CHAR
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.DA #0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE DRV/SSC.DRV.S
|
|
|
|
|
ASM
|