From e547b56003952fb9cd4e8856c1b3f5bf3649861b Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sun, 5 May 2019 01:26:37 +0930 Subject: [PATCH] fix various problems with LOAD taking a real filename. More to do. --- c64/basic/basic_execute_line.s | 22 ++++++++++++++++- c64/basic/cmd_load.s | 44 ++++++++++++++++++++++++++++------ c64/basic/injest_number.s | 3 +++ c64/kernal/load.s | 18 ++++++++++++-- 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index 494a82c6..99033e14 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -29,8 +29,12 @@ no_space_to_skip: basic_execute_statement: ;; Skip over any white space and : + ldy #0 + ldx #basic_current_line_ptr @@ -94,6 +98,12 @@ basic_skip_char: jsr basic_consume_character jmp basic_execute_statement +basic_fetch_and_consume_character: + ldy #0 + ldx #$0801 ;; Set filename and length - lda #$24 - sta $0400 - lda #$01 + lda #$00 sta current_filename_length - lda #<$0400 + + ;; Without tape support, LOAD must have a filename + ;; (This also skips any leading spaces) + jsr basic_end_of_statement_check + bcc + + jmp do_MISSING_FILENAME_error +* + jsr basic_fetch_and_consume_character + cmp #$22 + beq + + jmp do_SYNTAX_ERROR +* + ;; Filename starts here so set pointer + lda basic_current_statement_ptr+0 sta current_filename_ptr+0 - lda #>$0401 + lda basic_current_statement_ptr+1 sta current_filename_ptr+1 + ;; Now search for end of line or closing quote + ;; so that we know the length of the filename +getting_filename: + jsr basic_fetch_and_consume_character + cmp #$22 + beq got_filename + cmp #$00 + bne + + jsr basic_unconsume_character + + jmp got_filename +* + inc current_filename_length + jmp getting_filename + +got_filename: + + lda current_filename_length + jsr $ffd5 bcc + @@ -36,7 +66,7 @@ cmd_load: ;; error code to X, decrement, and handle normally tax dex - jmp do_basic_error + jmp do_LOAD_error * ;; $YYXX is the last loaded address, so store it @@ -58,7 +88,7 @@ cmd_load: sta basic_current_line_ptr+1 ;; Try to keep executing - jmp basic_execute_statement + jmp basic_execute_from_current_line basic_relink_program: diff --git a/c64/basic/injest_number.s b/c64/basic/injest_number.s index a48c995a..50b4203d 100644 --- a/c64/basic/injest_number.s +++ b/c64/basic/injest_number.s @@ -5,6 +5,9 @@ ;; XXX - Remember decimal position and exponent, and apply them ;; after to produce normalised floating point number. + ;; XXX - Doesn't use routines to access memory under ROMs etc. + ;; This is important, because this routine operates on numbers in BASIC text. + ij_not_a_digit: ;; XXX check for "." or "E" ;; Other chars terminate the accumulation. diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 4b6aff8b..59de1aab 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -31,7 +31,20 @@ load: ;; Display SEARCHING FOR jsr printf - .byte "SEARCHING FOR ",$0d,$0 + .byte "SEARCHING FOR " + + ldy #0 +print_filename_loop: + cpy current_filename_length + beq + + lda (current_filename_ptr),y + jsr $ffd2 + iny + jmp print_filename_loop +* + + lda #$0d + jsr $ffd2 ;; Begin sending under attention jsr iec_assert_atn @@ -79,7 +92,7 @@ send_filename: tya pha txa - + jsr iec_tx_byte pla @@ -191,6 +204,7 @@ load_error: ;; XXX - Indicate KERNAL (not BASIC) LOAD error condtion sec + lda #$02 ;; Re-enable interrupts and return cli