Dynamic drive (#114)

* Fix for when not using dynamic drive
This commit is contained in:
Terence Boldt 2023-01-08 18:03:57 -05:00 committed by GitHub
parent c64f187251
commit 28dc09a877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -33,7 +33,8 @@ const menuCommand = 8
const shellCommand = 9 const shellCommand = 9
func main() { func main() {
drive1, drive2 := getDriveFiles() drive1Name, drive2Name := getFlags()
drive1, drive2 := getDriveFiles(drive1Name, drive2Name)
fmt.Printf("Starting Apple II RPi v%s...\n", info.Version) fmt.Printf("Starting Apple II RPi v%s...\n", info.Version)
@ -59,7 +60,7 @@ func main() {
case readBlockCommand: case readBlockCommand:
var block int var block int
block, err = handlers.ReadBlockCommand(drive1, drive2) block, err = handlers.ReadBlockCommand(drive1, drive2)
if err == nil && block == 0 { if err == nil && block == 0 && len(drive1Name) == 0 {
resetCwd() resetCwd()
drive1, _ = generateDriveFromCwd() drive1, _ = generateDriveFromCwd()
} }
@ -72,8 +73,10 @@ func main() {
newCwd, _ := os.Getwd() newCwd, _ := os.Getwd()
if newCwd != cwd { if newCwd != cwd {
cwd = newCwd cwd = newCwd
if len(drive1Name) == 0 {
drive1, _ = generateDriveFromCwd() drive1, _ = generateDriveFromCwd()
} }
}
case loadFileCommand: case loadFileCommand:
handlers.LoadFileCommand() handlers.LoadFileCommand()
case menuCommand: case menuCommand:
@ -88,7 +91,7 @@ func main() {
} }
} }
func getDriveFiles() (prodos.ReaderWriterAt, prodos.ReaderWriterAt) { func getFlags() (string, string) {
var drive1Name string var drive1Name string
var drive2Name string var drive2Name string
@ -101,6 +104,10 @@ func getDriveFiles() (prodos.ReaderWriterAt, prodos.ReaderWriterAt) {
flag.StringVar(&drive2Name, "d2", "", "A ProDOS format drive image for drive 2 and will be used for drive 1 if drive 1 empty") flag.StringVar(&drive2Name, "d2", "", "A ProDOS format drive image for drive 2 and will be used for drive 1 if drive 1 empty")
flag.Parse() flag.Parse()
return drive1Name, drive2Name
}
func getDriveFiles(drive1Name string, drive2Name string) (prodos.ReaderWriterAt, prodos.ReaderWriterAt) {
var drive1 prodos.ReaderWriterAt var drive1 prodos.ReaderWriterAt
var drive2 prodos.ReaderWriterAt var drive2 prodos.ReaderWriterAt
var err error var err error

View File

@ -5,5 +5,5 @@ go 1.16
require ( require (
github.com/creack/pty v1.1.18 github.com/creack/pty v1.1.18
github.com/stianeikeland/go-rpio/v4 v4.6.0 github.com/stianeikeland/go-rpio/v4 v4.6.0
github.com/tjboldt/ProDOS-Utilities v0.4.1 github.com/tjboldt/ProDOS-Utilities v0.4.2
) )

View File

@ -4,3 +4,5 @@ github.com/stianeikeland/go-rpio/v4 v4.6.0 h1:eAJgtw3jTtvn/CqwbC82ntcS+dtzUTgo5q
github.com/stianeikeland/go-rpio/v4 v4.6.0/go.mod h1:A3GvHxC1Om5zaId+HqB3HKqx4K/AqeckxB7qRjxMK7o= github.com/stianeikeland/go-rpio/v4 v4.6.0/go.mod h1:A3GvHxC1Om5zaId+HqB3HKqx4K/AqeckxB7qRjxMK7o=
github.com/tjboldt/ProDOS-Utilities v0.4.1 h1:tbXgLFXO4xh7t4XAuMgPwM9wXUcEAxH7/ByffjvgsPk= github.com/tjboldt/ProDOS-Utilities v0.4.1 h1:tbXgLFXO4xh7t4XAuMgPwM9wXUcEAxH7/ByffjvgsPk=
github.com/tjboldt/ProDOS-Utilities v0.4.1/go.mod h1:eBQRf0U+goRbBOxzFCwRW+FZmALC8dfYaqCwcqwzi74= github.com/tjboldt/ProDOS-Utilities v0.4.1/go.mod h1:eBQRf0U+goRbBOxzFCwRW+FZmALC8dfYaqCwcqwzi74=
github.com/tjboldt/ProDOS-Utilities v0.4.2 h1:0F02Ddhyc/su3twFNXg57boHsV0pnXKxwCPThrrSdMI=
github.com/tjboldt/ProDOS-Utilities v0.4.2/go.mod h1:eBQRf0U+goRbBOxzFCwRW+FZmALC8dfYaqCwcqwzi74=