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 // Check if line is not empty
jsr peek_line_pointer_null_check jsr is_line_pointer_null
bcc find_line_fail beq find_line_fail
// Fetch the high byte of line number and compare // Fetch the high byte of line number and compare
ldy #$03 ldy #$03
@@ -62,8 +61,8 @@ find_line_next:
// Advance to the next line // Advance to the next line
jsr peek_line_pointer_null_check jsr is_line_pointer_null
bcc find_line_fail // branch in no more lines exist beq find_line_fail // branch in no more lines exist
ldy #$00 ldy #$00
+23 -7
View File
@@ -25,8 +25,8 @@ 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 'peek_line_pointer_null_check', it maps out/in the BASIC ROM jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq_16 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
@@ -35,7 +35,7 @@ find_line_from_current:
cmp LINNUM+1 cmp LINNUM+1
beq !+ 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 bne find_line_next
!: !:
// Fetch the low byte of line number and compare // Fetch the low byte of line number and compare
@@ -44,16 +44,16 @@ find_line_from_current:
lda (OLDTXT),y lda (OLDTXT),y
cmp LINNUM+0 cmp LINNUM+0
beq_16 remap_BASIC_clc_rts beq remap_BASIC_clc_rts
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 bne find_line_next
find_line_next: find_line_next:
// Advance to the next line // 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 jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM
beq_16 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
lda (OLDTXT),y lda (OLDTXT),y
@@ -83,4 +83,20 @@ find_line_null_ptr_check:
rts rts
remap_BASIC_clc_rts:
lda #$27
sta CPU_R6510
clc
rts
remap_BASIC_sec_rts:
lda #$27
sta CPU_R6510
sec
rts
#endif #endif
@@ -189,9 +189,8 @@ execute_line:
// Check if pointer is null, if so, we are at the end of the program // Check if pointer is null, if so, we are at the end of the program
ldy #0 jsr is_line_pointer_null
jsr peek_line_pointer_null_check beq_16 shell_main_loop // branch if end of program reached
bcc_16 shell_main_loop // branch if end of program reached
// Skip pointer and line number to get address of first statement // Skip pointer and line number to get address of first statement
@@ -2,13 +2,12 @@
// #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE // #LAYOUT# * * #IGNORE
// Return C=1 if a pointer in BASIC memory space is NULL, else C=0 // Return pointer in BASIC memory space status in Z flag
// X = ZP pointer to check
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
peek_line_pointer_null_check: is_line_pointer_null:
// Check the pointer // Check the pointer
@@ -32,16 +31,7 @@ peek_line_pointer_null_check:
lda (OLDTXT),y lda (OLDTXT),y
#endif #endif
bne !+
// Pointer is NULL
clc
rts
!: !:
// Pointer not NULL
sec
rts rts
#endif #endif
@@ -4,13 +4,12 @@
// This has to go $E000 or above - routine below banks out the main BASIC ROM! // 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 // Return pointer in BASIC memory space status in Z flag
// X = ZP pointer to check
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K #if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
peek_line_pointer_null_check: is_line_pointer_null:
// Unmap BASIC lower ROM // Unmap BASIC lower ROM
@@ -25,28 +24,14 @@ peek_line_pointer_null_check:
dey dey
lda (OLDTXT),y 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 lda #$27
sta CPU_R6510 sta CPU_R6510
plp
sec
rts rts
#endif #endif