1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 20:20:55 +11:00

Compare commits

..

No commits in common. "5e0a548faa623c8c420bfbf70247870d996fa11c" and "08392fee601e2d00af84792ec661da35ad9e2a8c" have entirely different histories.

2 changed files with 40 additions and 43 deletions

View File

@ -17,10 +17,9 @@
; *** Variables *** ; *** Variables ***
; Set to previously received scan code ; Set to previously received scan code
.equ KBD_PREV_KC KBD_RAMSTART .equ KBD_PREV_KC KBD_RAMSTART
; Whether Shift key is pressed. When not pressed, holds 0. When pressed, holds ; Whether Shift key is pressed
; 0x80. This allows for quick shifting in the glyph table. .equ KBD_SHIFT_ON KBD_PREV_KC+1
.equ KBD_SHIFT_ON @+1 .equ KBD_RAMEND KBD_SHIFT_ON+1
.equ KBD_RAMEND @+1
kbdInit: kbdInit:
xor a xor a
@ -46,50 +45,59 @@ kbdGetC:
cp KBD_KC_BREAK cp KBD_KC_BREAK
jr z, .break jr z, .break
cp KBD_KC_EXT cp KBD_KC_EXT
jr z, .nothing jr z, .ignore
ex af, af' ; restore saved KC ex af, af' ; restore saved KC
; A scan code over 0x80 is out of bounds or prev KC tell us we should
; skip. Ignore.
cp 0x80 cp 0x80
jr nc, .nothing jr nc, .ignore
; No need to skip, code within bounds, we have something! ; No need to skip, code within bounds, we have something!
call .isShift call .isShift
jr z, .shiftPressed jr z, .shiftPressed
; Let's see if there's a ASCII code associated to it. ; Let's see if there's a ASCII code associated to it.
push hl ; --> lvl 1 push hl ; --> lvl 1
ld hl, KBD_SHIFT_ON ld hl, KBD_SHIFT_ON
or (hl) ; if shift is on, A now ranges in 0x80-0xff. bit 0, (hl)
ld hl, kbdScanCodes ; no flag changed ld hl, kbdScanCodes ; no flag changed
jr z, .shiftNotPressed
; Shift is being pressed. Use Shifted table.
ld hl, kbdScanCodesS
.shiftNotPressed:
call addHL call addHL
ld a, (hl) ld a, (hl)
pop hl ; <-- lvl 1 pop hl ; <-- lvl 1
or a or a
jr z, kbdGetC ; no code. jp z, unsetZ ; no code. Keep A at 0, but unset Z
; We have something! ; We have something!
cp a ; ensure Z cp a ; ensure Z
ret ret
.shiftPressed: .shiftPressed:
ld a, 0x80 ld a, 1
ld (KBD_SHIFT_ON), a ld (KBD_SHIFT_ON), a
jr .nothing ; no actual char to return jr .ignore ; to actual char to return
.break: .break:
ex af, af' ; restore saved KC ex af, af' ; restore saved KC
call .isShift call .isShift
jr nz, .nothing jr nz, .ignore
; We had a shift break, update status ; We had a shift break, update status
xor a xor a
ld (KBD_SHIFT_ON), a ld (KBD_SHIFT_ON), a
; continue to .nothing ; continue to .ignore
.ignore:
; A scan code over 0x80 is out of bounds or prev KC tell us we should
; skip. Ignore.
xor a
jp unsetZ
.nothing: .nothing:
; We have nothing. Before we go further, we'll wait a bit to give our ; We have nothing. Before we go further, we'll wait a bit to give our
; device the time to "breathe". When we're in a "nothing" loop, the z80 ; device the time to "breathe". When we're in a "nothing" loop, the z80
; hammers the device really fast and continuously generates interrupts ; hammers the device really fast and continuously generates interrupts
; on it and it interferes with its other task of reading the keyboard. ; on it and it interferes with its other task of reading the keyboard.
xor a push bc
ld b, 0
.wait: .wait:
inc a nop
jr nz, .wait djnz .wait
jr kbdGetC pop bc
jp unsetZ
; Whether KC in A is L or R shift ; Whether KC in A is L or R shift
.isShift: .isShift:
cp KBD_KC_LSHIFT cp KBD_KC_LSHIFT
@ -98,7 +106,7 @@ kbdGetC:
ret ret
; A list of the values associated with the 0x80 possible scan codes of the set ; A list of the values associated with the 0x80 possible scan codes of the set
; 2 of the PS/2 keyboard specs. 0 means no value. That value is a character that ; 2 of the PS/2 keyboard specs. 0 means no value. That value is a character than
; can be read in a GetC routine. No make code in the PS/2 set 2 reaches 0x80. ; can be read in a GetC routine. No make code in the PS/2 set 2 reaches 0x80.
kbdScanCodes: kbdScanCodes:
; 0x00 1 2 3 4 5 6 7 8 9 a b c d e f ; 0x00 1 2 3 4 5 6 7 8 9 a b c d e f
@ -118,7 +126,8 @@ kbdScanCodes:
; 0x70 27 = ESC ; 0x70 27 = ESC
.db '0','.','2','5','6','8', 27, 0, 0, 0,'3', 0, 0,'9', 0, 0 .db '0','.','2','5','6','8', 27, 0, 0, 0,'3', 0, 0,'9', 0, 0
; Same values, but shifted, exactly 0x80 bytes after kbdScanCodes ; Same values, but shifted
kbdScanCodesS:
; 0x00 1 2 3 4 5 6 7 8 9 a b c d e f ; 0x00 1 2 3 4 5 6 7 8 9 a b c d e f
.db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,'~', 0 .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,'~', 0
; 0x10 9 = TAB ; 0x10 9 = TAB

View File

@ -21,37 +21,25 @@ jp init
.equ STDIO_PUTC aciaPutC .equ STDIO_PUTC aciaPutC
.inc "stdio.asm" .inc "stdio.asm"
; *** BASIC *** ; *** Shell ***
; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20
.equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm"
.inc "lib/parse.asm" .inc "lib/parse.asm"
.inc "lib/fmt.asm" .inc "lib/args.asm"
.equ EXPR_PARSE parseLiteralOrVar .inc "lib/stdio.asm"
.inc "lib/expr.asm" .equ SHELL_RAMSTART STDIO_RAMEND
.inc "basic/util.asm" .equ SHELL_EXTRA_CMD_COUNT 0
.inc "basic/parse.asm" .inc "shell/main.asm"
.inc "basic/tok.asm"
.equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
.inc "basic/var.asm"
.equ BUF_RAMSTART VAR_RAMEND
.inc "basic/buf.asm"
.equ BAS_RAMSTART BUF_RAMEND
.inc "basic/main.asm"
init: init:
di di
ld sp, RAMEND ; setup stack
im 1 ld hl, RAMEND
ld sp, hl
call aciaInit call aciaInit
call kbdInit call kbdInit
call basInit call shellInit
ei jp shellLoop
jp basStart
KBD_FETCHKC: KBD_FETCHKC:
in a, (KBD_PORT) in a, (KBD_PORT)