From bc5e3cdbb9ea27ba03c8624f3e43444d7cccb340 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Mon, 29 Apr 2019 21:00:00 +0930 Subject: [PATCH] Fix Issue #15 --- c64/basic/basic_shift_mem_up.s | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/c64/basic/basic_shift_mem_up.s b/c64/basic/basic_shift_mem_up.s index c5731047..0a4cb357 100644 --- a/c64/basic/basic_shift_mem_up.s +++ b/c64/basic/basic_shift_mem_up.s @@ -4,6 +4,8 @@ basic_shift_mem_up_and_relink: ;; Shift memory up from basic_current_line_ptr ;; X bytes. + ;; NOTE: Pointers need to be reduced by one, due to the way + ;; the copyroutine works, so we do that here. ;; Work out end point of destination txa clc @@ -12,10 +14,21 @@ basic_shift_mem_up_and_relink: lda basic_end_of_text_ptr+1 adc #0 sta memmove_dst+1 + lda memmove_dst+0 + sec + sbc #1 + sta memmove_dst+0 + lda memmove_dst+1 + sbc #0 + sta memmove_dst+1 + ;; End point of source is just current end of BASIC text lda basic_end_of_text_ptr+0 + sec + sbc #1 sta memmove_src+0 lda basic_end_of_text_ptr+1 + sbc #0 sta memmove_src+1 ;; Work out size of region to copy @@ -67,6 +80,7 @@ basic_shift_mem_up_and_relink: ;; Then set Y to the number offset required ldy memmove_size+0 + iny stx tokenise_work3 @@ -102,16 +116,36 @@ relink_up_next_line: ;; inc $d020 ;; jmp relink_up_next_line + ;; Advance pointer by tokenise_word3 bytes ldy #0 ldx #basic_end_of_text_ptr + ;; .byte $f0,basic_end_of_text_ptr + ;; .byte $d," BEFORE = $" + ;; .byte $f1,memmove_dst + ;; .byte $f0,memmove_dst + ;; .byte ", AFTER = $" + ;; .byte $f1,memmove_src + ;; .byte $f0,memmove_src + ;; .byte $d + ;; .byte 0 + + ;; Write memmove_src back to current line pointer ldy #0 ldx #