A2osX/DRV/SSC.DRV.S.txt
2016-10-24 17:54:43 +02:00

228 lines
5.0 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/DRV/SSC.DRV
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
ZPTmpPtr1 .EQ ZPDRV
*--------------------------------------
* 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.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.TENOIRQ .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
*--------------------------------------
* 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
>SYSCALL PrintFYA
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
>SYSCALL PrintFYA
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
>PUSHW L.DEV.HEADER.NAME
>LDYA L.MSG.DETECT.OK
>SYSCALL PrintFYA
clc
rts
*--------------------------------------
CS.END
DEVSIG.Offset .HS 05070B0C
DEVSIG.Value .HS 38180131
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
MSG.DETECT >CSTR "Apple SSC (Super Serial Card,//c Serial Port) Driver.\n"
MSG.DETECT.OK >CSTR "SSC Installed As Device : %S\n"
MSG.DETECT.KO >CSTR "No SSC Found.\n"
hArgs .BS 1
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER cld
jmp (DRV.CS.START,x)
.DA #S.DEV.F.EVENT+S.DEV.F.COUT+S.DEV.F.CHAR
DEV.HEADER.NAME >PSTR "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 ldx DEVSLOTn0
php
sei
stz SSC.REG.RESET,x
lda #$1E
sta SSC.REG.CTL,x
ldx DEVSLOTn0
lda #SSC.REG.CMD.TENOIRQ+SSC.REG.CMD.RIRQDIS
sta SSC.REG.CMD,x
lda SSC.REG.STATUS,x clear any IRQ pending
bmi *
plp
clc
rts
*--------------------------------------
GETEVENT ldx DEVSLOTn0
lda SSC.REG.STATUS,x
bmi *
and #SSC.REG.STATUS.RDRF incoming char?
beq .9
lda SSC.REG.DATA,x
ldy #S.EVT.DATA
sta (pEvent),y
iny
lda #0
sta (pEvent),y
lda #S.EVT.F.KEY
sta (pEvent)
clc
rts
.9 lda #0
sec
rts
*--------------------------------------
COUT pha
ldx DEVSLOTn0
.1 lda SSC.REG.STATUS,x
bmi *
and #SSC.REG.STATUS.DCD+SSC.REG.STATUS.DSR
beq .9
and #SSC.REG.STATUS.TDRE Outgoing char?
bne .1
pla
sta SSC.REG.DATA,x
clc
rts
.9 pla
sec
rts
*--------------------------------------
CLOSE php
sei
ldx DEVSLOTn0
stz SSC.REG.RESET,x
plp
clc
rts
*--------------------------------------
GETINFO >LDYA L.DEVINFO
IRQ clc
rts
*--------------------------------------
DRV.CS.END
DEVSLOT0n .BS 1
DEVSLOTCn .BS 1
DEVSLOTn0 .BS 1
DEVINFO .DA #S.DEVINFO.TYPE.CHAR
.DA #0
*--------------------------------------
MAN
SAVE DRV/SSC.DRV.S
ASM