optimization in variable search

This commit is contained in:
FeralChild64 committed 2020-07-19 12:56:51 +02:00
1 parent 46ee7e476e
commit b440034414
5 files changed
+52 -17

No files matched your search

+3 -4
View File
@@ -25,7 +25,7 @@ find_line_from_current:
// Check if line is not empty
jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
jsr line_pointer_null_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
@@ -52,7 +52,7 @@ find_line_next:
// Advance to the next line
jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
jsr line_pointer_null_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
@@ -68,7 +68,7 @@ find_line_next:
jmp_8 find_line_from_current
find_line_null_ptr_check:
line_pointer_null_check: // reused by 'is_line_pointer_null'
// Check the pointer
@@ -82,7 +82,6 @@ find_line_null_ptr_check:
!:
rts
remap_BASIC_clc_rts:
lda #$27
@@ -16,15 +16,9 @@ is_line_pointer_null:
lda #$26
sta CPU_R6510
// Check the pointer
// Check the pointer - reuse code from other routine
ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL
lda (OLDTXT),y
bne !+ // branch if pointer not NULL
dey
lda (OLDTXT),y
!:
jsr line_pointer_null_check
// Restore memory mapping and quit
@@ -32,6 +26,7 @@ is_line_pointer_null:
lda #$27
sta CPU_R6510
plp
rts
#endif
+7 -4
View File
@@ -130,13 +130,15 @@ fetch_variable_find_addr_loop:
// Compare current variable name with searched one
// XXX consider creating optimized version for 46K/50K memory models
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr helper_cmp_varnam
#else
ldy #$00
#if CONFIG_MEMORY_MODEL_60K
ldx #<VARPNT
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_VARPNT
#else // CONFIG_MEMORY_MODEL_38K
lda (VARPNT),y
#endif
@@ -148,13 +150,14 @@ fetch_variable_find_addr_loop:
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_VARPNT
#else // CONFIG_MEMORY_MODEL_38K
lda (VARPNT),y
#endif
cmp VARNAM+1
#endif
bne fetch_variable_find_addr_next
// FALLTROUGH
@@ -0,0 +1,38 @@
// #LAYOUT# STD * #TAKE-HIGH
// #LAYOUT# * BASIC_0 #TAKE-HIGH
// #LAYOUT# * * #IGNORE
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
helper_cmp_varnam:
// Unmap BASIC lower ROM
lda #$26
sta CPU_R6510
// Compare variable name
ldy #$00
lda (VARPNT),y
cmp VARNAM+0
bne !+
iny
lda (VARPNT),y
cmp VARNAM+1
!:
// Restore default memory mapping
// XXX consider deduplicating with 'is_line_pointer_null'
php
lda #$27
sta CPU_R6510
plp
rts
#endif
@@ -2,7 +2,7 @@
// #LAYOUT# * BASIC_0 #TAKE-HIGH
// #LAYOUT# * * #IGNORE
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
// This has to go $E000 or above - routine below banks out the main BASIC ROM!
//
// Helper routine to copy string descriptor