diff --git a/auxmem.chario.s b/auxmem.chario.s index 1aab318..e7d22b7 100644 --- a/auxmem.chario.s +++ b/auxmem.chario.s @@ -34,6 +34,7 @@ * combined with EscAck clearing keyboard. * 06-Dec-2022 Moved *KEY into here. * 12-Dec-2022 Test code to write *KEY data to mainmem. +* 24-Dec-2022 Minor bit of tidying. * Hardware locations @@ -44,22 +45,26 @@ KBDAPPRGT EQU $C062 ; Right Apple key IOVBLNK EQU $C019 ; VBLNK pulse FLASHER EQU BYTEVARBASE+176 ; VSync counter for flashing cursor -FXEXEC EQU BYTEVARBASE+198 -FXSPOOL EQU BYTEVARBASE+199 +FXEXEC EQU BYTEVARBASE+198 ; *EXEC handle +FXSPOOL EQU BYTEVARBASE+199 ; *SPOOL handle -FXTABCHAR EQU BYTEVARBASE+219 -FXESCCHAR EQU BYTEVARBASE+220 -FXKEYBASE EQU BYTEVARBASE+221 -FXESCON EQU BYTEVARBASE+229 -FXESCEFFECT EQU BYTEVARBASE+230 -FX200VAR EQU BYTEVARBASE+200 -FXSOFTLEN EQU BYTEVARBASE+216 -FXSOFTOK EQU BYTEVARBASE+244 +FXTABCHAR EQU BYTEVARBASE+219 ; Char for TAB key to return +FXESCCHAR EQU BYTEVARBASE+220 ; Char to match as Escape key +FXKEYBASE EQU BYTEVARBASE+221 ; Base of char &80+ translations +FXESCON EQU BYTEVARBASE+229 ; Escape key is ASC or ESC +FXESCEFFECT EQU BYTEVARBASE+230 ; Actions when Escape acknowledged +FX200VAR EQU BYTEVARBASE+200 ; Completely ignore CHR$(escape) +FXSOFTLEN EQU BYTEVARBASE+216 ; Length of current soft key +FXSOFTOFF EQU BYTEVARBASE+233 ; Offset to current soft key +FXSOFTOK EQU BYTEVARBASE+244 ; Soft keys not unstable -FX254VAR EQU BYTEVARBASE+254 -FX2VAR EQU BYTEVARBASE+$B1 -FX3VAR EQU BYTEVARBASE+$EC -FX4VAR EQU BYTEVARBASE+$ED +FX254VAR EQU BYTEVARBASE+254 ; Keyboard map +FX2VAR EQU BYTEVARBASE+$B1 ; Input stream +FX3VAR EQU BYTEVARBASE+$EC ; Output streams +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 @@ -102,18 +107,17 @@ DEFBYTE DB $09,$1B ; Default key codes DB $01,$80,$90,$00 ; Default key expansion DEFBYTEEND - KBDINIT LDX #DEFBYTEEND-DEFBYTE-1 :KBDINITLP LDA DEFBYTE,X ; Initialise KBD OSBYTE variables STA BYTEVARBASE+DEFBYTELOW,X DEX BPL :KBDINITLP JSR SOFTKEYCHK ; Clear soft keys - LDX #$C3 + LDX #$C0 STX FX254VAR ; b7-b4=default KBD map, b3-b0=default MODE BIT SETV ; Set V JSR KBDTEST ; Test if key being pressed - BCS :KBDINITOK ; Return default MODE=3 + BCS :KBDINITOK ; Return default MODE=0 STA KBDACK ; Ack. keypress TAX ; Use keypress as default MODE :KBDINITOK TXA @@ -440,72 +444,25 @@ MOVELEN DB $00 ; # bytes remaining to move * ---------------------------- SOFTKEYCHK LDA FXSOFTOK BEQ BYTE12OK ; Soft keys ok, exit -BYTE12 LDX #$FF - STX FXSOFTOK ; Soft keys being updated -:L1 >>> WRTMAIN ; Zero the buffer (nice when debugging) - STZ FKEYBUF,X - >>> WRTAUX - DEX - BNE :L1 +BYTE12 +* LDX #$FF +* STX FXSOFTOK ; Soft keys being updated +*:L1 >>> WRTMAIN ; Zero the buffer (nice when debugging) +* STZ FKEYBUF,X +* >>> WRTAUX +* DEX +* BNE :L1 LDX #15 -:L2 >>> WRTMAIN ; Zero the lengths - STZ FKEYLENS,X - >>> WRTAUX + STX FXSOFTOK ; Soft keys being updated + >>> WRTMAIN ; Short enough to page for whole loop +:L2 STZ FKEYLENS,X ; Zero the lengths DEX BNE :L2 + >>> WRTAUX STZ FXSOFTOK ; Soft keys updated 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 ************************ * 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 STA FXEXEC ; Clear EXEC handle JSR OSFIND ; And close it -KEYREAD1 LDA FXSOFTLEN ; Are we replaying a function key? - BEQ KEYREAD2 ; No, skip over - LDX SOFTKEYOFF ; Obtain current f-key buffer offset +KEYREAD1 LDA FXSOFTLEN + BEQ KEYREAD2 + LDX FXSOFTOFF ; SOFTKEYOFF >>> RDMAIN - LDA FKEYBUF,X ; Read char from buf in main mem + LDA FKEYBUF,X >>> RDAUX - INC SOFTKEYOFF ; Next char in buffer - DEC FXSOFTLEN ; One less char remaining + INC FXSOFTOFF ; SOFTKEYOFF + DEC FXSOFTLEN CLC RTS KEYREAD2 JSR KBDREAD ; Fetch character from KBD "buffer" BCS KEYREADOK ; Nothing pending - JSR EXTENDKBD ; Handle ADB Extended Keyboard f-keys TAY ; Y=unmodified character BPL KEYREADOK ; Not top-bit key AND #$CF ; Drop Shift/Ctrl bits @@ -550,7 +506,6 @@ KEYREAD2 JSR KBDREAD ; Fetch character from KBD "buffer" KEYREADOK1 CLC KEYREADOK RTS - * Process soft key KEYSOFTHI LDX FX254VAR CPX #$C0 @@ -568,7 +523,7 @@ KEYSOFTY TYA ; Get key including Shift/Ctrl LDA FXKEYBASE-8,X BEQ KEYNONE ; Value 0 means 'ignore key' DEC A - BEQ EXPANDKEY ; Value 1 means 'expand key' + BEQ KEYEXPAND ; Value 1 means 'expand key' TYA AND #$0F CLC @@ -579,19 +534,19 @@ KEYSOFTY TYA ; Get key including Shift/Ctrl * Expand soft key * On entry: Y key code ($8n where n is F-key num) -EXPANDKEY TYA +KEYEXPAND TYA AND #$0F ; Obtain F-key number TAX PHX JSR KEYSUMLENS ; Obtain starting offset - STA SOFTKEYOFF + STA FXSOFTOFF ; SOFTKEYOFF PLX >>> RDMAIN LDA FKEYLENS,X ; Obtain length of *KEY string >>> RDAUX STA FXSOFTLEN RTS -SOFTKEYOFF DB $00 +* SOFTKEYOFF DB $00 * Process cursor keys