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
+96 -40

No files matched your search

+2 -3
View File
@@ -20,9 +20,8 @@ cmd_load:
*
jsr JSETMSG
;; XXX temporary, to set valid device number
lda #$08
sta current_device_number
;; XXX handle device number from arguments, if not present, use the call below
jsr set_sane_devnum
;; Set filename and length
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
+10 -14
View File
@@ -5,16 +5,12 @@ wedge_dos:
;; Close all the channels, so that wedge has full control
jsr wedge_dos_CLALL
;; Take last device number, make sure it's a drive
;; If not, set to 8 (first drive number)
ldx DFLTN
cpx #$07
bpl +
bcs +
ldx #$08
*
;; Set remaining file parameters; channel 15 is a typical one for commands
;; Make sure current device number is sane
jsr set_sane_devnum
;; Set remaining file parameters (X already set by set_sane_devnum);
;; channel 15 is a typical one for commands
lda #$0F
ldy #$0F
jsr JSETFLS
@@ -67,7 +63,7 @@ wedge_dos_change_drive:
bcs +
jmp do_ILLEGAL_DEVICE_NUMBER_error
*
sta DFLTN
sta current_device_number
jmp basic_end_of_line
wedge_dos_status:
@@ -77,7 +73,7 @@ wedge_dos_status:
;; Set remaining file parameters, open the channel
lda #$00 ; empty file name
jsr $FFBD ; SETNAM
jsr JSETNAM
jsr wedge_dos_OPEN
bcc +
jmp do_DEVICE_NOT_PRESENT_error
@@ -90,8 +86,8 @@ wedge_dos_status:
*
;; Print out everything retrieved from the drive
bne +
jsr $FFCF ; CHRIN
jsr $FFD2 ; CHROUT
jsr JCHRIN
jsr JCHROUT
jmp -
*
;; Clean-up and exit
+16
View File
@@ -1,3 +1,19 @@
; Function defined on pp272-273 of C64 Programmers Reference Guide
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
+14
View File
@@ -1,3 +1,17 @@
; Function defined on pp272-273 of C64 Programmers Reference Guide
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
+10 -15
View File
@@ -4,19 +4,14 @@ close:
;; Implemented accorging to 'C64 Programmers Reference Guide', page 281
;; XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature
;; Find the LAT / SAT / FAT entry which LAT corresponds to A
ldy LDTND
beq close_error_not_found ; table empty
*
dey
bmi close_error_not_found ; no more entries
cmp LAT, y
bne - ; does not match, try the next one
jsr find_fls
bcs close_error_not_found ;; XXX can we report error in IOSTATUS here?
;; We have the entry index in Y
;; XXX some devices (like IEC) needs special support here, to free their internal resources!
;; Just make sure the Y register value is kept, or redo ldy DFTLN
*
@@ -33,9 +28,9 @@ close:
*
;; Decrement the list size variable
dec LDTND
;; FALLTHROUGH (for now) - success
;; FALLTHROUGH - success
close_error_not_found:
;; XXX it seems that this function can't report errors, am I right?
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
jmp print_filename_loop
*
lda #$0d
jsr JCHROUT
;; XXX - Use default device number
;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
;; p13, 16.
@@ -145,11 +142,11 @@ sent_filename:
lda kernal_load_or_verify_flag
beq +
jsr printf
.byte "VERIFYING", 0
.byte $0D, "VERIFYING", 0
jmp load_print_start_addr
*
jsr printf
.byte "LOADING", 0
.byte $0D, "LOADING", 0
load_print_start_addr:
jsr printf
.byte " FROM $",0
@@ -223,9 +220,8 @@ load_done:
;; Set IEC status back to idle
jsr iec_set_idle
;; Return last address written to +1
;; (Even though Compute's Mapping the 64 says without the +1.
;; I'm suspicious. Will have to check behavour on an original C64)
;; Return last address - Compute's Mapping the 64 says without the '+1',
;; checked on original ROMs that this is really the case
ldx load_save_start_ptr+0
ldy load_save_start_ptr+1