Mount more than one disk and block devices easily

This commit is contained in:
Iván Izaguirre 2025-02-17 20:08:48 +01:00
parent 9b228a4e75
commit 48eee330b7
7 changed files with 55 additions and 22 deletions

View File

@ -241,6 +241,7 @@ The available pre-configured models are:
cpm65: Apple //e with CPM-65
desktop: Apple II DeskTop
dos32: Apple ][ with 13 sectors disk adapter and DOS 3.2x
prodos: Apple //e Prodos
swyft: swyft
ultraterm: Apple ][+ with Videx Ultraterm demo

View File

@ -179,8 +179,6 @@ func (c *CardSmartPort) exec(call *smartPortCall) uint8 {
call.statusCode() == smartPortStatusCodeDevice {
result = c.hostStatus(call)
} else if unit > len(c.devices) {
result = smartPortErrorNoDevice
} else {
if unit == 0 {
unit = 1 // For unit 0(host) use the first device

3
configs/prodos.cfg Normal file
View File

@ -0,0 +1,3 @@
name: Apple //e Prodos
parent: 2enh
s6: diskii,disk1=<internal>/ProDOS_2_4_3.po

View File

@ -4,9 +4,10 @@ import (
"embed"
"flag"
"fmt"
"maps"
"strings"
"golang.org/x/exp/slices"
"slices"
)
const configSuffix = ".cfg"
@ -255,10 +256,10 @@ func setupFlags(models *configurationModels, configuration *configuration) error
return nil
}
func getConfigurationFromCommandLine() (*configuration, string, error) {
func getConfigurationFromCommandLine() (*configuration, []string, error) {
models, configuration, err := loadConfigurationModelsAndDefault()
if err != nil {
return nil, "", err
return nil, nil, err
}
setupFlags(models, configuration)
@ -270,7 +271,7 @@ func getConfigurationFromCommandLine() (*configuration, string, error) {
// Replace the model
configuration, err = models.get(modelFlag.Value.String())
if err != nil {
return nil, "", err
return nil, nil, err
}
}
@ -278,14 +279,17 @@ func getConfigurationFromCommandLine() (*configuration, string, error) {
configuration.set(f.Name, f.Value.String())
})
filename := flag.Arg(0)
filenames := flag.Args()
return configuration, filename, nil
return configuration, filenames, nil
}
func (c *configuration) dump() {
fmt.Println("Configuration:")
for k, v := range c.data {
fmt.Printf(" %s: %s\n", k, v)
keys := slices.Sorted(maps.Keys(c.data))
for _, key := range keys {
fmt.Printf(" %s: %s\n", key, c.data[key])
}
}

View File

@ -58,6 +58,7 @@ The available pre-configured models are:
cpm65: Apple //e with CPM-65
desktop: Apple II DeskTop
dos32: Apple ][ with 13 sectors disk adapter and DOS 3.2x
prodos: Apple //e Prodos
swyft: swyft
ultraterm: Apple ][+ with Videx Ultraterm demo

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/ivanizag/izapple2
go 1.22.0
go 1.23.0
toolchain go1.23.2

View File

@ -242,21 +242,47 @@ func loadMultiPageRom(a *Apple2, filenames []string) error {
// CreateConfiguredApple is a device independent main. Video, keyboard and speaker won't be defined
func CreateConfiguredApple() (*Apple2, error) {
// Get configuration from defaults and the command line
configuration, filename, err := getConfigurationFromCommandLine()
configuration, filenames, err := getConfigurationFromCommandLine()
if err != nil {
return nil, err
}
if filename != "" {
// Try loading as diskette
_, err := LoadDiskette(filename)
isDiskette := err == nil
if isDiskette {
// Let's force a DiskII with the diskette in slot 6
configuration.set(confS6, fmt.Sprintf("diskii,disk1=\"%s\"", filename))
} else {
// Let's force a Smartport card with a block device in slot 7
configuration.set(confS7, fmt.Sprintf("smartport,image1=\"%s\"", filename))
if len(filenames) > 0 {
diskettes := []string{}
blockDevices := []string{}
for _, filename := range filenames {
_, err := LoadDiskette(filename)
isDiskette := err == nil
if isDiskette {
diskettes = append(diskettes, filename)
} else {
blockDevices = append(blockDevices, filename)
}
}
if len(diskettes) == 1 {
configuration.set(confS6, fmt.Sprintf("diskii,disk1=\"%s\"", filenames[0]))
} else if len(diskettes) >= 2 {
configuration.set(confS6, fmt.Sprintf("diskii,disk1=\"%s\",disk2=\"%s\"", filenames[0], filenames[1]))
}
if len(diskettes) == 3 {
configuration.set(confS5, fmt.Sprintf("diskii,disk1=\"%s\"", filenames[2]))
} else if len(diskettes) >= 4 {
configuration.set(confS5, fmt.Sprintf("diskii,disk1=\"%s\",disk2=\"%s\"", filenames[2], filenames[3]))
}
if len(diskettes) > 4 {
return nil, fmt.Errorf("up to 4 diskettes can be loaded, %v found", len(diskettes))
}
if len(blockDevices) > 8 {
return nil, fmt.Errorf("up to 8 block devices can be loaded, %v found", len(blockDevices))
}
if len(blockDevices) > 0 {
smartportConfig := "smartport"
for i, filename := range blockDevices {
smartportConfig += fmt.Sprintf(",image%v=\"%s\"", i+1, filename)
}
configuration.set(confS5, smartportConfig)
}
}