From 1e73e8d8865069db107667436519cc5e7148dad3 Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Fri, 7 Jun 2024 18:30:08 -0400 Subject: [PATCH] Fix #170 driver crash on unload drive --- RaspberryPi/apple2driver/handlers/block.go | 7 ++++++- RaspberryPi/apple2driver/info/version.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RaspberryPi/apple2driver/handlers/block.go b/RaspberryPi/apple2driver/handlers/block.go index 0ee8414..539e13f 100644 --- a/RaspberryPi/apple2driver/handlers/block.go +++ b/RaspberryPi/apple2driver/handlers/block.go @@ -22,7 +22,7 @@ func ReadBlockCommand(drive1 prodos.ReaderWriterAt, drive2 prodos.ReaderWriterAt driveUnit, err = comm.ReadByte() if err != nil { - fmt.Printf("Failed to read block") + fmt.Printf("Failed to receive requested block number") return 0, err } @@ -34,6 +34,11 @@ func ReadBlockCommand(drive1 prodos.ReaderWriterAt, drive2 prodos.ReaderWriterAt driveNumber = 2 } + if file == nil { + fmt.Printf("Requested drive not loaded") + return 0, err + } + slotNumber := driveUnit & 0x7F >> 4 block := int(blockHigh)*256 + int(blockLow) diff --git a/RaspberryPi/apple2driver/info/version.go b/RaspberryPi/apple2driver/info/version.go index 6b8aa97..beeef6c 100644 --- a/RaspberryPi/apple2driver/info/version.go +++ b/RaspberryPi/apple2driver/info/version.go @@ -8,4 +8,4 @@ package info // Version is the hexadecimal version number that // should be incremented with each driver update -const Version = "002D" +const Version = "002E"