added backpointer rewrite for memory models 46K/50K

This commit is contained in:
FeralChild64 committed 2020-08-02 12:21:50 +02:00
1 parent 1682cc8934
commit dcbe9d6c5e
4 files changed
+120 -11

No files matched your search

@@ -177,11 +177,6 @@ fetch_variable_alocate_adjust_vars:
// We need to recreate the back-pointers to string arrays
lda ARYTAB+0
sta INDEX+0
lda ARYTAB+1
sta INDEX+1
jsr helper_array_refresh_bptrs
// Fill-in the new variable name and descriptor (it is enough to zero first 2 bytes of content)
@@ -6,9 +6,6 @@
// Refresh back-pointer to arrays
//
#if CONFIG_MEMORY_MODEL_38K // XXX! create versions for other memory models
helper_array_refresh_bptrs:
// Refresh back-pointers to arrays
@@ -33,6 +30,17 @@ helper_array_refresh_bptrs_loop_1:
!:
// Calculate start address of the next array, store it in INDEX+2/+3
#if CONFIG_MEMORY_MODEL_60K
// XXX!
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr helper_array_refresh_bptrs_part1
bcs helper_array_refresh_bptrs_loop_next
#else // CONFIG_MEMORY_MODEL_38K
ldy #$02
lda (INDEX+0), y // XXX
@@ -62,15 +70,27 @@ helper_array_refresh_bptrs_loop_1:
adc #$05
jsr helper_INDEX_up_A
#endif
// FALLTROUGH
helper_array_refresh_bptrs_loop_2:
// Recreate the back-pointer
#if CONFIG_MEMORY_MODEL_60K
// XXX!
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr helper_array_refresh_bptrs_part2
#else // CONFIG_MEMORY_MODEL_38K
ldy #$00
lda (INDEX+0), y // XXX
beq helper_array_refresh_bptrs_skip // skip empty strings
beq !+ // skip empty strings
iny
clc
@@ -87,6 +107,8 @@ helper_array_refresh_bptrs_loop_2:
iny
lda INDEX+1
sta (INDEX+4), y // XXX
!:
#endif
// FALLTROUGH
@@ -118,5 +140,3 @@ helper_array_refresh_bptrs_loop_next:
helper_array_refresh_bptrs_end:
rts
#endif
@@ -0,0 +1,51 @@
// #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!
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
helper_array_refresh_bptrs_part1:
// Unmap BASIC lower ROM
lda #$26
sta CPU_R6510
// Calculate start address of the next array, store it in INDEX+2/+3
ldy #$02
lda (INDEX+0), y // XXX
clc
adc INDEX+0
sta INDEX+2
iny
lda (INDEX+0), y // XXX
adc INDEX+1
sta INDEX+3
// Check if the current array is a string - if not, go to next array
ldy #$00
lda (INDEX+0), y // XXX
bmi_16 remap_BASIC_sec_rts
iny
lda (INDEX+0), y // XXX
bpl_16 remap_BASIC_sec_rts
// It's a string array - scroll INDEX+0/+1 to the first descriptor
ldy #$04
lda (INDEX+0), y // XXX
asl
clc
adc #$05
jsr helper_INDEX_up_A
!:
// Restore default memory mapping
jmp remap_BASIC_clc_rts
#endif
@@ -0,0 +1,43 @@
// #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!
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
helper_array_refresh_bptrs_part2:
// Unmap BASIC lower ROM
lda #$26
sta CPU_R6510
// Write new back-pointer
ldy #$00
lda (INDEX+0), y
beq !+
iny
clc
adc (INDEX+0), y
sta INDEX+4
iny
lda #$00
adc (INDEX+0), y
sta INDEX+5
ldy #$00
lda INDEX+0
sta (INDEX+4), y
iny
lda INDEX+1
sta (INDEX+4), y
!:
// Restore default memory mapping
jmp remap_BASIC
#endif