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

Compare commits

...

5 Commits

Author SHA1 Message Date
Virgil Dupras
6d9f96aee6 ti/lcd: add support for backspace
Also, fix visual glitch on line wrap.
2019-11-09 14:37:52 -05:00
Virgil Dupras
a4190f9984 recipes/ti84: document usage
ref #41
2019-11-09 14:20:01 -05:00
Virgil Dupras
2026113480 ti/kbd: lowercase letters by default, 2nd to upcase 2019-11-09 13:38:35 -05:00
Virgil Dupras
9c37471780 ti/kbd: improve debouncing
Previously, on real hardware (emulator behaved fine), we would routinely
get repeat keys unless pressing the button very fast. This commit solves that.
2019-11-09 13:22:01 -05:00
Virgil Dupras
418af5f626 ti/kbd: make Alpha and 2nd toggle
Previously, when being in A-Lock mode, activating Alpha wouldn't make
us go temporarily in digit mode, as is expected.
2019-11-09 13:12:36 -05:00
3 changed files with 78 additions and 21 deletions

View File

@ -19,7 +19,7 @@
; *** Code ***
kbdInit:
xor a
ld a, 1 ; begin with A-Lock on
ld (KBD_MODS), a
ret
@ -31,7 +31,7 @@ kbdInit:
; waitForKey only go through after two actual key presses (otherwise, the user
; doesn't have enough time to de-press the button before the next waitForKey
; routine registers the same key press as a second one).
;
;
; Sending 0xff to the port resets the keyboard, and then we have to send groups
; we want to "listen" to, with a 0 in the group bit. Thus, to know if *any* key
; is pressed, we send 0xff to reset the keypad, then 0x00 to select all groups,
@ -84,13 +84,16 @@ kbdGetC:
jr z, .loop ; yes? unsupported. loop.
call .debounce
cp KBD_KEY_ALPHA
jr c, .end ; A < 0x80? valid char, return it.
jr c, .result ; A < 0x80? valid char, return it.
jr z, .handleAlpha
cp KBD_KEY_2ND
jr z, .handle2nd
jp .loop
.handleAlpha:
set 0, c
; Toggle Alpha bit in C. Also, if 2ND bit is set, toggle A-Lock mod.
ld a, 1 ; mask for Alpha
xor c
ld c, a
bit 1, c ; 2nd set?
jp z, .loop ; unset? loop
; we've just hit Alpha with 2nd set. Toggle A-Lock and set Alpha to
@ -101,9 +104,22 @@ kbdGetC:
ld c, a
jp .loop
.handle2nd:
set 1, c
; toggle 2ND bit in C
ld a, 2 ; mask for 2ND
xor c
ld c, a
jp .loop
.result:
; We have our result in A, *almost* time to return it. One last thing:
; Are in in both Alpha and 2nd mode? If yes, then it means that we
; should return the upcase version of our letter (if it's a letter).
bit 0, c
jr z, .end ; nope
bit 1, c
jr z, .end ; nope
; yup, we have Alpha + 2nd. Upcase!
call upcase
.end:
pop hl
pop bc
@ -120,13 +136,20 @@ kbdGetC:
ret
.debounce:
; wait until all keys are de-pressed
; To avoid repeat keys, we require 64 subsequent polls to indicate all
; depressed keys
push af ; --> lvl 1
push bc ; --> lvl 2
.pressed:
ld b, 64
.wait:
xor a
call .get
inc a ; if a was 0xff, will become 0 (nz test)
jr nz, .wait ; non-zero? something is pressed
jr nz, .pressed ; non-zero? something is pressed
djnz .wait
pop bc ; <-- lvl 2
pop af ; <-- lvl 1
ret
@ -144,9 +167,9 @@ kbdGetC:
; alpha table. same as .dtbl, for when we're in alpha mode.
.atbl:
.db 0xfe, 0, 0, 0, 0, 0, 0, 0, 0
.db 0xfd, 0x0d, '"' ,'W' ,'R', 'M', 'H', 0, 0
.db 0xfb, '?', 0, 'V', 'Q', 'L', 'G', 0, 0
.db 0xf7, ':', 'Z', 'U', 'P', 'K', 'F', 'C', 0
.db 0xef, ' ', 'Y', 'T', 'O', 'J', 'E', 'B', 0
.db 0xdf, 0, 'X', 'S', 'N', 'I', 'D', 'A', KBD_KEY_ALPHA
.db 0xfd, 0x0d, '"' ,'w' ,'r', 'm', 'h', 0, 0
.db 0xfb, '?', 0, 'v', 'q', 'l', 'g', 0, 0
.db 0xf7, ':', 'z', 'u', 'p', 'k', 'f', 'c', 0
.db 0xef, ' ', 'y', 't', 'o', 'j', 'e', 'b', 0
.db 0xdf, 0, 'x', 's', 'n', 'i', 'd', 'a', KBD_KEY_ALPHA
.db 0xbf, 0, 0, 0, 0, 0, KBD_KEY_2ND, 0, 0x7f

View File

@ -153,13 +153,6 @@ lcdSendGlyph:
ld a, (LCD_CURCOL)
call lcdSetCol
; let's increase (and wrap) col now
inc a
ld (LCD_CURCOL), a
cp 16
jr nz, .skip
call lcdLinefeed
.skip:
ld b, FNT_HEIGHT
.loop:
ld a, (hl)
@ -167,6 +160,14 @@ lcdSendGlyph:
call lcdData
djnz .loop
; Increase column and wrap if necessary
ld a, (LCD_CURCOL)
inc a
ld (LCD_CURCOL), a
cp 16
jr nz, .skip
call lcdLinefeed
.skip:
pop hl
pop bc
pop af
@ -240,6 +241,8 @@ lcdClrScr:
lcdPutC:
cp ASCII_LF
jp z, lcdLinefeed
cp ASCII_BS
jr z, .bs
push hl
call fntGet
jr nz, .end
@ -247,3 +250,11 @@ lcdPutC:
.end:
pop hl
ret
.bs:
ld a, (LCD_CURCOL)
or a
ret z ; going back one line is too complicated.
; not implemented yet
dec a
ld (LCD_CURCOL), a
ret

View File

@ -1,6 +1,6 @@
# TI-84+
**This is a work-in-progress, this is far from complete.**
**This is a work-in-progress**
## Recipe
@ -25,7 +25,7 @@ You will start with a blank screen, it's normal, you haven't pressed the "ON"
key yet. This key is mapped to F12 in the emulator. Once you press it, the
Collapse OS prompt will appear.
**WIP: the keyboard does nothing else than halting the CPU for now.**
See z80e's `KEYBINDINGS.md` file for details.
## Upload to the calculator
@ -51,6 +51,29 @@ Press "1" to continue.
When this is done, you can press the ON button to see Collapse OS' prompt!
## Usage
The shell works like a normal shell, but with very tight screen space.
When pressing a "normal" key, it spits the symbol associated to it depending
on the current mode. In normal mode, it spits the digit/symbol. In Alpha mode,
it spits the letter. In Alpha+2nd, it spits the uppercase letter.
Special keys are Alpha and 2nd. Pressing them toggles the associated mode.
Alpha and 2nd mode don't persist for more than one character. After the
character is spit, mode reset to normal.
Pressing 2nd then Alpha will toggle the A-Lock mode, which is a persistent mode.
The A-Lock mode makes Alpha enabled all the time. While A-Lock mode is enabled,
you have to enable Alpha to spit a digit/symbol.
Simultaneous keypresses have undefined behavior. One of the keys will be
registered as pressed. Mode key don't work by simultaneously pressing them with
a "normal" key. The presses must be sequential.
Keys that aren't a digit, a letter, a symbol that is part of 7-bit ASCII or one
of the two mode key have no effect.
[knightos]: https://knightos.org/
[z80e]: https://github.com/KnightOS/z80e
[mktiupgrade]: https://github.com/KnightOS/mktiupgrade