// #LAYOUT# STD * #TAKE // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE varstr_garbage_collect: // The routine utilizes the 'shift_mem_up' - which leaves INDEX+0 and INDEX+1 // free to be used, but INDEX+2 and beyond would be overwritten // We will reuse TXTPTR as the moving pointer, so store it on the stack lda TXTPTR+0 pha lda TXTPTR+1 pha // Similarly, we will reuse OLDTXT as the pointer to string descriptor lda OLDTXT+0 pha lda OLDTXT+1 pha // INDEX+0 and INDEX+1 will be our cumulative shift counter lda #$00 sta INDEX+0 sta INDEX+1 // Start from the highest string and go downwards lda MEMSIZ+0 sta TXTPTR+0 lda MEMSIZ+1 sta TXTPTR+1 varstr_garbage_collect_loop: // Check if this was the last (lowest) string (if FRETOP == TXTPTR) lda FRETOP+1 cmp TXTPTR+1 bne varstr_garbage_collect_check_bptr lda FRETOP+0 cmp TXTPTR+0 bne varstr_garbage_collect_check_bptr // End of strings - adapt FRETOP clc lda INDEX+0 adc FRETOP+0 sta FRETOP+0 lda INDEX+1 adc FRETOP+1 sta FRETOP+1 // FALLTROUGH varstr_garbage_collect_end: // Restore OLDTXT and TXTPTR, and quit pla sta OLDTXT+1 pla sta OLDTXT+0 pla sta TXTPTR+1 pla sta TXTPTR+0 rts varstr_garbage_collect_check_bptr: // Decrement TXTPTR by 2, so that it points to the back-pointer #if !HAS_OPCODES_65CE02 lda #$02 jsr helper_TXTPTR_down_A #else // HAS_OPCODES_65CE02 dew TXTPTR dew TXTPTR #endif // Copy the back-pointer to OLDTXT, check if it is NULL ldy #$00 #if CONFIG_MEMORY_MODEL_60K ldx #