Merge pull request #224 from jgharston/main

Minor tidying of soft key code
This commit is contained in:
Bobbi Webber-Manners 2022-12-25 12:38:00 -05:00 committed by GitHub
commit 823aed11fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@
* combined with EscAck clearing keyboard. * combined with EscAck clearing keyboard.
* 06-Dec-2022 Moved *KEY into here. * 06-Dec-2022 Moved *KEY into here.
* 12-Dec-2022 Test code to write *KEY data to mainmem. * 12-Dec-2022 Test code to write *KEY data to mainmem.
* 24-Dec-2022 Minor bit of tidying.
* Hardware locations * Hardware locations
@ -44,22 +45,26 @@ KBDAPPRGT EQU $C062 ; Right Apple key
IOVBLNK EQU $C019 ; VBLNK pulse IOVBLNK EQU $C019 ; VBLNK pulse
FLASHER EQU BYTEVARBASE+176 ; VSync counter for flashing cursor FLASHER EQU BYTEVARBASE+176 ; VSync counter for flashing cursor
FXEXEC EQU BYTEVARBASE+198 FXEXEC EQU BYTEVARBASE+198 ; *EXEC handle
FXSPOOL EQU BYTEVARBASE+199 FXSPOOL EQU BYTEVARBASE+199 ; *SPOOL handle
FXTABCHAR EQU BYTEVARBASE+219 FXTABCHAR EQU BYTEVARBASE+219 ; Char for TAB key to return
FXESCCHAR EQU BYTEVARBASE+220 FXESCCHAR EQU BYTEVARBASE+220 ; Char to match as Escape key
FXKEYBASE EQU BYTEVARBASE+221 FXKEYBASE EQU BYTEVARBASE+221 ; Base of char &80+ translations
FXESCON EQU BYTEVARBASE+229 FXESCON EQU BYTEVARBASE+229 ; Escape key is ASC or ESC
FXESCEFFECT EQU BYTEVARBASE+230 FXESCEFFECT EQU BYTEVARBASE+230 ; Actions when Escape acknowledged
FX200VAR EQU BYTEVARBASE+200 FX200VAR EQU BYTEVARBASE+200 ; Completely ignore CHR$(escape)
FXSOFTLEN EQU BYTEVARBASE+216 FXSOFTLEN EQU BYTEVARBASE+216 ; Length of current soft key
FXSOFTOK EQU BYTEVARBASE+244 FXSOFTOFF EQU BYTEVARBASE+233 ; Offset to current soft key
FXSOFTOK EQU BYTEVARBASE+244 ; Soft keys not unstable
FX254VAR EQU BYTEVARBASE+254 FX254VAR EQU BYTEVARBASE+254 ; Keyboard map
FX2VAR EQU BYTEVARBASE+$B1 FX2VAR EQU BYTEVARBASE+$B1 ; Input stream
FX3VAR EQU BYTEVARBASE+$EC FX3VAR EQU BYTEVARBASE+$EC ; Output streams
FX4VAR EQU BYTEVARBASE+$ED FX4VAR EQU BYTEVARBASE+$ED ; Cursor key state
* FKEYLENS defined in mainmem.misc.s ; Length of soft key definitions
* FKEYBUF defined in mainmem.misc.s ; Base of soft key definitions
* OSWRCH handler * OSWRCH handler
@ -102,18 +107,17 @@ DEFBYTE DB $09,$1B ; Default key codes
DB $01,$80,$90,$00 ; Default key expansion DB $01,$80,$90,$00 ; Default key expansion
DEFBYTEEND DEFBYTEEND
KBDINIT LDX #DEFBYTEEND-DEFBYTE-1 KBDINIT LDX #DEFBYTEEND-DEFBYTE-1
:KBDINITLP LDA DEFBYTE,X ; Initialise KBD OSBYTE variables :KBDINITLP LDA DEFBYTE,X ; Initialise KBD OSBYTE variables
STA BYTEVARBASE+DEFBYTELOW,X STA BYTEVARBASE+DEFBYTELOW,X
DEX DEX
BPL :KBDINITLP BPL :KBDINITLP
JSR SOFTKEYCHK ; Clear soft keys JSR SOFTKEYCHK ; Clear soft keys
LDX #$C3 LDX #$C0
STX FX254VAR ; b7-b4=default KBD map, b3-b0=default MODE STX FX254VAR ; b7-b4=default KBD map, b3-b0=default MODE
BIT SETV ; Set V BIT SETV ; Set V
JSR KBDTEST ; Test if key being pressed JSR KBDTEST ; Test if key being pressed
BCS :KBDINITOK ; Return default MODE=3 BCS :KBDINITOK ; Return default MODE=0
STA KBDACK ; Ack. keypress STA KBDACK ; Ack. keypress
TAX ; Use keypress as default MODE TAX ; Use keypress as default MODE
:KBDINITOK TXA :KBDINITOK TXA
@ -440,72 +444,25 @@ MOVELEN DB $00 ; # bytes remaining to move
* ---------------------------- * ----------------------------
SOFTKEYCHK LDA FXSOFTOK SOFTKEYCHK LDA FXSOFTOK
BEQ BYTE12OK ; Soft keys ok, exit BEQ BYTE12OK ; Soft keys ok, exit
BYTE12 LDX #$FF BYTE12
STX FXSOFTOK ; Soft keys being updated * LDX #$FF
:L1 >>> WRTMAIN ; Zero the buffer (nice when debugging) * STX FXSOFTOK ; Soft keys being updated
STZ FKEYBUF,X *:L1 >>> WRTMAIN ; Zero the buffer (nice when debugging)
>>> WRTAUX * STZ FKEYBUF,X
DEX * >>> WRTAUX
BNE :L1 * DEX
* BNE :L1
LDX #15 LDX #15
:L2 >>> WRTMAIN ; Zero the lengths STX FXSOFTOK ; Soft keys being updated
STZ FKEYLENS,X >>> WRTMAIN ; Short enough to page for whole loop
>>> WRTAUX :L2 STZ FKEYLENS,X ; Zero the lengths
DEX DEX
BNE :L2 BNE :L2
>>> WRTAUX
STZ FXSOFTOK ; Soft keys updated STZ FXSOFTOK ; Soft keys updated
BYTE12OK RTS BYTE12OK RTS
* Handle function keys on ADB Extended Keyboard & BMOW Wombat
* For Apple IIGS only
EXTENDKBD BIT VDUBANK ; Use VDUBANK to see if ...
BMI :GS ; ... this is a GS
RTS ; If not, bail
:GS PHA ; Preserve character typed
LDA KEYMOD ; GS-specific register
AND #$10 ; Bit 4 is the 'keypad bit'
BEQ :NOTKEYPAD ; Not an extended key
PLA
LDX #$00
:LOOP CMP :TABLE,X ; Lookup keycode in table
BEQ :FOUND
INX
INX
CPX #20 ; 10 rows of two bytes each
BNE :LOOP
RTS ; Not found, return unchanged
:FOUND LDA KEYMOD ; Look at the modifiers
AND #$C3 ; Mask only the modifier bits
CMP #$01 ; Only shift pressed
BNE :S1
LDA #$10 ; Offset for shift+f-key
BRA :S2
:S1 CMP #$02 ; Onlt ctrl pressed
BNE :S2
LDA #$20 ; Offset for ctrl+f-key
:S2 CLC
ADC :TABLE+1,X ; Lookup translation + add
RTS
* TODO Add $10 if shift is down
* TODO Add $20 if ctrl is down
RTS
:NOTKEYPAD PLA ; Get original key back
RTS
:TABLE DB $7A, $81 ; Extended keyboard F1 code -> f1
DB $78, $82 ; Extended keyboard F2 code -> f2
DB $63, $83 ; Extended keyboard F3 code -> f3
DB $76, $84 ; Extended keyboard F4 code -> f4
DB $60, $85 ; Extended keyboard F5 code -> f5
DB $61, $86 ; Extended keyboard F6 code -> f6
DB $62, $87 ; Extended keyboard F7 code -> f7
DB $64, $88 ; Extended keyboard F8 code -> f8
DB $65, $89 ; Extended keyboard F9 code -> f9
DB $6D, $80 ; Extended keyboard F10 code -> f0
* KEYREAD * KEYREAD
************************ ************************
* Test for and read from input, * Test for and read from input,
@ -521,19 +478,18 @@ KEYREAD LDY FXEXEC ; See if EXEC file is open
LDA #$00 ; EOF, close EXEC file LDA #$00 ; EOF, close EXEC file
STA FXEXEC ; Clear EXEC handle STA FXEXEC ; Clear EXEC handle
JSR OSFIND ; And close it JSR OSFIND ; And close it
KEYREAD1 LDA FXSOFTLEN ; Are we replaying a function key? KEYREAD1 LDA FXSOFTLEN
BEQ KEYREAD2 ; No, skip over BEQ KEYREAD2
LDX SOFTKEYOFF ; Obtain current f-key buffer offset LDX FXSOFTOFF ; SOFTKEYOFF
>>> RDMAIN >>> RDMAIN
LDA FKEYBUF,X ; Read char from buf in main mem LDA FKEYBUF,X
>>> RDAUX >>> RDAUX
INC SOFTKEYOFF ; Next char in buffer INC FXSOFTOFF ; SOFTKEYOFF
DEC FXSOFTLEN ; One less char remaining DEC FXSOFTLEN
CLC CLC
RTS RTS
KEYREAD2 JSR KBDREAD ; Fetch character from KBD "buffer" KEYREAD2 JSR KBDREAD ; Fetch character from KBD "buffer"
BCS KEYREADOK ; Nothing pending BCS KEYREADOK ; Nothing pending
JSR EXTENDKBD ; Handle ADB Extended Keyboard f-keys
TAY ; Y=unmodified character TAY ; Y=unmodified character
BPL KEYREADOK ; Not top-bit key BPL KEYREADOK ; Not top-bit key
AND #$CF ; Drop Shift/Ctrl bits AND #$CF ; Drop Shift/Ctrl bits
@ -550,7 +506,6 @@ KEYREAD2 JSR KBDREAD ; Fetch character from KBD "buffer"
KEYREADOK1 CLC KEYREADOK1 CLC
KEYREADOK RTS KEYREADOK RTS
* Process soft key * Process soft key
KEYSOFTHI LDX FX254VAR KEYSOFTHI LDX FX254VAR
CPX #$C0 CPX #$C0
@ -568,7 +523,7 @@ KEYSOFTY TYA ; Get key including Shift/Ctrl
LDA FXKEYBASE-8,X LDA FXKEYBASE-8,X
BEQ KEYNONE ; Value 0 means 'ignore key' BEQ KEYNONE ; Value 0 means 'ignore key'
DEC A DEC A
BEQ EXPANDKEY ; Value 1 means 'expand key' BEQ KEYEXPAND ; Value 1 means 'expand key'
TYA TYA
AND #$0F AND #$0F
CLC CLC
@ -579,19 +534,19 @@ KEYSOFTY TYA ; Get key including Shift/Ctrl
* Expand soft key * Expand soft key
* On entry: Y key code ($8n where n is F-key num) * On entry: Y key code ($8n where n is F-key num)
EXPANDKEY TYA KEYEXPAND TYA
AND #$0F ; Obtain F-key number AND #$0F ; Obtain F-key number
TAX TAX
PHX PHX
JSR KEYSUMLENS ; Obtain starting offset JSR KEYSUMLENS ; Obtain starting offset
STA SOFTKEYOFF STA FXSOFTOFF ; SOFTKEYOFF
PLX PLX
>>> RDMAIN >>> RDMAIN
LDA FKEYLENS,X ; Obtain length of *KEY string LDA FKEYLENS,X ; Obtain length of *KEY string
>>> RDAUX >>> RDAUX
STA FXSOFTLEN STA FXSOFTLEN
RTS RTS
SOFTKEYOFF DB $00 * SOFTKEYOFF DB $00
* Process cursor keys * Process cursor keys