Skip to content

Commit

Permalink
Better usage info
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Feb 8, 2024
1 parent 3a6b864 commit 9178372
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cardBrainBoard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<internal>/wozaniam_integer.rom"},
{"dips", "DIP switches, leftmost is DIP 1", "1-011010"},
Expand Down
2 changes: 1 addition & 1 deletion cardBrainBoard2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<internal>/ApplesoftInteger.BIN"},
{"dip2", "Use the upper half of the ROM", "true"},
Expand Down
5 changes: 4 additions & 1 deletion cardBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

type paramSpec struct {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cardDan2Controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""},
Expand Down
2 changes: 1 addition & 1 deletion cardFastChip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion cardMemoryExpansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
Expand Down
2 changes: 1 addition & 1 deletion cardMouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
Expand Down
2 changes: 1 addition & 1 deletion cardMultiRom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<internal>/MultiRom(SP boot)-Prog aid-28C256.BIN"},
{"basic", "Bank for D000 to F7FF", "1"},
Expand Down
2 changes: 1 addition & 1 deletion cardParallelPrinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion cardSaturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
6 changes: 5 additions & 1 deletion cardSwyft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cardVidHD.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion configs/2enh.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Apple IIe
name: Apple //e
parent: _base
board: 2e
cpu: 65c02
Expand Down
26 changes: 19 additions & 7 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (c *configurationModels) availableModels() []string {
models = append(models, name)
}
}
slices.Sort(models)
return models
}

Expand Down Expand Up @@ -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()
Expand Down
15 changes: 12 additions & 3 deletions traceBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

type executionTracer interface {
Expand All @@ -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{
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9178372

Please sign in to comment.