From 6d74679a5ca7137eb0d433028a7666e77132d00e Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sat, 4 May 2019 23:52:48 +0930 Subject: [PATCH] set end of loaded memory pointer in BASIC LOAD routine. Other small fixes. --- c64/basic/cmd_load.s | 49 +++++++++++++++++++++++++++++++++++ c64/basic/cmd_unimplemented.s | 19 -------------- c64/kernal/load.s | 12 +++++++-- 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 c64/basic/cmd_load.s diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s new file mode 100644 index 00000000..4090be5b --- /dev/null +++ b/c64/basic/cmd_load.s @@ -0,0 +1,49 @@ +cmd_load: + + ;; Parse filename + ;; (we can tell the KERNAL where it is in memory directly, since the + ;; KERNAL will be able to peek under ROMs to read it, since it will have + ;; to be able to peek under the ROMs for SAVE and VERIFY). + ;; Parse optional device # + ;; Parse optional secondary address + + ;; XXX - C64 BASIC apparently doesn't clear variables after a LOAD in the + ;; middle of a program. For safety, we do. + jsr basic_do_clr + + ;; Try to load an IEC file + lda #0 ; use supplied load address, not the one from the file + sta current_secondary_address + lda #$00 ; LOAD not verify + ldx #<$0801 ; LOAD address = $0801 + ldy #>$0801 + jsr $ffd5 + bcc + + + ;; A = KERNAL error code, which also almost match + ;; basic ERROR codes, so we can just copy the + ;; error code to X, decrement, and handle normally + tax + dex + jmp do_basic_error + +* + ;; $YYXX is the last loaded address, so store it + stx basic_end_of_text_ptr+0 + sty basic_end_of_text_ptr+1 + + ;; Now relink the loaded program, as we cannot trust the line + ;; links supplied. For example, the VICE virtual drive emulation + ;; always supplies $0101 as the address of the next line. + + ;; After LOADing, we either start the program from the beginning, + ;; or go back to the READY prompt if LOAD was called from direct mode. + + ;; Reset to start of program + lda basic_start_of_text_ptr+0 + sta basic_current_line_ptr+0 + lda basic_start_of_text_ptr+1 + sta basic_current_line_ptr+1 + + ;; Try to keep executing + jmp basic_execute_statement diff --git a/c64/basic/cmd_unimplemented.s b/c64/basic/cmd_unimplemented.s index 4561cd47..56269f91 100644 --- a/c64/basic/cmd_unimplemented.s +++ b/c64/basic/cmd_unimplemented.s @@ -20,7 +20,6 @@ cmd_rem: cmd_stop: cmd_on: cmd_wait: -cmd_load: cmd_save: cmd_verify: cmd_def: @@ -82,24 +81,6 @@ cmd_go: ;; Undefined tokens cmd_unimplemented: - ;; Dummy action while testing IEC support - - ;; Try to load an IEC file - lda #0 ; use supplied load address, not the one from the file - sta current_secondary_address - lda #$00 ; LOAD not verify - ldx #<$0801 ; LOAD address = $0801 - ldy #>$0801 - jsr $ffd5 - bcc + - - ;; A = KERNAL error code, which also almost match - ;; basic ERROR codes, so we can just copy the - ;; error code to X, decrement, and handle normally - tax - dex - jmp do_basic_error -* jmp do_NOT_IMPLEMENTED_error diff --git a/c64/kernal/load.s b/c64/kernal/load.s index b53450cb..76a64a60 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -154,13 +154,21 @@ load_done: jsr iec_tx_byte jsr iec_release_atn - ;; FALL THROUGH + ;; Return last address written to +1 + ;; (Even though Compute's Mapping the 64 says without the +1. + ;; I'm suspicious. Will have to check behavour on an original C64) + ldx load_save_start_ptr+0 + ldy load_save_start_ptr+1 + clc + cli + rts load_error: ;; XXX - Indicate KERNAL (not BASIC) LOAD error condtion - + sec + ;; Re-enable interrupts and return cli ;; (iec_tx_byte will have set/cleared C flag and put result code