line search optimized
This commit is contained in:
1 parent
e85b5dbccf
commit
b48d576698
4 files changed
+157
-23
No files matched your search
@@ -6,6 +6,8 @@
|
|||||||
// Find the BASIC line with number in LINNUM
|
// Find the BASIC line with number in LINNUM
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
find_line_from_start:
|
find_line_from_start:
|
||||||
|
|
||||||
// Get pointer to start of BASIC text
|
// Get pointer to start of BASIC text
|
||||||
@@ -24,13 +26,9 @@ find_line_from_current:
|
|||||||
// Fetch the high byte of line number and compare
|
// Fetch the high byte of line number and compare
|
||||||
ldy #$03
|
ldy #$03
|
||||||
|
|
||||||
// XXX consider optimized 46K/50K version
|
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<OLDTXT+0
|
ldx #<OLDTXT+0
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_OLDTXT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
@@ -46,8 +44,6 @@ find_line_from_current:
|
|||||||
|
|
||||||
#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_OLDTXT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
@@ -69,15 +65,11 @@ find_line_next:
|
|||||||
jsr peek_line_pointer_null_check
|
jsr peek_line_pointer_null_check
|
||||||
bcc find_line_fail // branch in no more lines exist
|
bcc find_line_fail // branch in no more lines exist
|
||||||
|
|
||||||
// XXX consider optimized 46K/50K version
|
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<OLDTXT+0
|
ldx #<OLDTXT+0
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_OLDTXT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
@@ -87,8 +79,6 @@ find_line_next:
|
|||||||
|
|
||||||
#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_OLDTXT
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
@@ -103,3 +93,5 @@ find_line_fail:
|
|||||||
|
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE-HIGH
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
// This has to go $E000 or above - routine below banks out the main BASIC ROM!
|
||||||
|
|
||||||
|
// Find the BASIC line with number in LINNUM
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
find_line_from_start:
|
||||||
|
|
||||||
|
// Get pointer to start of BASIC text
|
||||||
|
jsr init_oldtxt
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
find_line_from_current:
|
||||||
|
|
||||||
|
// Unmap BASIC lower ROM
|
||||||
|
|
||||||
|
lda #$26
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
// Check if line is not empty
|
||||||
|
|
||||||
|
jsr peek_line_pointer_null_check
|
||||||
|
bcc find_line_fail
|
||||||
|
|
||||||
|
// Fetch the high byte of line number and compare
|
||||||
|
|
||||||
|
ldy #$03
|
||||||
|
lda (OLDTXT),y
|
||||||
|
|
||||||
|
cmp LINNUM+1
|
||||||
|
beq !+
|
||||||
|
bcs find_line_fail // branch if line number too high
|
||||||
|
bne find_line_next
|
||||||
|
!:
|
||||||
|
|
||||||
|
// Fetch the low byte of line number and compare
|
||||||
|
|
||||||
|
dey
|
||||||
|
lda (OLDTXT),y
|
||||||
|
|
||||||
|
cmp LINNUM+0
|
||||||
|
beq find_line_success
|
||||||
|
bcs find_line_fail // branch if line number too high
|
||||||
|
bne find_line_next
|
||||||
|
|
||||||
|
find_line_success:
|
||||||
|
|
||||||
|
// Restore default memory mapping and quit
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
find_line_next:
|
||||||
|
|
||||||
|
// Advance to the next line
|
||||||
|
|
||||||
|
jsr peek_line_pointer_null_check
|
||||||
|
bcc find_line_fail // branch in no more lines exist
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda (OLDTXT),y
|
||||||
|
|
||||||
|
pha
|
||||||
|
iny
|
||||||
|
lda (OLDTXT),y
|
||||||
|
|
||||||
|
sta OLDTXT+1
|
||||||
|
pla
|
||||||
|
sta OLDTXT+0
|
||||||
|
|
||||||
|
jmp_8 find_line_from_current
|
||||||
|
|
||||||
|
find_line_fail:
|
||||||
|
|
||||||
|
// Restore default memory mapping and quit
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
+14
-11
@@ -5,40 +5,43 @@
|
|||||||
// Return C=1 if a pointer in BASIC memory space is NULL, else C=0
|
// Return C=1 if a pointer in BASIC memory space is NULL, else C=0
|
||||||
// X = ZP pointer to check
|
// X = ZP pointer to check
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
peek_line_pointer_null_check:
|
peek_line_pointer_null_check:
|
||||||
|
|
||||||
ldy #$00
|
// Check the pointer
|
||||||
|
|
||||||
|
ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<OLDTXT+0
|
ldx #<OLDTXT+0
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
cmp #$00
|
cmp #$00
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_OLDTXT
|
|
||||||
cmp #$00
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bne ptr_not_null
|
bne !+
|
||||||
iny
|
dey
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
cmp #$00
|
cmp #$00
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
jsr peek_under_roms_via_OLDTXT
|
|
||||||
cmp #$00
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (OLDTXT),y
|
lda (OLDTXT),y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bne ptr_not_null
|
bne !+
|
||||||
|
|
||||||
// Pointer is NULL
|
// Pointer is NULL
|
||||||
|
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
!:
|
||||||
|
// Pointer not NULL
|
||||||
|
|
||||||
ptr_not_null:
|
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE-HIGH
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
peek_line_pointer_null_check:
|
||||||
|
|
||||||
|
// Unmap BASIC lower ROM
|
||||||
|
|
||||||
|
lda #$26
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
// Check the pointer
|
||||||
|
|
||||||
|
ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL
|
||||||
|
lda (OLDTXT),y
|
||||||
|
bne !+
|
||||||
|
|
||||||
|
dey
|
||||||
|
lda (OLDTXT),y
|
||||||
|
bne !+
|
||||||
|
|
||||||
|
// Pointer is NULL
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
!:
|
||||||
|
// Pointer not NULL
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user