From 3b11d1b881d62d03011cc697504406df1145b11b Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jun 2020 22:47:55 +0200 Subject: [PATCH] tape wedge now accepts file name --- CONFIG.md | 4 +- STATUS.md | 2 +- src/basic/editor/shell.s | 30 +++----- src/basic/engine/prepare_direct_execution.s | 27 +++++++ src/basic/wedge/wedge_tape.s | 85 ++++++++++++++++----- 5 files changed, 106 insertions(+), 42 deletions(-) create mode 100644 src/basic/engine/prepare_direct_execution.s diff --git a/CONFIG.md b/CONFIG.md index 9c1fa54c..6aae84a7 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -285,9 +285,9 @@ Feature needs about 330 bytes in BASIC segment. If unsure - enable. ### `CONFIG_TAPE_WEDGE` -If enabled, a simple DOS wedge is available from the direct mode for tape loading - supports `←L` only. +If enabled, a simple DOS wedge is available from the direct mode for tape loading - supports `←L` only, optionally with a file name. -Feature needs few bytes in BASIC segment. If unsure - enable. +Feature needs several bytes in BASIC segment. If unsure - enable. ### `CONFIG_TAPE_HEAD_ALIGN` diff --git a/STATUS.md b/STATUS.md index 9f31e493..4504bd90 100644 --- a/STATUS.md +++ b/STATUS.md @@ -12,7 +12,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * DOS wedge (direct mode only) - `@`, `@`, `@$`, `@$`, `@` * BASIC extensions, see the [documentation](doc/Extended-BASIC.md) -* turbo tape load support (as device 7, or using `←L`), quite sophisticated: up to 250 blocks (can store bytes under I/O), automatically adjusts for tape speed differences +* turbo tape load support (as device 7, or using `←L`, optionallly with a file name), quite sophisticated: up to 250 blocks (can store bytes under I/O), automatically adjusts for tape speed differences * normal tape load error log is limited by free stack space only (no artificial limitation like in original ROMs) * tape format autodetection; normal vs turbo is mostly transparent to user * improved support for tape adapters (for using regular casette players and other audio devices instead of Datasette) and emulators diff --git a/src/basic/editor/shell.s b/src/basic/editor/shell.s index fe4eafe1..da8ba2a3 100644 --- a/src/basic/editor/shell.s +++ b/src/basic/editor/shell.s @@ -37,7 +37,10 @@ shell_got_line: // Store length of input buffer ready for tokenising stx __tokenise_work1 - // XXX we should probably store 0 at the end of used BUF + + // Store 0 as the sentinel + lda #$00 + sta BUF, x // FALLTROUGH @@ -76,10 +79,13 @@ shell_process_line: // Check if a wedge should take over +#if CONFIG_DOS_WEDGE + + ldx __tokenise_work1 // size of the input, DOS wedges needs this XXX this should not be needed + +#endif #if CONFIG_DOS_WEDGE || CONFIG_TAPE_WEDGE - ldx __tokenise_work1 // size of the input, wedges need this XXX this should not be needed - // Check if DOS wedge should take over lda BUF @@ -170,20 +176,6 @@ shell_add_delete_line: shell_execute_line: - // Setup pointer to the statement - lda #BUF - sta TXTPTR+1 - - // There is no stored line, so zero that pointer out - lda #$00 - sta OLDTXT+0 - sta OLDTXT+1 - - // Put invalid line number in current line number value, - // so that we know we are in direct mode (Computes Mapping the 64 p19) - lda #$FF - sta CURLIN+1 - + jsr prepare_direct_execution jmp execute_statements + diff --git a/src/basic/engine/prepare_direct_execution.s b/src/basic/engine/prepare_direct_execution.s new file mode 100644 index 00000000..1b2b1bb0 --- /dev/null +++ b/src/basic/engine/prepare_direct_execution.s @@ -0,0 +1,27 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Prepare interpreter to execute commands in direct mode +// + +prepare_direct_execution: + + // Setup pointer to the statement + lda #BUF + sta TXTPTR+1 + + // There is no stored line, so zero that pointer out + lda #$00 + sta OLDTXT+0 + sta OLDTXT+1 + + // Put invalid line number in current line number value, + // so that we know we are in direct mode (Computes Mapping the 64 p19) + lda #$FF + sta CURLIN+1 + + rts diff --git a/src/basic/wedge/wedge_tape.s b/src/basic/wedge/wedge_tape.s index ac89415d..f2608a1f 100644 --- a/src/basic/wedge/wedge_tape.s +++ b/src/basic/wedge/wedge_tape.s @@ -6,17 +6,16 @@ #if CONFIG_TAPE_WEDGE -// .X has to contain size of the buffer - wedge_tape: - lda #$FF - sta CURLIN+1 // in case of error do not print line number + // Prepare for execution - cpx #$02 - bne_16 do_SYNTAX_error + jsr prepare_direct_execution + jsr fetch_character - lda BUF+1 + // First character is a 'left arrow', we can ignore it - determine the command + + jsr fetch_character cmp #$4C // 'L' beq wedge_arrow_L @@ -30,12 +29,69 @@ wedge_tape: jmp do_SYNTAX_error +#if CONFIG_TAPE_HEAD_ALIGN + +wedge_arrow_H: + + // Make sure the syntax is correct + + jsr injest_spaces + jsr fetch_character + + cmp #$00 + bne_16 do_SYNTAX_error + + jsr tape_head_align + + jsr print_return + jmp do_BREAK_error + +#endif + wedge_arrow_L: - // Execute 'arrow + L' + // Make sure the syntax is correct + + jsr injest_spaces + jsr fetch_character + cmp #$00 + beq wedge_arrow_L_no_filename // branch if no file name given + cmp #$22 + bne_16 do_SYNTAX_error // branch if no opening quote + + // Fetch the file name + + lda TXTPTR+0 + sta FNADDR+0 + lda TXTPTR+1 + sta FNADDR+1 + + ldx #$00 +!: + jsr fetch_character + + cmp #$00 + beq !+ + cmp #$22 + beq !+ + + inx + bne !- +!: + stx FNLEN + lda #$00 - sta FNLEN // default file name is empty + beq wedge_arrow_L_got_filename + +wedge_arrow_L_no_filename: + + sta FNLEN // .A is 0 here, default file name is empty + + // FALLTROUGH + +wedge_arrow_L_got_filename: // .A has to be 0 + sta VERCKB // operation is LOAD, not VERIFY ldy #$01 @@ -51,16 +107,5 @@ wedge_arrow_L: jmp cmd_load_got_params -#if CONFIG_TAPE_HEAD_ALIGN - -wedge_arrow_H: - - jsr tape_head_align - - jsr print_return - jmp do_BREAK_error - -#endif - #endif // CONFIG_TAPE_WEDGE