Skip to content

Commit

Permalink
[KERNAL] use dedicated tmp memory location for kbd_scan (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
mooinglemur authored Mar 12, 2024
1 parent 2d07153 commit eff3963
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions cfg/kernal-x16.cfgtpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ MEMORY {
SEGMENTS {
ZPKERNAL: load = ZPKERNAL, type = zp;
ZPCHANNEL: load = ZPKERNAL, type = zp;
ZPKBD: load = ZPKERNAL, type = zp;
ZPFONTS: load = ZPKERNAL, type = zp;

KVAR: load = KVAR, type = bss;
Expand Down
6 changes: 3 additions & 3 deletions cfg/x16.cfginc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

/* zero page */
/* start = $0000, size = $0080; # available to the user */
ZPKERNAL: start = $0080, size = $0010; # KERNAL
ZPDOS: start = $0090, size = $000B; # DOS
/* start = $009B, size = $000C; # reserved for DOS or BASIC growth */
ZPKERNAL: start = $0080, size = $0011; # KERNAL
ZPDOS: start = $0091, size = $000B; # DOS
/* start = $009C, size = $000B; # reserved for DOS or BASIC growth */
ZPAUDIO: start = $00A7, size = $0002; # AUDIO
ZPMATH: start = $00A9, size = $002B; # MATH
ZPBASIC: start = $00D4, size = $002B; # BASIC (last byte used: $FE)
Expand Down
17 changes: 11 additions & 6 deletions kernal/drivers/x16/ps2kbd.s
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ KBDNAM_LEN = 14
.segment "ZPKERNAL" : zeropage
ckbtab: .res 2 ; used for keyboard lookup

.segment "ZPKBD": zeropage
kbtmp: .res 1 ; meant for exclusive use in kbd_scan
; The routine formerly used tmp2 which
; can conflict with usage outside of the ISR

.segment "KVARSB0"

prefix: .res 1 ; PS/2: prefix code (e0/e1)
Expand Down Expand Up @@ -320,7 +325,7 @@ is_reg_key:
; Pause/break key?
cmp #KEYCODE_PAUSEBRK
bne :+

ldx #$03 * 2 ; stop (-> run)
lda shflag
lsr ; shift -> C
Expand Down Expand Up @@ -354,7 +359,7 @@ cont: jsr find_table
; the tables use modifiers $C6 (Alt/AltGr) and $C7 (Shift+Alt/AltGr).
; If we don't find a table and the modifier is (Shift+)Alt/AltGr,
; try these modifier codes.
lda tmp2
lda kbtmp
cmp #$82
beq @again
cmp #$83
Expand All @@ -377,7 +382,7 @@ cont: jsr find_table
; scan dead key tables; if nothing found, it's unassigned
@maybe_dead:
sty dk_scan
lda tmp2
lda kbtmp
sta dk_shift
@skip: rts

Expand Down Expand Up @@ -496,14 +501,14 @@ handle_caps:

find_table:
.assert keymap_data = $a000, error; so we can ORA instead of ADC and carry
sta tmp2
sta kbtmp
lda #<keymap_data
sta ckbtab
lda #>keymap_data
sta ckbtab+1
ldx #TABLE_COUNT
@loop: lda (ckbtab)
cmp tmp2
cmp kbtmp
beq @ret ; .C = 1: found
lda ckbtab
eor #$80
Expand Down Expand Up @@ -571,4 +576,4 @@ modifier_shift_states:
.byt MODIFIER_ALTGR
.byt MODIFIER_CTRL
.byt MODIFIER_WIN
.byt MODIFIER_4080
.byt MODIFIER_4080

0 comments on commit eff3963

Please sign in to comment.