From bfda74a9bccf0d3c5a12d9817803c4b60977e1b7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 26 Jul 2019 17:34:24 +0200 Subject: [PATCH] more work towards DOS wedge --- c64/aliases/,aliases_ram_lowmem.s | 8 ++-- c64/basic/,aliases.s | 2 +- c64/basic/cmd_list.s | 11 +++-- c64/basic/wedge_dos.s | 74 ++++++++++++++++++++++++++++--- 4 files changed, 82 insertions(+), 13 deletions(-) diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index ac9f8dd8..0cef3f43 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -44,10 +44,12 @@ .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address - ;; + ;; ;; Other low memory addresses - ;; - + ;; + + .alias BUF $200 ; $200-$250 (81 bytes), BASIC line editor input buffer + ;; Kernal tables for opened files, 10 entries each .alias LAT $259 ; logical file numbers .alias FAT $263 ; device numbers diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 6f98fbf4..e54dd5a9 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -91,7 +91,7 @@ .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 - .alias basic_input_buffer $0200 + .alias basic_input_buffer BUF ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index 13038f54..a1be1724 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -26,6 +26,12 @@ list_more_lines: bmi + jmp basic_do_break * + jsr list_single_line + ;; Now link to the next line + jsr basic_find_next_line + jmp list_loop + +list_single_line: ; entry point needed by DOS wedge ;; Print line number ldy #3 jsr peek_under_roms @@ -116,8 +122,5 @@ list_end_of_line: ;; Print end of line lda #$0d jsr via_IBSOUT + rts - ;; Now link to the next line - jsr basic_find_next_line - jmp list_loop - diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 3d6c0c84..041949c7 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -61,7 +61,7 @@ wedge_dos_command: jsr via_IBSOUT bcs wedge_dos_basic_error - ;; XXX close here, check status - print it if not OK + ;; XXX check status - print it if not OK ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -115,12 +115,77 @@ wedge_dos_status: wedge_dos_directory: - ;; XXX - implement this - jmp do_NOT_IMPLEMENTED_error + ;; First change the secondary address to the one suitable for + ;; directory loading + lda #$00 + sta current_secondary_address + + ;; Now determine the length of the 'file' name + ldy #$FF +* + iny + lda (basic_current_statement_ptr), y + bne - + + ;; Set the name to open + tya + ldx basic_current_statement_ptr+0 + ldy basic_current_statement_ptr+1 + jsr JSETNAM + + ;; Open the file + jsr via_IOPEN + bcs wedge_dos_basic_error + + ;; Set channel for input + ldx #$0F + jsr via_ICHKIN + bcs wedge_dos_basic_error + + ;; Ignore start address (2 first bytes) - XXX check for errors + jsr via_IBASIN + bcs wedge_dos_basic_error + jsr via_IBASIN + bcs wedge_dos_basic_error + +wedge_dos_directory_line: + + ;; Load a single line, reuse BASIC input buffer + ldy #$FF +* + iny + jsr via_IBASIN + bcs wedge_dos_basic_error + sta BUF, y + cpy #$50 + beq + ; line too long, terminate loading file + jsr JREADST + beq + ; end of file + lda BUF, y + bne - + ;; End of line, but not end of file + beq wedge_dos_directory_display +* + lda #K_STS_END_OF_FILE + sta IOSTATUS ; make sure end of file is marked + ;; FALLTROUGH + +wedge_dos_directory_display: + + lda #$00 ; extra protection + sta BUF, y + + ;; Display line + ldx #