some more size/speed optimizations

This commit is contained in:
FeralChild64 committed 2020-07-19 12:34:41 +02:00
1 parent fc3a40a254
commit 46ee7e476e
5 files changed
+36 -47

No files matched your search

+4 -5
View File
@@ -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
+23 -7
View File
@@ -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
@@ -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
@@ -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
@@ -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