-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for the Softcard Z80 card and CP/M
- Loading branch information
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package izapple2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/koron-go/z80" | ||
) | ||
|
||
/* | ||
Microsoft Z80 SoftCard | ||
See: | ||
http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Interface%20Cards/Z80%20Cards/Microsoft%20SoftCard/ | ||
This card activates DMA to take control of the system. DMA is actiavted or | ||
deactivated by writing to the Csxx area. | ||
The emulation works on the Apple II+, but doesn't work when 80 columns are | ||
available. It is not working then on the Apple IIe or the Apple II+ with a | ||
Videx card. | ||
*/ | ||
|
||
// CardVidHD represents a VidHD card | ||
type CardZ80SoftCard struct { | ||
cardBase | ||
|
||
cpu *z80.CPU | ||
z80Active bool | ||
} | ||
|
||
func newCardZ80SoftCardBuilder() *cardBuilder { | ||
return &cardBuilder{ | ||
name: "Microsoft Z80 SoftCard", | ||
description: "Microsoft Z80 SoftCard to run CP/M", | ||
buildFunc: func(params map[string]string) (Card, error) { | ||
var c CardZ80SoftCard | ||
c.romCxxx = &cardROMWriteTrap{ | ||
callback: func() { | ||
c.flipDMA() | ||
}, | ||
} | ||
|
||
return &c, nil | ||
}, | ||
} | ||
} | ||
|
||
func (c *CardZ80SoftCard) assign(a *Apple2, slot int) { | ||
mem := &cardZ80SoftCardMMU{ | ||
mmu: a.mmu, | ||
} | ||
|
||
c.cpu = &z80.CPU{ | ||
Memory: mem, | ||
} | ||
|
||
c.cardBase.assign(a, slot) | ||
} | ||
|
||
func (c *CardZ80SoftCard) flipDMA() { | ||
c.tracef("Z80 DMA flip\n") | ||
c.z80Active = !c.z80Active | ||
if c.z80Active { | ||
c.activateDMA() | ||
} else { | ||
c.deactivateDMA() | ||
} | ||
} | ||
|
||
func (c *CardZ80SoftCard) runDMACycle() { | ||
if c.a.cpuTrace { | ||
fmt.Printf("Z80 pc=$%04x ($%04x for the 6502) Opcode: $%02x \n", | ||
c.cpu.PC, z80AddressTranslation(c.cpu.PC), c.cpu.Memory.Get(c.cpu.PC)) | ||
} | ||
c.cpu.Step() | ||
} | ||
|
||
type cardROMWriteTrap struct { | ||
callback func() | ||
} | ||
|
||
func (r *cardROMWriteTrap) peek(address uint16) uint8 { | ||
return 0 | ||
} | ||
|
||
func (r *cardROMWriteTrap) poke(address uint16, value uint8) { | ||
if address >= 0xC000 && address < 0xC800 { | ||
r.callback() | ||
} | ||
} | ||
|
||
type cardZ80SoftCardMMU struct { | ||
mmu *memoryManager | ||
} | ||
|
||
func (m *cardZ80SoftCardMMU) Get(addr uint16) uint8 { | ||
return m.mmu.Peek(z80AddressTranslation(addr)) | ||
} | ||
|
||
func (m *cardZ80SoftCardMMU) Set(addr uint16, value uint8) { | ||
m.mmu.Poke(z80AddressTranslation(addr), value) | ||
} | ||
|
||
func z80AddressTranslation(addr uint16) uint16 { | ||
if addr < 0xb000 { | ||
return addr + 0x1000 | ||
} else if addr < 0xe000 { | ||
return addr + 0x2000 | ||
} else if addr < 0xf000 { | ||
return addr - 0x2000 | ||
} else { | ||
return addr - 0xf000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package izapple2 | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestCPMBoot(t *testing.T) { | ||
at, err := makeApple2Tester("cpm", nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
banner := "APPLE ][ CP/M" | ||
prompt := "A>" | ||
at.terminateCondition = buildTerminateConditionTexts([]string{banner, prompt}, testTextMode40, 10_000_000) | ||
|
||
at.run() | ||
|
||
text := at.getText(testTextMode40) | ||
if !strings.Contains(text, banner) { | ||
t.Errorf("Expected '%s', got '%s'", banner, text) | ||
} | ||
if !strings.Contains(text, prompt) { | ||
t.Errorf("Expected prompt '%s', got '%s'", prompt, text) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: Apple ][+ with CP/M | ||
parent: 2plus | ||
# Fails with 80 columns | ||
s3: empty | ||
s4: z80softcard | ||
s6: diskii,disk1=<internal>/cpm_2.20B_56K.po |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.