Skip to content

Commit

Permalink
scrntest: added "B" command to toggle blocking and non-blocking scree…
Browse files Browse the repository at this point in the history
…n_getchar
  • Loading branch information
andreasbaumann committed Dec 1, 2024
1 parent 3e45209 commit 463a7ee
Showing 1 changed file with 75 additions and 2 deletions.
77 changes: 75 additions & 2 deletions apps/scrntest.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
.zp style, 1
.zp ptr1, 2
.zp ptr2, 2
.zp kbd_blocking, 1
.zp spinner_pos, 1
.label string_init
.label string_a
.label chars_spinner
.label BIOS
.label SCREEN
.label update_cursor
Expand Down Expand Up @@ -59,6 +62,10 @@

lda #0
sta style
sta spinner_pos
lda #1
sta kbd_blocking

help:
\ Clear screen and print help
Expand Down Expand Up @@ -95,9 +102,55 @@ mainloop:
stx cur_y

timeout:
\ Show spinnig bar to test non-blocking keyboard read
lda #39
ldx #0
ldy #SCREEN_SETCURSOR
jsr SCREEN
ldy spinner_pos
iny
tya
cmp #4
.zif eq
ldy #0
.zendif
sty spinner_pos
ldx kbd_blocking
.zif ne
lda #'*'
.zendif
ldx kbd_blocking
.zif eq
lda chars_spinner, y
.zendif
ldy #SCREEN_PUTCHAR
jsr SCREEN

lda #39
ldx #1
ldy #SCREEN_SETCURSOR
jsr SCREEN
lda #32
ldy #SCREEN_PUTCHAR
jsr SCREEN
lda cur_x
ldx cur_y
ldy #SCREEN_SETCURSOR
jsr SCREEN

\ Get and parse command
lda #10
ldx #00
ldy kbd_blocking
.zif ne
lda #0xff
ldx #0x7f
.zendif
ldy kbd_blocking
.zif eq
lda #0x10
ldx #0x0
.zendif
ldy #SCREEN_GETCHAR
jsr SCREEN
bcs timeout \ make sure we don't have consecutive key presses because of short timeouts
Expand Down Expand Up @@ -252,6 +305,21 @@ case_done:
jsr SCREEN
jmp mainloop
.zendif
\ Toggle keyboard read mode
cmp #'B'
.zif eq
lda kbd_blocking
.zif eq
lda #1
sta kbd_blocking
jmp mainloop
.zendif
lda #0
sta kbd_blocking
jmp mainloop
.zendif
\ Clear screen and print help
cmp #'H'
Expand Down Expand Up @@ -402,6 +470,7 @@ string_init:
.byte "J - Scroll down\r\n"
.byte "L - Clear to End of Line\r\n"
.byte "I - Toggle style\r\n"
.byte "B - Toggle blocking/non-blocking read\r\n"
.byte "H - Clear screen and print this help\r\n"
.byte "Q - Quit\r\n"
.byte 0
Expand All @@ -410,3 +479,7 @@ string_a:
.byte "String"
.byte 0

chars_spinner:
.byte "-\\|/"
.byte 0

0 comments on commit 463a7ee

Please sign in to comment.