GOTO command got performance optimization
This commit is contained in:
1 parent
a17f810d50
commit
76ed0d1f9f
4 files changed
+73
-28
No files matched your search
@@ -6,32 +6,83 @@
|
||||
cmd_run:
|
||||
|
||||
// RUN clears all variables
|
||||
|
||||
jsr do_clr
|
||||
|
||||
cmd_goto:
|
||||
// Initialize OLDTXT pointer, disable Kernal messages
|
||||
|
||||
// XXX optimize this: deduplicate last part (and init_oldtxt) with load/verify,
|
||||
// if line number greater than current line - find line backwards
|
||||
|
||||
// Disable Kernal messages
|
||||
jsr init_oldtxt
|
||||
lda #$00
|
||||
jsr JSETMSG
|
||||
|
||||
// Reset line pointer to first line of program.
|
||||
jsr init_oldtxt
|
||||
// Check if we have any paramenters
|
||||
|
||||
jsr is_end_of_statement
|
||||
bcs !+
|
||||
bcs cmd_run_goto_launch
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_goto:
|
||||
|
||||
// GOTO requires line number
|
||||
|
||||
jsr fetch_line_number
|
||||
bcs_16 do_SYNTAX_error
|
||||
jsr find_line
|
||||
bcc !+
|
||||
// Line does not exist, so report error
|
||||
jmp do_UNDEFD_STATEMENT_error
|
||||
|
||||
// Check for direct mode
|
||||
|
||||
lda CURLIN+1
|
||||
bmi cmd_goto_direct
|
||||
|
||||
// Not a direct mode - compare desired line number (LINNUM) with the current one (CURLIN)
|
||||
|
||||
lda LINNUM+1
|
||||
cmp CURLIN+1
|
||||
bne !+
|
||||
lda LINNUM+0
|
||||
cmp CURLIN+0
|
||||
!:
|
||||
// If desired line number is lower - search line number from start
|
||||
|
||||
bcc cmd_goto_from_start
|
||||
|
||||
// Else - search from the current line
|
||||
|
||||
jsr find_line_from_current
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
bra cmd_goto_check
|
||||
#else
|
||||
jmp cmd_goto_check
|
||||
#endif
|
||||
|
||||
cmd_goto_direct:
|
||||
|
||||
// Disable Kernal messages
|
||||
|
||||
lda #$00
|
||||
jsr JSETMSG
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_goto_from_start:
|
||||
|
||||
// Direct mode - find the line from the beginning
|
||||
|
||||
jsr find_line_from_start
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_goto_check:
|
||||
|
||||
bcs_16 do_UNDEFD_STATEMENT_error
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_run_goto_launch:
|
||||
|
||||
// Run it!
|
||||
|
||||
|
||||
pha
|
||||
pha
|
||||
jmp execute_line
|
||||
@@ -3,23 +3,17 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// Find the BASIC line with number LINNUM
|
||||
|
||||
// XXX it should be possible to start from the current line (OLDTXT), or from the startup,
|
||||
// depending on the current and target line number
|
||||
// Find the BASIC line with number in LINNUM
|
||||
|
||||
|
||||
find_line:
|
||||
find_line_from_start:
|
||||
|
||||
// Get pointer to start of BASIC text
|
||||
lda TXTTAB+0
|
||||
sta OLDTXT+0
|
||||
lda TXTTAB+1
|
||||
sta OLDTXT+1
|
||||
jsr init_oldtxt
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
find_line_loop:
|
||||
find_line_from_current:
|
||||
|
||||
// Check if line is not empty
|
||||
|
||||
@@ -100,9 +94,9 @@ find_line_next:
|
||||
sta OLDTXT+0
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
bra find_line_loop
|
||||
bra find_line_from_current
|
||||
#else
|
||||
jmp find_line_loop
|
||||
jmp find_line_from_current
|
||||
#endif
|
||||
|
||||
find_line_fail:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
insert_line:
|
||||
|
||||
// ASSUMES find_line has been called to set the insert point.
|
||||
// ASSUMES find_line_from_start has been called to set the insert point.
|
||||
|
||||
// jsr printf
|
||||
// .text "INSERTING LINE AT $"
|
||||
|
||||
@@ -169,12 +169,12 @@ shell_add_delete_line:
|
||||
jsr update_VARTAB_do_clr
|
||||
|
||||
// Check if line already present
|
||||
jsr find_line
|
||||
jsr find_line_from_start
|
||||
bcs !+
|
||||
|
||||
// Line already present - delete it
|
||||
jsr delete_line
|
||||
jsr find_line // refresh OLDTXT
|
||||
jsr find_line_from_start // refresh OLDTXT
|
||||
!:
|
||||
// Insert new line if non-zero length, i.e., that
|
||||
// we are not just deleting the line.
|
||||
|
||||
Reference in new issue
Block a user