diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 172c50e1..3d6c0c84 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -18,9 +18,6 @@ wedge_dos: ldy #$00 lda (basic_current_statement_ptr), y beq wedge_dos_status - cmp #$20 - beq wedge_dos_status - ;; XXX consider SYNTAX ERROR if anything besides spaces is there ;; Check if asked for a directory cmp #$24 @@ -28,15 +25,14 @@ wedge_dos: * ;; Check if asked to change drive number, or if it is a regular command cmp #$30 - bmi wedge_dos_command ; char code before 0 + bcc wedge_dos_command ; char code before 0 cmp #$3A - bpl wedge_dos_command ; char code after 9 + bcs wedge_dos_command ; char code after 9 iny lda (basic_current_statement_ptr), y beq wedge_dos_change_drive ; end of buffer cmp #$20 beq wedge_dos_change_drive - ;; XXX consider SYNTAX ERROR if anything besides spaces is there jmp - wedge_dos_command: @@ -45,24 +41,27 @@ wedge_dos_command: lda #$00 ; empty file name jsr JSETNAM jsr via_IOPEN - bcc + - jmp do_DEVICE_NOT_PRESENT_error + bcs wedge_dos_basic_error * ;; Set channel for output ldx #$0F jsr via_ICKOUT -* - jsr JREADST ; retrieve errors - ;; XXX error in case of status != 0 + bcs wedge_dos_basic_error * - ;; XXX this loop does not seem to work, check it jsr basic_fetch_and_consume_character + cmp #$00 beq + + jsr via_IBSOUT - ;; XXX check errors here + bcs wedge_dos_basic_error jmp - * - ;; XXX check status - print it if not OK + ;; Finalize command + lda #$0D + jsr via_IBSOUT + bcs wedge_dos_basic_error + + ;; XXX close here, check status - print it if not OK ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -92,15 +91,15 @@ wedge_dos_status: lda #$00 ; empty file name jsr JSETNAM jsr via_IOPEN - bcc + - jmp do_DEVICE_NOT_PRESENT_error -* + bcs wedge_dos_basic_error + ;; Set channel for input ldx #$0F jsr via_ICHKIN + bcs wedge_dos_basic_error * jsr JREADST ; retrieve errors - ;; XXX error in case of status != 0 + ;; XXX error in case of status != EOF ;; Print out everything retrieved from the drive bne + jsr via_IBASIN @@ -117,8 +116,6 @@ wedge_dos_status: wedge_dos_directory: ;; XXX - implement this - jsr printf - .byte "DBG: DIR", 0 jmp do_NOT_IMPLEMENTED_error wedge_dos_clean_exit: @@ -126,4 +123,12 @@ wedge_dos_clean_exit: jsr via_ICLRCH jmp basic_end_of_line +wedge_dos_basic_error: + tax + dex + jsr do_basic_error + jsr via_ICLALL + jsr via_ICLRCH + jmp basic_end_of_line + ;; END wedge support diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index 9a267264..4004df20 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -61,8 +61,10 @@ chkin_set_device: ;; Common part for booth CHKIN and CKOUT chkinout_end: + tax pla tay + txa rts chkinout_file_not_open: diff --git a/c64/kernal/load.s b/c64/kernal/load.s index e83d3a6b..b3137cfe 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -42,7 +42,7 @@ load: lda current_device_number and #$FC beq lvs_illegal_device_number ; device number below 4, not an IEC device - + ;; Device numbers above 30 are also illegal (see https://www.pagetable.com/?p=1031), ;; as the protocol combines device number with command code int one byte, ;; above 30 it is no longer possible (UNLISTEN and UNTALK codes prevent using @@ -56,7 +56,7 @@ load: ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; p13, 16; also p16 tells us this routine doesn't mess with the file table ;; in the C64, only in the drive. - + ;; Call device to LISTEN (p16) lda current_device_number jsr listen @@ -67,6 +67,8 @@ load: sta BSOUR jsr iec_tx_command bcs lvs_load_verify_error + jsr iec_tx_command_finalize + bcs lvs_load_verify_error ;; Send filename (p16) ldy #0 @@ -97,7 +99,6 @@ load_filename_sent: ;; Command device to unlisten to indicate end of file name. (p16) jsr unlsn bcs lvs_load_verify_error - jsr iec_set_idle ;; XXX is it needed? ;; Now command device to talk (p16) lda current_device_number @@ -162,12 +163,10 @@ load_loop: lda #$E0 sta BSOUR jsr iec_tx_command + jsr iec_tx_command_finalize ;; Tell drive to unlisten jsr unlsn - - ;; Set IEC status back to idle - jsr iec_set_idle ;; Return last address jmp lvs_return_last_address diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 3f54a917..1205a7f6 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -30,8 +30,7 @@ open: ldy LDTND cpy #$0A - bcs + - bmi open_has_space + bcc open_has_space * ;; Table is full jmp kernalerror_TOO_MANY_OPEN_FILES