small LOAD cleanup

This commit is contained in:
FeralChild64 committed 2019-10-28 21:27:26 +01:00
1 parent 05253c3e92
commit 3d9e713f07
20 files changed
+98 -84

No files matched your search

+2 -2
View File
@@ -41,7 +41,7 @@ chkin_real:
// For IEC devices, send TALK + TKSA first
lda FAT,Y
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs chkin_set_device
jsr TALK
@@ -123,7 +123,7 @@ ckout_real:
// For IEC devices, send LISTEN + SECOND first
lda FAT,Y
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs chkout_set_device
jsr LISTEN
+1 -1
View File
@@ -23,7 +23,7 @@ chrin_real:
beq chrin_keyboard // #$00 - keyboard
// XXX add screen support
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcc chrin_iec
jmp lvs_device_not_found_error // not a supported device
+2 -2
View File
@@ -13,14 +13,14 @@ clrchn_real:
// Handle IEC input device
lda DFLTN
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs !+
// Previous device was IEC one - send UNTALK first
jsr UNTLK
!:
// Restore output device to default
lda DFLTO
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs !+
// Handle IEC output device
jsr UNLSN
+1 -1
View File
@@ -30,7 +30,7 @@ CHROUT:
bne !+
jmp chrout_screen
!:
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs chrout_done_unknown_device // not a supported device
chrout_iec:
+1 -1
View File
@@ -20,7 +20,7 @@ CLOSE:
// We have the entry index in Y - check whether this is IEC device
lda FAT, y
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcs close_remove_from_table
// IEC device
+1 -1
View File
@@ -59,7 +59,7 @@ open_has_space:
// Check for IEC device
lda FA
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcc open_iec
// FALLTROUGH
-13
View File
@@ -1,13 +0,0 @@
//
// XXX Note: something unusual was done with LOAD routine - although the vector at $330 points to $F4A5,
// the Kernal jump table points to $F49E (see also Mapping the C64, page 76). By experimenting
// I have already discovered that $F4A5 performs indirect jump via ($0330) vector, but it must
// be doing a little bit more - not sure yet, what. Something similar is done with SAVE.
//
// This has to be clarified.
//
LOAD_INT:
jmp (ILOAD)
+15 -6
View File
@@ -5,18 +5,27 @@
// Preserves .A, .X and .Y
//
iec_check_devnum:
// 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore
cmp #$04
iec_check_devnum_lvs: // for load/verify/save
cmp #$08 // below 8 are illegal for load/save
bcs !+
// FALLTROUGH
iec_check_devnum_oc: // for open/close
cmp #$04 // below 4 are illegal, reserved for non-IEC devices on Commodore
bcs !+
// FALLTROUGH
iec_check_devnum_failed:
sec // indicate non-IEC device
rts
!:
// 31 and above are illegal too, due to IEC command encoding scheme,
// see https://www.pagetable.com/?p=1031
cmp #$1F
bcs iec_check_devnum_failed
// Carry is clear here - indicates IEC device
cmp #$1F // sets carry for 31 or above
rts
+1 -4
View File
@@ -17,7 +17,7 @@ LISTEN:
jsr iec_tx_flush
// Check whether device number is correct
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcc !+
jmp kernalerror_DEVICE_NOT_FOUND
!:
@@ -25,6 +25,3 @@ LISTEN:
ora #$20
jmp common_talk_listen
@@ -1,60 +1,17 @@
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmer's Reference Guide - page 286
// - [CM64] Compute's Mapping the Commodore 64 - page 231
// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
//
// CPU registers that has to be preserved (see [RG64]): none
// IEC part of the LOAD routine
//
// Expects that SETLFS and SETNAM are called before hand.
// $YYXX = load address.
// (ignored if SETLFS channel = 1, i.e., like ,8,1)
// If A=1 then VERIFY instead of LOAD.
// On exit, $YYXX is the highest address into which data
// will have been placed.
// XXX honor MSGFLG bit 6
// XXX add VERIFY support
LOAD:
// Are we loading or verifying?
sta VERCKK
// Store start address of LOAD
stx STAL+0
sty STAL+1
// Reset status
jsr kernalstatus_reset
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Check whether we support the requested device
lda FA
and #$FC
bne !+
jmp 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
// number 31), yet original ROMs show ILLEGAL DEVICE NUMBER error only
// for devices 0-3; in our implementation LISTEN / TALK will cause device
// not present detected for numbers above 30
load_iec:
// Display SEARCHING FOR + filename
jsr lvs_display_searching_for
// 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.
// p13, 16; also p16 tells us this routine does not mess with the file
// table in the C64, only in the drive.
// Call device to LISTEN (p16)
lda FA
@@ -111,7 +68,7 @@ LOAD:
// Display start address
jsr lvs_display_loading_verifying
load_loop:
iec_load_loop:
// We are now ready to receive bytes
jsr iec_rx_byte
bcc !+
@@ -130,7 +87,7 @@ load_loop:
// Check for EOI - if so, this was the last byte
lda IOSTATUS
and #K_STS_EOI
beq load_loop
beq iec_load_loop
// Display end address
jsr lvs_display_done
+1 -3
View File
@@ -17,7 +17,7 @@ TALK:
jsr iec_tx_flush
// Check whether device number is correct
jsr iec_check_devnum
jsr iec_check_devnum_oc
bcc !+
jmp kernalerror_DEVICE_NOT_FOUND
!:
@@ -28,5 +28,3 @@ common_talk_listen: // common part of TALK and LISTEN
sta TBTCNT
jmp iec_tx_command
File renamed without changes.
+12
View File
@@ -0,0 +1,12 @@
//
// Note: Although the vector at $330 points to $F4A5, the Kernal jump table points to $F49E
// (see also Mapping the C64, page 76). By experimenting I have discovered that $F49E performs
// indirect jump via ($0330) vector, after setting MEMUSS.
//
LOAD_INT:
sty MEMUSS+1
stx MEMUSS+0
jmp (ILOAD)
File renamed without changes.
+54
View File
@@ -0,0 +1,54 @@
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmer's Reference Guide - page 286
// - [CM64] Compute's Mapping the Commodore 64 - page 231
// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
//
// CPU registers that has to be preserved (see [RG64]): none
//
// Expects that SETLFS and SETNAM are called before hand.
// $YYXX = load address.
// (ignored if SETLFS channel = 1, i.e., like ,8,1)
// If A=1 then VERIFY instead of LOAD.
// On exit, $YYXX is the highest address into which data
// will have been placed.
// XXX add VERIFY support
LOAD:
// Are we loading or verifying?
sta VERCKK
// Store start address of LOAD
lda MEMUSS+0
sta STAL+0
lda MEMUSS+1
sty STAL+1
// Reset status
jsr kernalstatus_reset
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Check whether we support the requested device
lda FA
// Try IEC - legal device numbers for LOAD are 8-30
// Device numbers above 30 can not be used as IEC (see https://www.pagetable.com/?p=1031),
// as the protocol combines device number with command code in one byte, above 30 it is
// no longer possible. Original ROMs show ILLEGAL DEVICE NUMBER error only for devices
// 0-3; our implementation is more strict here
cmp #$1F
bcs !+ // >= 31
cmp #$08
bcs_far load_iec // >= 8
!:
jmp lvs_illegal_device_number
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.