From c7727d4f0f4c21b3234e0a48c38eb019fb3dbc3c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 17:59:24 +0200 Subject: [PATCH] LOAD command understands device number and secondary address --- STATUS.md | 2 +- c64/basic/cmd_load.s | 49 ++++++++++++++++++++++++++++++++-------- c64/basic/injest_comma.s | 20 ++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 c64/basic/injest_comma.s diff --git a/STATUS.md b/STATUS.md index ab419717..281a9951 100644 --- a/STATUS.md +++ b/STATUS.md @@ -8,7 +8,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * banking in the BASIC interpreter: 61436 bytes free * LOAD start/end addresses are displayed, in the Final cartridge style * LOAD command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 - +* LOAD secondary address over 255 is considered a start address; NOTE: syntax will most likely change here in the future! # Features missing diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 22b648eb..2931b607 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -19,10 +19,6 @@ cmd_load: lda #$00 ; direct mode - don't display anything * jsr JSETMSG - - ;; XXX handle device number from arguments, if not present, use the call below - jsr select_device - stx current_device_number ;; Set filename and length lda #$00 @@ -47,7 +43,7 @@ cmd_load: ;; Now search for end of line or closing quote ;; so that we know the length of the filename -getting_filename: +getting_filename: jsr basic_fetch_and_consume_character cmp #$22 beq got_filename @@ -60,15 +56,48 @@ getting_filename: inc FNLEN jmp getting_filename -got_filename: +got_filename: - ;; Try to load an IEC file - lda #0 ; use supplied load address, not the one from the file + ;; Now fetch the file number, start from the default one + jsr select_device + stx current_device_number + jsr injest_comma + bcs got_devicenumber + + jsr basic_parse_line_number + lda basic_line_number+1 + bne do_ILLEGAL_QUANTITY_error + lda basic_line_number+0 + sta current_device_number + +got_devicenumber: + + ;; Now fetch the secondary address + lda #$00 sta current_secondary_address - lda #$00 ; LOAD not verify - ldx #<$0801 ; LOAD address = $0801 + jsr injest_comma + bcs got_secondaryaddress + jsr basic_parse_line_number + lda basic_line_number+1 + bne + + lda basic_line_number+0 + sta current_secondary_address + jmp got_secondaryaddress +* + ;; Second parameter is above 255, this can't be a secondary address + ;; Use it as load address instead + ;; XXX temporary syntax, it would be better to use something + ;; XXX like 'LOAD"FILE",8 TO 49152' + ldx basic_line_number+0 + ldy basic_line_number+1 + bne got_loadaddress + +got_secondaryaddress: + ldx #<$0801 ldy #>$0801 +got_loadaddress: + lda #$00 ; LOAD not verify jsr JLOAD bcc + diff --git a/c64/basic/injest_comma.s b/c64/basic/injest_comma.s new file mode 100644 index 00000000..43be5113 --- /dev/null +++ b/c64/basic/injest_comma.s @@ -0,0 +1,20 @@ + +;; Consummes a comma in a BASIC code, C set for no coma found + +injest_comma: + + jsr basic_fetch_and_consume_character + cmp #$2C ; comma character + beq injest_comma_found + cmp #$20 + beq injest_comma ; space, can always be skipped + + ;; not found + jsr basic_unconsume_character + sec + rts + +injest_comma_found: + clc + rts +