small cleanup in BASIC

This commit is contained in:
FeralChild64 committed 2020-06-28 08:32:25 +02:00
1 parent 5db25db3b5
commit 996327b335
3 files changed
+23 -24

No files matched your search

@@ -2,14 +2,12 @@
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
// Delete the current BASIC line, which is assumed to have already
// been found with find_line.
// Really only consists of copying memory down.
// The only complication is that we have to do the copy with ROMs
// banked out. Oh, yes, and we have to update all the links in
// the following basic lines.
//
// Delete the current BASIC line, which is assumed to have already been found with find_line.
// Consists of copying memory down and lline linkage update.
//
basic_delete_line:
delete_line:
// jsr printf
// .text "DELETING LINE AT $"
@@ -61,6 +59,7 @@ basic_delete_line:
sbc #0
cmp #$00
beq !+
// Line length is <0 or >255 bytes.
// Either way, things are bad, so abort.
jmp do_MEMORY_CORRUPT_error
@@ -2,17 +2,18 @@
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Insert the tokenised line stored at $0200.
// First work out where in the list to put it
// (basic_find_line with the line number can be used to work
// out the insertion point, as it should abort once it finds a
// line number too high).
//
// First work out where in the list to put it (find_line with the line number can be used to work
// out the insertion point, as it should abort once it finds a line number too high).
// Then all we have to do is push the rest of the BASIC text up,
// and update the pointers in all following basic lines.
//
basic_insert_line:
insert_line:
// ASSUMES basic_find_line has been called to set the insert point.
// ASSUMES find_line has been called to set the insert point.
// We need to insert space for the link link token, the line number,
// and the zero-terminated line itself. This means 2+2+1 plus length
// of tokenised string after the line number
@@ -36,6 +37,7 @@ basic_insert_line:
lda __tokenise_work2
sec
sbc __tokenise_work1
// Add on the four bytes space we need
clc
adc #5
@@ -82,7 +84,7 @@ basic_insert_line:
// Now store the line body itself
inc __tokenise_work2
line_store_loop:
!:
ldx __tokenise_work1
lda $0200,x
inc __tokenise_work1
@@ -97,7 +99,7 @@ line_store_loop:
lda __tokenise_work1
cmp __tokenise_work2
bne line_store_loop
bne !-
dec __tokenise_work2
clc
+7 -9
View File
@@ -148,24 +148,22 @@ shell_add_delete_line:
// First, clear all variables, so that we only have to shove BASIC text around
jsr basic_do_clr
.break
// Delete line if present
// Check if line already present
jsr find_line
// XXX
bcs !+
// Delete the line, whether we are deleting or
// replacing the line
jsr basic_delete_line
// Line already present - delete it
.break
jsr delete_line
!:
// Insert new line if non-zero length, i.e., that
// we are not just deleting the line.
lda __tokenise_work1
cmp __tokenise_work2
beq !+
jsr basic_insert_line
jsr insert_line
!:
// No READY message after entering or deleting a line of BASIC
jmp shell_read_next_line