work towards being able to delete BASIC lines
This commit is contained in:
1 parent
490dda059f
commit
906fe108b3
8 files changed
+275
-60
No files matched your search
@@ -127,6 +127,7 @@
|
||||
.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 shift_mem_down tiny_nmi_handler+shift_mem_down_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
|
||||
|
||||
@@ -5,5 +5,56 @@
|
||||
;; banked out. Oh, yes, and we have to update all the links in
|
||||
;; the following basic lines.
|
||||
basic_delete_line:
|
||||
|
||||
jsr printf
|
||||
.byte "DELETING LINE AT $"
|
||||
.byte $f1,<basic_current_line_ptr,>basic_current_line_ptr
|
||||
.byte $f0,<basic_current_line_ptr,>basic_current_line_ptr
|
||||
.byte $0d,0
|
||||
|
||||
;; Get address of next line
|
||||
ldx #<basic_current_line_ptr
|
||||
ldy #0
|
||||
jsr peek_under_roms
|
||||
sta tokenise_work3
|
||||
iny
|
||||
jsr peek_under_roms
|
||||
sta tokenise_work4
|
||||
|
||||
;; Work out length of this line by looking at the pointer
|
||||
lda tokenise_work3
|
||||
sec
|
||||
sbc basic_current_line_ptr+0
|
||||
sta tokenise_work3
|
||||
lda tokenise_work4
|
||||
sbc #0
|
||||
cmp #$00
|
||||
beq +
|
||||
;; Line length is <0 or >255 bytes.
|
||||
;; Either way, things are bad, so abort.
|
||||
ldx #35
|
||||
jmp do_basic_error
|
||||
*
|
||||
;; Length can now be safely assumed to be in the low
|
||||
;; byte only, i.e., stored in tokenise_work3
|
||||
|
||||
lda tokenise_work3
|
||||
pha
|
||||
tax
|
||||
|
||||
;; Shuffle everything down
|
||||
jsr basic_shift_mem_down_and_relink
|
||||
|
||||
;; Now decrease top of BASIC mem
|
||||
pla
|
||||
sta tokenise_work3
|
||||
lda basic_end_of_text_ptr+0
|
||||
sec
|
||||
sbc tokenise_work3
|
||||
sta basic_end_of_text_ptr+0
|
||||
lda basic_end_of_text_ptr+1
|
||||
sbc #0
|
||||
sta basic_end_of_text_ptr+1
|
||||
|
||||
clc
|
||||
rts
|
||||
@@ -14,11 +14,17 @@ basic_insert_line:
|
||||
|
||||
;; But first, remember where the pointer will be, so that we can
|
||||
;; put the line in there after.
|
||||
|
||||
jsr printf
|
||||
.byte "INSERTING LINE AT $"
|
||||
.byte $f1,<basic_current_line_ptr,>basic_current_line_ptr
|
||||
.byte $f0,<basic_current_line_ptr,>basic_current_line_ptr
|
||||
.byte $0d,0
|
||||
|
||||
lda basic_current_line_ptr+0
|
||||
sta $0438
|
||||
pha
|
||||
lda basic_current_line_ptr+1
|
||||
sta $0439
|
||||
|
||||
pha
|
||||
|
||||
;; Get number of bytes in tokenised line after line number
|
||||
@@ -75,6 +81,6 @@ line_store_loop:
|
||||
bne line_store_loop
|
||||
dec tokenise_work2
|
||||
|
||||
sec
|
||||
clc
|
||||
rts
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
basic_shift_mem_down_and_relink:
|
||||
;; Shift memory down to basic_current_line_pointer
|
||||
;; from X bytes further along.
|
||||
|
||||
;; Destination is basic_current_line_ptr
|
||||
lda basic_current_line_ptr+0
|
||||
sta memmove_dst+0
|
||||
lda basic_current_line_ptr+1
|
||||
sta memmove_dst+1
|
||||
|
||||
;; Source is that plus X
|
||||
txa
|
||||
pha ; also keep for later
|
||||
clc
|
||||
adc basic_current_line_ptr+0
|
||||
sta memmove_src+0
|
||||
lda basic_current_line_ptr+1
|
||||
adc #0
|
||||
sta memmove_src+1
|
||||
|
||||
;; Size is distance from source to end of BASIC text.
|
||||
lda basic_end_of_text_ptr+0
|
||||
sec
|
||||
sbc memmove_src+0
|
||||
sta memmove_size+0
|
||||
lda basic_end_of_text_ptr+1
|
||||
sbc memmove_src+1
|
||||
sta memmove_size+1
|
||||
|
||||
jsr printf
|
||||
.byte "TOP OF BASIC = $"
|
||||
.byte $f1,<basic_end_of_text_ptr,>basic_end_of_text_ptr
|
||||
.byte $f0,<basic_end_of_text_ptr,>basic_end_of_text_ptr
|
||||
.byte $0d
|
||||
.byte "SHIFTING UP $"
|
||||
.byte $f1,<memmove_size,>memmove_size
|
||||
.byte $f0,<memmove_size,>memmove_size
|
||||
.byte " BYTES FROM $"
|
||||
.byte $f1,<memmove_src,>memmove_src
|
||||
.byte $f0,<memmove_src,>memmove_src
|
||||
.byte " TO $"
|
||||
.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
|
||||
;; as possible to be as small as possible, so we have
|
||||
;; to adjust the pointers and counts so that the simple
|
||||
;; increment and decrement bounds checks work.
|
||||
|
||||
;; Specifically we want Y pre-set so that the end of the
|
||||
;; copy ends when Y = $00.
|
||||
;; So if copying 1 byte, we want Y=$FF
|
||||
;; This means we have to then reduce the source and
|
||||
;; target pointers by the same amount
|
||||
|
||||
lda memmove_size
|
||||
eor #$ff
|
||||
sta tokenise_work3
|
||||
|
||||
lda memmove_src+0
|
||||
sec
|
||||
sbc tokenise_work3
|
||||
sta memmove_src+0
|
||||
lda memmove_src+1
|
||||
sbc #0
|
||||
sta memmove_src+1
|
||||
|
||||
lda memmove_dst+0
|
||||
sec
|
||||
sbc tokenise_work3
|
||||
sta memmove_dst+0
|
||||
lda memmove_dst+1
|
||||
sbc #0
|
||||
sta memmove_dst+1
|
||||
|
||||
;; Get Y value ready for the copy
|
||||
ldy memmove_size+0
|
||||
|
||||
jsr printf
|
||||
.byte "REVISED BOUNDS $"
|
||||
.byte $f1,<memmove_size,>memmove_size
|
||||
.byte $f0,<memmove_size,>memmove_size
|
||||
.byte " BYTES FROM $"
|
||||
.byte $f1,<memmove_src,>memmove_src
|
||||
.byte $f0,<memmove_src,>memmove_src
|
||||
.byte " TO $"
|
||||
.byte $f1,<memmove_dst,>memmove_dst
|
||||
.byte $f0,<memmove_dst,>memmove_dst
|
||||
.byte $0d,0
|
||||
|
||||
jsr shift_mem_down
|
||||
|
||||
;; Get length of deletion back
|
||||
pla
|
||||
sta tokenise_work3
|
||||
|
||||
relink_down_next_line:
|
||||
inc $d020
|
||||
jmp relink_down_next_line
|
||||
|
||||
;; Subtract tokenise_work3 from the pointer
|
||||
ldy #0
|
||||
ldx #<basic_current_line_ptr+0
|
||||
jsr peek_under_roms
|
||||
sec
|
||||
sbc tokenise_Work3
|
||||
sta memmove_src+0
|
||||
iny
|
||||
jsr peek_under_roms
|
||||
sbc #0
|
||||
sta memmove_src+1
|
||||
|
||||
ldy #0
|
||||
ldx #<basic_current_line_ptr
|
||||
lda memmove_src+0
|
||||
jsr poke_under_roms
|
||||
iny
|
||||
lda memmove_src+1
|
||||
jsr poke_under_roms
|
||||
|
||||
relink_down_loop:
|
||||
;; Now advance pointer to the next line,
|
||||
lda memmove_src+0
|
||||
sta basic_current_line_ptr+0
|
||||
lda memmove_src+1
|
||||
sta basic_current_line_ptr+1
|
||||
|
||||
;; Have we run out of lines to patch?
|
||||
ldx #<basic_current_line_ptr
|
||||
jsr peek_pointer_null_check
|
||||
bcs relink_down_next_line
|
||||
|
||||
rts
|
||||
|
||||
@@ -19,13 +19,13 @@ basic_shift_mem_up_and_relink:
|
||||
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
|
||||
sec
|
||||
sbc basic_current_line_ptr+0
|
||||
sta memmove_size+0
|
||||
lda basic_end_of_text_ptr+1
|
||||
sbc basic_current_line_ptr+1
|
||||
sta memmove_size+1
|
||||
|
||||
jsr printf
|
||||
.byte "TOP OF BASIC = $"
|
||||
|
||||
+54
-53
@@ -12,9 +12,9 @@ packed_message_chars:
|
||||
.byte $44 ; 'D' = $b (nybl)
|
||||
.byte $55 ; 'U' = $c (nybl)
|
||||
.byte $50 ; 'P' = $d (nybl)
|
||||
.byte $43 ; 'C' = $e (nybl)
|
||||
.byte $47 ; 'G' = $F1 / $xF $47
|
||||
.byte $4D ; 'M' = $F2 / $xF $4D
|
||||
.byte $4D ; 'M' = $e (nybl)
|
||||
.byte $43 ; 'C' = $F1 / $xF $43
|
||||
.byte $47 ; 'G' = $F2 / $xF $47
|
||||
.byte $59 ; 'Y' = $F3 / $xF $59
|
||||
.byte $56 ; 'V' = $F4 / $xF $56
|
||||
.byte $42 ; 'B' = $F5 / $xF $42
|
||||
@@ -52,72 +52,73 @@ packed_message_tokens:
|
||||
.byte $03,$17,$ff,$29,$00,$2a,$ff,$2b
|
||||
.byte $2c,$ff,$1b,$2d,$ff,$2e,$ff,$2f
|
||||
.byte $ff,$30,$ff,$31,$ff,$32,$ff,$33
|
||||
.byte $ff
|
||||
.byte $34
|
||||
.byte $ff
|
||||
.byte $35
|
||||
.byte $36
|
||||
.byte $ff,$34,$ff,$35,$36,$ff,$1a,$37
|
||||
.byte $ff
|
||||
packed_message_words:
|
||||
.byte $23,$30,$f2,$74,$f3,$00,$a5,$91
|
||||
.byte $23,$30,$e7,$4f,$59,$00,$a5,$91
|
||||
.byte $80,$a5,$91,$00,$3d,$14,$00,$43
|
||||
.byte $20,$a3,$c4,$b0,$b1,$f4,$5e,$10
|
||||
.byte $d6,$18,$14,$20,$54,$dc,$20,$3c
|
||||
.byte $2d,$c2,$00,$f2,$58,$85,$4f,$47
|
||||
.byte $00,$a5,$91,$47,$f2,$10,$59,$91
|
||||
.byte $f1,$79,$00,$4c,$f2,$f5,$16,$00
|
||||
.byte $20,$a3,$c4,$b0,$b1,$f4,$5f,$43
|
||||
.byte $10,$d6,$18,$14,$20,$54,$dc,$20
|
||||
.byte $3c,$2d,$c2,$00,$e5,$88,$54,$f2
|
||||
.byte $00,$a5,$91,$47,$e1,$00,$59,$91
|
||||
.byte $f2,$79,$00,$4c,$ef,$42,$16,$00
|
||||
.byte $41,$f7,$20,$f8,$52,$f6,$3c,$20
|
||||
.byte $a3,$60,$8f,$59,$42,$7f,$58,$00
|
||||
.byte $61,$2c,$64,$00,$f1,$38,$cf,$42
|
||||
.byte $61,$2c,$64,$00,$f2,$38,$cf,$42
|
||||
.byte $00,$3c,$20,$3a,$00,$b7,$27,$00
|
||||
.byte $fc,$c7,$42,$52,$f3,$00,$3f,$56
|
||||
.byte $16,$a9,$3f,$57,$00,$f2,$1f,$4d
|
||||
.byte $36,$f3,$00,$c4,$b1,$af,$27,$b0
|
||||
.byte $82,$72,$1f,$4d,$14,$20,$f5,$7b
|
||||
.byte $00,$8c,$f5,$8e,$65,$d2,$00,$61
|
||||
.byte $b5,$f2,$fa,$b0,$76,$67,$f3,$00
|
||||
.byte $b5,$f4,$58,$53,$40,$f5,$f3,$00
|
||||
.byte $ff,$5a,$16,$30,$b5,$61,$e2,$00
|
||||
.byte $2f,$59,$d1,$00,$f2,$58,$f2,$72
|
||||
.byte $ef,$48,$00,$82,$65,$4f,$47,$00
|
||||
.byte $93,$4f,$47,$00,$a3,$6f,$4d,$c9
|
||||
.byte $70,$e3,$f2,$d9,$1f,$58,$00,$e7
|
||||
.byte $4f,$27,$20,$e3,$42,$54,$c1,$00
|
||||
.byte $ac,$4e,$25,$34,$00,$f4,$16,$5a
|
||||
.byte $f3,$00,$93,$7b,$00,$61,$7b,$f3
|
||||
.byte $fd,$fb,$00,$93,$7b,$54,$f1,$00
|
||||
.byte $f4,$16,$5a,$f3,$54,$f1,$00,$87
|
||||
.byte $f4,$54,$f1,$00,$16,$63,$60,$f5
|
||||
.byte $f3,$21,$80,$a6,$11,$fd,$fb,$fb
|
||||
.byte $16,$a9,$3f,$57,$00,$e1,$e3,$6f
|
||||
.byte $59,$00,$c4,$b1,$af,$27,$b0,$82
|
||||
.byte $72,$1e,$14,$20,$f5,$7b,$00,$8c
|
||||
.byte $f5,$8f,$43,$65,$d2,$00,$61,$b5
|
||||
.byte $ef,$27,$b0,$76,$67,$f3,$00,$b5
|
||||
.byte $f4,$58,$53,$40,$f5,$f3,$00,$ff
|
||||
.byte $5a,$16,$30,$b5,$61,$f1,$20,$2f
|
||||
.byte $59,$d1,$00,$e5,$8e,$72,$f1,$f6
|
||||
.byte $00,$82,$65,$4f,$47,$00,$93,$4f
|
||||
.byte $47,$00,$a3,$6e,$c9,$70,$f1,$3e
|
||||
.byte $d9,$1f,$58,$00,$f1,$74,$fa,$20
|
||||
.byte $f1,$34,$25,$4c,$10,$ac,$4f,$43
|
||||
.byte $25,$34,$00,$f4,$16,$5a,$f3,$00
|
||||
.byte $93,$7b,$00,$61,$7b,$f3,$fd,$fb
|
||||
.byte $00,$93,$7b,$54,$f2,$00,$f4,$16
|
||||
.byte $5a,$f3,$54,$f2,$00,$87,$f4,$54
|
||||
.byte $f2,$00,$16,$63,$60,$f5,$f3,$21
|
||||
.byte $80,$a6,$11,$fd,$fb,$fb,$00,$f1
|
||||
.byte $36
|
||||
.byte $6c
|
||||
.byte $d2
|
||||
.byte $00
|
||||
packed_keywords:
|
||||
.byte $14,$b0,$a3,$60,$41,$f7,$20,$b7
|
||||
.byte $27,$00,$54,$dc,$2f,$23,$00,$54
|
||||
.byte $dc,$20,$b5,$f2,$00,$61,$7b,$00
|
||||
.byte $91,$20,$f1,$32,$30,$6c,$40,$5a
|
||||
.byte $00,$61,$82,$36,$10,$f1,$38,$cf
|
||||
.byte $42,$00,$61,$2c,$64,$00,$61,$f2
|
||||
.byte $00,$82,$3d,$00,$34,$00,$f8,$75
|
||||
.byte $20,$93,$7b,$00,$87,$f4,$10,$f4
|
||||
.byte $16,$5a,$f3,$00,$b1,$a0,$d3,$ff
|
||||
.byte $4b,$10,$d6,$54,$2f,$23,$00,$d6
|
||||
.byte $54,$20,$e3,$42,$00,$95,$82,$00
|
||||
.byte $e9,$60,$ef,$4d,$b0,$8f,$59,$80
|
||||
.byte $3d,$14,$00,$e9,$38,$10,$f1,$12
|
||||
.byte $dc,$20,$b5,$e0,$61,$7b,$00,$91
|
||||
.byte $20,$f2,$32,$30,$6c,$40,$5a,$00
|
||||
.byte $61,$82,$36,$10,$f2,$38,$cf,$42
|
||||
.byte $00,$61,$2c,$64,$00,$61,$e0,$82
|
||||
.byte $3d,$00,$34,$00,$f8,$75,$20,$93
|
||||
.byte $7b,$00,$87,$f4,$10,$f4,$16,$5a
|
||||
.byte $f3,$00,$b1,$a0,$d3,$ff,$4b,$10
|
||||
.byte $d6,$54,$2f,$23,$00,$d6,$54,$20
|
||||
.byte $f1,$34,$20,$95,$82,$00,$f1,$96
|
||||
.byte $00,$f1,$eb,$00,$8f,$59,$80,$3d
|
||||
.byte $14,$00,$f1,$93,$81,$00,$f2,$12
|
||||
.byte $00,$41,$f8,$00,$27,$f5,$fe,$28
|
||||
.byte $23,$00,$a4,$00,$8d,$ef,$28,$00
|
||||
.byte $23,$00,$a4,$00,$8d,$f1,$fe,$28
|
||||
.byte $2f,$48,$14,$00,$43,$20,$82,$1d
|
||||
.byte $00,$fe,$2b,$fe,$2d,$fe,$2a,$fe
|
||||
.byte $2f,$fe,$5e,$74,$b0,$36,$00,$fe
|
||||
.byte $3e,$fe,$3d,$fe,$3c,$8f,$47,$40
|
||||
.byte $54,$20,$7f,$42,$80,$c8,$60,$a6
|
||||
.byte $10,$d3,$80,$8f,$51,$60,$64,$b0
|
||||
.byte $93,$f1,$00,$1f,$58,$d0,$e3,$80
|
||||
.byte $85,$40,$27,$40,$72,$40,$d1,$1f
|
||||
.byte $4b,$00,$91,$40,$82,$6f,$24,$00
|
||||
.byte $f4,$79,$00,$78,$e0,$ef,$48,$6f
|
||||
.byte $24,$00,$91,$a2,$f9,$00,$65,$f1
|
||||
.byte $f6,$2f,$24,$00,$f2,$5b,$f9,$00
|
||||
.byte $f1
|
||||
.byte $93,$f2,$00,$1f,$58,$d0,$f1,$38
|
||||
.byte $00,$85,$40,$27,$40,$72,$40,$d1
|
||||
.byte $1f,$4b,$00,$91,$40,$82,$6f,$24
|
||||
.byte $00,$f4,$79,$00,$78,$f1,$00,$f1
|
||||
.byte $f6,$6f,$24,$00,$91,$a2,$f9,$00
|
||||
.byte $65,$f2,$f6,$2f,$24,$00,$e5,$bf
|
||||
.byte $24
|
||||
.byte $00
|
||||
.byte $f2
|
||||
.byte $30
|
||||
.alias packed_keyword_table_len $DA
|
||||
.alias packed_keyword_table_len $DC
|
||||
@@ -46,7 +46,27 @@ smu1:
|
||||
bne smu1
|
||||
|
||||
jmp memmap_normal
|
||||
|
||||
shift_mem_down_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
|
||||
smd1:
|
||||
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
|
||||
|
||||
jmp memmap_normal
|
||||
|
||||
|
||||
peek_under_roms_routine:
|
||||
stx peek_under_roms+7 ;Offset of arg of lda ($00),y
|
||||
|
||||
@@ -164,6 +164,7 @@ char *error_list[]={
|
||||
"SAVING",
|
||||
"ERROR", // #33 // Simply the word error that is attached to the other parts of messages https://fjkraan.home.xs4all.nl/comp/apple2faq/app2asoftfaq.html
|
||||
"BYTES FREE.\r\r", // #34 // https://github.com/stefanhaustein/expressionparser
|
||||
"MEMORY CORRUPT", // #35
|
||||
NULL};
|
||||
|
||||
// Token $FF is end of message, so we can have only 255 unique words
|
||||
|
||||
Reference in new issue
Block a user