Fix #170 driver crash on unload drive

This commit is contained in:
Terence Boldt 2024-06-07 18:30:08 -04:00
parent 9786590f6e
commit 1e73e8d886
2 changed files with 7 additions and 2 deletions

View File

@ -22,7 +22,7 @@ func ReadBlockCommand(drive1 prodos.ReaderWriterAt, drive2 prodos.ReaderWriterAt
driveUnit, err = comm.ReadByte() driveUnit, err = comm.ReadByte()
if err != nil { if err != nil {
fmt.Printf("Failed to read block") fmt.Printf("Failed to receive requested block number")
return 0, err return 0, err
} }
@ -34,6 +34,11 @@ func ReadBlockCommand(drive1 prodos.ReaderWriterAt, drive2 prodos.ReaderWriterAt
driveNumber = 2 driveNumber = 2
} }
if file == nil {
fmt.Printf("Requested drive not loaded")
return 0, err
}
slotNumber := driveUnit & 0x7F >> 4 slotNumber := driveUnit & 0x7F >> 4
block := int(blockHigh)*256 + int(blockLow) block := int(blockHigh)*256 + int(blockLow)

View File

@ -8,4 +8,4 @@ package info
// Version is the hexadecimal version number that // Version is the hexadecimal version number that
// should be incremented with each driver update // should be incremented with each driver update
const Version = "002D" const Version = "002E"