can now store a single line of basic into memory

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-28 01:06:16 +09:30
1 parent 580b7961a5
commit 64dbdcdefb
4 files changed
+92 -10

No files matched your search

+53
View File
@@ -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 #<basic_current_line_ptr
lda basic_line_number+0
jsr poke_under_roms
iny
lda basic_line_number+1
jsr poke_under_roms
;; Now store the line body itself
line_store_loop:
ldx tokenise_work1
lda $0200,x
inc tokenise_work1
ldx #<basic_current_line_ptr
iny
jsr poke_under_roms
lda tokenise_work1
cmp tokenise_work2
bne line_store_loop
sec
rts
+10
View File
@@ -91,6 +91,16 @@ ml_bad_line_number:
;; Got a valid line number.
;; Skip any spaces after the line number
ldx tokenise_work1
skip_spaces:
lda $0200,x
cmp #$20
bne +
inx
bne skip_spaces
* stx tokenise_work1
;; First, clear all variables, so that we only have to shove BASIC text around.
;; (We could later remove this requirement, and the only effect should be
;; to slow things down, and that you might have to either CLR if there is no
+27 -9
View File
@@ -30,31 +30,49 @@ basic_shift_mem_up_and_relink:
;; To make life simple for the copy routine that lives in RAM,
;; we have to adjust the end pointers down one page and set Y to the low
;; byte of the copy size.
tay
dec memmove_src+1
dec memmove_dst+1
lda memmove_src+0
sec
sbc memmove_size+0
sta memmove_src+0
lda memmove_src+1
sbc #0
sta memmove_src+1
lda memmove_dst+0
sec
sbc memmove_size+0
sta memmove_dst+0
lda memmove_dst+1
sbc #0
sta memmove_dst+1
;; Now make exit easy, by being able to check for zero on size high byte when done
inc memmove_size+1
;; Then set Y to the number offset required
ldy memmove_size+0
;; Do the copy
jsr shift_mem_up
;; Now fix the pointer for the BASIC lines
;; Now fix the pointer to the next line
;; First, we need to point the current BASIC line
;; pointer to the previously present lines
stx tokenise_work3
relink_up_next_line:
ldx tokenise_work3
lda tokenise_work3
clc
adc basic_current_line_ptr+0
sta memmove_src+0
lda basic_current_line_ptr+1
adc #0
sta memmove_src+1
ldx #0
ldy #<basic_current_line_ptr
ldy #0
ldx #<basic_current_line_ptr
lda memmove_src+0
jsr poke_under_roms
inx
iny
lda memmove_src+1
jsr poke_under_roms
+2 -1
View File
@@ -39,7 +39,6 @@ smu1:
lda (memmove_src),y
sta (memmove_dst),y
dey
cpy #$ff
bne smu1
dec memmove_src+1
dec memmove_dst+1
@@ -70,8 +69,10 @@ memmap_normal_routine:
memmap_allram_routine:
sei
pha
lda #$04
sta $01
pla
rts
ram_routines_end: