Post #5:better support for CR/LF & ANSI esc seq

This commit is contained in:
Rémy GIBERT 2015-12-12 11:13:14 +01:00
parent 09cd40820d
commit eccd903539
7 changed files with 108 additions and 26 deletions

Binary file not shown.

Binary file not shown.

View File

@ -172,7 +172,7 @@ A2osX.EnumKM >LDAXI MSG.KMENUM
A2osX.MLIQuit >LDAXI MSG.STAGE0OK A2osX.MLIQuit >LDAXI MSG.STAGE0OK
jsr PrintCStrAX jsr PrintCStrAX
>DEBUG >DEBUGOA
jsr MLI jsr MLI
.DA #MLIQUIT .DA #MLIQUIT

View File

@ -73,6 +73,7 @@ J.EscSeq .DA Esc.DispAttr m
.DA 0 end of relocation .DA 0 end of relocation
*-------------------------------------- *--------------------------------------
OPEN stz CURON OPEN stz CURON
stz KeyRemapIdx
stz bEscMode stz bEscMode
stz bEscModeCSI stz bEscModeCSI
@ -95,10 +96,50 @@ GETEVENT lda A2osX.TIMER16
and #A2osX.SCREENS.C is screen active? and #A2osX.SCREENS.C is screen active?
beq .9 beq .9
>SYSCALL SYS.GetKeyboardEvent ldx KeyRemapIdx are we in remap mode ?
bne .4
.11 >SYSCALL SYS.GetKeyboardEvent
bcs .9 bcs .9
ldy #S.EVT.DATAHI
lda (pEvent),y
bne .8
dey
lda (pEvent),y
ldx KeyRemapped
.2 cmp KeyRemapped,x
beq .3
dex
bne .2
clc
rts rts
.3 lda KeyRemappedIdx,x
tax
lda KeyRemappedTable,x
sta (pEvent),y
inx
stx KeyRemapIdx
clc
rts
.4 lda KeyRemappedTable,x
bne .5
stz KeyRemapIdx
bra .11
.5 inx
stx KeyRemapIdx
ldy #S.EVT.DATALO
sta (pEvent),y
iny
lda #0
sta (pEvent),y
lda #S.EVT.F.KEY
sta (pEvent)
clc
.8 rts
.9 lda #0 Error = no event .9 lda #0 Error = no event
sec sec
rts rts
@ -546,6 +587,17 @@ SCROLLTOP .BS 1
SCROLLBOT .BS 1 SCROLLBOT .BS 1
CURON .BS 1 CURON .BS 1
CURCHAR .BS 1 CURCHAR .BS 1
*--------------------------------------
KeyRemapIdx .BS 1
KeyRemapped .HS 0508090A0D15 L,D,U,CR,R
KeyRemappedIdx .HS 050004080C0F
KeyRemappedTable .EQ *
KeyRemappedLEFT .HS 1B5B4400 esc[D
KeyRemappedDOWN .HS 1B5B4200 esc[B
KeyRemappedUP .HS 1B5B4100 esc[A
KeyRemappedCR .HS 0D0A00 crlf
KeyRemappedRGHT .HS 1B5B4300 esc[C
*--------------------------------------
bEscMode .BS 1 bEscMode .BS 1
bEscModeCSI .BS 1 bEscModeCSI .BS 1
EscSeq .BS ESCSEQ.MAXLEN+1 EscSeq .BS ESCSEQ.MAXLEN+1
@ -553,6 +605,7 @@ EscSeqParamCnt .BS 1
EscSeqParam .BS 4 EscSeqParam .BS 4
EscSeqInNum .BS 1 EscSeqInNum .BS 1
EscSeqCmds >PSTRING "mrKH" EscSeqCmds >PSTRING "mrKH"
*--------------------------------------
DEVINFO .DA #S.DEVINFO.TYPE.CHAR DEVINFO .DA #S.DEVINFO.TYPE.CHAR
.DA #80 .DA #80
.DA #24 .DA #24

View File

@ -16,6 +16,10 @@ BUF.MASK .EQ $1F
*-------------------------------------- *--------------------------------------
ZPTmpPtr1 .EQ ZPDRV ZPTmpPtr1 .EQ ZPDRV
*-------------------------------------- *--------------------------------------
* see this :
* http://mirrors.apple2.org.za/apple.cabi.net/Applications/Telcom/SSC.DRIVER/SSC.DRIVER.TXT
* About False read issue in SSC
*--------------------------------------
* SSC/ACIA I/O * SSC/ACIA I/O
*-------------------------------------- *--------------------------------------
SSC.REG.DIPSW1 .EQ $C081 R SSC.REG.DIPSW1 .EQ $C081 R
@ -130,7 +134,9 @@ Dev.Detect sta hArgs
asl asl
asl asl
sta DEVSLOTn0 sta DEVSLOTn0
clc
adc #SSC.REG.DATA+1
sta DEV.DATA.BFFF
>LDYA L.MSG.DETECT.OK >LDYA L.MSG.DETECT.OK
>SYSCALL SYS.PSTROutYA >SYSCALL SYS.PSTROutYA
>LDYA L.DEV.HEADER.NAME >LDYA L.DEV.HEADER.NAME
@ -232,20 +238,20 @@ GETEVENT php
*-------------------------------------- *--------------------------------------
COUT php COUT php
sei sei
* tay save char in Y tay save char in Y
ldx DEVSLOTn0 * ldx DEVSLOTn0
* lda SSC.REG.STATUS,x * lda SSC.REG.STATUS,x
bit #SSC.REG.STATUS.DCD+SSC.REG.STATUS.DSR * bit #SSC.REG.STATUS.DCD+SSC.REG.STATUS.DSR
* beq .9 * beq .9
* ldx OUTBUF.CNT Buffer Empty? ldx OUTBUF.CNT Buffer Empty?
* bne .10 bne .10
* bit #SSC.REG.STATUS.TDRE Register Empty ? bit #SSC.REG.STATUS.TDRE Register Empty ?
* beq .10 not empty, queue char beq .10 not empty, queue char
* tya yes, write directly to ACIA tya yes, write directly to ACIA
ldx DEVSLOTn0 ldx DEVSLOTn0
sta SSC.REG.DATA,x sta SSC.REG.DATA,x
@ -339,8 +345,9 @@ IRQ ldx DEVSLOTn0
and #BUF.MASK and #BUF.MASK
tay tay
ldx DEV.DATA.BFFF
lda OUTBUF,Y lda OUTBUF,Y
sta SSC.REG.DATA,x sta $BFFF,x
ora #$80 ora #$80
sta $401 sta $401
@ -357,6 +364,7 @@ DRV.CS.END
IDX .BS 1 IDX .BS 1
DEVSLOT0n .BS 1 DEVSLOT0n .BS 1
*DEVSLOTCn .BS 1 *DEVSLOTCn .BS 1
DEV.DATA.BFFF .BS 1
DEVSLOTn0 .BS 1 DEVSLOTn0 .BS 1
INBUF.PTR .BS 1 INBUF.PTR .BS 1
INBUF.CNT .BS 1 INBUF.CNT .BS 1

View File

@ -89,7 +89,7 @@ CS.INIT ldy #S.PS.hARGS
sec sec
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
CS.RUN lda #13 try send a CR... CS.RUN lda #12 try send a FF...
>SYSCALL SYS.COutA Device Is Ready ? >SYSCALL SYS.COutA Device Is Ready ?
bcs .8 no..loop... bcs .8 no..loop...

View File

@ -13,7 +13,7 @@ AUTO 6
*-------------------------------------- *--------------------------------------
ZPPTR1 .EQ ZPBIN ZPPTR1 .EQ ZPBIN
*-------------------------------------- *--------------------------------------
INPUT.BUFFER.SIZE .EQ 16 INPUT.BufPtr.SIZE .EQ 16
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
*-------------------------------------- *--------------------------------------
@ -132,24 +132,26 @@ CS.QUIT ldy #hSHELL
*-------------------------------------- *--------------------------------------
* PRIVATE * PRIVATE
*-------------------------------------- *--------------------------------------
INPUT.RESET ldy #INPUT.STATUS INPUT.RESET ldy #INPUT.PassChar
sta (pData),y sta (pData),y
lda #0 lda #0
ldy #INPUT.BUFFER ldy #INPUT.BufPtr
sta (pData),y
ldy #INPUT.Status
sta (pData),y sta (pData),y
rts rts
*-------------------------------------- *--------------------------------------
INPUT.CHARIN tax saver char... INPUT.CHARIN tax saver char...
ldy #INPUT.STATUS ldy #INPUT.Status
lda (pData),y lda (pData),y
bmi .9 bmi .9
lda #INPUT.BUFFER lda #INPUT.BufPtr
clc clc
adc pData adc pData
sta ZPPTR1 sta ZPPTR1
lda pData+1 lda pData+1
adc /INPUT.BUFFER adc /INPUT.BufPtr
sta ZPPTR1+1 sta ZPPTR1+1
cpx #$20 Control Char? cpx #$20 Control Char?
@ -157,7 +159,7 @@ INPUT.CHARIN tax saver char...
lda (ZPPTR1) lda (ZPPTR1)
cmp #INPUT.BUFFER.SIZE Buffer full? cmp #INPUT.BufPtr.SIZE Buffer full?
beq .9 beq .9
inc inc
@ -167,22 +169,40 @@ INPUT.CHARIN tax saver char...
txa txa
sta (ZPPTR1),y sta (ZPPTR1),y
ldy #INPUT.STATUS ldy #INPUT.PassChar
lda (pData),y lda (pData),y
bne .1 bne .1
txa txa
.1 >SYSCALL SYS.COutA .1 >SYSCALL SYS.COutA
rts rts
.2 cpx #$0D .2 cpx #13 CR
bne .3
ldy #INPUT.Status
lda (pData),y
bne .9 bne .9
ldy #INPUT.STATUS
inc
sta (pData),y
rts
.3 cpx #10 LF
bne .4
ldy #INPUT.Status
lda (pData),y
beq .31
lda #$80 lda #$80
sta (pData),y sta (pData),y
rts
.31
.4
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
INPUT.LINEIN ldy #INPUT.STATUS INPUT.LINEIN ldy #INPUT.Status
lda (pData),y lda (pData),y
asl CS if a line is in the buffer asl CS if a line is in the buffer
rts rts
@ -194,8 +214,9 @@ SHELL >PSTRING "SBIN/SHELL"
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START DS.START
INPUT.BUFFER .BS INPUT.BUFFER.SIZE+1 INPUT.BufPtr .BS INPUT.BufPtr.SIZE+1
INPUT.STATUS .BS 1 INPUT.Status .BS 1
INPUT.PassChar .BS 1
hUSERNAME .BS 1 hUSERNAME .BS 1
hPASSWORD .BS 1 hPASSWORD .BS 1
hSHELL .BS 1 hSHELL .BS 1