small improvements for LOAD command and IEC routines

This commit is contained in:
FeralChild64 committed 2019-07-16 22:22:01 +02:00
1 parent 3cae7f7366
commit ecf1b3aa50
8 files changed
+89 -33

No files matched your search

+2 -3
View File
@@ -20,9 +20,8 @@ cmd_load:
* *
jsr JSETMSG jsr JSETMSG
;; XXX temporary, to set valid device number ;; XXX handle device number from arguments, if not present, use the call below
lda #$08 jsr set_sane_devnum
sta current_device_number
;; Set filename and length ;; Set filename and length
lda #$00 lda #$00
+17
View File
@@ -0,0 +1,17 @@
set_sane_devnum:
;; Take last device number, make sure it's a drive
;; If not, set to 8 (first drive number)
;; Device number is left in X, for SETFLS Kernal routine
;; Note: if tape support is introduced here, make sure DOS wedge won't get broken
ldx current_device_number
cpx #$07
bpl +
bcs +
ldx #$08
stx current_device_number
*
rts
+9 -13
View File
@@ -6,15 +6,11 @@ wedge_dos:
;; Close all the channels, so that wedge has full control ;; Close all the channels, so that wedge has full control
jsr wedge_dos_CLALL jsr wedge_dos_CLALL
;; Take last device number, make sure it's a drive ;; Make sure current device number is sane
;; If not, set to 8 (first drive number) jsr set_sane_devnum
ldx DFLTN
cpx #$07 ;; Set remaining file parameters (X already set by set_sane_devnum);
bpl + ;; channel 15 is a typical one for commands
bcs +
ldx #$08
*
;; Set remaining file parameters; channel 15 is a typical one for commands
lda #$0F lda #$0F
ldy #$0F ldy #$0F
jsr JSETFLS jsr JSETFLS
@@ -67,7 +63,7 @@ wedge_dos_change_drive:
bcs + bcs +
jmp do_ILLEGAL_DEVICE_NUMBER_error jmp do_ILLEGAL_DEVICE_NUMBER_error
* *
sta DFLTN sta current_device_number
jmp basic_end_of_line jmp basic_end_of_line
wedge_dos_status: wedge_dos_status:
@@ -77,7 +73,7 @@ wedge_dos_status:
;; Set remaining file parameters, open the channel ;; Set remaining file parameters, open the channel
lda #$00 ; empty file name lda #$00 ; empty file name
jsr $FFBD ; SETNAM jsr JSETNAM
jsr wedge_dos_OPEN jsr wedge_dos_OPEN
bcc + bcc +
jmp do_DEVICE_NOT_PRESENT_error jmp do_DEVICE_NOT_PRESENT_error
@@ -90,8 +86,8 @@ wedge_dos_status:
* *
;; Print out everything retrieved from the drive ;; Print out everything retrieved from the drive
bne + bne +
jsr $FFCF ; CHRIN jsr JCHRIN
jsr $FFD2 ; CHROUT jsr JCHROUT
jmp - jmp -
* *
;; Clean-up and exit ;; Clean-up and exit
+16
View File
@@ -1,3 +1,19 @@
; Function defined on pp272-273 of C64 Programmers Reference Guide ; Function defined on pp272-273 of C64 Programmers Reference Guide
chkin: chkin:
;; Implemented according to 'C64 Programmers Reference Guide', page 277
;; First retrieve the FAT/LAT/SAT table index (and check if file is open)
; txa
; jsr find_fls
; bcs kernalerror_FILE_NOT_OPEN
;; Now we have table index in Y - check if file is open for reading
;; XXX continue implementation
rts rts
+14
View File
@@ -1,3 +1,17 @@
; Function defined on pp272-273 of C64 Programmers Reference Guide ; Function defined on pp272-273 of C64 Programmers Reference Guide
chkout: chkout:
;; Implemented according to 'C64 Programmers Reference Guide', page 278
;; First retrieve the FAT/LAT/SAT table index (and check if file is open)
; txa
; jsr find_fls
; bcs kernalerror_FILE_NOT_OPEN
;; Now we have table index in Y - check if file is open for writing
;; XXX continue implementation
rts rts
+4 -9
View File
@@ -7,13 +7,8 @@ close:
;; Find the LAT / SAT / FAT entry which LAT corresponds to A ;; Find the LAT / SAT / FAT entry which LAT corresponds to A
ldy LDTND jsr find_fls
beq close_error_not_found ; table empty bcs close_error_not_found ;; XXX can we report error in IOSTATUS here?
*
dey
bmi close_error_not_found ; no more entries
cmp LAT, y
bne - ; does not match, try the next one
;; We have the entry index in Y ;; We have the entry index in Y
@@ -33,9 +28,9 @@ close:
* *
;; Decrement the list size variable ;; Decrement the list size variable
dec LDTND dec LDTND
;; FALLTHROUGH (for now) - success
;; FALLTHROUGH - success
close_error_not_found: close_error_not_found:
;; XXX it seems that this function can't report errors, am I right?
rts rts
+23
View File
@@ -0,0 +1,23 @@
;; Just a helper routine
;; Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y
;; Carry flag set means not found
find_fls:
ldy LDTND
beq find_fls_not_found ; table empty
*
dey
bmi find_fls_not_found ; no more entries
cmp LAT, y
bne - ; does not match, try the next one
clc
rts
find_fls_not_found:
sec
rts
+4 -8
View File
@@ -54,9 +54,6 @@ print_filename_loop:
iny iny
jmp print_filename_loop jmp print_filename_loop
* *
lda #$0d
jsr JCHROUT
;; XXX - Use default device number ;; XXX - Use default device number
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
;; p13, 16. ;; p13, 16.
@@ -145,11 +142,11 @@ sent_filename:
lda kernal_load_or_verify_flag lda kernal_load_or_verify_flag
beq + beq +
jsr printf jsr printf
.byte "VERIFYING", 0 .byte $0D, "VERIFYING", 0
jmp load_print_start_addr jmp load_print_start_addr
* *
jsr printf jsr printf
.byte "LOADING", 0 .byte $0D, "LOADING", 0
load_print_start_addr: load_print_start_addr:
jsr printf jsr printf
.byte " FROM $",0 .byte " FROM $",0
@@ -223,9 +220,8 @@ load_done:
;; Set IEC status back to idle ;; Set IEC status back to idle
jsr iec_set_idle jsr iec_set_idle
;; Return last address written to +1 ;; Return last address - Compute's Mapping the 64 says without the '+1',
;; (Even though Compute's Mapping the 64 says without the +1. ;; checked on original ROMs that this is really the case
;; I'm suspicious. Will have to check behavour on an original C64)
ldx load_save_start_ptr+0 ldx load_save_start_ptr+0
ldy load_save_start_ptr+1 ldy load_save_start_ptr+1