changed handling of external token lists
This commit is contained in:
1 parent
151b9440dd
commit
985a0882f6
29 files changed
+295
-316
No files matched your search
@@ -0,0 +1,60 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Jumptable for BASIC commands with tokens prefixed by $02
|
||||
//
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
.const command_02_list = List().add(
|
||||
|
||||
// NOTE! These commands are temporarily placed in list 01!
|
||||
|
||||
// cmd_merge,
|
||||
|
||||
// cmd_bload,
|
||||
// cmd_bsave,
|
||||
// cmd_bverify,
|
||||
|
||||
// cmd_clear,
|
||||
// varstr_garbage_collect, // cmd_dispose
|
||||
|
||||
cmd_cold,
|
||||
cmd_mem
|
||||
)
|
||||
|
||||
|
||||
#if !HAS_OPCODES_65C02
|
||||
|
||||
|
||||
command_02_jumptable_lo:
|
||||
|
||||
put_jumptable_lo(command_02_list)
|
||||
|
||||
|
||||
command_02_jumptable_hi:
|
||||
|
||||
put_jumptable_hi(command_02_list)
|
||||
|
||||
|
||||
#else // HAS_OPCODES_65C02
|
||||
|
||||
|
||||
__before_command_02_jumptable:
|
||||
|
||||
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
|
||||
|
||||
command_02_jumptable:
|
||||
|
||||
put_jumptable(command_02_list)
|
||||
|
||||
// Make sure routine size is always the same - build system limitation
|
||||
|
||||
.if (__before_command_02_jumptable == command_02_jumptable) { brk }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
cmd_bverify:
|
||||
|
||||
// LOAD and VERIFY are very similar, from BASIC perspective there is almost no difference;
|
||||
// just different parameter passed to Kernal and different error message in case of failure
|
||||
|
||||
lda #$01 // mark operation as VERIFY
|
||||
skip_2_bytes_trash_nvz
|
||||
|
||||
cmd_bload:
|
||||
|
||||
lda #$00 // mark operation as LOAD
|
||||
jsr helper_load_init_params
|
||||
|
||||
// Fetch the file name
|
||||
|
||||
jsr helper_bload_fetch_filename
|
||||
|
||||
// Fetch device number
|
||||
|
||||
jsr fetch_coma_uint8
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
sta FA
|
||||
|
||||
// Fetch the start address
|
||||
|
||||
jsr helper_bload_fetch_address
|
||||
|
||||
// Perform loading
|
||||
|
||||
lda VERCKB // LOAD or VERIFY
|
||||
jsr JLOAD
|
||||
bcs_16 do_kernal_error
|
||||
|
||||
// Execute next statement
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,42 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
cmd_bsave:
|
||||
|
||||
// Set default device and secondary address
|
||||
|
||||
jsr helper_load_init_params_no_VERCKB
|
||||
|
||||
// Fetch the file name
|
||||
|
||||
jsr helper_load_fetch_filename
|
||||
bcs_16 do_MISSING_FILENAME_error
|
||||
|
||||
// Fetch device number
|
||||
|
||||
jsr helper_load_fetch_devnum
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
// Fetch memory area start address
|
||||
|
||||
jsr helper_bload_fetch_address
|
||||
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
|
||||
// Fetch memory area end address
|
||||
|
||||
jsr helper_bload_fetch_address
|
||||
|
||||
pla
|
||||
sta LINNUM+1
|
||||
pla
|
||||
sta LINNUM+0
|
||||
|
||||
lda #LINNUM
|
||||
|
||||
// Perform SAVE - reuse regular command
|
||||
|
||||
jmp cmd_save_do
|
||||
@@ -0,0 +1,10 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
cmd_clear:
|
||||
|
||||
// XXX in the future add separate implementation for graphics screen
|
||||
|
||||
jmp clear_screen
|
||||
@@ -0,0 +1,18 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
cmd_cold:
|
||||
|
||||
jsr helper_ask_if_sure
|
||||
bcs !+
|
||||
|
||||
jsr JCLALL // for extra safety
|
||||
jmp (vector_reset) // hardware CPU vector
|
||||
!:
|
||||
rts
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// PLACEHOLDER for completeness - jumptable contains direct address
|
||||
@@ -0,0 +1,149 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 * #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
#if (!ROM_LAYOUT_M65 || SEGMENT_BASIC_0)
|
||||
|
||||
cmd_mem:
|
||||
|
||||
// First perform the garbage collection - to be able to determine real values
|
||||
|
||||
jsr varstr_garbage_collect
|
||||
|
||||
#endif // ROM layout
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__cmd_mem_cont
|
||||
jmp map_NORMAL
|
||||
|
||||
#else
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_1)
|
||||
|
||||
cmd_mem_cont:
|
||||
|
||||
#endif
|
||||
|
||||
// Print header
|
||||
|
||||
lda #$12
|
||||
jsr JCHROUT
|
||||
ldx #IDX__STR_MEM_HDR
|
||||
jsr print_packed_misc_str
|
||||
|
||||
// Print all the information, in a loop, in reverse order
|
||||
|
||||
ldy #$04
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_mem_loop:
|
||||
|
||||
// First print the information string
|
||||
|
||||
ldx helper_mem_tab_str, y
|
||||
phy_trash_a
|
||||
jsr print_packed_misc_str
|
||||
|
||||
// Print start address
|
||||
|
||||
ldx #IDX__STR_MEM_1
|
||||
jsr print_packed_misc_str
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
ply
|
||||
phy
|
||||
#else
|
||||
pla
|
||||
pha
|
||||
tay
|
||||
#endif
|
||||
ldx helper_mem_tab_y, y
|
||||
lda $01, x
|
||||
jsr print_hex_byte
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
ply
|
||||
phy
|
||||
#else
|
||||
pla
|
||||
pha
|
||||
tay
|
||||
#endif
|
||||
ldx helper_mem_tab_y, y
|
||||
lda $00, x
|
||||
jsr print_hex_byte
|
||||
|
||||
|
||||
ldx #IDX__STR_MEM_2
|
||||
jsr print_packed_misc_str
|
||||
|
||||
// Fetch addresses of zeropage variables
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
ply
|
||||
phy
|
||||
#else
|
||||
pla
|
||||
pha
|
||||
tay
|
||||
#endif
|
||||
|
||||
ldx helper_mem_tab_x, y
|
||||
lda helper_mem_tab_y, y
|
||||
tay
|
||||
|
||||
// Print difference between two zeropage variables
|
||||
|
||||
sec
|
||||
lda $00, x
|
||||
sbc $0000, y
|
||||
pha
|
||||
inx
|
||||
iny
|
||||
lda $00, x
|
||||
sbc $0000, y
|
||||
|
||||
#if HAS_OPCODES_65C02
|
||||
plx
|
||||
#else
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
tya
|
||||
#endif
|
||||
|
||||
// Before printing, make sure the result is not negative
|
||||
|
||||
bcs !+
|
||||
lda #$3F
|
||||
jsr JCHROUT
|
||||
jmp_8 cmd_mem_next
|
||||
|
||||
!:
|
||||
jsr print_integer
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_mem_next:
|
||||
|
||||
// Check if more iterations needed
|
||||
|
||||
ply_trash_a
|
||||
dey
|
||||
bpl cmd_mem_loop
|
||||
|
||||
// Finish
|
||||
|
||||
jmp print_return
|
||||
|
||||
|
||||
#endif // ROM layout
|
||||
|
||||
#endif // !HAS_SMALL_BASIC
|
||||
@@ -0,0 +1,47 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
cmd_merge:
|
||||
|
||||
lda #$00 // mark operation as LOAD
|
||||
jsr helper_load_init_params
|
||||
|
||||
// Fetch the file name
|
||||
|
||||
jsr helper_bload_fetch_filename
|
||||
|
||||
// Fetch device number
|
||||
|
||||
jsr helper_load_fetch_devnum
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_merge_got_params:
|
||||
|
||||
// Make sure VARTAB is correctly set
|
||||
|
||||
jsr update_VARTAB_do_clr
|
||||
|
||||
// Perform loading - just for a different address
|
||||
|
||||
sec
|
||||
lda VARTAB+0
|
||||
sbc #$02
|
||||
sta VARTAB+0
|
||||
tax
|
||||
bcs !+
|
||||
dec VARTAB+1
|
||||
!:
|
||||
ldy VARTAB+1
|
||||
|
||||
lda VERCKB // LOAD or VERIFY
|
||||
jsr JLOAD
|
||||
bcs_16 do_kernal_error
|
||||
|
||||
cmd_merge_no_error:
|
||||
|
||||
// Relink loaded program, clear variables, execute next statement
|
||||
|
||||
jmp update_LINKPRG_VARTAB_do_clr
|
||||
@@ -0,0 +1,81 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// For direct mode, asks the user if he is sure (sets Carry if not);
|
||||
// otherwise returns with Carry clear
|
||||
//
|
||||
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
helper_ask_if_sure:
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__helper_ask_if_sure
|
||||
jmp map_NORMAL
|
||||
|
||||
#else
|
||||
|
||||
// First check, if we are in direct mode,; if not, do not ask
|
||||
|
||||
ldx CURLIN+1
|
||||
inx
|
||||
bne helper_ask_if_sure_ok // branch if not direct mode
|
||||
|
||||
// Not direct mode - display the question
|
||||
|
||||
ldx #IDX__STR_IF_SURE
|
||||
jsr print_packed_misc_str
|
||||
|
||||
// Clear the keyboard queue
|
||||
|
||||
lda #$00
|
||||
sta NDX
|
||||
|
||||
// Enable cursor, fetch the answer
|
||||
|
||||
lda #$00
|
||||
sta BLNSW
|
||||
!:
|
||||
jsr JGETIN
|
||||
cmp #$00
|
||||
beq !-
|
||||
|
||||
// Check if 'Y'
|
||||
|
||||
cmp #$59
|
||||
beq !+
|
||||
|
||||
lda #$4E // 'N'
|
||||
jsr JCHROUT
|
||||
|
||||
sec
|
||||
rts
|
||||
!:
|
||||
// Display 'Y' and wait a short moment for a better user experience
|
||||
|
||||
jsr JCHROUT
|
||||
|
||||
clc
|
||||
lda TIME+2
|
||||
adc #$0C
|
||||
!:
|
||||
cmp TIME+2
|
||||
bne !-
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
helper_ask_if_sure_ok:
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
|
||||
#endif // ROM layout
|
||||
|
||||
#endif // !HAS_SMALL_BASIC
|
||||
@@ -0,0 +1,22 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches address for BLOAD/BVERIFY/BSAVE, reports error if not found
|
||||
//
|
||||
|
||||
|
||||
helper_bload_fetch_address:
|
||||
|
||||
jsr injest_comma
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
lda #IDX__EV2_0B // 'SYNTAX ERROR'
|
||||
jsr fetch_uint16
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
ldx LINNUM+0
|
||||
ldy LINNUM+1
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,26 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Fetches file name for BLOAD/BVERIFY/MERGE, reports error if not found
|
||||
//
|
||||
|
||||
|
||||
helper_bload_fetch_filename:
|
||||
|
||||
// Fetch the file name
|
||||
|
||||
jsr helper_load_fetch_filename
|
||||
bcc !+
|
||||
|
||||
// No filename supplied - this should only be allowed for tape (device number below 8)
|
||||
|
||||
lda FA
|
||||
and #%11111000
|
||||
bne_16 do_MISSING_FILENAME_error
|
||||
|
||||
lda #$00
|
||||
sta FNLEN
|
||||
!:
|
||||
rts
|
||||
@@ -0,0 +1,20 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper table for 'MEM' command - list of strings to print
|
||||
//
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
helper_mem_tab_str:
|
||||
|
||||
.byte IDX__STR_MEM_FREE
|
||||
.byte IDX__STR_MEM_STRS
|
||||
.byte IDX__STR_MEM_ARRS
|
||||
.byte IDX__STR_MEM_VARS
|
||||
.byte IDX__STR_MEM_TEXT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper table for 'MEM' command - list of minuend zeropage variables
|
||||
//
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
helper_mem_tab_x:
|
||||
|
||||
.byte FRETOP
|
||||
.byte MEMSIZ
|
||||
.byte STREND
|
||||
.byte ARYTAB
|
||||
.byte VARTAB
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 BASIC_1 #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper table for 'MEM' command - list of subtrahend zeropage variables
|
||||
//
|
||||
|
||||
#if !HAS_SMALL_BASIC
|
||||
|
||||
helper_mem_tab_y:
|
||||
|
||||
.byte STREND
|
||||
.byte FRETOP
|
||||
.byte ARYTAB
|
||||
.byte VARTAB
|
||||
.byte TXTTAB
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user