From 46ee7e476e34385f1b579857b499b636800e3429 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 19 Jul 2020 12:34:41 +0200 Subject: [PATCH] some more size/speed optimizations --- src/basic/engine_editor/find_line_38K_60K.s | 9 +++--- src/basic/engine_editor/find_line_46K_50K.s | 30 ++++++++++++++----- .../engine_runtime/execute_line_statements.s | 5 ++-- .../is_line_pointer_null_38K_60K.s} | 14 ++------- .../is_line_pointer_null_46K_50K.s} | 25 ++++------------ 5 files changed, 36 insertions(+), 47 deletions(-) rename src/basic/{peek_line_pointer_null_check_38K_60K.s => engine_runtime/is_line_pointer_null_38K_60K.s} (74%) rename src/basic/{peek_line_pointer_null_check_46K_50K.s => engine_runtime/is_line_pointer_null_46K_50K.s} (62%) diff --git a/src/basic/engine_editor/find_line_38K_60K.s b/src/basic/engine_editor/find_line_38K_60K.s index 8a52c25c..309975da 100644 --- a/src/basic/engine_editor/find_line_38K_60K.s +++ b/src/basic/engine_editor/find_line_38K_60K.s @@ -19,9 +19,8 @@ find_line_from_current: // Check if line is not empty - jsr peek_line_pointer_null_check - bcc find_line_fail - + jsr is_line_pointer_null + beq find_line_fail // Fetch the high byte of line number and compare ldy #$03 @@ -62,8 +61,8 @@ find_line_next: // Advance to the next line - jsr peek_line_pointer_null_check - bcc find_line_fail // branch in no more lines exist + jsr is_line_pointer_null + beq find_line_fail // branch in no more lines exist ldy #$00 diff --git a/src/basic/engine_editor/find_line_46K_50K.s b/src/basic/engine_editor/find_line_46K_50K.s index 235129d3..da797733 100644 --- a/src/basic/engine_editor/find_line_46K_50K.s +++ b/src/basic/engine_editor/find_line_46K_50K.s @@ -25,8 +25,8 @@ find_line_from_current: // Check if line is not empty - jsr find_line_null_ptr_check // we can't use 'peek_line_pointer_null_check', it maps out/in the BASIC ROM - beq_16 remap_BASIC_sec_rts // search failed if there is no program + jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM + beq remap_BASIC_sec_rts // search failed if there is no program // Fetch the high byte of line number and compare @@ -35,7 +35,7 @@ find_line_from_current: cmp LINNUM+1 beq !+ - bcs_16 remap_BASIC_sec_rts // search failed if line number too high + bcs remap_BASIC_sec_rts // search failed if line number too high bne find_line_next !: // Fetch the low byte of line number and compare @@ -44,16 +44,16 @@ find_line_from_current: lda (OLDTXT),y cmp LINNUM+0 - beq_16 remap_BASIC_clc_rts - bcs_16 remap_BASIC_sec_rts // search failed if line number too high + beq remap_BASIC_clc_rts + bcs remap_BASIC_sec_rts // search failed if line number too high bne find_line_next find_line_next: // Advance to the next line - jsr find_line_null_ptr_check // we can't use 'peek_line_pointer_null_check', it maps out/in the BASIC ROM - beq_16 remap_BASIC_sec_rts // search failed if no more line exists + jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM + beq remap_BASIC_sec_rts // search failed if no more line exists ldy #$00 lda (OLDTXT),y @@ -83,4 +83,20 @@ find_line_null_ptr_check: rts +remap_BASIC_clc_rts: + + lda #$27 + sta CPU_R6510 + + clc + rts + +remap_BASIC_sec_rts: + + lda #$27 + sta CPU_R6510 + + sec + rts + #endif diff --git a/src/basic/engine_runtime/execute_line_statements.s b/src/basic/engine_runtime/execute_line_statements.s index 40ad1821..3ac95047 100644 --- a/src/basic/engine_runtime/execute_line_statements.s +++ b/src/basic/engine_runtime/execute_line_statements.s @@ -189,9 +189,8 @@ execute_line: // Check if pointer is null, if so, we are at the end of the program - ldy #0 - jsr peek_line_pointer_null_check - bcc_16 shell_main_loop // branch if end of program reached + jsr is_line_pointer_null + beq_16 shell_main_loop // branch if end of program reached // Skip pointer and line number to get address of first statement diff --git a/src/basic/peek_line_pointer_null_check_38K_60K.s b/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s similarity index 74% rename from src/basic/peek_line_pointer_null_check_38K_60K.s rename to src/basic/engine_runtime/is_line_pointer_null_38K_60K.s index 7f3457f4..5ca5b151 100644 --- a/src/basic/peek_line_pointer_null_check_38K_60K.s +++ b/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s @@ -2,13 +2,12 @@ // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE -// Return C=1 if a pointer in BASIC memory space is NULL, else C=0 -// X = ZP pointer to check +// Return pointer in BASIC memory space status in Z flag #if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K -peek_line_pointer_null_check: +is_line_pointer_null: // Check the pointer @@ -32,16 +31,7 @@ peek_line_pointer_null_check: lda (OLDTXT),y #endif - bne !+ - - // Pointer is NULL - - clc - rts !: - // Pointer not NULL - - sec rts #endif diff --git a/src/basic/peek_line_pointer_null_check_46K_50K.s b/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s similarity index 62% rename from src/basic/peek_line_pointer_null_check_46K_50K.s rename to src/basic/engine_runtime/is_line_pointer_null_46K_50K.s index da4856be..0f743885 100644 --- a/src/basic/peek_line_pointer_null_check_46K_50K.s +++ b/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s @@ -4,13 +4,12 @@ // This has to go $E000 or above - routine below banks out the main BASIC ROM! -// Return C=1 if a pointer in BASIC memory space is NULL, else C=0 -// X = ZP pointer to check +// Return pointer in BASIC memory space status in Z flag #if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K -peek_line_pointer_null_check: +is_line_pointer_null: // Unmap BASIC lower ROM @@ -25,28 +24,14 @@ peek_line_pointer_null_check: dey lda (OLDTXT),y - bne !+ // branch if pointer not NULL - - // Pointer is NULL - - // FALLTROUGH - -remap_BASIC_clc_rts: - - lda #$27 - sta CPU_R6510 - - clc - rts !: - // Pointer not NULL -remap_BASIC_sec_rts: + // Restore memory mapping and quit + php lda #$27 sta CPU_R6510 - - sec + plp rts #endif