begin implementing memory copy routines for inserting and deleting BASIC lines.
This commit is contained in:
1 parent
b7de93a3a6
commit
84c02486fe
3 files changed
+66
-2
No files matched your search
@@ -39,9 +39,12 @@
|
||||
.alias basic_fac2_exponent $69
|
||||
.alias basic_fac2_mantissa $6A ; $6A - $6D
|
||||
.alias basic_fac2_sign $6E
|
||||
|
||||
|
||||
|
||||
;; We also re-use FAC2 for memory move pointers, since
|
||||
;; we can't be doing calculations while moving memory
|
||||
.alias memmove_src $69
|
||||
.alias memmove_dst $6b
|
||||
.alias memmove_size $6d
|
||||
|
||||
.alias TXTTAB $2B
|
||||
.alias IOSTATUS $90
|
||||
@@ -123,6 +126,7 @@
|
||||
;; a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured.
|
||||
.alias missed_nmi_flag $2A7
|
||||
.alias tiny_nmi_handler $2A8
|
||||
.alias shift_mem_up tiny_nmi_handler+shift_mem_up_routine-tiny_nmi_handler_routine
|
||||
.alias peek_under_roms tiny_nmi_handler+peek_under_roms_routine-tiny_nmi_handler_routine
|
||||
.alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine
|
||||
.alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine
|
||||
|
||||
@@ -105,6 +105,7 @@ ml_bad_line_number:
|
||||
|
||||
;; Delete line if present
|
||||
jsr basic_find_line
|
||||
|
||||
bcs +
|
||||
jsr basic_delete_line
|
||||
*
|
||||
|
||||
@@ -20,6 +20,43 @@ install_ram_routines:
|
||||
sta $FFFF
|
||||
|
||||
rts
|
||||
|
||||
basic_shift_mem_up_and_relink:
|
||||
;; Shift memory up from basic_current_line_ptr
|
||||
;; X bytes.
|
||||
|
||||
;; Work out end point of destination
|
||||
txa
|
||||
clc
|
||||
adc basic_end_of_text_ptr+0
|
||||
sta memmove_dst+0
|
||||
lda basic_end_of_text_ptr+1
|
||||
adc #0
|
||||
sta memmove_dst+1
|
||||
;; End point of source is just current end of BASIC text
|
||||
lda basic_end_of_text_ptr+0
|
||||
sta memmove_src
|
||||
lda basic_end_of_text_ptr+1
|
||||
sta memmove_src+1
|
||||
|
||||
;; Work out size of region to copy
|
||||
lda basic_end_of_text_ptr+1
|
||||
sec
|
||||
sbc basic_current_line_ptr+1
|
||||
sta memmove_size+1
|
||||
lda basic_end_of_text_ptr+0
|
||||
sbc #0
|
||||
sta memmove_size+0
|
||||
|
||||
;; 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
|
||||
|
||||
;; Do the copy
|
||||
jmp shift_mem_up
|
||||
|
||||
ram_routines_start:
|
||||
|
||||
@@ -27,6 +64,28 @@ tiny_nmi_handler_routine:
|
||||
inc missed_nmi_flag
|
||||
rti
|
||||
|
||||
shift_mem_up_routine:
|
||||
;; Move memmove_size bytes from memmove_src to memmove_dst,
|
||||
;; where memmove_dst > memmove_src
|
||||
;; This means we have to copy from the back end down.
|
||||
;; This routine assumes the pointers are already pointed
|
||||
;; to the end of the areas, and that Y is correctly initialised
|
||||
;; to allow the copy to begin.
|
||||
jsr memmap_allram
|
||||
smu1:
|
||||
lda (memmove_src),y
|
||||
sta (memmove_dst),y
|
||||
dey
|
||||
cpy #$ff
|
||||
bne smu1
|
||||
dec memmove_src+1
|
||||
dec memmove_dst+1
|
||||
dec memmove_size+1
|
||||
bne smu1
|
||||
|
||||
jmp memmap_normal
|
||||
|
||||
|
||||
peek_under_roms_routine:
|
||||
stx peek_under_roms+7 ;Offset of arg of lda ($00),y
|
||||
jsr memmap_allram
|
||||
|
||||
Reference in new issue
Block a user