From 64dbdcdefb98a906ea3a26a0a49daf72af2516c8 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sun, 28 Apr 2019 01:06:16 +0930 Subject: [PATCH] can now store a single line of basic into memory --- c64/basic/basic_insert_line.s | 53 ++++++++++++++++++++++++++++++++++ c64/basic/basic_main_loop.s | 10 +++++++ c64/basic/basic_shift_mem_up.s | 36 +++++++++++++++++------ c64/basic/under_rom_routines.s | 3 +- 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/c64/basic/basic_insert_line.s b/c64/basic/basic_insert_line.s index 9bad7286..f89ddfbc 100644 --- a/c64/basic/basic_insert_line.s +++ b/c64/basic/basic_insert_line.s @@ -6,6 +6,59 @@ ;; Then all we have to do is push the rest of the BASIC text up, ;; and update the pointers in all following basic lines. basic_insert_line: + + ;; ASSUMES basic_find_line has been called to set the insert point. + ;; We need to insert space for the link link token, the line number, + ;; and the zero-terminated line itself. This means 2+2+1 plus length + ;; of tokenised string after the line number + + ;; But first, remember where the pointer will be, so that we can + ;; put the line in there after. + lda basic_current_line_ptr+0 + pha + lda basic_current_line_ptr+1 + pha + + ;; Get number of bytes in tokenised line after line number + lda tokenise_work2 + sec + sbc tokenise_work1 + ;; Add on the four bytes space we need + clc + adc #5 + tax + ;; Make the space + jsr basic_shift_mem_up_and_relink + + ;; Get pointer back + pla + sta basic_current_line_ptr+1 + pla + sta basic_current_line_ptr+0 + + inc $0427 + ;; Write the line number + ldy #2 + ldx #