mirror of
https://github.com/bobbimanners/Applecorn.git
synced 2025-01-16 16:30:54 +00:00
Latest VDU driver from JGH. Copy cursor now works!
This commit is contained in:
parent
8f35f76d62
commit
f9a5d36ffb
BIN
applecorn.po
BIN
applecorn.po
Binary file not shown.
495
auxmem.chario.s
495
auxmem.chario.s
@ -1,5 +1,5 @@
|
||||
*********************************************************
|
||||
* Kernel / Misc
|
||||
* Kernel / Character I/O
|
||||
*********************************************************
|
||||
|
||||
* KERNEL/CHARIO.S
|
||||
@ -7,16 +7,48 @@
|
||||
* Character read and write
|
||||
*
|
||||
* 14-Aug-2021 Flashing cursor and INKEY sync'd to frame rate
|
||||
* with VBLK. Ensured cursor turned on straight away.
|
||||
* with VBLK. Ensured cursor turned on straightaway.
|
||||
* 15-Aug-2021 Cursor keys move copy cursor, copy reads char.
|
||||
* Copy cursor not visible yet.
|
||||
* 16-Aug-2021 Copy cursor and Edit cursor visible.
|
||||
* 17-Aug-2021 OSBYTE 4 for cursors, OSBYTE 221-228 for topbit
|
||||
* keys.
|
||||
* *BUGS* INKEY doesn't restore cursor on timeout.
|
||||
* KBDREAD has several paths that don't test ESCCHAR.
|
||||
|
||||
|
||||
* TEMP:
|
||||
FXESCCHAR EQU $240
|
||||
FXESCON EQU $241
|
||||
FLASHER EQU $242
|
||||
OLDCHAR EQU $243
|
||||
CURSOR EQU $244
|
||||
FLASHER EQU $290
|
||||
CURSOR EQU $291
|
||||
CURSORED EQU $292
|
||||
OLDCHAR EQU $294
|
||||
COPYCHAR EQU $295
|
||||
|
||||
FXTABCHAR EQU BYTEVARBASE+219
|
||||
FXESCCHAR EQU BYTEVARBASE+220
|
||||
FXKEYBASE EQU BYTEVARBASE+221
|
||||
FXESCON EQU BYTEVARBASE+229
|
||||
FXESCEFFECT EQU BYTEVARBASE+230
|
||||
FX254VAR EQU BYTEVARBASE+254
|
||||
FX2VAR EQU BYTEVARBASE+$B1
|
||||
FX3VAR EQU BYTEVARBASE+$EC
|
||||
FX4VAR EQU BYTEVARBASE+$ED
|
||||
|
||||
|
||||
** Default keyboard OSBYTE variables
|
||||
*DEFBYTELOW EQU 219 ; First default OSBYTE value
|
||||
*DEFBYTE DB $09,$1B ; Default key codes
|
||||
* DB $01,$D0,$E0,$F0 ; Default key expansion
|
||||
* DB $01,$80,$90,$00 ; Default key expansion
|
||||
*DEFBYTEEND
|
||||
|
||||
* TEMP as no *KEY
|
||||
* Default keyboard OSBYTE variables
|
||||
DEFBYTELOW EQU 219 ; First default OSBYTE value
|
||||
DEFBYTE DB $09,$1B ; Default key codes
|
||||
DB $C0,$D0,$E0,$F0 ; Default key expansion
|
||||
DB $80,$90,$A0,$B0 ; Default key expansion
|
||||
DEFBYTEEND
|
||||
|
||||
|
||||
* OSWRCH handler
|
||||
@ -24,17 +56,17 @@ CURSOR EQU $244
|
||||
* Send a character to current output
|
||||
* All registers preserved
|
||||
*
|
||||
WRCHHND PHA
|
||||
PHX
|
||||
PHY
|
||||
WRCHHND PHA
|
||||
PHX
|
||||
PHY
|
||||
* TO DO Check any output redirections
|
||||
* TO DO Check any spool output
|
||||
JSR OUTCHAR
|
||||
JSR OUTCHAR
|
||||
* TO DO Check any printer output
|
||||
PLY
|
||||
PLX
|
||||
PLA
|
||||
RTS
|
||||
PLY
|
||||
PLX
|
||||
PLA
|
||||
RTS
|
||||
|
||||
* OSRDCH/INKEY handler
|
||||
**********************
|
||||
@ -42,109 +74,157 @@ WRCHHND PHA
|
||||
* All registers preserved except A, Carry
|
||||
* Flashes a fake cursor while waiting for input
|
||||
*
|
||||
RDCHHND LDA #$80 ; flag=wait forever
|
||||
PHY
|
||||
TAY
|
||||
RDCHHND LDA #$80 ; flag=wait forever
|
||||
PHY
|
||||
TAY
|
||||
* TEST
|
||||
LDA CURSOR
|
||||
BNE INKEYGO
|
||||
LDA #'_'
|
||||
STA CURSOR
|
||||
LDA FXESCCHAR
|
||||
BNE INKEYGO
|
||||
* LDA #'_'
|
||||
* STA CURSOR
|
||||
* LDA #$A0
|
||||
* STA CURSORED
|
||||
* ^ moved to VDU.S
|
||||
LDA #$1B
|
||||
STA FXESCCHAR
|
||||
* TEST
|
||||
BRA INKEYGO ; Wait forever for input
|
||||
BRA INKEYGO ; Wait forever for input
|
||||
|
||||
; XY<$8000 - wait for a keypress
|
||||
INKEY PHY ; Dummy PHY to balance RDCH
|
||||
INKEYGO PHX ; Save registers
|
||||
PHY
|
||||
JSR GETCHRC ; Get character under cursor
|
||||
STA OLDCHAR
|
||||
CLI
|
||||
BRA INKEY1 ; Turn cursor on
|
||||
INKEY PHY ; Dummy PHY to balance RDCH
|
||||
INKEYGO PHX ; Save registers
|
||||
PHY
|
||||
;
|
||||
INKEYLP1 PHX
|
||||
INKEYLP2 PHY
|
||||
* TO DO: display copy cursor as well
|
||||
INKEYLP INC FLASHER ; Increment cursor counter
|
||||
INC FLASHER
|
||||
* INC FLASHER ; Fast flash
|
||||
* INC FLASHER
|
||||
LDA FLASHER
|
||||
AND #127 ; Flash every 64/100sec = 32/50sec
|
||||
BNE INKEY3 ; Not time to toggle yet
|
||||
LDA OLDCHAR ; Prepare to remove cursor
|
||||
BIT FLASHER
|
||||
BMI INKEY2 ; Remove cursor
|
||||
INKEY1 LDA CURSOR ; Add cursor
|
||||
INKEY2 JSR PUTCHRC ; Toggle cursor
|
||||
INKEY3 LDA ESCFLAG
|
||||
BMI INKEYOK ; Escape pending, return it
|
||||
INKEY4 JSR KEYREAD ; Test for input, all can be trashed
|
||||
BCC INKEYOK ; Char returned, return it
|
||||
* JSR DELAY ; Wait 1/100sec
|
||||
BIT VDUSTATUS
|
||||
BVC INKEYGO2 ; No editing cursor
|
||||
JSR GETCHRC ; Get character under cursor
|
||||
STA COPYCHAR ; Save char under edit cursor
|
||||
LDA CURSORED
|
||||
JSR PUTCHRC ; Display edit cursor
|
||||
JSR COPYSWAP1 ; Swap to copy cursor
|
||||
INKEYGO2 JSR GETCHRC ; Get character under cursor
|
||||
STA OLDCHAR
|
||||
;
|
||||
|
||||
;* This can be optimised
|
||||
; JSR GETCHRC ; Get character under cursor
|
||||
; STA OLDCHAR
|
||||
; BIT VDUSTATUS
|
||||
; BVC INKEYGO2 ; No editing cursor
|
||||
; STA COPYCHAR ; Save char under edit cursor
|
||||
; LDA CURSORED
|
||||
; JSR PUTCHRC ; Display edit cursor
|
||||
; JSR COPYSWAP1 ; Swap to copy cursor
|
||||
; JSR GETCHRC ; Get character under copy cursor
|
||||
; STA OLDCHAR
|
||||
;*
|
||||
;INKEYGO2
|
||||
CLI
|
||||
BRA INKEY1 ; Turn cursor on
|
||||
;
|
||||
INKEYLP1 PHX
|
||||
INKEYLP2 PHY
|
||||
INKEYLP CLC
|
||||
LDA #$01 ; Slow flash, every 32 frames
|
||||
BIT VDUSTATUS
|
||||
BVC INKEY0
|
||||
ASL A ; Fast flash, every 16 frames
|
||||
INKEY0 ADC FLASHER
|
||||
STA FLASHER
|
||||
AND #15
|
||||
BNE INKEY3 ; Not time to toggle yet
|
||||
LDA OLDCHAR ; Prepare to remove cursor
|
||||
BIT FLASHER
|
||||
BMI INKEY2 ; Remove cursor
|
||||
INKEY1 LDA CURSOR ; Add cursor
|
||||
INKEY2 JSR PUTCHRC ; Toggle cursor
|
||||
INKEY3 LDA ESCFLAG
|
||||
BMI INKEYOK ; Escape pending, return it
|
||||
INKEY4 JSR KEYREAD ; Test for input, all can be trashed
|
||||
BCC INKEYOK ; Char returned, return it
|
||||
;
|
||||
* VBLK pulses at 50Hz, changes at 100Hz
|
||||
* (60Hz in US, will need tweeking)
|
||||
LDX $C019 ; Get initial VBLK state
|
||||
INKEY5 BIT $C000
|
||||
BMI INKEY4 ; Key pressed
|
||||
TXA
|
||||
EOR $C019
|
||||
BPL INKEY5 ; Wait for VBLK change
|
||||
LDX $C019 ; Get initial VBLK state
|
||||
INKEY5 BIT $C000
|
||||
BMI INKEY4 ; Key pressed
|
||||
TXA
|
||||
EOR $C019
|
||||
BPL INKEY5 ; Wait for VBLK change
|
||||
;
|
||||
PLY
|
||||
BMI INKEYLP2 ; Loop forever
|
||||
PLX
|
||||
TXA
|
||||
BNE INKEYDEC ; Decrement XY
|
||||
DEY
|
||||
INKEYDEC DEX
|
||||
BNE INKEYLP1 ; Not 0, loop back
|
||||
TYA
|
||||
BNE INKEYLP1 ; Not 0, loop back
|
||||
DEY ; Y=$FF
|
||||
TYA ; A=$FF
|
||||
PLX ; Drop dummy PHY
|
||||
RTS ; CS from above
|
||||
PLY
|
||||
BMI INKEYLP2 ; Loop forever
|
||||
PLX
|
||||
TXA
|
||||
BNE INKEYDEC ; Decrement XY
|
||||
DEY
|
||||
INKEYDEC DEX
|
||||
BNE INKEYLP1 ; Not 0, loop back
|
||||
TYA
|
||||
BNE INKEYLP1 ; Not 0, loop back
|
||||
DEY ; Y=$FF
|
||||
TYA ; A=$FF
|
||||
PLX ; Drop dummy PHY
|
||||
RTS ; CS from above
|
||||
; Timeout: CS, AY=$FFFF, becomes XY=$FFFF
|
||||
|
||||
INKEYOK PHA
|
||||
LDA OLDCHAR
|
||||
JSR PUTCHRC ; Remove cursor
|
||||
PLA
|
||||
PLY ; <$80=INKEY or $80=RDCH
|
||||
PLX ; Restore X
|
||||
PLY ; <$80=INKEY or restore=RDCH
|
||||
PHA ; Save char for a mo
|
||||
LDA ESCFLAG
|
||||
ASL A ; Cy=Escape flag
|
||||
PLA ; Get char back
|
||||
RTS
|
||||
INKEYOK PHA
|
||||
;
|
||||
LDA OLDCHAR
|
||||
JSR PUTCHRC ; Remove cursor
|
||||
BIT VDUSTATUS
|
||||
BVC INKEYOK2 ; No editing cursor
|
||||
JSR COPYSWAP1 ; Swap cursor back
|
||||
LDA COPYCHAR
|
||||
JSR PUTCHRC ; Remove edit cursor
|
||||
INKEYOK2
|
||||
;
|
||||
;* This can be optimised
|
||||
; BIT VDUSTATUS
|
||||
; BVC INKEYOK2 ; No editing cursor
|
||||
; LDA OLDCHAR
|
||||
; JSR PUTCHRC ; Remove copy cursor
|
||||
; JSR COPYSWAP1 ; Swap cursor back
|
||||
; LDA COPYCHAR
|
||||
; BRA INKEYOK3 ; Restore char under edit cursor
|
||||
;*
|
||||
;INKEYOK2 LDA OLDCHAR ; and swap cursor back
|
||||
;INKEYOK3 JSR PUTCHRC ; Remove edit cursor
|
||||
;
|
||||
PLA
|
||||
PLY ; <$80=INKEY or $80=RDCH
|
||||
PLX ; Restore X
|
||||
PLY ; <$80=INKEY or restore=RDCH
|
||||
PHA ; Save char for a mo
|
||||
LDA ESCFLAG
|
||||
ASL A ; Cy=Escape flag
|
||||
PLA ; Get char back
|
||||
RTS
|
||||
; Character read: CC, A=char, X=???, Y<$80
|
||||
; Escape: CS, A=?? , X=???, Y<$80
|
||||
|
||||
|
||||
BYTE81 TYA
|
||||
BMI NEGINKEY ; XY<0, scan for keypress
|
||||
JSR INKEY ; XY>=0, wait for keypress
|
||||
BYTE81 TYA
|
||||
BMI NEGINKEY ; XY<0, scan for keypress
|
||||
JSR INKEY ; XY>=0, wait for keypress
|
||||
* Y=$FF, A=FF, X=??, CS - timeout
|
||||
* Y<$80, A=esc, X=??, CS - escape
|
||||
* Y<$80, A=char, X=??, CC - character read
|
||||
TAX ; X=character returned
|
||||
TYA
|
||||
BMI BYTE81DONE ; Y=$FF, timeout
|
||||
LDY #$00
|
||||
BCC BYTE81DONE ; CC, not Escape
|
||||
LDY #$1B ; Y=27
|
||||
BYTE81DONE RTS
|
||||
TAX ; X=character returned
|
||||
TYA
|
||||
BMI BYTE81DONE ; Y=$FF, timeout
|
||||
LDY #$00
|
||||
BCC BYTE81DONE ; CC, not Escape
|
||||
LDY #$1B ; Y=27
|
||||
BYTE81DONE RTS
|
||||
* Returns: Y=$FF, X=$FF, CS - timeout
|
||||
* Y=$1B, X=???, CS - escape
|
||||
* Y=$00, X=char, CC - keypress
|
||||
|
||||
NEGINKEY LDX #$00 ; Unimplemented
|
||||
LDY #$00
|
||||
CLC
|
||||
RTS
|
||||
NEGINKEY LDX #$00 ; Unimplemented
|
||||
LDY #$00
|
||||
CLC
|
||||
RTS
|
||||
|
||||
|
||||
* KERNEL/KEYBOARD.S
|
||||
@ -157,35 +237,104 @@ NEGINKEY LDX #$00 ; Unimplemented
|
||||
*
|
||||
* On exit, CS=no keypress
|
||||
* CC=keypress
|
||||
* A =keycode, X=corrupted
|
||||
* A =keycode, X,Y=corrupted
|
||||
KEYREAD
|
||||
* TO DO: check *EXEC source
|
||||
* TO DO: expand current soft key
|
||||
JSR KBDREAD ; Fetch character from KBD "buffer"
|
||||
BCS KEYREADOK ; Nothing pending
|
||||
* TO DO: process new soft keys
|
||||
* LDY FXVAREXEC
|
||||
* BEQ KEYREAD1
|
||||
* JSR OSBGET
|
||||
* BCC KEYREADOK
|
||||
* LDA #0
|
||||
* STA FXVAREXEC
|
||||
* JSR OSFIND
|
||||
* KEYREAD1
|
||||
*
|
||||
* Process cursor keys
|
||||
* TO DO: check FX4VAR
|
||||
CMP #$C9
|
||||
BEQ KEYCOPY
|
||||
CMP #$CC
|
||||
BCC KEYREADOK ; Not cursor key
|
||||
JSR MOVECOPY ; Move copy cursor
|
||||
KEYCOPYBAD SEC
|
||||
KEYREADOK RTS
|
||||
* TO DO: expand current soft key
|
||||
* LDA SOFTKEYLEN
|
||||
* BEQ KEYREAD2
|
||||
* LDX SOFTKEYOFF
|
||||
* LDA SOFTKEYS,X
|
||||
* INC SOFTKEYOFF
|
||||
* DEC SOFTKEYLEN
|
||||
* CLC
|
||||
* RTS
|
||||
* KEYREAD2
|
||||
*
|
||||
JSR KBDREAD ; Fetch character from KBD "buffer"
|
||||
BCS KEYREADOK ; Nothing pending
|
||||
;
|
||||
TAY
|
||||
BPL KEYREADOK ; Not top-bit key
|
||||
AND #$CF
|
||||
CMP #$C9
|
||||
BCC KEYSOFT ; Not cursor key
|
||||
LDX FX4VAR
|
||||
BEQ KEYCURSOR ; *FX4,0 - editing keys
|
||||
DEX
|
||||
BNE KEYSOFT1 ; Not *FX4,1 - soft key
|
||||
LDY FXTABCHAR
|
||||
CMP #$C9
|
||||
BEQ KEYREADOKY ; TAB key
|
||||
SBC #$44 ; Return $88-$8B
|
||||
TAY
|
||||
KEYREADOKY TYA
|
||||
KEYREADOK1 CLC
|
||||
KEYREADOK RTS
|
||||
;
|
||||
* Process soft key
|
||||
KEYSOFT1 LDX FX254VAR
|
||||
CPX #$C0
|
||||
BCC KEYSOFT
|
||||
AND #$BF
|
||||
TAY
|
||||
KEYSOFT TYA
|
||||
LSR A
|
||||
LSR A
|
||||
LSR A
|
||||
LSR A ; A=key DIV 16
|
||||
EOR #$04 ; Offset into KEYBASE
|
||||
TAX
|
||||
LDA FXKEYBASE-8,X
|
||||
* TO DO:
|
||||
*BEQ KEYNONE ; $00=ignored
|
||||
*DEC A
|
||||
*BEQ expandfunction
|
||||
CMP #2 ; *TEMP*
|
||||
BCC KEYNONE ; *TEMP*
|
||||
TYA
|
||||
AND #$0F
|
||||
CLC
|
||||
ADC FXKEYBASE-8,X
|
||||
CLC
|
||||
RTS
|
||||
|
||||
KEYCOPY AND #$0F ; TAB=$09 if no copy cursor
|
||||
BIT VDUSTATUS
|
||||
BVC KEYCOPYOK ; No copy cursor
|
||||
JSR COPYSWAP ; Swap to copy cursor
|
||||
JSR GETCHRC ; Get the character
|
||||
PHA
|
||||
JSR MOVECOPY3 ; Move copy cursor, swap back
|
||||
PLA
|
||||
BEQ KEYCOPYBAD ; Bad character read
|
||||
KEYCOPYOK CLC
|
||||
RTS ; Return the character
|
||||
* Process cursor keys
|
||||
KEYCURSOR CMP #$C9
|
||||
BEQ KEYCOPY
|
||||
; CMP #$CC
|
||||
; BCC KEYREADOK ; Not cursor key
|
||||
PHA
|
||||
LDA OLDCHAR
|
||||
JSR PUTCHRC ; Remove cursor
|
||||
PLA
|
||||
JSR COPYMOVE ; Move copy cursor
|
||||
JSR GETCHRC ; Save char under cursor
|
||||
STA OLDCHAR
|
||||
KEYNONE SEC
|
||||
RTS
|
||||
|
||||
KEYCOPY LDA FXTABCHAR ; Prepare TAB if no copy cursor
|
||||
BIT VDUSTATUS
|
||||
BVC KEYREADOK1 ; No copy cursor, return TAB
|
||||
LDA OLDCHAR ; Get the char under cursor
|
||||
PHA
|
||||
JSR OUTCHARGO ; Output it to restore and move cursor
|
||||
JSR GETCHRC ; Save char under cursor
|
||||
STA OLDCHAR
|
||||
PLA
|
||||
BNE KEYREADOK1 ; Ok character
|
||||
SEC
|
||||
JMP BEEP ; Beep and return CS=No char
|
||||
|
||||
|
||||
* KBDREAD
|
||||
@ -200,60 +349,58 @@ KEYCOPYOK CLC
|
||||
* TAB -> $C9
|
||||
* Cursors -> $CC-$CF
|
||||
*
|
||||
KBDREAD CLV ; VC=return keypress
|
||||
KBDTEST LDA $C000 ; VS here to test for keypress
|
||||
EOR #$80 ; Toggle bit 7
|
||||
CMP #$80
|
||||
BCS KBDDONE ; No key pressed
|
||||
BVS KBDDONE ; VS=test for keypress
|
||||
STA $C010 ; Ack. keypress
|
||||
BIT $C061
|
||||
BMI KBDLALT ; Left Apple pressed
|
||||
BIT $C062
|
||||
BMI KBDRALT ; Right Apple pressed
|
||||
CMP #$09
|
||||
BEQ KBDTAB ;
|
||||
CMP #$08
|
||||
BCC KBDDONE ; <$08 not cursor key
|
||||
CMP #$0C
|
||||
BCC KBDCURSR
|
||||
CMP #$15
|
||||
BEQ KBDCUR15
|
||||
KBDREAD CLV ; VC=return keypress
|
||||
KBDTEST LDA $C000 ; VS here to test for keypress
|
||||
EOR #$80 ; Toggle bit 7
|
||||
CMP #$80
|
||||
BCS KBDDONE ; No key pressed
|
||||
BVS KBDDONE ; VS=test for keypress
|
||||
STA $C010 ; Ack. keypress
|
||||
BIT $C061
|
||||
BMI KBDLALT ; Left Apple pressed
|
||||
BIT $C062
|
||||
BMI KBDRALT ; Right Apple pressed
|
||||
CMP #$09
|
||||
BEQ KBDTAB ;
|
||||
CMP #$08
|
||||
BCC KBDESC ; <$08 not cursor key
|
||||
CMP #$0C
|
||||
BCC KBDCURSR
|
||||
CMP #$15
|
||||
BEQ KBDCUR15
|
||||
* Test for Escape key
|
||||
KBDESC CMP #27 ; TEMP
|
||||
* CMP FXESCCHAR ; Current ESCAPE char?
|
||||
BNE KBDNOESC ; No
|
||||
LDX FXESCON ; Is ESCAPE enabled?
|
||||
BNE KBDNOESC ; No
|
||||
ROR ESCFLAG ; Set Escape flag
|
||||
KBDNOESC CLC ; CLC=Ok
|
||||
KBDDONE RTS
|
||||
|
||||
KBDRALT ; Right Apple key pressed
|
||||
KBDLALT CMP #$40 ; Left Apple key pressed
|
||||
BCS KBDCTRL
|
||||
CMP #$30
|
||||
BCC KBDFUNOK ; <'0'
|
||||
CMP #$3A
|
||||
BCS KBDOK ; >'9'
|
||||
KBDFUNC AND #$0F ; Convert Apple-Num to function key
|
||||
ORA #$80
|
||||
BIT $C062
|
||||
BPL KBDFUNOK ; Left+Digit -> $8x
|
||||
ORA #$90 ; Right+Digit -> $9x
|
||||
BIT $C061
|
||||
BPL KBDFUNOK
|
||||
EOR #$30 ; Left+Right+Digit -> $Ax
|
||||
KBDFUNOK RTS
|
||||
KBDCTRL AND #$1F ; Apple-Letter -> Ctrl-Letter
|
||||
KBDOK CLC
|
||||
RTS
|
||||
|
||||
KBDTAB LDA #$11 ; Convert TAB to $C9, expanded later
|
||||
KBDCUR15 SBC #$0C ; Convert RGT to $09
|
||||
KBDCURSR CLC
|
||||
ADC #$C4 ; Cursor keys $CC-$CF
|
||||
RTS ; CLC=Ok set earlier
|
||||
KBDESC CMP FXESCCHAR ; Current ESCAPE char?
|
||||
* CMP #27 ; TEMP
|
||||
BNE KBDNOESC ; No
|
||||
LDX FXESCON ; Is ESCAPE enabled?
|
||||
BNE KBDNOESC ; No
|
||||
ROR ESCFLAG ; Set Escape flag
|
||||
KBDNOESC CLC ; CLC=Ok
|
||||
KBDDONE RTS
|
||||
|
||||
KBDRALT ; Right Apple key pressed
|
||||
KBDLALT CMP #$40 ; Left Apple key pressed
|
||||
BCS KBDCTRL
|
||||
CMP #$30
|
||||
BCC KBDFUNOK ; <'0'
|
||||
CMP #$3A
|
||||
BCS KBDOK ; >'9'
|
||||
KBDFUNC AND #$0F ; Convert Apple-Num to function key
|
||||
ORA #$80
|
||||
BIT $C062
|
||||
BPL KBDFUNOK ; Left+Digit -> $8x
|
||||
ORA #$90 ; Right+Digit -> $9x
|
||||
BIT $C061
|
||||
BPL KBDFUNOK
|
||||
EOR #$30 ; Left+Right+Digit -> $Ax
|
||||
KBDFUNOK RTS
|
||||
KBDCTRL AND #$1F ; Apple-Letter -> Ctrl-Letter
|
||||
KBDOK CLC
|
||||
RTS
|
||||
|
||||
KBDTAB LDA #$11 ; Convert TAB to $C9, expanded later
|
||||
KBDCUR15 SBC #$0C ; Convert RGT to $09
|
||||
KBDCURSR CLC
|
||||
ADC #$C4 ; Cursor keys $CC-$CF
|
||||
RTS ; CLC=Ok set earlier
|
||||
|
||||
|
132
auxmem.vdu.s
132
auxmem.vdu.s
@ -6,6 +6,7 @@
|
||||
* 15-Aug-2021 Optimised address calculations and PRCHRC.
|
||||
* Entry point to move copy cursor.
|
||||
* Start to consolidate VDU workspace.
|
||||
* 16-Aug-2021 Added COPY cursor handling.
|
||||
|
||||
|
||||
**********************************
|
||||
@ -30,6 +31,8 @@ VDUTEXTX EQU COL
|
||||
VDUTEXTY EQU ROW
|
||||
VDUCOPYX EQU $250+2 ; copy cursor X coord
|
||||
VDUCOPYY EQU $250+3 ; copy cursor Y coord
|
||||
* VDUCOPYCHR EQU $260+0 ; char underneath cursor when copying
|
||||
|
||||
* VDUCURSOR EQU $250+4 ; cursor character
|
||||
* VDUMODE EQU $250+5 ; current MODE
|
||||
* VDUCHAR EQU $250+6 ; VDU command, 1 byte
|
||||
@ -42,34 +45,55 @@ VDUCOPYY EQU $250+3 ; copy cursor Y coord
|
||||
|
||||
|
||||
* Move editing cursor
|
||||
* A=cursor key
|
||||
MOVECOPY PHA
|
||||
* A=cursor key, CS from caller
|
||||
COPYMOVE PHA
|
||||
BIT VDUSTATUS
|
||||
BVS MOVECOPY2 ; Edit cursor already on
|
||||
LDX #1
|
||||
MOVECOPY1 LDA VDUTEXTX,X ; Initialise copy cursor
|
||||
STA VDUCOPYX,X
|
||||
DEX
|
||||
BPL MOVECOPY1
|
||||
LDA #$40
|
||||
BVS COPYMOVE2 ; Edit cursor already on
|
||||
JSR GETCHRC
|
||||
STA COPYCHAR
|
||||
LDA CURSORED
|
||||
JSR PUTCHRC ; Edit cursor
|
||||
SEC
|
||||
JSR COPYSWAP2 ; Initialise copy cursor
|
||||
ROR FLASHER
|
||||
ASL FLASHER ; Ensure b0=0
|
||||
LDA #$42
|
||||
ORA VDUSTATUS
|
||||
STA VDUSTATUS ; Turn edit cursor on
|
||||
MOVECOPY2 JSR COPYSWAP ; Use edit cursor
|
||||
PLA
|
||||
AND #3
|
||||
STA VDUSTATUS ; Turn cursor editing on
|
||||
COPYMOVE2 PLA
|
||||
AND #3 ; Convert to 8/9/10/11
|
||||
ORA #8
|
||||
MOVECOPY3 JSR OUTCHARGO ; Move edit cursor
|
||||
* JSR CHARADDR ; Get character address
|
||||
* ; Swap cursors back
|
||||
COPYSWAP LDX #1
|
||||
COPYMOVE3 JMP OUTCHARGO ; Move edit cursor
|
||||
|
||||
;* Turn editing cursor on/off
|
||||
;COPYCURSOR BIT VDUSTATUS
|
||||
; BVC COPYSWAP4 ; Copy cursor not active
|
||||
; PHP ; Save CS=Turn On, CC=Turn Off
|
||||
; JSR COPYSWAP1 ; Swap to edit cursor
|
||||
; LDA COPYCHAR ; Prepare to turn edit cursor off
|
||||
; PLP
|
||||
; BCC COPYCURS2 ; Restore character
|
||||
;COPYCURS1 JSR GETCHRC ; Get character under edit cursor
|
||||
; STA COPYCHAR
|
||||
; LDA #$A0 ; Output edit cursor
|
||||
;COPYCURS2 JSR PUTCHRC
|
||||
;* ; Drop through to swap back
|
||||
|
||||
* Swap between edit and copy cursors
|
||||
;COPYSWAP BIT VDUSTATUS
|
||||
; BVC COPYSWAP4 ; Edit cursor off
|
||||
COPYSWAP1 CLC ; CC=Swap TEXT and COPY
|
||||
COPYSWAP2 LDX #1
|
||||
COPYSWAPLP LDY VDUCOPYX,X
|
||||
LDA VDUTEXTX,X
|
||||
STA VDUCOPYX,X
|
||||
BCS COPYSWAP3 ; CS=Copy TEXT to COPY
|
||||
TYA
|
||||
STA VDUTEXTX,X
|
||||
DEX
|
||||
COPYSWAP3 DEX
|
||||
BPL COPYSWAPLP
|
||||
RTS
|
||||
COPYSWAP4 RTS
|
||||
|
||||
|
||||
* Clear to EOL
|
||||
CLREOL LDA ROW
|
||||
@ -100,6 +124,11 @@ CLREOL LDA ROW
|
||||
RTS
|
||||
|
||||
* Clear the screen
|
||||
VDUINIT STA $C00F
|
||||
LDA #'_'
|
||||
STA CURSOR
|
||||
LDA #$A0
|
||||
STA CURSORED
|
||||
CLEAR STZ ROW
|
||||
STZ COL
|
||||
:L1 JSR CLREOL
|
||||
@ -169,14 +198,14 @@ PRCHR6 EOR #$80 ; Convert character
|
||||
RTS
|
||||
|
||||
* PHA
|
||||
* LDA $C000 ; Kbd data/strobe
|
||||
* LDA $C000 ; Kbd data/strobe
|
||||
* BMI :KEYHIT
|
||||
* :RESUME LDA ROW
|
||||
* ASL
|
||||
* TAX
|
||||
* LDA SCNTAB,X ; LSB of row address
|
||||
* LDA SCNTAB,X ; LSB of row address
|
||||
* STA ZP1
|
||||
* LDA SCNTAB+1,X ; MSB of row address
|
||||
* LDA SCNTAB+1,X ; MSB of row address
|
||||
* STA ZP1+1
|
||||
* LDA COL
|
||||
* BIT $C01F
|
||||
@ -187,25 +216,25 @@ PRCHR6 EOR #$80 ; Convert character
|
||||
*:S1 TAY
|
||||
* PLA
|
||||
* EOR #$80
|
||||
* STA (ZP1),Y ; Screen address
|
||||
* STA (ZP1),Y ; Screen address
|
||||
* >>> WRTAUX
|
||||
* RTS
|
||||
*:KEYHIT STA $C010 ; Clear strobe
|
||||
*:KEYHIT STA $C010 ; Clear strobe
|
||||
* AND #$7F
|
||||
* CMP #$13 ; Ctrl-S
|
||||
* CMP #$13 ; Ctrl-S
|
||||
* BEQ :PAUSE
|
||||
* CMP #$1B ; Esc
|
||||
* CMP #$1B ; Esc
|
||||
* BNE :RESUME
|
||||
*:ESC SEC
|
||||
* ROR ESCFLAG ; Set ESCFLAG
|
||||
* ROR ESCFLAG ; Set ESCFLAG
|
||||
* BRA :RESUME
|
||||
*:PAUSE STA $C010 ; Clear strobe
|
||||
*:L1 LDA $C000 ; Kbd data/strobe
|
||||
*:PAUSE STA $C010 ; Clear strobe
|
||||
*:L1 LDA $C000 ; Kbd data/strobe
|
||||
* BPL :L1
|
||||
* AND #$7F
|
||||
* CMP #$11 ; Ctrl-Q
|
||||
* CMP #$11 ; Ctrl-Q
|
||||
* BEQ :RESUME
|
||||
* CMP #$1B ; Esc
|
||||
* CMP #$1B ; Esc
|
||||
* BEQ :ESC
|
||||
* BRA :PAUSE
|
||||
|
||||
@ -239,11 +268,11 @@ GETCHROK RTS
|
||||
* BPL :S1A ; 40-col
|
||||
* LSR
|
||||
* BCC :S1
|
||||
*:S1A STA $C002 ; Read main memory
|
||||
*:S1A STA $C002 ; Read main memory
|
||||
*:S1 TAY
|
||||
* LDA (ZP1),Y
|
||||
* EOR #$80
|
||||
* STA $C003 ; Read aux mem again
|
||||
* STA $C003 ; Read aux mem again
|
||||
* TAX
|
||||
* LDY #$00
|
||||
* BIT $C01F
|
||||
@ -346,23 +375,27 @@ OUTCHARGO CMP #$00 ; NULL
|
||||
BNE :T5
|
||||
LDA ROW
|
||||
CMP #23
|
||||
BEQ SCROLL
|
||||
* BEQ SCROLL ; BOBBI
|
||||
BEQ :TOSCROLL ; JGH
|
||||
INC ROW
|
||||
:IDONE RTS
|
||||
; BRA :DONE
|
||||
:TOSCROLL JMP SCROLL ; JGH
|
||||
:T5 CMP #$0B ; Cursor up
|
||||
BNE :T6
|
||||
LDA ROW
|
||||
BEQ :IDONE
|
||||
DEC ROW
|
||||
BRA :IDONE
|
||||
; BRA :IDONE
|
||||
RTS
|
||||
:T6 CMP #$0D ; Carriage return
|
||||
BNE :T7
|
||||
LDA #$BF
|
||||
AND VDUSTATUS
|
||||
STA VDUSTATUS ; Turn copy cursor off
|
||||
STZ COL
|
||||
BRA :IDONE
|
||||
; BRA :IDONE
|
||||
RTS
|
||||
:T7 CMP #$0C ; Ctrl-L
|
||||
BEQ :T7A
|
||||
CMP #$16 ; MODE
|
||||
@ -373,16 +406,35 @@ OUTCHARGO CMP #$00 ; NULL
|
||||
TAX
|
||||
STA $C00C,X
|
||||
:T7A JSR CLEAR
|
||||
BRA :IDONE
|
||||
; BRA :IDONE
|
||||
RTS
|
||||
:T8 CMP #$1E ; Home
|
||||
BNE :T9
|
||||
STZ ROW
|
||||
STZ COL
|
||||
BRA :IDONE
|
||||
:T9 CMP #$7F ; Delete
|
||||
; BRA :IDONE
|
||||
RTS
|
||||
:T9
|
||||
CMP #$1F ; TAB
|
||||
BNE :T9B
|
||||
LDY VDUQ+8
|
||||
CPY #24
|
||||
BCS :IDONE
|
||||
LDX VDUQ+7
|
||||
CPX #80
|
||||
BCS :IDONE
|
||||
BIT $C01F
|
||||
BMI :T9A
|
||||
CPX #80
|
||||
BCS :IDONE
|
||||
:T9A STX COL
|
||||
STY ROW
|
||||
RTS
|
||||
:T9B CMP #$7F ; Delete
|
||||
BNE :T10
|
||||
JSR DELETE
|
||||
BRA :IDONE
|
||||
; BRA :IDONE
|
||||
RTS
|
||||
:T10 CMP #$20
|
||||
BCC :IDONE
|
||||
JSR PRCHRC ; Store char, checking keypress
|
||||
|
Loading…
x
Reference in New Issue
Block a user