From c0d4df362fbe9e9b021bde577fc0f2ddc4be6c59 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 23:32:46 +0200 Subject: [PATCH] DOS wedge can now change device number --- c64/basic/basic_execute_line.s | 3 ++- c64/basic/wedge_dos.s | 36 ++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index 1571575f..749935cb 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -98,7 +98,8 @@ not_a_token: ;; Are we in direct mode? ;; DOS Wedge is a hacky solution (inelegant, but convenient), ;; BASIC programmers should implement communication with drives - ;; the standard way, handling channels properly + ;; the standard way, handling channels properly. Besides, + ;; current implementation does not support characters under ROM ldx basic_current_line_number+1 cpx #$ff bne + diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 2f7a5506..191be0f2 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -9,9 +9,9 @@ wedge_dos: ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) lda current_device_number - cmp #$07 + cmp #$07 ;; XXX allow high device numbers, like 170 bpl + - lda #$08 + lda #$08 * ;; Set remaining file parameters ldx #$0F @@ -26,12 +26,24 @@ wedge_dos: 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 beq wedge_dos_directory * - ;; XXX Check if asked to change drive number + ;; Check if asked to change drive number, or if it is a regular command + cmp #$30 + bmi wedge_dos_command ; char code before 0 + cmp #$3A + bpl 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: ; default @@ -42,10 +54,19 @@ wedge_dos_command: ; default wedge_dos_change_drive: - ;; XXX - implement this - jsr printf - .byte "DBG: CHANGE DRIVE", 0 - jmp do_NOT_IMPLEMENTED_error + ;; Reuse the line number parser for device number retrieval + jsr basic_parse_line_number + lda basic_line_number+1 + beq + + jmp do_ILLEGAL_QUANTITY_error +* + lda basic_line_number+0 + cmp #$08 ;; XXX allow high device numbers, like 170 + bpl + + jmp do_ILLEGAL_DEVICE_NUMBER_error +* + sta current_device_number + jmp basic_end_of_line wedge_dos_status: @@ -62,4 +83,3 @@ wedge_dos_directory: jmp do_NOT_IMPLEMENTED_error ;; END wedge support -