From 4462a15061790f6551143707ff3bf998cf6de07d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 24 Jun 2020 17:30:49 +0200 Subject: [PATCH] BLOAD/BVERIFY can now parse parameters and read data --- c64/basic/basic_commands/cmd_load_verify.s | 2 -- .../basic_commands_CC/cmd_bload_bverify.s | 29 +++++++++------ c64/basic/basic_commands_CC/cmd_bsave.s | 21 +++-------- c64/basic/basic_commands_CC/cmd_merge.s | 36 ++++++++++++------- .../helper_bload_fetch_address.s | 20 +++++++++++ .../helper_bload_fetch_filename.s | 26 ++++++++++++++ 6 files changed, 92 insertions(+), 42 deletions(-) create mode 100644 c64/basic/basic_commands_CC/helper_bload_fetch_address.s create mode 100644 c64/basic/basic_commands_CC/helper_bload_fetch_filename.s diff --git a/c64/basic/basic_commands/cmd_load_verify.s b/c64/basic/basic_commands/cmd_load_verify.s index a9d719cb..aab37558 100644 --- a/c64/basic/basic_commands/cmd_load_verify.s +++ b/c64/basic/basic_commands/cmd_load_verify.s @@ -38,8 +38,6 @@ cmd_load_got_params: // input for tape wedge ldy TXTTAB+1 ldx TXTTAB+0 -cmd_load_loadmerge: // entry point for 'cmd_merge' - lda VERCKB // LOAD or VERIFY jsr JLOAD bcs_16 do_kernal_error diff --git a/c64/basic/basic_commands_CC/cmd_bload_bverify.s b/c64/basic/basic_commands_CC/cmd_bload_bverify.s index 8ec63ef5..325257fd 100644 --- a/c64/basic/basic_commands_CC/cmd_bload_bverify.s +++ b/c64/basic/basic_commands_CC/cmd_bload_bverify.s @@ -18,18 +18,25 @@ cmd_bload: // Fetch the file name - jsr helper_load_fetch_filename - bcc !+ + jsr helper_bload_fetch_filename - // No filename supplied - this should only be allowed for tape (device number below 8) + // Fetch device number - lda FA - and #%11111000 - bne_16 do_MISSING_FILENAME_error + jsr fetch_coma_uint8 + bcs_16 do_SYNTAX_error - lda #$00 - sta FNLEN -!: - // XXX finish the implementation + sta FA - jmp do_NOT_IMPLEMENTED_error + // Fetch the start address + + jsr helper_bload_fetch_address + + // Perform loading + + lda VERCKB // LOAD or VERIFY + jsr JLOAD + bcs_16 do_kernal_error + + // That is it - continue execution + + jmp execute_line diff --git a/c64/basic/basic_commands_CC/cmd_bsave.s b/c64/basic/basic_commands_CC/cmd_bsave.s index 886501a0..1e2dbdf8 100644 --- a/c64/basic/basic_commands_CC/cmd_bsave.s +++ b/c64/basic/basic_commands_CC/cmd_bsave.s @@ -21,27 +21,14 @@ cmd_bsave: // Fetch memory area start address - jsr injest_comma - bcs_16 do_SYNTAX_error + jsr helper_bload_fetch_address - jsr basic_parse_line_number // XXX detect errors here - - lda LINNUM+0 - pha - lda LINNUM+1 - pha + phx_trash_a + phy_trash_a // Fetch memory area end address - jsr injest_comma - bcs_16 do_SYNTAX_error - - jsr basic_parse_line_number // XXX detect errors here - - // Setup start/end addresses - - ldx LINNUM+0 - ldy LINNUM+1 + jsr helper_bload_fetch_address pla sta LINNUM+1 diff --git a/c64/basic/basic_commands_CC/cmd_merge.s b/c64/basic/basic_commands_CC/cmd_merge.s index 375c61f9..6de6c68d 100644 --- a/c64/basic/basic_commands_CC/cmd_merge.s +++ b/c64/basic/basic_commands_CC/cmd_merge.s @@ -10,24 +10,16 @@ cmd_merge: // Fetch the file name - jsr helper_load_fetch_filename - bcc !+ + jsr helper_bload_fetch_filename - // 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 -!: // Fetch device number jsr helper_load_fetch_devnum // Perform loading - just for a different address + // XXX sometimes works, sometimes does not - probably improper handling of VARTAB somewhere + sec lda VARTAB+0 sbc #$02 @@ -38,4 +30,24 @@ cmd_merge: !: ldy VARTAB+1 - jmp cmd_load_loadmerge // XXX check variable handling (VARTAB) after failure to load + lda VERCKB // LOAD or VERIFY + jsr JLOAD + bcs_16 do_kernal_error + +cmd_merge_no_error: + + // Store last loaded address + + stx VARTAB+0 + sty VARTAB+1 + + // Clear the variables + jsr basic_do_clr + + // Now relink the loaded program, line links supplied are almost certainly wrong + + jsr LINKPRG + + // Continue execution + + jmp execute_statements diff --git a/c64/basic/basic_commands_CC/helper_bload_fetch_address.s b/c64/basic/basic_commands_CC/helper_bload_fetch_address.s new file mode 100644 index 00000000..f5fca8f6 --- /dev/null +++ b/c64/basic/basic_commands_CC/helper_bload_fetch_address.s @@ -0,0 +1,20 @@ +// #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 + + jsr basic_parse_line_number // XXX detect errors here + + ldx LINNUM+0 + ldy LINNUM+1 + + rts diff --git a/c64/basic/basic_commands_CC/helper_bload_fetch_filename.s b/c64/basic/basic_commands_CC/helper_bload_fetch_filename.s new file mode 100644 index 00000000..13da848c --- /dev/null +++ b/c64/basic/basic_commands_CC/helper_bload_fetch_filename.s @@ -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