diff --git a/.gitignore b/.gitignore index a8494fb..a263031 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ frontend/a2sdl/*.dsk frontend/a2fyne/a2fyne frontend/headless/headless frontend/*/snapshot.gif -frontend/*/snapshot.png \ No newline at end of file +frontend/*/snapshot.png +frontend/*/printer.out \ No newline at end of file diff --git a/README.md b/README.md index 9b5f574..4933531 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,11 @@ Portable emulator of an Apple II+ or //e. Written in Go. - DiskII controller (state machine based for WOZ files) - 16Kb Language Card - 256Kb Saturn RAM + - Parallel Printer Interface card - 1Mb Memory Expansion Card (slinky) - RAMWorks style expansion Card (up to 16MB additional) (Apple //e only) - ThunderClock Plus real time clock - - Apple //e 80 columns with 64Kb extra RAM and optional RGB modes + - Apple //e 80 columns card with 64Kb extra RAM and optional RGB modes - No Slot Clock based on the DS1216 - Videx Videoterm 80 column card with the Videx Soft Video Switch (Apple ][+ only) - SwyftCard (Apple //e only) @@ -78,7 +79,7 @@ By default the following configuration is launched: - Enhanced Apple //e with 65c02 processor - RAMWorks card with 80 column, RGB (with Video7 modes) and 8Gb RAM in aux slot -- Memory Expansion card with 1Gb in slot 1 +- Parallel print inteface in slot 1 - VidHD card (SHR support) in slot 2 - FASTChip Accelerator card in slot 3 - Mouse card in slot 4 @@ -206,7 +207,7 @@ Only valid on SDL mode -languageCardSlot int slot for the 16kb language card. -1 for none -memoryExpSlot int - slot for the Memory Expansion card with 1GB. -1 for none (default 1) + slot for the Memory Expansion card with 1GB. -1 for none (default -1) -mhz float cpu speed in Mhz, use 0 for full speed. Use F5 to toggle. (default 1.0227142857142857) -model string @@ -217,6 +218,8 @@ Only valid on SDL mode add a DS1216 No-Slot-Clock on the main ROM (use 0) or a slot ROM. -1 for none (default -1) -panicSS panic if a not implemented softswitch is used + -printer int + slot for the Parallel Printer Interface. -1 for none (default 1) -profile generate profile trace to analyse with pprof -ramworks int diff --git a/apple2Setup.go b/apple2Setup.go index 09d5db1..91400a5 100644 --- a/apple2Setup.go +++ b/apple2Setup.go @@ -169,6 +169,11 @@ func (a *Apple2) AddSaturnCard(slot int) { a.insertCard(NewCardSaturn(), slot) } +// AddParallelPrinter inserts an Apple II Parallel Printer card +func (a *Apple2) AddParallelPrinter(slot int) { + a.insertCard(NewCardParallelPrinter(), slot) +} + // AddMemoryExpansionCard inserts an Apple II Memory Expansion card with 1GB func (a *Apple2) AddMemoryExpansionCard(slot int) { a.insertCard(NewCardMemoryExpansion(), slot) diff --git a/apple2main.go b/apple2main.go index 8ef518e..e4364c0 100644 --- a/apple2main.go +++ b/apple2main.go @@ -62,8 +62,12 @@ func MainApple() *Apple2 { "slot for the FASTChip accelerator card, -1 for none") memoryExpansionCardSlot := flag.Int( "memoryExpSlot", - 1, + -1, "slot for the Memory Expansion card with 1GB. -1 for none") + parallelPrinterSlot := flag.Int( + "printer", + 1, + "slot for the Parallel Printer Interface. -1 for none") ramWorksKb := flag.Int( "ramworks", 8192, @@ -227,6 +231,9 @@ func MainApple() *Apple2 { if *saturnCardSlot >= 0 { a.AddSaturnCard(*saturnCardSlot) } + if *parallelPrinterSlot >= 0 { + a.AddParallelPrinter(*parallelPrinterSlot) + } if *memoryExpansionCardSlot >= 0 { a.AddMemoryExpansionCard(*memoryExpansionCardSlot) } diff --git a/cardParallelPrinter.go b/cardParallelPrinter.go new file mode 100644 index 0000000..b54101b --- /dev/null +++ b/cardParallelPrinter.go @@ -0,0 +1,48 @@ +package izapple2 + +import ( + "os" +) + +/* +Apple II Parallel Printer Interface card. + +See: + https://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Interface%20Cards/Parallel/Apple%20II%20Parallel%20Printer%20Interface%20Card/ + +*/ + +// CardParallelPrinter represents a Parallel Printer Interface card +type CardParallelPrinter struct { + cardBase + file *os.File +} + +// NewCardParallelPrinter creates a new CardParallelPrinter +func NewCardParallelPrinter() *CardParallelPrinter { + var c CardParallelPrinter + c.name = "Parallel Printer Interface" + c.loadRomFromResource("/Apple II Parallel Printer Interface Card ROM fixed.bin") + return &c +} + +func (c *CardParallelPrinter) assign(a *Apple2, slot int) { + f, err := os.OpenFile(printerFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + panic(err) + } + c.file = f + + c.addCardSoftSwitchW(0, func(_ *ioC0Page, value uint8) { + c.printByte(value) + }, "PARALLELDEVW") + + c.cardBase.assign(a, slot) +} + +const printerFile = "printer.out" + +func (c *CardParallelPrinter) printByte(value uint8) { + value = value & 0x7f // Remove the MSB bit + c.file.Write([]byte{value}) +} diff --git a/resources/Apple II Parallel Printer Interface Card ROM fixed.bin b/resources/Apple II Parallel Printer Interface Card ROM fixed.bin new file mode 100644 index 0000000..c9ebafc --- /dev/null +++ b/resources/Apple II Parallel Printer Interface Card ROM fixed.bin @@ -0,0 +1,11 @@ +8HHHx Xhhhhʚh(GN)I0 +)x8Jj  +(!=~hhh` +}8!88穉86]8 +^H + + + +@9I + 8j) +_hhhL8!i$p!8$hH) ,X8p \ No newline at end of file