From 1ef37c2a8c614426d6b27c959b2c0f4b3d849f71 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 7 Oct 2019 21:49:26 +0200 Subject: [PATCH] fixed DOS wedge operating on tokenized string --- c64/basic/basic_execute_line.s | 20 ------------------- c64/basic/basic_main_loop.s | 35 +++++++++++++++++++++++----------- c64/basic/wedge_dos.s | 19 +++++++++++++++++- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index 15c533fa..e8c2c191 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -112,26 +112,6 @@ not_a_token: cmp #$3a beq basic_skip_char -#if CONFIG_DOS_WEDGE - - // Are we in direct mode? - // DOS Wedge is a hacky solution (inelegant, but convenient), - // BASIC programmers should implement communication with drives - // the standard way, handling channels properly. Besides, - // current implementation does not support characters under ROM - ldx CURLIN+1 - cpx #$ff - bne !+ - // We are in direct mode, allow wedge to handle '@' sign - // XXX Maybe it should be allowed only as the first command? - cmp #$40 - bne !+ - jsr basic_consume_character - jmp wedge_dos -!: - -#endif // CONFIG_DOS_WEDGE - // If all else fails, it's a syntax error jmp do_SYNTAX_error diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 911e0f7f..0c93e2a8 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -39,12 +39,13 @@ got_line_of_input: // Strip leading spaces from the line remove_leading_spaces: - lda $0200 + lda BUF cmp #$20 bne !+ ldx #1 -rsl_l1: lda $0200,x - sta $01ff,x +rsl_l1: + lda BUF,x + sta BUF-1,x inx cpx __tokenise_work1 bne rsl_l1 @@ -61,11 +62,23 @@ rsl_l1: lda $0200,x lda __tokenise_work1 beq basic_read_next_line +#if CONFIG_DOS_WEDGE + + // Check if DOS wedge should take over + lda BUF + cmp #$40 // '@' + bne !+ + ldx __tokenise_work1 // here is the size of input + jmp wedge_dos +!: + +#endif // CONFIG_DOS_WEDGE + // Else, tokenise the line jsr tokenise_line // Has the user entered a line of BASIC beginning with a number? - lda $0200 + lda BUF cmp #$30 bcc not_a_line cmp #$39 @@ -82,9 +95,9 @@ rsl_l1: lda $0200,x sta __tokenise_work1 // Try to read line number - lda #<$0200 + lda #$0200 + lda #>BUF sta TXTPTR+1 jsr basic_parse_line_number @@ -98,13 +111,13 @@ rsl_l1: lda $0200,x // Skip any spaces after the line number ldx __tokenise_work1 skip_spaces: - lda $0200,x + lda BUF,x cmp #$20 bne !+ inx bne skip_spaces !: stx __tokenise_work1 - + // First, clear all variables, so that we only have to shove BASIC text around. // (We could later remove this requirement, and the only effect should be // to slow things down, and that you might have to either CLR if there is no @@ -135,9 +148,9 @@ not_a_line: // Actually interpret the line // Setup pointer to the statement - lda #<$0200 + lda #$0200 + lda #>BUF sta TXTPTR+1 // There is no stored line, so zero that pointer out @@ -148,7 +161,7 @@ not_a_line: // Put invalid line number in current line number value, // so that we know we are in direct mode // (Compute's Mapping the 64 p19) - lda #$ff + lda #$FF sta CURLIN+1 jmp basic_execute_statement diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 47322a6a..7ede8e76 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -1,8 +1,15 @@ #if CONFIG_DOS_WEDGE +// .X has to contain size of the buffer + wedge_dos: + // Prepare buffer - finish it with '0' + + lda #$00 + sta BUF,x + // Close all the channels, so that wedge has full control jsr JCLALL @@ -12,6 +19,16 @@ wedge_dos: ldy #$0F jsr JSETFLS + // Setup necessary parts of BASIC + + lda #<(BUF+1) + sta TXTPTR+0 + lda #>(BUF+1) + sta TXTPTR+1 + + lda #$FF + sta CURLIN+1 + // Now we have to check what the user wants us to do // Check if user asked for a status @@ -210,7 +227,7 @@ wedge_dos_clean_exit: jsr JCLALL // Print new line jsr print_return - jmp basic_end_of_line + jmp basic_main_loop wedge_dos_basic_error: pha