Mercurial > hg > index.cgi
changeset 61:a0f7c8768867
Add SHIFT-@ handling for BREAK check
This adds SHIFT-@ handling to the BREAK check routine. It has to do the same
thing as BREAK so that it works even if the keyboard buffer is full. Note
that after using SHIFT-@, the keyboard buffer is emptied while the wait for
a key press occurs.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 20 Feb 2023 16:13:40 -0700 |
parents | 1190f66329ab |
children | eba95ed43423 |
files | src/lwbasic.s |
diffstat | 1 files changed, 37 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lwbasic.s Mon Feb 20 15:22:29 2023 -0700 +++ b/src/lwbasic.s Mon Feb 20 16:13:40 2023 -0700 @@ -538,6 +538,41 @@ fcc 'WIZARD ENTERPRISES INC.\r\n' fcn '\n' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Check for BREAK; this needs to check the keyboard directly instead of just using the usual key fetching routine so +; we don't interfere with keyboard buffering if BREAK isn't pressed. We also need to scan the keyboard directly for this +; so we react even if the keyboard buffer is full. If BREAK is pressed, the keyboard buffer is emptied. +breakcheck lda #0xfb ; strobe column for BREAK + sta PIA0.DB + clra ; clear carry for no BREAK + lda PIA0.DA ; read rows + bita #0x40 ; is BREAK down? + bne breakcheck0 ; brif not - check for SHIFT-@ + sync ; wait for interrupt to scan keyboard + bsr keyb_clearbuff ; reset keyboard buffer + coma ; flag BREAK +breakcheck1 rts +breakcheck0 lda #0x7f ; check for SHIFT + sta PIA0.DB + lda PIA0.DA + bita #0x40 ; shift? + bne breakcheck1 ; brif not + lda #0xfe ; check for @ + sta PIA0.DB + lda PIA0.DA + bita #1 ; @? + bne breakcheck1 ; brif not + bsr keyb_clearbuff ; clear buffer +breakcheck2 sync ; wait for keyboard to actually be scanned + bsr keyb_getkey + bcs breakcheck2 ; brif no key down + bra breakcheck ; go do the break/pause check dance again +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Empty the keyboard buffer +keyb_clearbuff ldx #keyb_buff ; point to start of buffer + stx keyb_buffr ; set both pointers to the start + stx keyb_buffw + rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; IRQ handler ; ; Note that the interrupt flag in the PIA is cleared at the start of the interrupt handler. That means that if it takes @@ -589,9 +624,7 @@ ; Console keyboard input driver ; ; Reset the keyboard state, which means clearing the buffer and state flags -keyb_reset ldx #keyb_buff ; point to start of keyboard ring buffer - stx keyb_buffw ; set write point there - stx keyb_buffr ; set read point there (pointers equal means empty buffer) +keyb_reset bsr keyb_clearbuff ; clear keyboard buffer lda keyb_flags ; reset keyboard state flags but keep capslock anda #keyb_caps sta keyb_flags @@ -1236,22 +1269,6 @@ clr contstmt+1 jmp ,x ; return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Check for BREAK; this needs to check the keyboard directly instead of just using the usual key fetching routine so -; we don't interfere with keyboard buffering if BREAK isn't pressed. We also need to scan the keyboard directly for this -; so we react even if the keyboard buffer is full. If BREAK is pressed, the keyboard buffer is emptied. -breakcheck lda #0xfb ; strobe column for BREAK - sta PIA0.DB - clra ; clear carry for no BREAK - lda PIA0 ; read rows - bita #0x40 ; is BREAK down? - bne breakcheck0 ; brif not - just return - sync ; wait for interrupt to scan keyboard - ldx #keyb_buff ; reset keyboard buffer - stx keyb_buffr - stx keyb_buffw - coma ; flag BREAK -breakcheck0 rts -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Main interpretation loop ; ; Enter at interpret with inputptr pointing to the code stream to interpret. @@ -1259,7 +1276,7 @@ ; command stream has completed. STOP or BREAK will return with carry set while END or falling off the end of the ; code will return with carry clear. In the event of an error, the usual error processing will be done and control ; will return to immediate mode with the stack reset. -interpret bsr breakcheck ; check for BREAK +interpret jsr breakcheck ; check for BREAK bcs cmd_stop0 ; brif BREAK detected - go stop the program ldx inputptr ; get interpration address stx curstmt ; save address of the current statement (needed for some stuff)