more cleanup in BASIC
This commit is contained in:
1 parent
0a85c12f42
commit
2085e426c8
8 files changed
+149
-157
No files matched your search
@@ -11,9 +11,3 @@
|
||||
.label __tokenise_work3 = $0B // COUNT
|
||||
.label __tokenise_work4 = $0F // GARBFL
|
||||
.label __tokenise_work5 = $0C // DIMFLG
|
||||
|
||||
// We re-use FAC2 for memory move pointers, since
|
||||
// we can't be doing calculations while moving memory
|
||||
.label __memmove_src = $69
|
||||
.label __memmove_dst = $6B
|
||||
.label __memmove_size = $6D
|
||||
@@ -9,28 +9,28 @@ basic_shift_mem_down_and_relink:
|
||||
|
||||
// Destination is OLDTXT
|
||||
lda OLDTXT+0
|
||||
sta __memmove_dst+0
|
||||
sta memmove__dst+0
|
||||
lda OLDTXT+1
|
||||
sta __memmove_dst+1
|
||||
sta memmove__dst+1
|
||||
|
||||
// Source is that plus X
|
||||
txa
|
||||
pha // also keep for later
|
||||
clc
|
||||
adc OLDTXT+0
|
||||
sta __memmove_src+0
|
||||
sta memmove__src+0
|
||||
lda OLDTXT+1
|
||||
adc #0
|
||||
sta __memmove_src+1
|
||||
sta memmove__src+1
|
||||
|
||||
// Size is distance from source to end of BASIC text.
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc __memmove_src+0
|
||||
sta __memmove_size+0
|
||||
sbc memmove__src+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc __memmove_src+1
|
||||
sta __memmove_size+1
|
||||
sbc memmove__src+1
|
||||
sta memmove__size+1
|
||||
|
||||
// jsr printf
|
||||
// .text "TOP OF BASIC = $"
|
||||
@@ -38,14 +38,14 @@ basic_shift_mem_down_and_relink:
|
||||
// .byte $f0,<VARTAB,>VARTAB
|
||||
// .byte $0d
|
||||
// .text "SHIFTING DOWN $"
|
||||
// .byte $f1,<__memmove_size,>__memmove_size
|
||||
// .byte $f0,<__memmove_size,>__memmove_size
|
||||
// .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
|
||||
// .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 $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .byte $0d,0
|
||||
|
||||
// The copy routine that copies under the ROMs is as simple
|
||||
@@ -59,44 +59,44 @@ basic_shift_mem_down_and_relink:
|
||||
// This means we have to then reduce the source and
|
||||
// target pointers by the same amount
|
||||
|
||||
lda __memmove_size+0
|
||||
lda memmove__size+0
|
||||
eor #$ff
|
||||
sta __tokenise_work3
|
||||
sta __memmove_size+0
|
||||
sta memmove__size+0
|
||||
|
||||
lda __memmove_src+0
|
||||
lda memmove__src+0
|
||||
sec
|
||||
sbc __tokenise_work3
|
||||
sta __memmove_src+0
|
||||
lda __memmove_src+1
|
||||
sta memmove__src+0
|
||||
lda memmove__src+1
|
||||
sbc #0
|
||||
sta __memmove_src+1
|
||||
sta memmove__src+1
|
||||
|
||||
lda __memmove_dst+0
|
||||
lda memmove__dst+0
|
||||
sec
|
||||
sbc __tokenise_work3
|
||||
sta __memmove_dst+0
|
||||
lda __memmove_dst+1
|
||||
sta memmove__dst+0
|
||||
lda memmove__dst+1
|
||||
sbc #0
|
||||
sta __memmove_dst+1
|
||||
sta memmove__dst+1
|
||||
|
||||
// Increase copy page count so we can post-decrement compare with $00
|
||||
inc __memmove_size+1
|
||||
inc memmove__size+1
|
||||
|
||||
// jsr printf
|
||||
// .text "REVISED BOUNDS $"
|
||||
// .byte $f1,<__memmove_size,>__memmove_size
|
||||
// .byte $f0,<__memmove_size,>__memmove_size
|
||||
// .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
|
||||
// .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 $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .byte $0d,0
|
||||
|
||||
// Get Y value ready for the copy
|
||||
ldy __memmove_size+0
|
||||
ldy memmove__size+0
|
||||
|
||||
jsr shift_mem_down
|
||||
|
||||
@@ -131,7 +131,7 @@ relink_down_next_line:
|
||||
|
||||
sec
|
||||
sbc __tokenise_work3
|
||||
sta __memmove_src+0
|
||||
sta memmove__src+0
|
||||
iny
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
@@ -143,10 +143,10 @@ relink_down_next_line:
|
||||
#endif
|
||||
|
||||
sbc #0
|
||||
sta __memmove_src+1
|
||||
sta memmove__src+1
|
||||
|
||||
ldy #0
|
||||
lda __memmove_src+0
|
||||
lda memmove__src+0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
@@ -156,7 +156,7 @@ relink_down_next_line:
|
||||
#endif
|
||||
|
||||
iny
|
||||
lda __memmove_src+1
|
||||
lda memmove__src+1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr poke_under_roms
|
||||
@@ -166,9 +166,9 @@ relink_down_next_line:
|
||||
|
||||
relink_down_loop:
|
||||
// Now advance pointer to the next line,
|
||||
lda __memmove_src+0
|
||||
lda memmove__src+0
|
||||
sta OLDTXT+0
|
||||
lda __memmove_src+1
|
||||
lda memmove__src+1
|
||||
sta OLDTXT+1
|
||||
|
||||
// Have we run out of lines to patch?
|
||||
|
||||
@@ -13,35 +13,35 @@ basic_shift_mem_up_and_relink:
|
||||
txa
|
||||
clc
|
||||
adc VARTAB+0
|
||||
sta __memmove_dst+0
|
||||
sta memmove__dst+0
|
||||
lda VARTAB+1
|
||||
adc #0
|
||||
sta __memmove_dst+1
|
||||
lda __memmove_dst+0
|
||||
sta memmove__dst+1
|
||||
lda memmove__dst+0
|
||||
sec
|
||||
sbc #1
|
||||
sta __memmove_dst+0
|
||||
lda __memmove_dst+1
|
||||
sta memmove__dst+0
|
||||
lda memmove__dst+1
|
||||
sbc #0
|
||||
sta __memmove_dst+1
|
||||
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
|
||||
sta memmove__src+0
|
||||
lda VARTAB+1
|
||||
sbc #0
|
||||
sta __memmove_src+1
|
||||
sta memmove__src+1
|
||||
|
||||
// Work out size of region to copy
|
||||
lda VARTAB+0
|
||||
sec
|
||||
sbc OLDTXT+0
|
||||
sta __memmove_size+0
|
||||
sta memmove__size+0
|
||||
lda VARTAB+1
|
||||
sbc OLDTXT+1
|
||||
sta __memmove_size+1
|
||||
sta memmove__size+1
|
||||
|
||||
// jsr printf
|
||||
// .text "TOP OF BASIC = $"
|
||||
@@ -49,54 +49,54 @@ basic_shift_mem_up_and_relink:
|
||||
// .byte $f0,<VARTAB,>VARTAB
|
||||
// .byte $0d
|
||||
// .text "SHIFTING UP $"
|
||||
// .byte $f1,<__memmove_size,>__memmove_size
|
||||
// .byte $f0,<__memmove_size,>__memmove_size
|
||||
// .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
|
||||
// .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 $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
|
||||
lda memmove__src+0
|
||||
sec
|
||||
sbc __memmove_size+0
|
||||
sta __memmove_src+0
|
||||
lda __memmove_src+1
|
||||
sbc memmove__size+0
|
||||
sta memmove__src+0
|
||||
lda memmove__src+1
|
||||
sbc #0
|
||||
sta __memmove_src+1
|
||||
sta memmove__src+1
|
||||
|
||||
lda __memmove_dst+0
|
||||
lda memmove__dst+0
|
||||
sec
|
||||
sbc __memmove_size+0
|
||||
sta __memmove_dst+0
|
||||
lda __memmove_dst+1
|
||||
sbc memmove__size+0
|
||||
sta memmove__dst+0
|
||||
lda memmove__dst+1
|
||||
sbc #0
|
||||
sta __memmove_dst+1
|
||||
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
|
||||
inc memmove__size+1
|
||||
|
||||
// Then set Y to the number offset required
|
||||
ldy __memmove_size+0
|
||||
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
|
||||
// .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
|
||||
// .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 $f1,<memmove__dst,>memmove__dst
|
||||
// .byte $f0,<memmove__dst,>memmove__dst
|
||||
// .byte $0d,0
|
||||
|
||||
// Do the copy
|
||||
@@ -143,10 +143,10 @@ relink_up_next_line:
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
sta __memmove_dst+0
|
||||
sta memmove__dst+0
|
||||
clc
|
||||
adc __tokenise_work3
|
||||
sta __memmove_src+0
|
||||
sta memmove__src+0
|
||||
iny
|
||||
php
|
||||
|
||||
@@ -159,27 +159,27 @@ relink_up_next_line:
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
sta __memmove_dst+1
|
||||
sta memmove__dst+1
|
||||
plp
|
||||
adc #0
|
||||
sta __memmove_src+1
|
||||
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
|
||||
// .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 $f1,<memmove__src,>memmove__src
|
||||
// .byte $f0,<memmove__src,>memmove__src
|
||||
// .byte $d
|
||||
// .byte 0
|
||||
|
||||
// Write __memmove_src back to current line pointer
|
||||
// Write memmove__src back to current line pointer
|
||||
ldy #0
|
||||
lda __memmove_src+0
|
||||
lda memmove__src+0
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
@@ -189,7 +189,7 @@ relink_up_next_line:
|
||||
#endif
|
||||
|
||||
iny
|
||||
lda __memmove_src+1
|
||||
lda memmove__src+1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr poke_under_roms
|
||||
@@ -199,9 +199,9 @@ relink_up_next_line:
|
||||
|
||||
relink_up_loop:
|
||||
// Now advance pointer to the next line,
|
||||
lda __memmove_src+0
|
||||
lda memmove__src+0
|
||||
sta OLDTXT+0
|
||||
lda __memmove_src+1
|
||||
lda memmove__src+1
|
||||
sta OLDTXT+1
|
||||
|
||||
// Have we run out of lines to patch?
|
||||
|
||||
@@ -7,22 +7,20 @@
|
||||
|
||||
shift_mem_down:
|
||||
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
// 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.
|
||||
// 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
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
iny
|
||||
bne !-
|
||||
inc __memmove_src+1
|
||||
inc __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
inc memmove__src+1
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
@@ -7,22 +7,20 @@
|
||||
|
||||
shift_mem_up:
|
||||
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
// 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.
|
||||
// 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
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
dey
|
||||
bne !-
|
||||
dec __memmove_src+1
|
||||
dec __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
dec memmove__src+1
|
||||
dec memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
rts
|
||||
|
||||
@@ -72,12 +72,10 @@ peek_under_roms_via_FAC1_PLUS_1:
|
||||
|
||||
shift_mem_up:
|
||||
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
// 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.
|
||||
// This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
|
||||
|
||||
// Unmap BASIC lower ROM
|
||||
|
||||
@@ -88,13 +86,13 @@ shift_mem_up:
|
||||
|
||||
// Perform the copying
|
||||
!:
|
||||
lda (__memmove_src),y
|
||||
sta (__memmove_dst),y
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
dey
|
||||
bne !-
|
||||
dec __memmove_src+1
|
||||
dec __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
dec memmove__src+1
|
||||
dec memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
@@ -106,12 +104,10 @@ shift_mem_up:
|
||||
|
||||
shift_mem_down:
|
||||
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
// 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.
|
||||
// This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
|
||||
|
||||
// Unmap BASIC lower ROM
|
||||
|
||||
@@ -122,13 +118,13 @@ shift_mem_down:
|
||||
|
||||
// Perform the copying
|
||||
!:
|
||||
lda (__memmove_src),y
|
||||
sta (__memmove_dst),y
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
iny
|
||||
bne !-
|
||||
inc __memmove_src+1
|
||||
inc __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
inc memmove__src+1
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
// FALLTROUGH
|
||||
|
||||
|
||||
@@ -70,44 +70,44 @@ memmap_allram_routine:
|
||||
rts
|
||||
|
||||
shift_mem_up_routine:
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
|
||||
// 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.
|
||||
// This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
|
||||
|
||||
php
|
||||
jsr memmap_allram
|
||||
smu1:
|
||||
lda (__memmove_src),y
|
||||
sta (__memmove_dst),y
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
dey
|
||||
bne smu1
|
||||
dec __memmove_src+1
|
||||
dec __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
bne smu1
|
||||
bne !-
|
||||
dec memmove__src+1
|
||||
dec memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
jmp memmap_normal
|
||||
|
||||
shift_mem_down_routine:
|
||||
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
|
||||
// where __memmove_dst > __memmove_src
|
||||
|
||||
// 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.
|
||||
// This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
|
||||
|
||||
php
|
||||
jsr memmap_allram
|
||||
smd1:
|
||||
lda (__memmove_src),y
|
||||
sta (__memmove_dst),y
|
||||
!:
|
||||
lda (memmove__src),y
|
||||
sta (memmove__dst),y
|
||||
iny
|
||||
bne smd1
|
||||
inc __memmove_src+1
|
||||
inc __memmove_dst+1
|
||||
dec __memmove_size+1
|
||||
bne smd1
|
||||
bne !-
|
||||
inc memmove__src+1
|
||||
inc memmove__dst+1
|
||||
dec memmove__size+1
|
||||
bne !-
|
||||
plp
|
||||
jmp memmap_normal
|
||||
|
||||
|
||||
Reference in new issue
Block a user