one more string aloccation optimization - for extended ROM machines
This commit is contained in:
1 parent
4c648a7891
commit
54a6daa2c1
4 files changed
+148
-8
No files matched your search
@@ -364,3 +364,10 @@
|
|||||||
.const CONFIG_COLOR_TXT = $01
|
.const CONFIG_COLOR_TXT = $01
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Determine if we need space-savings in BASIC code
|
||||||
|
|
||||||
|
#if !ROM_LAYOUT_M65
|
||||||
|
#define HAS_SMALL_BASIC
|
||||||
|
#endif
|
||||||
@@ -243,14 +243,15 @@ assign_string_not_same:
|
|||||||
|
|
||||||
assign_string_not_text_area:
|
assign_string_not_text_area:
|
||||||
|
|
||||||
// Check if the new string is a temporary one - if so, reuse alocation
|
|
||||||
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
// Check if the old string belongs to the string area (is above FRETOP)
|
// Check if the old string belongs to the string area (is above FRETOP)
|
||||||
|
|
||||||
jsr helper_cmp_fretop
|
jsr helper_cmp_fretop
|
||||||
|
|
||||||
|
#if HAS_SMALL_BASIC
|
||||||
bcc assign_string_no_optimizations
|
bcc assign_string_no_optimizations
|
||||||
|
#else
|
||||||
|
bcc assign_string_try_takeover
|
||||||
|
#endif
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
@@ -261,18 +262,27 @@ assign_string_try_reuse:
|
|||||||
lda DSCPNT+0
|
lda DSCPNT+0
|
||||||
cmp __FAC1+0
|
cmp __FAC1+0
|
||||||
|
|
||||||
|
#if HAS_SMALL_BASIC
|
||||||
|
|
||||||
// If size of both string equals - simply reuse it
|
// If size of both string equals - simply reuse it
|
||||||
|
|
||||||
beq_16 helper_strvarcpy
|
beq_16 helper_strvarcpy
|
||||||
|
|
||||||
assign_string_try_reuse_unsuccesful:
|
|
||||||
|
|
||||||
// No special case optimization is possible - but first get rid of the old string
|
// No special case optimization is possible - but first get rid of the old string
|
||||||
|
|
||||||
jsr varstr_free
|
jsr varstr_free
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// If size of both string equals - simply reuse it
|
||||||
|
|
||||||
|
bne assign_string_try_takeover_free
|
||||||
|
jmp helper_strvarcpy
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
assign_string_no_optimizations:
|
assign_string_no_optimizations:
|
||||||
|
|
||||||
// Allocate memory for the new string
|
// Allocate memory for the new string
|
||||||
@@ -296,3 +306,126 @@ assign_string_no_optimizations:
|
|||||||
// Copy the string and quit
|
// Copy the string and quit
|
||||||
|
|
||||||
jmp helper_strvarcpy
|
jmp helper_strvarcpy
|
||||||
|
|
||||||
|
|
||||||
|
#if !HAS_SMALL_BASIC
|
||||||
|
|
||||||
|
assign_string_try_takeover_free:
|
||||||
|
|
||||||
|
jsr varstr_free
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
assign_string_try_takeover:
|
||||||
|
|
||||||
|
// Check if the new string is a temporary one - if so, takeover the allocation
|
||||||
|
|
||||||
|
ldx #$19
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
assign_string_tmp_check_loop:
|
||||||
|
|
||||||
|
cpx TEMPPT
|
||||||
|
beq assign_string_no_optimizations // branch if this is not a temporary string
|
||||||
|
|
||||||
|
lda $01, x
|
||||||
|
cmp __FAC1+1
|
||||||
|
bne assign_string_tmp_check_next
|
||||||
|
|
||||||
|
lda $02, x
|
||||||
|
cmp __FAC1+2
|
||||||
|
bne assign_string_tmp_check_next
|
||||||
|
|
||||||
|
lda $01, x
|
||||||
|
beq assign_string_tmp_check_next
|
||||||
|
|
||||||
|
// This is a temporary string - takeover the content
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
phx_trash_a
|
||||||
|
lda $00, x
|
||||||
|
ldx #<VARPNT
|
||||||
|
jsr poke_under_roms
|
||||||
|
plx_trash_a
|
||||||
|
|
||||||
|
iny
|
||||||
|
phx_trash_a
|
||||||
|
lda $01, x
|
||||||
|
sta INDEX+0
|
||||||
|
ldx #<VARPNT
|
||||||
|
jsr poke_under_roms
|
||||||
|
plx_trash_a
|
||||||
|
|
||||||
|
iny
|
||||||
|
phx_trash_a
|
||||||
|
lda $02, x
|
||||||
|
sta INDEX+1
|
||||||
|
ldx #<VARPNT
|
||||||
|
jsr poke_under_roms
|
||||||
|
plx_trash_a
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda $00, x
|
||||||
|
sta (VARPNT), y
|
||||||
|
|
||||||
|
iny
|
||||||
|
lda $01, x
|
||||||
|
sta INDEX+0
|
||||||
|
sta (VARPNT), y
|
||||||
|
|
||||||
|
iny
|
||||||
|
lda $02, x
|
||||||
|
sta INDEX+1
|
||||||
|
sta (VARPNT), y
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Mark the temporary string as free
|
||||||
|
|
||||||
|
lda #$00
|
||||||
|
sta $00, x
|
||||||
|
|
||||||
|
// Now we need to copy VARPNT to back-pointer
|
||||||
|
|
||||||
|
lda __FAC1+0
|
||||||
|
jsr helper_INDEX_up_A
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
ldx #<INDEX
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda VARPNT+0
|
||||||
|
jsr poke_under_roms
|
||||||
|
|
||||||
|
iny
|
||||||
|
lda VARPNT+1
|
||||||
|
jsr poke_under_roms
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda VARPNT+0
|
||||||
|
sta (INDEX), y
|
||||||
|
|
||||||
|
iny
|
||||||
|
lda VARPNT+1
|
||||||
|
sta (INDEX), y
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
assign_string_tmp_check_next:
|
||||||
|
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
bne assign_string_tmp_check_loop // branch always
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
helper_INDEX_up_A: // .A - bytes to increase TXTPTR, uses DSCPNT+0
|
helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSCPNT+0
|
||||||
|
|
||||||
sta DSCPNT+0
|
sta DSCPNT+0
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
helper_INDEX_up_A: // .A - bytes to increase TXTPTR, uses DSCPNT+0
|
helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSCPNT+0
|
||||||
|
|
||||||
sta DSCPNT+0
|
sta DSCPNT+0
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user