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