Add activity spinner
This commit is contained in:
+66
-2
@@ -9,6 +9,10 @@ lcd_ctrl equ 0dah
|
|||||||
celcius_offset equ 08ah
|
celcius_offset equ 08ah
|
||||||
pressure_offset equ 0cah
|
pressure_offset equ 0cah
|
||||||
humid_offset equ 09eh
|
humid_offset equ 09eh
|
||||||
|
spinner_offset equ 0e7h ; line 4, column 20 on a 20x4 panel
|
||||||
|
|
||||||
|
bs_char equ 01h ; cgram slot holding our backslash
|
||||||
|
bs_cgram equ 048h ; set cgram address, slot 1 row 0
|
||||||
|
|
||||||
bdos equ 0005h
|
bdos equ 0005h
|
||||||
conout equ 02h
|
conout equ 02h
|
||||||
@@ -26,6 +30,8 @@ start:
|
|||||||
call init_siob
|
call init_siob
|
||||||
call lcd_delay
|
call lcd_delay
|
||||||
|
|
||||||
|
call load_glyphs
|
||||||
|
|
||||||
ld a,celcius_offset ; write celcius label
|
ld a,celcius_offset ; write celcius label
|
||||||
out (lcd_ctrl),a
|
out (lcd_ctrl),a
|
||||||
call lcd_delay
|
call lcd_delay
|
||||||
@@ -47,10 +53,13 @@ start:
|
|||||||
main:
|
main:
|
||||||
call read_char_b ; never blocks now
|
call read_char_b ; never blocks now
|
||||||
jr nc,check_quit ; wire is idle, go look at the keyboard
|
jr nc,check_quit ; wire is idle, go look at the keyboard
|
||||||
|
ld hl,rx_seen
|
||||||
|
ld (hl),0ffh ; note traffic, a holds the char untouched
|
||||||
call parse_char
|
call parse_char
|
||||||
jr main ; drain the sio while it still has data
|
jr main ; drain the sio while it still has data
|
||||||
|
|
||||||
check_quit:
|
check_quit:
|
||||||
|
call spin_tick ; keep the spinner turning while idle
|
||||||
ld c,dconio ; direct console i/o, no echo
|
ld c,dconio ; direct console i/o, no echo
|
||||||
ld e,0ffh ; ff polls, returning zero if no key
|
ld e,0ffh ; ff polls, returning zero if no key
|
||||||
call bdos
|
call bdos
|
||||||
@@ -93,6 +102,21 @@ init_lcd:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
load_glyphs: ; the a00 rom has yen at 5ch, so draw our own backslash
|
||||||
|
ld a,bs_cgram
|
||||||
|
out (lcd_ctrl),a
|
||||||
|
call lcd_delay
|
||||||
|
ld hl,glyph_bs
|
||||||
|
ld e,08h ; eight rows, and e survives lcd_delay
|
||||||
|
glyph_row:
|
||||||
|
ld a,(hl)
|
||||||
|
out (lcd_data),a ; cgram address auto increments
|
||||||
|
call lcd_delay
|
||||||
|
inc hl
|
||||||
|
dec e
|
||||||
|
jr nz,glyph_row
|
||||||
|
ret
|
||||||
|
|
||||||
lcd_delay:
|
lcd_delay:
|
||||||
ld bc,500
|
ld bc,500
|
||||||
delay1:
|
delay1:
|
||||||
@@ -230,11 +254,44 @@ print_str_to_lcd: ; place memory address in hl f
|
|||||||
print_done:
|
print_done:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
spin_tick: ; count down, then step the spinner one frame
|
||||||
|
ld hl,(spin_cnt)
|
||||||
|
dec hl
|
||||||
|
ld (spin_cnt),hl
|
||||||
|
ld a,h ; dec hl leaves the flags alone
|
||||||
|
or l
|
||||||
|
ret nz ; not time yet
|
||||||
|
|
||||||
|
ld hl,spin_ticks ; reload, so the interval stays regular
|
||||||
|
ld (spin_cnt),hl
|
||||||
|
|
||||||
|
ld a,(rx_seen) ; did anything arrive this interval?
|
||||||
|
or a
|
||||||
|
ret z ; no, hold the frame and stop spinning
|
||||||
|
xor a
|
||||||
|
ld (rx_seen),a ; clear it for the next interval
|
||||||
|
|
||||||
|
ld a,(spin_idx)
|
||||||
|
inc a
|
||||||
|
and 03h ; four frames, then wrap
|
||||||
|
ld (spin_idx),a
|
||||||
|
|
||||||
|
ld hl,spinner
|
||||||
|
ld d,00h
|
||||||
|
ld e,a
|
||||||
|
add hl,de ; hl now points at the frame character
|
||||||
|
|
||||||
|
ld a,spinner_offset
|
||||||
|
out (lcd_ctrl),a ; park the cursor bottom right
|
||||||
|
call lcd_delay
|
||||||
|
ld a,(hl) ; fetch late, lcd_delay wrecks a and bc but not hl
|
||||||
|
out (lcd_data),a
|
||||||
|
call lcd_delay
|
||||||
|
ret
|
||||||
|
|
||||||
move_to_tempaddr:
|
move_to_tempaddr:
|
||||||
ld c,a
|
|
||||||
ld a,85h
|
ld a,85h
|
||||||
out (lcd_ctrl),a
|
out (lcd_ctrl),a
|
||||||
ld a,c
|
|
||||||
call lcd_delay
|
call lcd_delay
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@ -256,6 +313,13 @@ hlabel: DB '% RH',0
|
|||||||
|
|
||||||
quitmsg: DB 'Press Q to quit',0dh,0ah,'$'
|
quitmsg: DB 'Press Q to quit',0dh,0ah,'$'
|
||||||
|
|
||||||
|
spinner: DB '-','/','|',bs_char
|
||||||
|
glyph_bs: DB 00h,10h,08h,04h,02h,01h,00h,00h
|
||||||
|
spin_ticks equ 3000 ; idle polls per frame, tune on real hardware
|
||||||
|
spin_idx DB 03h ; wraps to the first frame on the next tick
|
||||||
|
spin_cnt DW spin_ticks
|
||||||
|
rx_seen DB 00h ; set on every byte off the sio
|
||||||
|
|
||||||
char_max equ 15
|
char_max equ 15
|
||||||
char_cnt DB 0
|
char_cnt DB 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user