From 917837294228552283699931c224e1b50008c5fc Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Thu, 8 Feb 2024 22:17:14 +0100 Subject: [PATCH] Better usage info --- cardBrainBoard.go | 2 +- cardBrainBoard2.go | 2 +- cardBuilder.go | 5 ++++- cardDan2Controller.go | 2 +- cardFastChip.go | 2 +- cardMemoryExpansion.go | 2 +- cardMouse.go | 2 +- cardMultiRom.go | 2 +- cardParallelPrinter.go | 2 +- cardSaturn.go | 2 +- cardSwyft.go | 6 +++++- cardVidHD.go | 2 +- configs/2enh.cfg | 2 +- configuration.go | 26 +++++++++++++++++++------- traceBuilder.go | 15 ++++++++++++--- 15 files changed, 51 insertions(+), 23 deletions(-) diff --git a/cardBrainBoard.go b/cardBrainBoard.go index 6f6f874..68e7de6 100644 --- a/cardBrainBoard.go +++ b/cardBrainBoard.go @@ -56,7 +56,7 @@ type CardBrainBoard struct { func newCardBrainBoardBuilder() *cardBuilder { return &cardBuilder{ name: "Brain Board", - description: "Firmware card for Apple. It has two ROM banks", + description: "Firmware card. It has two ROM banks", defaultParams: &[]paramSpec{ {"rom", "ROM file to load", "/wozaniam_integer.rom"}, {"dips", "DIP switches, leftmost is DIP 1", "1-011010"}, diff --git a/cardBrainBoard2.go b/cardBrainBoard2.go index fc2d138..28a89b0 100644 --- a/cardBrainBoard2.go +++ b/cardBrainBoard2.go @@ -52,7 +52,7 @@ const noForceBank = -1 func newCardBrainBoardIIBuilder() *cardBuilder { return &cardBuilder{ name: "Brain Board II", - description: "Firmware card for Apple II. It has ROM banks and can be used to boot wozaniam, Integer BASIC or other çustom ROMs.", + description: "Firmware card. It has up to four ROM banks", defaultParams: &[]paramSpec{ {"rom", "ROM file to load", "/ApplesoftInteger.BIN"}, {"dip2", "Use the upper half of the ROM", "true"}, diff --git a/cardBuilder.go b/cardBuilder.go index 3b5c657..085279f 100644 --- a/cardBuilder.go +++ b/cardBuilder.go @@ -6,6 +6,7 @@ import ( "strings" "golang.org/x/exp/maps" + "golang.org/x/exp/slices" ) type paramSpec struct { @@ -60,7 +61,9 @@ func getCardFactory() map[string]*cardBuilder { } func availableCards() []string { - return maps.Keys(getCardFactory()) + names := maps.Keys(getCardFactory()) + slices.Sort(names) + return names } func setupCard(a *Apple2, slot int, paramString string) (Card, error) { diff --git a/cardDan2Controller.go b/cardDan2Controller.go index 45a3f04..53a33d9 100644 --- a/cardDan2Controller.go +++ b/cardDan2Controller.go @@ -48,7 +48,7 @@ type cardDan2ControllerSlot struct { func newCardDan2ControllerBuilder() *cardBuilder { return &cardBuilder{ name: "Dan ][ Controller card", - description: "Apple II Peripheral Card that Interfaces to a ATMEGA328P for SD card storage.", + description: "Apple II Peripheral Card that Interfaces to a ATMEGA328P for SD card storage", defaultParams: &[]paramSpec{ {"improved", "Emulate improved firmware from ThorstenBr", "true"}, {"slot1", "Image in slot 1. File for raw device, folder for fs mode using files as BLKDEV0x.PO", ""}, diff --git a/cardFastChip.go b/cardFastChip.go index 96b5761..06ab047 100644 --- a/cardFastChip.go +++ b/cardFastChip.go @@ -29,7 +29,7 @@ type CardFastChip struct { func newCardFastChipBuilder() *cardBuilder { return &cardBuilder{ name: "FASTChip IIe Card - limited", - description: "Accelerator card for Apple IIe. Limited support.", + description: "Accelerator card for Apple IIe (limited support)", buildFunc: func(params map[string]string) (Card, error) { return &CardFastChip{}, nil }, diff --git a/cardMemoryExpansion.go b/cardMemoryExpansion.go index 0beb357..3116e52 100644 --- a/cardMemoryExpansion.go +++ b/cardMemoryExpansion.go @@ -50,7 +50,7 @@ type CardMemoryExpansion struct { func newCardMemoryExpansionBuilder() *cardBuilder { return &cardBuilder{ name: "Memory Expansion Card", - description: "Memory expansion card. It can be configured to have 256KB, 512KB, 768KB or 1MB.", + description: "Memory expansion card", defaultParams: &[]paramSpec{ {"size", "RAM of the card, can be 256, 512, 768 or 1024", "1024"}, }, diff --git a/cardMouse.go b/cardMouse.go index 779aadb..2e28f93 100644 --- a/cardMouse.go +++ b/cardMouse.go @@ -36,7 +36,7 @@ type CardMouse struct { func newCardMouseBuilder() *cardBuilder { return &cardBuilder{ name: "Mouse Card", - description: "Mouse card implementation. Does not emulate a real card, only the firmware behaviour.", + description: "Mouse card implementation, does not emulate a real card, only the firmware behaviour", defaultParams: &[]paramSpec{ {"trace", "Trace accesses to the card", "false"}, }, diff --git a/cardMultiRom.go b/cardMultiRom.go index 08b9b6a..d7028b2 100644 --- a/cardMultiRom.go +++ b/cardMultiRom.go @@ -32,7 +32,7 @@ type MultiRomCard struct { func newMultiRomCardBuilder() *cardBuilder { return &cardBuilder{ name: "MultiROM", - description: "Multiple Image ROM card.", + description: "Multiple Image ROM card", defaultParams: &[]paramSpec{ {"rom", "ROM file to load", "/MultiRom(SP boot)-Prog aid-28C256.BIN"}, {"basic", "Bank for D000 to F7FF", "1"}, diff --git a/cardParallelPrinter.go b/cardParallelPrinter.go index 2be09dc..267328e 100644 --- a/cardParallelPrinter.go +++ b/cardParallelPrinter.go @@ -22,7 +22,7 @@ type CardParallelPrinter struct { func newCardParallelPrinterBuilder() *cardBuilder { return &cardBuilder{ name: "Parallel Printer Interface", - description: "Card to dump to a file what would be printed to a parallel printer.", + description: "Card to dump to a file what would be printed to a parallel printer", defaultParams: &[]paramSpec{ {"file", "File to store the printed code", "printer.out"}, {"ascii", "Remove the 7 bit. Useful for normal text printing, but breaks graphics printing ", "false"}, diff --git a/cardSaturn.go b/cardSaturn.go index ffb78c9..fc8f009 100644 --- a/cardSaturn.go +++ b/cardSaturn.go @@ -19,7 +19,7 @@ type CardSaturn struct { func newCardSaturnBuilder() *cardBuilder { return &cardBuilder{ name: "Saturn 128KB Ram Card", - description: "RAM card with 128Kb. It's like 8 language cards.", + description: "RAM card with 128Kb, it's like 8 language cards", buildFunc: func(params map[string]string) (Card, error) { return &CardSaturn{}, nil }, diff --git a/cardSwyft.go b/cardSwyft.go index 4f608da..da04c00 100644 --- a/cardSwyft.go +++ b/cardSwyft.go @@ -68,7 +68,7 @@ type CardSwyft struct { func newCardSwyftBuilder() *cardBuilder { return &cardBuilder{ name: "SwyftCard", - description: "Card with the ROM needed to run the Swyftcard word processing system. Must run on slot 3 only on Apple IIe.", + description: "Card with the ROM needed to run the Swyftcard word processing system", requiresIIe: true, buildFunc: func(params map[string]string) (Card, error) { var c CardSwyft @@ -85,6 +85,10 @@ func newCardSwyftBuilder() *cardBuilder { } func (c *CardSwyft) assign(a *Apple2, slot int) { + if slot != 3 { + panic("SwyftCard must be installed in slot 3") + } + c.addCardSoftSwitchRW(0, func() uint8 { a.mmu.inhibitROM(c) c.bank2 = false diff --git a/cardVidHD.go b/cardVidHD.go index 2c82c7a..5b429c8 100644 --- a/cardVidHD.go +++ b/cardVidHD.go @@ -16,7 +16,7 @@ type CardVidHD struct { func newCardVidHDBuilder() *cardBuilder { return &cardBuilder{ name: "VidHD Card - limited", - description: "Firmware signature of the VidHD card to trick Total Replay to use the GS modes.", + description: "Firmware signature of the VidHD card to trick Total Replay to use the SHR mode", buildFunc: func(params map[string]string) (Card, error) { var c CardVidHD c.loadRom(buildVidHDRom()) diff --git a/configs/2enh.cfg b/configs/2enh.cfg index a5505c2..45e4bf7 100644 --- a/configs/2enh.cfg +++ b/configs/2enh.cfg @@ -1,4 +1,4 @@ -name: Apple IIe +name: Apple //e parent: _base board: 2e cpu: 65c02 diff --git a/configuration.go b/configuration.go index 6a74fc1..9086e79 100644 --- a/configuration.go +++ b/configuration.go @@ -175,6 +175,7 @@ func (c *configurationModels) availableModels() []string { models = append(models, name) } } + slices.Sort(models) return models } @@ -246,18 +247,29 @@ func getConfigurationFromCommandLine() (*configuration, string, error) { } flag.Usage = func() { - availableModels := strings.Join(configurationModels.availableModels(), ", ") - availableCards := strings.Join(availableCards(), ", ") - availableTracers := strings.Join(availableTracers(), ", ") - out := flag.CommandLine.Output() fmt.Fprintf(out, "Usage: %s [file]\n", os.Args[0]) fmt.Fprintf(out, " file\n") fmt.Fprintf(out, " path to image to use on the boot device\n") flag.PrintDefaults() - fmt.Fprintf(out, "\nThe available pre configured models are: %s.\n", availableModels) - fmt.Fprintf(out, "The available cards are: %s.\n", availableCards) - fmt.Fprintf(out, "The available tracers are: %s.\n", availableTracers) + + fmt.Fprintf(out, "\nThe available pre configured models are:\n") + for _, model := range configurationModels.availableModels() { + config, _ := configurationModels.getFromModel(model) + fmt.Fprintf(out, " %s: %s\n", model, config.get(confName)) + } + + fmt.Fprintf(out, "\nThe available cards are:\n") + for _, card := range availableCards() { + builder := getCardFactory()[card] + fmt.Fprintf(out, " %s: %s\n", card, builder.description) + } + + fmt.Fprintf(out, "\nThe available tracers are:\n") + for _, tracer := range availableTracers() { + builder := getTracerFactory()[tracer] + fmt.Fprintf(out, " %s: %s\n", tracer, builder.description) + } } flag.Parse() diff --git a/traceBuilder.go b/traceBuilder.go index 8ec16b9..5286b97 100644 --- a/traceBuilder.go +++ b/traceBuilder.go @@ -5,6 +5,7 @@ import ( "strings" "golang.org/x/exp/maps" + "golang.org/x/exp/slices" ) type executionTracer interface { @@ -19,7 +20,13 @@ type traceBuilder struct { connectFunc func(a *Apple2) } -func buildTracerFactory() map[string]*traceBuilder { +var traceFactory map[string]*traceBuilder + +func getTracerFactory() map[string]*traceBuilder { + if traceFactory != nil { + return traceFactory + } + tracerFactory := make(map[string]*traceBuilder) tracerFactory["mos"] = &traceBuilder{ @@ -71,11 +78,13 @@ func buildTracerFactory() map[string]*traceBuilder { } func availableTracers() []string { - return maps.Keys(buildTracerFactory()) + names := maps.Keys(getTracerFactory()) + slices.Sort(names) + return names } func setupTracers(a *Apple2, paramString string) error { - tracerFactory := buildTracerFactory() + tracerFactory := getTracerFactory() tracerNames := splitConfigurationString(paramString, ',') for _, tracer := range tracerNames { tracer = strings.ToLower(strings.TrimSpace(tracer))