Compare commits
5 Commits
2988fb9059
...
dce0719796
Author | SHA1 | Date | |
---|---|---|---|
dce0719796
|
|||
abeecf4e93
|
|||
180fc932c9
|
|||
f0104c74c2
|
|||
18a5615b53
|
@@ -6,6 +6,15 @@
|
||||
|
||||
BUZBEE IMPORT
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; BUZBEE Variables
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
BBIN_BASE EQU $0200
|
||||
BBIN_DEPTH EQU $7F
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; BUZBEE Structures
|
||||
@@ -13,5 +22,5 @@ BUZBEE IMPORT
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
BBVARS STRUCT
|
||||
INPUT rmb $7F
|
||||
INPUT rmb BBIN_DEPTH
|
||||
ENDSTRUCT
|
||||
|
81
src/buzbee.s
81
src/buzbee.s
@@ -2,6 +2,8 @@
|
||||
; Copyright (c) 2025 Gale Faraday
|
||||
; Licensed under MIT
|
||||
|
||||
INCLUDE "buzbee.inc"
|
||||
INCLUDE "hardware.inc"
|
||||
INCLUDE "serial.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 !!!"
|
||||
|
@@ -7,3 +7,12 @@
|
||||
INITUART IMPORT
|
||||
POUTCHAR IMPORT
|
||||
POUTZSTR IMPORT
|
||||
PINCHAR IMPORT
|
||||
|
||||
; POUTZSTR wrapper macro
|
||||
PZSTR MACRO
|
||||
pshs x
|
||||
ldx #\1
|
||||
jsr POUTZSTR
|
||||
puls x
|
||||
ENDM
|
||||
|
@@ -15,6 +15,7 @@
|
||||
EXPORT INITUART
|
||||
EXPORT POUTCHAR
|
||||
EXPORT POUTZSTR
|
||||
EXPORT PINCHAR
|
||||
|
||||
; Initializes the UART with LCR settings and a BAUD rate from DIVISORS.
|
||||
; ACCA: Index of the divsor to use in DIVISORS
|
||||
|
Reference in New Issue
Block a user