From ccb78c10b4e884e58672a5f41704eb1da498f3e5 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jul 2019 11:18:21 +0200 Subject: [PATCH] DOS wedge can now display directories --- STATUS.md | 13 ++++++++----- c64/basic/wedge_dos.s | 22 +++++++++++++++++----- c64/kernal/iec/iec_cmd_close.s | 8 ++------ c64/kernal/iec/iec_cmd_open.s | 21 +++++++++++++++++---- c64/kernal/open.s | 6 ++++-- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/STATUS.md b/STATUS.md index c4d99e8d..5132287c 100644 --- a/STATUS.md +++ b/STATUS.md @@ -5,10 +5,14 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input * joystick (port 1) can be used to move text cursor -* 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! +* uses RAM under ROM and I/O: 61436 bytes free +* extended `LOAD` command + * start/end addresses are displayed, in the Final cartridge style + * command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 + * secondary address over 255 is considered a start address +* DOS wedge (direct mode only) - `@`, `@`, `@$`, `@$`, `@` + +NOTE: extra features and their syntax can change in the future! # Features missing @@ -27,7 +31,6 @@ The following ROM features are currently missing: Features currently being worked on: * IEC support -* DOS wedge # API status diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 5c58829e..e147e9fe 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -129,8 +129,11 @@ wedge_dos_directory: ;; First change the secondary address to the one suitable for ;; directory loading - lda #$00 - sta current_secondary_address + ;; XXX + lda #$00 ; logical device number + ldx current_device_number + ldy #$60 + jsr JSETFLS ;; Provide file name jsr wedge_dos_setnam @@ -139,8 +142,8 @@ wedge_dos_directory: jsr via_IOPEN bcs wedge_dos_basic_error - ;; Set channel for input - ldx #$0F + ;; Set channel for file reading + ldx #$00 jsr via_ICHKIN bcs wedge_dos_basic_error @@ -162,7 +165,9 @@ wedge_dos_directory_line: cpy #$50 beq + ; line too long, terminate loading file jsr JREADST - beq + ; end of file + bne + ; end of file + cpy #$04 ; 2 bytes (pointer to next line) + 2 bytes (line number) + bcc - lda BUF, y bne - ;; End of line, but not end of file @@ -174,11 +179,18 @@ wedge_dos_directory_line: wedge_dos_directory_display: + cpy #$05 ; protection against malformed directory + bcc wedge_dos_clean_exit + lda #$00 ; extra protection agains buffer overflow sta BUF, y ;; Display line ldx #BUF + stx basic_current_line_ptr+1 + ldx #basic_current_line_ptr jsr list_single_line ;; Read & display next line or quit diff --git a/c64/kernal/iec/iec_cmd_close.s b/c64/kernal/iec/iec_cmd_close.s index 552428a2..60c30a96 100644 --- a/c64/kernal/iec/iec_cmd_close.s +++ b/c64/kernal/iec/iec_cmd_close.s @@ -7,12 +7,8 @@ iec_cmd_close: - jsr iec_tx_flush - - ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), - ;; allowed channels are 0-15; report error if out of range - cmp #$10 - bcc + + jsr iec_check_channel_openclose + bcc + jmp kernalerror_FILE_NOT_INPUT * ora #$E0 diff --git a/c64/kernal/iec/iec_cmd_open.s b/c64/kernal/iec/iec_cmd_open.s index cd184307..aa23a2c5 100644 --- a/c64/kernal/iec/iec_cmd_open.s +++ b/c64/kernal/iec/iec_cmd_open.s @@ -8,10 +8,8 @@ iec_cmd_open: ; similar to TKSA, but without turnaround - ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), - ;; allowed channels are 0-15; report error if out of range - cmp #$10 - bcc + + jsr iec_check_channel_openclose + bcc + jmp kernalerror_FILE_NOT_INPUT * ora #$F0 @@ -27,3 +25,18 @@ common_open_close_unlsn_second: ; common part of several commands * rts +iec_check_channel_openclose: + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + ;; Workaround to allow reading executable files and disk directory + ;; using OPEN routine - see https://www.pagetable.com/?p=273 for + ;; example usage + cmp #$60 + beq + + sec ; mark unsuitable channel number + rts +* + clc ; mark suitable channel number + rts diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 4cecbfe3..8d494dfe 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -78,9 +78,11 @@ open_iec: bcc + jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?) * + + ;; We need our helpers to get to filenames under ROMs or IO area + jsr install_ram_routines + ;; Send command ('file name') jsr lvs_send_file_name jmp open_done_success - -