From 9611993c8598b848d8d4f2e611dfb4cf7cf88ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Izaguirre?= Date: Mon, 4 Mar 2024 20:50:27 +0100 Subject: [PATCH] ProDOS ROM Drive Card --- README.md | 2 ++ cardBuilder.go | 1 + cardProDOSRomDrive.go | 73 +++++++++++++++++++++++++++++++++++++++++++ doc/usage.txt | 1 + 4 files changed, 77 insertions(+) create mode 100644 cardProDOSRomDrive.go diff --git a/README.md b/README.md index eea9b45..f4a25e1 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Portable emulator of an Apple II+ or //e. Written in Go. - Brain Board II - MultiROM card - Dan ][ Controller card + - ProDOS ROM card - Useful cards not emulating a real card - Bootable SmartPort / ProDOS card with the following smartport devices: - Block device (hard disks) @@ -240,6 +241,7 @@ The available cards are: mouse: Mouse card implementation, does not emulate a real card, only the firmware behaviour multirom: Multiple Image ROM card parallel: Card to dump to a file what would be printed to a parallel printer + prodosrom: A bootable 1 MB solid state disk saturn: RAM card with 128Kb, it's like 8 language cards smartport: SmartPort interface card softswitchlogger: Card to log softswitch accesses diff --git a/cardBuilder.go b/cardBuilder.go index 9e32221..b131335 100644 --- a/cardBuilder.go +++ b/cardBuilder.go @@ -51,6 +51,7 @@ func getCardFactory() map[string]*cardBuilder { cardFactory["mouse"] = newCardMouseBuilder() cardFactory["multirom"] = newMultiRomCardBuilder() cardFactory["parallel"] = newCardParallelPrinterBuilder() + cardFactory["prodosrom"] = newCardProDOSRomDriveBuilder() cardFactory["saturn"] = newCardSaturnBuilder() cardFactory["smartport"] = newCardSmartPortStorageBuilder() cardFactory["swyftcard"] = newCardSwyftBuilder() diff --git a/cardProDOSRomDrive.go b/cardProDOSRomDrive.go new file mode 100644 index 0000000..ed984a6 --- /dev/null +++ b/cardProDOSRomDrive.go @@ -0,0 +1,73 @@ +package izapple2 + +import "fmt" + +/* +ProDOS-ROM-Drive: A bootable 1 MB solid state disk for Apple ][ computers + +Emulates version 4.0+ + +See: + https://github.com/tjboldt/ProDOS-ROM-Drive + https://github.com/Alex-Kw/ProDOS-ROM-Drive-Images + +*/ + +// CardMemoryExpansion is a Memory Expansion card +type CardProDOSRomDrive struct { + cardBase + address uint16 + data []uint8 +} + +const proDOSRomDriveMask = 0xf_ffff // 1 MB mask + +func newCardProDOSRomDriveBuilder() *cardBuilder { + return &cardBuilder{ + name: "ProDOS ROM Drive", + description: "A bootable 1 MB solid state disk", + defaultParams: &[]paramSpec{ + //∫{"image", "ROM image with the ProDOS volume", "https://github.com/tjboldt/ProDOS-ROM-Drive/raw/v4.0/Firmware/GamesWithFirmware.po"}, + {"image", "ROM image with the ProDOS volume", "https://github.com/Alex-Kw/ProDOS-ROM-Drive-Images/raw/main/ProDOS242_Beta5.po"}, + }, + buildFunc: func(params map[string]string) (Card, error) { + image := paramsGetPath(params, "image") + if image == "" { + return nil, fmt.Errorf("image required for the ProDOS ROM drive") + } + + data, _, err := LoadResource(image) + if err != nil { + return nil, err + } + + var c CardProDOSRomDrive + c.data = data + c.loadRom(data[0x300:0x400]) + return &c, nil + }, + } +} + +func (c *CardProDOSRomDrive) assign(a *Apple2, slot int) { + + // Set pointer position + c.addCardSoftSwitchW(0, func(value uint8) { + c.address = uint16(value) | c.address&0xff00 + }, "LATCHLO") + c.addCardSoftSwitchW(1, func(value uint8) { + c.address = uint16(value)<<8 | c.address&0xff + }, "LATCHHI") + + // Read data + for i := uint8(0x0); i <= 0xf; i++ { + iCopy := i + c.addCardSoftSwitchR(iCopy, func() uint8 { + offset := uint32(c.address)<<4 + uint32(iCopy) + offset &= proDOSRomDriveMask + return c.data[offset] + }, fmt.Sprintf("READ%X", iCopy)) + } + + c.cardBase.assign(a, slot) +} diff --git a/doc/usage.txt b/doc/usage.txt index e1aa8b1..c3def2d 100644 --- a/doc/usage.txt +++ b/doc/usage.txt @@ -66,6 +66,7 @@ The available cards are: mouse: Mouse card implementation, does not emulate a real card, only the firmware behaviour multirom: Multiple Image ROM card parallel: Card to dump to a file what would be printed to a parallel printer + prodosrom: A bootable 1 MB solid state disk saturn: RAM card with 128Kb, it's like 8 language cards smartport: SmartPort interface card softswitchlogger: Card to log softswitch accesses