optimization in variable search
This commit is contained in:
1 parent
46ee7e476e
commit
b440034414
5 files changed
+52
-17
No files matched your search
@@ -25,7 +25,7 @@ find_line_from_current:
|
|||||||
|
|
||||||
// Check if line is not empty
|
// 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
|
beq remap_BASIC_sec_rts // search failed if there is no program
|
||||||
|
|
||||||
// Fetch the high byte of line number and compare
|
// Fetch the high byte of line number and compare
|
||||||
@@ -52,7 +52,7 @@ find_line_next:
|
|||||||
|
|
||||||
// Advance to the next line
|
// 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
|
beq remap_BASIC_sec_rts // search failed if no more line exists
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
@@ -68,7 +68,7 @@ find_line_next:
|
|||||||
|
|
||||||
jmp_8 find_line_from_current
|
jmp_8 find_line_from_current
|
||||||
|
|
||||||
find_line_null_ptr_check:
|
line_pointer_null_check: // reused by 'is_line_pointer_null'
|
||||||
|
|
||||||
// Check the pointer
|
// Check the pointer
|
||||||
|
|
||||||
@@ -82,7 +82,6 @@ find_line_null_ptr_check:
|
|||||||
!:
|
!:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
remap_BASIC_clc_rts:
|
remap_BASIC_clc_rts:
|
||||||
|
|
||||||
lda #$27
|
lda #$27
|
||||||
|
|||||||
@@ -16,15 +16,9 @@ is_line_pointer_null:
|
|||||||
lda #$26
|
lda #$26
|
||||||
sta CPU_R6510
|
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
|
jsr line_pointer_null_check
|
||||||
lda (OLDTXT),y
|
|
||||||
bne !+ // branch if pointer not NULL
|
|
||||||
|
|
||||||
dey
|
|
||||||
lda (OLDTXT),y
|
|
||||||
!:
|
|
||||||
|
|
||||||
// Restore memory mapping and quit
|
// Restore memory mapping and quit
|
||||||
|
|
||||||
@@ -32,6 +26,7 @@ is_line_pointer_null:
|
|||||||
lda #$27
|
lda #$27
|
||||||
sta CPU_R6510
|
sta CPU_R6510
|
||||||
plp
|
plp
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -130,13 +130,15 @@ fetch_variable_find_addr_loop:
|
|||||||
// Compare current variable name with searched one
|
// Compare current variable name with searched one
|
||||||
// XXX consider creating optimized version for 46K/50K memory models
|
// 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
|
ldy #$00
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<VARPNT
|
ldx #<VARPNT
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_VARPNT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (VARPNT),y
|
lda (VARPNT),y
|
||||||
#endif
|
#endif
|
||||||
@@ -148,13 +150,14 @@ fetch_variable_find_addr_loop:
|
|||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_VARPNT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (VARPNT),y
|
lda (VARPNT),y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmp VARNAM+1
|
cmp VARNAM+1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bne fetch_variable_find_addr_next
|
bne fetch_variable_find_addr_next
|
||||||
|
|
||||||
// FALLTROUGH
|
// 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# * BASIC_0 #TAKE-HIGH
|
||||||
// #LAYOUT# * * #IGNORE
|
// #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
|
// Helper routine to copy string descriptor
|
||||||
|
|||||||
Reference in new issue
Block a user