fix several bugs with storing BASIC lines
This commit is contained in:
1 parent
d2e4822f37
commit
5a5be5d8ec
4 files changed
+39
-13
No files matched your search
@@ -10,38 +10,49 @@ basic_find_line:
|
|||||||
|
|
||||||
basic_find_line_loop:
|
basic_find_line_loop:
|
||||||
;; Then search for line number
|
;; Then search for line number
|
||||||
;; Line number
|
;; Line number
|
||||||
|
|
||||||
ldy #3
|
ldy #3
|
||||||
ldx #<basic_current_line_ptr
|
ldx #<basic_current_line_ptr
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
cmp basic_line_number+1
|
cmp basic_line_number+1
|
||||||
|
beq +
|
||||||
bcs line_num_too_high
|
bcs line_num_too_high
|
||||||
bne not_this_line
|
bne not_this_line
|
||||||
|
*
|
||||||
|
|
||||||
dey
|
dey
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
cmp basic_line_number+0
|
cmp basic_line_number+0
|
||||||
|
beq +
|
||||||
bcs line_num_too_high
|
bcs line_num_too_high
|
||||||
bne not_this_line
|
bne not_this_line
|
||||||
|
*
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
not_this_line:
|
not_this_line:
|
||||||
;; Not this line, so advance to next line
|
;; Not this line, so advance to next line
|
||||||
ldy #0
|
|
||||||
ldx #<basic_current_line_ptr
|
ldx #<basic_current_line_ptr
|
||||||
jsr peek_pointer_null_check
|
jsr peek_pointer_null_check
|
||||||
bcs more_lines_exist
|
bcs more_lines_exist
|
||||||
|
|
||||||
;; no more lines exist, return failure
|
;; no more lines exist, return failure
|
||||||
line_num_too_high:
|
line_num_too_high:
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
more_lines_exist:
|
more_lines_exist:
|
||||||
;; A = high byte of line
|
|
||||||
pha
|
;; XXX - Add program mangled check here to be triggered
|
||||||
dey
|
;; 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
|
jsr peek_under_roms
|
||||||
sta basic_current_line_ptr+0
|
|
||||||
pla
|
|
||||||
sta basic_current_line_ptr+1
|
sta basic_current_line_ptr+1
|
||||||
|
lda $0100
|
||||||
|
sta basic_current_line_ptr+0
|
||||||
|
|
||||||
jmp basic_find_line_loop
|
jmp basic_find_line_loop
|
||||||
@@ -15,8 +15,10 @@ basic_insert_line:
|
|||||||
;; But first, remember where the pointer will be, so that we can
|
;; But first, remember where the pointer will be, so that we can
|
||||||
;; put the line in there after.
|
;; put the line in there after.
|
||||||
lda basic_current_line_ptr+0
|
lda basic_current_line_ptr+0
|
||||||
|
sta $0438
|
||||||
pha
|
pha
|
||||||
lda basic_current_line_ptr+1
|
lda basic_current_line_ptr+1
|
||||||
|
sta $0439
|
||||||
pha
|
pha
|
||||||
|
|
||||||
;; Get number of bytes in tokenised line after line number
|
;; Get number of bytes in tokenised line after line number
|
||||||
@@ -43,8 +45,10 @@ basic_insert_line:
|
|||||||
|
|
||||||
;; Get pointer back
|
;; Get pointer back
|
||||||
pla
|
pla
|
||||||
|
sta $0411
|
||||||
sta basic_current_line_ptr+1
|
sta basic_current_line_ptr+1
|
||||||
pla
|
pla
|
||||||
|
sta $0410
|
||||||
sta basic_current_line_ptr+0
|
sta basic_current_line_ptr+0
|
||||||
|
|
||||||
inc $0427
|
inc $0427
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ rsl_l1: lda $0200,x
|
|||||||
ora basic_fac1_mantissa+3
|
ora basic_fac1_mantissa+3
|
||||||
ora basic_fac1_exponent
|
ora basic_fac1_exponent
|
||||||
beq +
|
beq +
|
||||||
ml_bad_line_number:
|
ml_bad_line_number:
|
||||||
|
inc $0424
|
||||||
;; Syntax error
|
;; Syntax error
|
||||||
ldx #10
|
ldx #10
|
||||||
jmp do_basic_error
|
jmp do_basic_error
|
||||||
@@ -113,8 +114,18 @@ skip_spaces:
|
|||||||
lda basic_fac1_mantissa+1
|
lda basic_fac1_mantissa+1
|
||||||
sta basic_line_number+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
|
;; Delete line if present
|
||||||
jsr basic_find_line
|
jsr basic_find_line
|
||||||
|
|
||||||
|
lda basic_current_line_ptr+0
|
||||||
|
sta $0420
|
||||||
|
lda basic_current_line_ptr+1
|
||||||
|
sta $0421
|
||||||
|
|
||||||
bcs +
|
bcs +
|
||||||
jsr basic_delete_line
|
jsr basic_delete_line
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ basic_shift_mem_up_and_relink:
|
|||||||
sta memmove_dst+1
|
sta memmove_dst+1
|
||||||
;; End point of source is just current end of BASIC text
|
;; End point of source is just current end of BASIC text
|
||||||
lda basic_end_of_text_ptr+0
|
lda basic_end_of_text_ptr+0
|
||||||
sta memmove_src
|
sta memmove_src+0
|
||||||
lda basic_end_of_text_ptr+1
|
lda basic_end_of_text_ptr+1
|
||||||
sta memmove_src+1
|
sta memmove_src+1
|
||||||
|
|
||||||
@@ -47,14 +47,14 @@ basic_shift_mem_up_and_relink:
|
|||||||
sta memmove_dst+1
|
sta memmove_dst+1
|
||||||
|
|
||||||
;; Now make exit easy, by being able to check for zero on size high byte when done
|
;; Now make exit easy, by being able to check for zero on size high byte when done
|
||||||
inc memmove_size+1
|
inc memmove_size+1
|
||||||
|
|
||||||
;; Then set Y to the number offset required
|
;; Then set Y to the number offset required
|
||||||
ldy memmove_size+0
|
ldy memmove_size+0
|
||||||
|
|
||||||
;; Do the copy
|
;; Do the copy
|
||||||
jsr shift_mem_up
|
jsr shift_mem_up
|
||||||
|
|
||||||
;; Now fix the pointer to the next line
|
;; Now fix the pointer to the next line
|
||||||
|
|
||||||
;; First, we need to point the current BASIC line
|
;; First, we need to point the current BASIC line
|
||||||
|
|||||||
Reference in new issue
Block a user