fix several bugs with storing BASIC lines

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-28 02:07:17 +09:30
1 parent d2e4822f37
commit 5a5be5d8ec
4 files changed
+34 -8

No files matched your search

+18 -7
View File
@@ -11,23 +11,27 @@ basic_find_line:
basic_find_line_loop:
;; Then search for line number
;; Line number
ldy #3
ldx #<basic_current_line_ptr
jsr peek_under_roms
cmp basic_line_number+1
beq +
bcs line_num_too_high
bne not_this_line
*
dey
jsr peek_under_roms
cmp basic_line_number+0
beq +
bcs line_num_too_high
bne not_this_line
*
clc
rts
not_this_line:
;; Not this line, so advance to next line
ldy #0
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
bcs more_lines_exist
@@ -37,11 +41,18 @@ line_num_too_high:
sec
rts
more_lines_exist:
;; A = high byte of line
pha
dey
;; XXX - Add program mangled check here to be triggered
;; if the link goes backwards.
;; Follow link to next line
ldy #0
ldx #<basic_current_line_ptr
jsr peek_under_roms
sta $0100
iny
jsr peek_under_roms
sta basic_current_line_ptr+0
pla
sta basic_current_line_ptr+1
lda $0100
sta basic_current_line_ptr+0
jmp basic_find_line_loop
+4
View File
@@ -15,8 +15,10 @@ basic_insert_line:
;; But first, remember where the pointer will be, so that we can
;; put the line in there after.
lda basic_current_line_ptr+0
sta $0438
pha
lda basic_current_line_ptr+1
sta $0439
pha
;; Get number of bytes in tokenised line after line number
@@ -43,8 +45,10 @@ basic_insert_line:
;; Get pointer back
pla
sta $0411
sta basic_current_line_ptr+1
pla
sta $0410
sta basic_current_line_ptr+0
inc $0427
+11
View File
@@ -82,6 +82,7 @@ rsl_l1: lda $0200,x
ora basic_fac1_exponent
beq +
ml_bad_line_number:
inc $0424
;; Syntax error
ldx #10
jmp do_basic_error
@@ -113,9 +114,19 @@ skip_spaces:
lda basic_fac1_mantissa+1
sta basic_line_number+1
lda basic_current_line_ptr+0
sta $0420
lda basic_current_line_ptr+1
sta $0421
;; Delete line if present
jsr basic_find_line
lda basic_current_line_ptr+0
sta $0420
lda basic_current_line_ptr+1
sta $0421
bcs +
jsr basic_delete_line
*
+1 -1
View File
@@ -14,7 +14,7 @@ basic_shift_mem_up_and_relink:
sta memmove_dst+1
;; End point of source is just current end of BASIC text
lda basic_end_of_text_ptr+0
sta memmove_src
sta memmove_src+0
lda basic_end_of_text_ptr+1
sta memmove_src+1