BASIC editor rework finished
This commit is contained in:
1 parent
4bae8ae878
commit
8d705f2f6d
23 files changed
+302
-426
No files matched your search
@@ -22,7 +22,7 @@ cmd_merge_got_params:
|
||||
|
||||
// Make sure VARTAB is correctly set
|
||||
|
||||
jsr calculate_VARTAB
|
||||
jsr update_VARTAB_do_clr
|
||||
|
||||
// Perform loading - just for a different address
|
||||
|
||||
@@ -42,17 +42,9 @@ cmd_merge_got_params:
|
||||
|
||||
cmd_merge_no_error:
|
||||
|
||||
// Store last loaded address
|
||||
// Relink loaded program, clear variables
|
||||
|
||||
stx VARTAB+0
|
||||
sty VARTAB+1
|
||||
|
||||
// Clear the variables
|
||||
jsr do_clr
|
||||
|
||||
// Now relink the loaded program, line links supplied are almost certainly wrong
|
||||
|
||||
jsr LINKPRG
|
||||
jsr update_LINKPRG_VARTAB_do_clr
|
||||
|
||||
// XXX when number parsing is done, change to continue execution
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ cmd_old:
|
||||
tya
|
||||
sta (TXTTAB),y
|
||||
|
||||
jsr LINKPRG
|
||||
jsr calculate_VARTAB
|
||||
jsr update_LINKPRG_VARTAB_do_clr
|
||||
|
||||
// Quit
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
//
|
||||
// Shift the BASIC program down to cover the area of removed line
|
||||
//
|
||||
|
||||
|
||||
basic_shift_mem_down_and_relink:
|
||||
|
||||
// Destination is OLDTXT
|
||||
|
||||
lda OLDTXT+0
|
||||
sta memmove__dst+0
|
||||
lda OLDTXT+1
|
||||
sta memmove__dst+1
|
||||
|
||||
// Source is OLDTXT + .X
|
||||
|
||||
clc
|
||||
txa
|
||||
|
||||
adc OLDTXT+0
|
||||
sta memmove__src+0
|
||||
lda OLDTXT+1
|
||||
adc #$00
|
||||
sta memmove__src+1
|
||||
|
||||
// Size is distance from source (OLDTXT) to the end of BASIC text (VARTAB)
|
||||
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc memmove__src+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc memmove__src+1
|
||||
sta memmove__size+1
|
||||
|
||||
// The copy routine is simplified, so that it is fast and (for memory model 60K)
|
||||
// can fit in a small RAM area - therefore it requires to pre-set .Y, so that
|
||||
// the copy ends when it reaches 0; so if copying one byte we want .Y = $FF
|
||||
|
||||
sec
|
||||
lda #$00
|
||||
sbc memmove__size+0
|
||||
tay
|
||||
sty __tokenise_work3
|
||||
|
||||
// Now we have to move down the memmove_src and memmove_dst pointers
|
||||
// to compensate for .Y not being 0
|
||||
|
||||
sec
|
||||
lda memmove__src+0
|
||||
sbc __tokenise_work3
|
||||
sta memmove__src+0
|
||||
bcs !+
|
||||
dec memmove__src+1
|
||||
!:
|
||||
sec
|
||||
lda memmove__dst+0
|
||||
sbc __tokenise_work3
|
||||
sta memmove__dst+0
|
||||
bcs !+
|
||||
dec memmove__dst+1
|
||||
!:
|
||||
// Perform the copy XXX add more documentation inside the copy routine!
|
||||
|
||||
inc memmove__size+1
|
||||
jsr shift_mem_down
|
||||
|
||||
// Now fix program linkage and calculate VARTAB
|
||||
|
||||
jsr LINKPRG
|
||||
jmp calculate_VARTAB
|
||||
@@ -1,211 +0,0 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
basic_shift_mem_up_and_relink:
|
||||
// Shift memory up from OLDTXT
|
||||
// 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
|
||||
adc VARTAB+0
|
||||
sta memmove__dst+0
|
||||
lda VARTAB+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 VARTAB+0
|
||||
sec
|
||||
sbc #1
|
||||
sta memmove__src+0
|
||||
lda VARTAB+1
|
||||
sbc #0
|
||||
sta memmove__src+1
|
||||
|
||||
// Work out size of region to copy
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc OLDTXT+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc OLDTXT+1
|
||||
sta memmove__size+1
|
||||
|
||||
// jsr printf
|
||||
// .text "TOP OF BASIC = $"
|
||||
// .byte $f1,<VARTAB,>VARTAB
|
||||
// .byte $f0,<VARTAB,>VARTAB
|
||||
// .byte $0d
|
||||
// .text "SHIFTING UP $"
|
||||
// .byte $f1,<memmove__size,>memmove__size
|
||||
// .byte $f0,<memmove__size,>memmove__size
|
||||
// .text " BYTES FROM $"
|
||||
// .byte $f1,<memmove__src,>memmove__src
|
||||
// .byte $f0,<memmove__src,>memmove__src
|
||||
// .text " TO $"
|
||||
// .byte $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .byte $0d,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.
|
||||
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
|
||||
iny
|
||||
|
||||
stx __tokenise_work3
|
||||
|
||||
// jsr printf
|
||||
// .text "REVISED BOUNDS $"
|
||||
// .byte $f1,<memmove__size,>memmove__size
|
||||
// .byte $f0,<memmove__size,>memmove__size
|
||||
// .text " BYTES FROM $"
|
||||
// .byte $f1,<memmove__src,>memmove__src
|
||||
// .byte $f0,<memmove__src,>memmove__src
|
||||
// .text " TO $"
|
||||
// .byte $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .byte $0d,0
|
||||
|
||||
// Do the copy
|
||||
jsr shift_mem_up
|
||||
|
||||
// Now fix the pointer to the next line
|
||||
|
||||
// First, we need to point the current BASIC line
|
||||
// pointer to itself, so that we can add the shift
|
||||
// to make it end up pointing to the next line
|
||||
ldy #0
|
||||
|
||||
lda OLDTXT+0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
jsr poke_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
iny
|
||||
lda OLDTXT+1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr poke_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
relink_up_next_line:
|
||||
|
||||
// XXX reuse code from cmd_old
|
||||
|
||||
// Advance pointer by tokenise_word3 bytes
|
||||
ldy #0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
sta memmove__dst+0
|
||||
clc
|
||||
adc __tokenise_work3
|
||||
sta memmove__src+0
|
||||
iny
|
||||
php
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
jsr peek_under_roms_via_OLDTXT
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
sta memmove__dst+1
|
||||
plp
|
||||
adc #0
|
||||
sta memmove__src+1
|
||||
|
||||
// jsr printf
|
||||
// .text "LINE ADDR = $"
|
||||
// .byte $f1,<OLDTXT,>VARTAB
|
||||
// .byte $f0,<OLDTXT,>VARTAB
|
||||
// .text $d," BEFORE = $"
|
||||
// .byte $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .text ", AFTER = $"
|
||||
// .byte $f1,<memmove__src,>memmove__src
|
||||
// .byte $f0,<memmove__src,>memmove__src
|
||||
// .byte $d
|
||||
// .byte 0
|
||||
|
||||
// Write memmove__src back to current line pointer
|
||||
ldy #0
|
||||
lda memmove__src+0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
jsr poke_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
iny
|
||||
lda memmove__src+1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr poke_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
relink_up_loop:
|
||||
// Now advance pointer to the next line,
|
||||
lda memmove__src+0
|
||||
sta OLDTXT+0
|
||||
lda memmove__src+1
|
||||
sta OLDTXT+1
|
||||
|
||||
// Have we run out of lines to patch?
|
||||
jsr peek_line_pointer_null_check
|
||||
bcs relink_up_next_line
|
||||
|
||||
rts
|
||||
@@ -68,23 +68,11 @@ delete_line:
|
||||
// Length can now be safely assumed to be in the low
|
||||
// byte only, i.e., stored in __tokenise_work3
|
||||
|
||||
lda __tokenise_work3
|
||||
pha
|
||||
tax
|
||||
ldx __tokenise_work3
|
||||
|
||||
// Shuffle everything down
|
||||
jsr basic_shift_mem_down_and_relink
|
||||
jsr shift_txt_down
|
||||
|
||||
// Now decrease top of BASIC mem
|
||||
pla
|
||||
sta __tokenise_work3
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc __tokenise_work3
|
||||
sta VARTAB+0
|
||||
lda VARTAB+1
|
||||
sbc #0
|
||||
sta VARTAB+1
|
||||
// Finish by fixing program linkage and calculating new
|
||||
|
||||
clc
|
||||
rts
|
||||
jmp update_LINKPRG_VARTAB_do_clr
|
||||
@@ -14,57 +14,29 @@
|
||||
insert_line:
|
||||
|
||||
// ASSUMES 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.
|
||||
|
||||
// jsr printf
|
||||
// .text "INSERTING LINE AT $"
|
||||
// .byte $f1,<OLDTXT,>OLDTXT
|
||||
// .byte $f0,<OLDTXT,>OLDTXT
|
||||
// .byte $0d,0
|
||||
|
||||
lda OLDTXT+0
|
||||
pha
|
||||
lda OLDTXT+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
|
||||
// Add on the five bytes space we need (2 bytes for linkage, 2 bytes for line number, 1 byte for terminator)
|
||||
clc
|
||||
adc #5
|
||||
pha
|
||||
adc #$05
|
||||
tax
|
||||
|
||||
// Make the space
|
||||
jsr basic_shift_mem_up_and_relink
|
||||
jsr shift_txt_up
|
||||
|
||||
// Now increase top of BASIC mem
|
||||
pla
|
||||
clc
|
||||
adc VARTAB+0
|
||||
sta VARTAB+0
|
||||
lda VARTAB+1
|
||||
adc #0
|
||||
sta VARTAB+1
|
||||
|
||||
// Get pointer back
|
||||
pla
|
||||
sta OLDTXT+1
|
||||
pla
|
||||
sta OLDTXT+0
|
||||
|
||||
// Write the line number
|
||||
ldy #2
|
||||
lda LINNUM+0
|
||||
// Put dummy linkage, we will correct it later
|
||||
ldy #$01
|
||||
tya
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
@@ -73,6 +45,16 @@ insert_line:
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
// Put the line number
|
||||
iny
|
||||
lda LINNUM+0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr poke_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
sta (OLDTXT),y
|
||||
#endif
|
||||
|
||||
iny
|
||||
lda LINNUM+1
|
||||
|
||||
@@ -100,7 +82,12 @@ insert_line:
|
||||
lda __tokenise_work1
|
||||
cmp __tokenise_work2
|
||||
bne !-
|
||||
dec __tokenise_work2
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
update_LINKPRG_VARTAB_do_clr:
|
||||
|
||||
// Finish by fixing program linkage and calculating new VARTAB
|
||||
|
||||
jsr LINKPRG
|
||||
jmp update_VARTAB_do_clr
|
||||
@@ -153,7 +153,7 @@ shell_process_line:
|
||||
shell_add_delete_line:
|
||||
|
||||
// First make sure VARTAB is correct and clear all the variables
|
||||
jsr calculate_VARTAB
|
||||
jsr update_VARTAB_do_clr
|
||||
|
||||
// Check if line already present
|
||||
jsr find_line
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
//
|
||||
// Shift the BASIC program down to cover the area of removed line
|
||||
//
|
||||
|
||||
|
||||
shift_txt_down:
|
||||
|
||||
// First byte of destination is OLDTXT
|
||||
|
||||
lda OLDTXT+0
|
||||
sta memmove__dst+0
|
||||
lda OLDTXT+1
|
||||
sta memmove__dst+1
|
||||
|
||||
// First byte of source is memmove__dst + .X
|
||||
|
||||
clc
|
||||
txa
|
||||
|
||||
adc memmove__dst+0
|
||||
sta memmove__src+0
|
||||
lda memmove__dst+1
|
||||
adc #$00
|
||||
sta memmove__src+1
|
||||
|
||||
// Size is distance from source to the end of BASIC text (VARTAB)
|
||||
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc memmove__src+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc memmove__src+1
|
||||
sta memmove__size+1
|
||||
|
||||
// Perform the copy
|
||||
|
||||
jmp shift_mem_down
|
||||
@@ -0,0 +1,58 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
//
|
||||
// Shift the BASIC program up to make space for a new line
|
||||
//
|
||||
|
||||
|
||||
shift_txt_up:
|
||||
|
||||
// Last byte of source is VARTAB-1
|
||||
|
||||
#if !HAS_OPCODES_65CE02
|
||||
|
||||
sec
|
||||
lda VARTAB+0
|
||||
sbc #$01
|
||||
sta memmove__src+0
|
||||
lda VARTAB+1
|
||||
sbc #$00
|
||||
sta memmove__src+1
|
||||
|
||||
#else // HAS_OPCODES_65CE02
|
||||
|
||||
lda VARTAB+0
|
||||
sta memmove__src+0
|
||||
lda VARTAB+1
|
||||
sta memmove__src+1
|
||||
dew memmove__src
|
||||
|
||||
#endif
|
||||
|
||||
// Last byte of destination is memmove__src + .X
|
||||
|
||||
clc
|
||||
txa
|
||||
|
||||
adc memmove__src+0
|
||||
sta memmove__dst+0
|
||||
lda memmove__src+1
|
||||
adc #$00
|
||||
sta memmove__dst+1
|
||||
|
||||
// Size is distance from OLDTXT to the end of BASIC text (VARTAB)
|
||||
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc OLDTXT+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc OLDTXT+1
|
||||
sta memmove__size+1
|
||||
|
||||
// Perform the copy
|
||||
|
||||
jmp shift_mem_up
|
||||
@@ -6,7 +6,7 @@
|
||||
// Calculate the VARTAB value - to mark the end of BASIC program code. Also clears all variables.
|
||||
//
|
||||
|
||||
calculate_VARTAB:
|
||||
update_VARTAB_do_clr:
|
||||
|
||||
lda TXTTAB+0
|
||||
sta OLDTXT+0
|
||||
@@ -0,0 +1,36 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper routine for memory copy. Moves down the memmove_src and memmove_dst pointers to compensate for .Y not being 0
|
||||
//
|
||||
|
||||
|
||||
shift_mem_adapt_pointers:
|
||||
|
||||
sty RESHO+4
|
||||
|
||||
// Adapt source pointer
|
||||
|
||||
sec
|
||||
lda memmove__src+0
|
||||
sbc RESHO+4
|
||||
sta memmove__src+0
|
||||
bcs !+
|
||||
dec memmove__src+1
|
||||
!:
|
||||
// Adapt destination pointer
|
||||
|
||||
sec
|
||||
lda memmove__dst+0
|
||||
sbc RESHO+4
|
||||
sta memmove__dst+0
|
||||
bcs !+
|
||||
dec memmove__dst+1
|
||||
!:
|
||||
// Adapt data size
|
||||
|
||||
inc memmove__size+1
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,59 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
//
|
||||
// Copies the memory down
|
||||
//
|
||||
// Input:
|
||||
// - memmove__src - pointer to the first byte of source
|
||||
// - memmove__dst - pointer to the first byte of destination
|
||||
// - memmove__size - number of bytes to copy
|
||||
//
|
||||
// All the input variables, .A, and .Y register, are destroyed. Also uses RESHO+4 variable.
|
||||
//
|
||||
|
||||
|
||||
shift_mem_down:
|
||||
|
||||
// The copy routine is simplified, so that it is fast and (for memory model 60K)
|
||||
// can fit in a small RAM area - therefore it requires to pre-set .Y, so that
|
||||
// the copy ends when it reaches 0; so if copying one byte we want .Y = $FF
|
||||
|
||||
sec
|
||||
lda #$00
|
||||
sbc memmove__size+0
|
||||
tay
|
||||
|
||||
// Now we have to move down the memmove_src and memmove_dst pointers to compensate for .Y not being 0
|
||||
|
||||
jsr shift_mem_adapt_pointers
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
shift_mem_down_internal:
|
||||
|
||||
// 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 initialized
|
||||
|
||||
php
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
iny
|
||||
bne !-
|
||||
inc memmove__src+1
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
#else
|
||||
|
||||
jmp shift_mem_down_internal
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
shift_mem_down:
|
||||
|
||||
// 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 initialized
|
||||
|
||||
php
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
iny
|
||||
bne !-
|
||||
inc memmove__src+1
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
//
|
||||
// Copies the memory up
|
||||
//
|
||||
// Input:
|
||||
// - memmove__src - pointer to the last byte of source
|
||||
// - memmove__dst - pointer to the last byte of destination
|
||||
// - memmove__size - number of bytes to copy
|
||||
//
|
||||
// All the input variables, .A, and .Y register, are destroyed. Also uses RESHO+4 variable.
|
||||
//
|
||||
|
||||
|
||||
shift_mem_up:
|
||||
|
||||
// The copy routine is simplified, so that it is fast and (for memory model 60K)
|
||||
// can fit in a small RAM area - therefore it requires to pre-set .Y, so that
|
||||
// the copy ends when it reaches 0; so if copying one byte we want .Y = $01
|
||||
|
||||
ldy memmove__size+0
|
||||
|
||||
// Now we have to move down the memmove_src and memmove_dst pointers to compensate for .Y not being 0
|
||||
|
||||
jsr shift_mem_adapt_pointers
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
shift_mem_up_internal:
|
||||
|
||||
// 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 initialized
|
||||
|
||||
php
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
dey
|
||||
bne !-
|
||||
dec memmove__src+1
|
||||
dec memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
#else
|
||||
|
||||
jmp shift_mem_up_internal
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
shift_mem_up:
|
||||
|
||||
// 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 initialized
|
||||
|
||||
php
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
dey
|
||||
bne !-
|
||||
dec memmove__src+1
|
||||
dec memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
#endif
|
||||
@@ -70,7 +70,7 @@ peek_under_roms_via_FAC1_PLUS_1:
|
||||
|
||||
|
||||
|
||||
shift_mem_up:
|
||||
shift_mem_up_internal:
|
||||
|
||||
// Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
|
||||
//
|
||||
@@ -96,13 +96,13 @@ shift_mem_up:
|
||||
bne !-
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
bra shift_mem_finalize
|
||||
bra shift_mem_internal_finalize
|
||||
#else
|
||||
jmp shift_mem_finalize
|
||||
jmp shift_mem_internal_finalize
|
||||
#endif
|
||||
|
||||
|
||||
shift_mem_down:
|
||||
shift_mem_down_internal:
|
||||
|
||||
// Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
|
||||
//
|
||||
@@ -126,9 +126,10 @@ shift_mem_down:
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
shift_mem_finalize:
|
||||
shift_mem_internal_finalize:
|
||||
|
||||
// Restore memory mapping and quit
|
||||
|
||||
|
||||
Reference in new issue
Block a user