feat(buzbee): implement buzbee input processing

This commit is contained in:
2025-09-27 10:38:36 -05:00
parent f0104c74c2
commit 180fc932c9
2 changed files with 82 additions and 6 deletions

View File

@@ -8,10 +8,9 @@ BUZBEE IMPORT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BUZBEE Structures
;; BUZBEE Variables
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BBVARS STRUCT
INPUT rmb $7F
ENDSTRUCT
BBIN_BASE EQU $0200
BBIN_DEPTH EQU $7F

View File

@@ -2,7 +2,9 @@
; Copyright (c) 2025 Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
INCLUDE "buzbee.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -15,8 +17,83 @@
EXPORT BUZBEE
BUZBEE
jsr INITBBVARS
bsr NEWLINE ; Setup the new input line and handle display.
bsr INPLOOP ; Fill input buffer.
cmpy #$0000 ; No data?
beq BUZBEE ; Try again...
; TODO: Parse the input buffer
bra BUZBEE
; Handle new lines; prints a new prompt and then clears the input buffer
NEWLINE
PZSTR PROMPTLINE ; Print prompt line
CLRIN ; Label to just clear input buffer without newline
clra ; Init A and X
ldx #$0000
NEXT@
sta BBIN_BASE,x ; Clear input buffer
leax 1,x
cmpx #BBIN_DEPTH
blo NEXT@
ldy #$0000 ; Reset buffer fill pointer
rts
INITBBVARS
; Fills input buffer with characters from the serial console. Sets Y to the
; offset in the input buffer of the last char read.
INPLOOP
jsr PINCHAR ; Try to read a char
cmpd #$0000 ; If no char keep waitin'
beq INPLOOP
bitb #UARTF_LSR_DR ; Is there a char in A?
beq NOCHAR@
cmpa #$1B ; ESC?
beq HESC@ ; Handle ESC
cmpa #$0D ; CR?
beq EXIT@ ; Then parse input buffer
cmpy #BBIN_DEPTH ; Are we at the end of the input buffer?
beq FULLBUF@ ; Handle the buffer being full
sta BBIN_BASE,y ; Add it to the input buffer
leay 1,y
NOCHAR@
; Check for error condition, work based on The Serial Port release 19
bitb #(UARTF_LSR_FIFO|UARTF_LSR_BI|UARTF_LSR_FE|UARTF_LSR_PE|UARTF_LSR_OE)
beq INPLOOP
bitb #UARTF_LSR_OE ; Check for overrun error
beq NOOVER@
PZSTR EM_OVERRUN
NOOVER@
bitb #UARTF_LSR_PE ; Check for parity error
beq NOPARITY@
PZSTR EM_PARITY
NOPARITY@
bitb #UARTF_LSR_FE ; Check for framing error
beq NOFRAM@
PZSTR EM_FRAMING
NOFRAM@
bitb #UARTF_LSR_FIFO ; Check for FIFO error
beq INPLOOP
PZSTR EM_FIFO
bra INPLOOP
EXIT@
rts
HESC@
lda #'^ ; Print a char that signifies that ESC was pressed
jsr POUTCHAR
ldy #$0000 ; On return we cmpy #$0000 and if eq then newline.
rts
FULLBUF@
lda #$07 ; ASCII BEL
jsr POUTCHAR
bra INPLOOP
PROMPTLINE
fcb $0D,$0A,$25,$00 ; CR LF '%' NUL
EM_OVERRUN
fcn "!!! Overrun Error !!!"
EM_PARITY
fcn "!!! Parity Error !!!"
EM_FRAMING
fcn "!!! Framing Error !!!"
EM_FIFO
fcn "!!! FIFO Error !!!"