add files for BASIC interpretor main loop and message printing
This commit is contained in:
1 parent
12a20d0962
commit
f2e2db3a4d
6 files changed
+110
-2
No files matched your search
@@ -53,6 +53,7 @@
|
|||||||
.alias rs232_rx_buffer_ptr $F7
|
.alias rs232_rx_buffer_ptr $F7
|
||||||
.alias rs232_tx_buffer_ptr $F9
|
.alias rs232_tx_buffer_ptr $F9
|
||||||
|
|
||||||
|
.alias basic_input_buffer $0200
|
||||||
|
|
||||||
; "Compute's Mapping the 64" book
|
; "Compute's Mapping the 64" book
|
||||||
.alias keyboard_buffer $0277
|
.alias keyboard_buffer $0277
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
;; Print string at $YYAA
|
||||||
|
;; Compute's Mapping the 64 p101
|
||||||
|
|
||||||
|
print_string:
|
||||||
|
;; Setup pointer
|
||||||
|
sty temp_string_ptr+1
|
||||||
|
sta temp_string_ptr+0
|
||||||
|
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
|
||||||
|
;; Get offset ready
|
||||||
|
ldy #$00
|
||||||
|
|
||||||
|
print_string_loop:
|
||||||
|
;; Save Y in X, since X is preserved by chrout, but Y is not
|
||||||
|
tya
|
||||||
|
tax
|
||||||
|
|
||||||
|
lda (temp_string_ptr),y
|
||||||
|
beq print_string_end
|
||||||
|
|
||||||
|
jsr $FFD2 ; KERNAL CHROUT
|
||||||
|
|
||||||
|
txa
|
||||||
|
tay
|
||||||
|
|
||||||
|
iny
|
||||||
|
bne print_string_loop
|
||||||
|
|
||||||
|
|
||||||
|
print_string_end:
|
||||||
|
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
rts
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
;; Compute's Mapping the 64 p93
|
||||||
|
|
||||||
|
basic_do_error:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
basic_error_messages:
|
||||||
|
.byte "TOO MANY FILES",0
|
||||||
|
.byte "FILE OPEN",0
|
||||||
|
.byte "FILE NOT OPEN",0
|
||||||
|
.byte "FILE NOT FOUND",0
|
||||||
|
.byte "DEVICE NOT PRESENT",0
|
||||||
|
.byte "NOT INPUT FILE",0
|
||||||
|
.byte "NOT OUTPUT FILE",0
|
||||||
|
.byte "MISSING FILENAME",0
|
||||||
|
.byte "ILLEGAL DEVICE NUMBER",0
|
||||||
|
.byte "NEXT WITHOUT FOR",0
|
||||||
|
.byte "SYNTAX",0
|
||||||
|
.byte "RETURN WITHOUT GOSUB",0
|
||||||
|
.byte "OUT OF DATA",0
|
||||||
|
.byte "ILLEGAL QUANTITY",0
|
||||||
|
.byte "OVERFLOW",0
|
||||||
|
.byte "OUT OF MEMORY",0
|
||||||
|
.byte "UNDEF'D STATEMENT",0
|
||||||
|
.byte "BAD SUBSCRIPT",0
|
||||||
|
.byte "REDIM'D ARRAY",0
|
||||||
|
.byte "DIVISION BY ZERO",0
|
||||||
|
.byte "ILLEGAL DIRECT",0
|
||||||
|
.byte "TYPE MISMATCH",0
|
||||||
|
.byte "STRING TOO LONG",0
|
||||||
|
.byte "FILE DATA",0
|
||||||
|
.byte "FORMULA TOO COMPLEX",0
|
||||||
|
.byte "CAN'T CONTINUE",0
|
||||||
|
.byte "UNDEF'D FUNCTION",0
|
||||||
|
.byte "VERIFY",0
|
||||||
|
.byte "LOAD",0
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
basic_main_loop:
|
||||||
|
|
||||||
|
;; XXX - Check if direct or program mode, and get next line of input
|
||||||
|
;; the appropriate way.
|
||||||
|
;; XXX - For now, it is hard coded to direct mode
|
||||||
|
|
||||||
|
;; Read a line of input
|
||||||
|
ldx #$00
|
||||||
|
read_line_loop:
|
||||||
|
jsr $ffe4 ; KERNAL CHRIN
|
||||||
|
cmp #$0d
|
||||||
|
beq got_line_of_input
|
||||||
|
;; Not carriage return, so try to append to line so far
|
||||||
|
cpx #80
|
||||||
|
bcc +
|
||||||
|
;; Report STRING TOO LONG error (Compute's Mapping the 64 p93)
|
||||||
|
ldx #23
|
||||||
|
jmp basic_do_error
|
||||||
|
*
|
||||||
|
sta basic_input_buffer,x
|
||||||
|
inx
|
||||||
|
jmp read_line_loop
|
||||||
|
|
||||||
|
got_line_of_input:
|
||||||
|
jsr ready_message
|
||||||
|
|
||||||
|
jmp basic_main_loop
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
;; Clear screen etc, show READY prompt.
|
;; Clear screen etc, show READY prompt.
|
||||||
|
|
||||||
basic_warm_start:
|
basic_warm_start:
|
||||||
* inc $d020
|
jsr ready_message
|
||||||
jmp -
|
jmp basic_main_loop
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ready_message:
|
||||||
|
;; See src/make_error_tables.c for packed message handling
|
||||||
|
;; information.
|
||||||
|
ldx #0
|
||||||
|
jmp print_packed_message
|
||||||
Reference in new issue
Block a user