Skip to content

Commit

Permalink
Update tests for Card Cat 1.6 supporting more cards
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Sep 15, 2024
1 parent 87dbe86 commit 3813096
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 63 deletions.
33 changes: 7 additions & 26 deletions a2audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"testing"
)

func testA2AuditInternal(t *testing.T, model string, removeLangCard bool, cycles uint64, messages []string) {
func testA2AuditInternal(t *testing.T, model string, slot0card string, cycles uint64, messages []string) {
overrides := newConfiguration()
if removeLangCard {
overrides.set(confS0, "empty")
}
overrides.set(confS0, slot0card)
overrides.set(confS1, "empty")
overrides.set(confS2, "empty")
overrides.set(confS3, "empty")
Expand All @@ -36,7 +34,7 @@ func testA2AuditInternal(t *testing.T, model string, removeLangCard bool, cycles
func TestA2Audit(t *testing.T) {

t.Run("test a2audit on Apple IIe enhanced", func(t *testing.T) {
testA2AuditInternal(t, "2enh", false, 4_000_000, []string{
testA2AuditInternal(t, "2enh", "language", 4_000_000, []string{
"MEMORY:128K",
"APPLE IIE (ENHANCED)",
"LANGUAGE CARD TESTS SUCCEEDED",
Expand All @@ -46,7 +44,7 @@ func TestA2Audit(t *testing.T) {
})

t.Run("test a2audit on Apple IIe", func(t *testing.T) {
testA2AuditInternal(t, "2e", false, 4_000_000, []string{
testA2AuditInternal(t, "2e", "language", 4_000_000, []string{
"MEMORY:128K",
"APPLE IIE",
"LANGUAGE CARD TESTS SUCCEEDED",
Expand All @@ -56,7 +54,7 @@ func TestA2Audit(t *testing.T) {
})

t.Run("test a2audit on Apple II plus", func(t *testing.T) {
testA2AuditInternal(t, "2plus", false, 4_000_000, []string{
testA2AuditInternal(t, "2plus", "language", 4_000_000, []string{
"MEMORY:64K",
"APPLE II PLUS",
"LANGUAGE CARD TESTS SUCCEEDED",
Expand All @@ -66,7 +64,7 @@ func TestA2Audit(t *testing.T) {
})

t.Run("test a2audit on Apple II plus without lang card", func(t *testing.T) {
testA2AuditInternal(t, "2plus", true, 4_000_000, []string{
testA2AuditInternal(t, "2plus", "empty", 4_000_000, []string{
"MEMORY:48K",
"APPLE II PLUS",
"48K:SKIPPING LANGUAGE CARD TEST",
Expand All @@ -75,22 +73,5 @@ func TestA2Audit(t *testing.T) {
})
})

/*
t.Run("test Mouse card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "mouse", 50_000_000, "2 38-18-01-20 Apple II Mouse Card")
})
t.Run("test Parallel printer card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "parallel", 50_000_000, "2 48-48-58-FF Apple Parallel Interface Card")
})
// Saturn not detected
// VidHD not detected
// Swyftcard not compatible with Card Cat
// Pending to try Saturn, 80col with 2plus.
t.Run("test ThunderClock Plus card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "thunderclock", 50_000_000, "2 FF-05-18-B8 ThunderClock Plus Card")
})
*/
// A2Audit may not support the Saturn card
}
15 changes: 15 additions & 0 deletions apple2Tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ func (at *apple2Tester) getText(textMode testTextModeFunc) string {
return textMode(at.a)
}

func (at *apple2Tester) getTextBest() string {
videxMaybe := at.a.cards[3]
if videxMaybe != nil {
if videx, ok := videxMaybe.(*CardVidex); ok {
return videx.getText()
}
}

videoMode := at.a.video.GetCurrentVideoMode()
if videoMode&screen.VideoBaseMask == screen.VideoText80 {
return at.getText(testTextMode80)
}
return at.getText(testTextMode40)
}

/*
func buildTerminateConditionCycles(cycles uint64) terminateConditionFunc {
return func(a *Apple2) bool {
Expand Down
51 changes: 39 additions & 12 deletions cardCat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (
"testing"
)

func testCardDetectedInternal(t *testing.T, model string, card string, cycles uint64, banner string) {
func testCardDetectedInternal(t *testing.T, model string, card string, slot string, cycles uint64, banner string) {
overrides := newConfiguration()
overrides.set(confS2, "empty")
overrides.set(confS3, "empty")
overrides.set(confS4, "empty")
overrides.set(confS5, "empty")
overrides.set(confS7, "empty")
overrides.set(confRamworks, "none")
overrides.set(slot, card)

overrides.set(confS2, card)
overrides.set(confS6, "diskii,disk1=\"<internal>/Card Cat 1.0b9.dsk\"")
overrides.set(confS6, "diskii,disk1=\"<internal>/Card Cat 1.6.dsk\"")

at, err := makeApple2Tester(model, overrides)
if err != nil {
Expand All @@ -22,7 +24,7 @@ func testCardDetectedInternal(t *testing.T, model string, card string, cycles ui
at.terminateCondition = buildTerminateConditionText(banner, testTextMode80, cycles)
at.run()

text := at.getText(testTextMode80)
text := at.getTextBest()
if !strings.Contains(text, banner) {
t.Errorf("Expected '%s', got '%s'", banner, text)
}
Expand All @@ -31,24 +33,49 @@ func testCardDetectedInternal(t *testing.T, model string, card string, cycles ui
func TestCardsDetected(t *testing.T) {

t.Run("test Memory Expansion card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "memexp", 50_000_000, "2 03-00-05-D0 Apple II Memory Expansion Card (SP)")
testCardDetectedInternal(t, "2enh", "memexp", "s2", 50_000_000, "2 03-00-05-D0 Apple II Memory Expansion Card (SP)")
})

t.Run("test Mouse card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "mouse", 50_000_000, "2 38-18-01-20 Apple II Mouse Card")
testCardDetectedInternal(t, "2enh", "mouse", "s2", 50_000_000, "2 38-18-01-20 Apple II Mouse Card")
})

t.Run("test Parallel printer card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "parallel", 50_000_000, "2 48-48-58-FF Apple Parallel Interface Card")
testCardDetectedInternal(t, "2enh", "parallel", "s2", 50_000_000, "2 48-48-58-FF Apple Parallel Interface Card")
})

t.Run("test ThunderClock Plus card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "thunderclock", 50_000_000, "2 FF-05-18-B8 ThunderClock Plus Card")
testCardDetectedInternal(t, "2enh", "thunderclock", "s2", 50_000_000, "2 FF-05-18-B8 ThunderClock Plus Card")
})

// Saturn not detected
// VidHD not detected
// Swyftcard not compatible with Card Cat
// Pending to try Saturn, 80col with 2plus but fails with an illegal opcode
t.Run("test Z80 Softcard card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "z80softcard", "s2", 50_000_000, "2 :: :: :: :: Z80 Card")
})

t.Run("test VidHD card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "vidhd", "s2", 50_000_000, "2 :: :: :: :: No Firmware Card Detected")
})

t.Run("test Saturn card", func(t *testing.T) {
testCardDetectedInternal(t, "2plus", "saturn", "s0", 50_000_000, "SATURN 128K CARD IN SLOT 0")
})

t.Run("test Videx card", func(t *testing.T) {
testCardDetectedInternal(t, "2plus", "videx", "s3", 50_000_000, "3 38-18-01-82 Videx 80 Column Text Display Card")
})

t.Run("test Dan 2 SD card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "dan2sd", "s2", 50_000_000, "2 03-3C-01-9D DAN II Card")
})

t.Run("test ProDOS ROM Drive card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "prodosromdrive", "s2", 50_000_000, "2 03-3C-C9-9B ProDOS ROM Drive Card")
})

t.Run("test RAMWorks aux card", func(t *testing.T) {
testCardDetectedInternal(t, "2enh", "4096", "ramworks", 50_000_000, "RAMWorks 4096K Card in Aux Slot")
})

// Swyftcard not compatible with Card Cat
// Unknonw cards: prodosromcard3
}
15 changes: 4 additions & 11 deletions cardSaturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,11 @@ func (c *CardSaturn) assign(a *Apple2, slot int) {
c.altBank = true
c.activeBlock = 0
a.mmu.initLanguageRAM(saturnBlocks)
c.addCardSoftSwitches(func(address uint8, data uint8, write bool) uint8 {
c.ssAction(address)
return 0
}, "SATURN")

// TODO: use addCardSoftSwitches()
for i := uint8(0x0); i <= 0xf; i++ {
iCopy := i
c.addCardSoftSwitchR(iCopy, func() uint8 {
c.ssAction(iCopy)
return 0
}, "SATURNR")
c.addCardSoftSwitchW(iCopy, func(uint8) {
c.ssAction(iCopy)
}, "SATURNW")
}
c.cardBase.assign(a, slot)
c.applyState()
}
Expand Down
17 changes: 17 additions & 0 deletions cardVidex.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"image"
"image/color"
"strings"
"time"

"github.com/ivanizag/izapple2/component"
Expand Down Expand Up @@ -192,3 +193,19 @@ func (c *CardVidex) buildImage(light color.Color) *image.RGBA {

return img
}

func (c *CardVidex) getText() string {
text := ""
params := c.mc6845.ImageData()
address := params.FirstChar
for line := uint8(0); line < params.Lines; line++ {
for column := uint8(0); column < params.Columns; column++ {
char := c.sram[address&0x7ff]
text += string(char)
address++
}
text = strings.TrimRight(text, " ")
text += "\n"
}
return text
}
6 changes: 4 additions & 2 deletions cardZ80Softcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ func (c *CardZ80SoftCard) flipDMA() {

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))
fmt.Printf("Z80 PC: $%04X, A: $%02X, B: $%02X, C: $%02X, D: $%02X, E: $%02X, HL: $%04X\n",
c.cpu.States.PC, c.cpu.States.AF.Hi, c.cpu.States.BC.Hi,
c.cpu.States.BC.Lo, c.cpu.States.DE.Hi, c.cpu.States.DE.Lo,
c.cpu.States.HL)
}
c.cpu.Step()
}
Expand Down
24 changes: 12 additions & 12 deletions component/mc6845.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func (m *MC6845) Write(rs bool, value uint8) {
func (m *MC6845) ImageData() MC6845ImageData {
var data MC6845ImageData

data.firstChar = uint16(m.reg[12]&0x3f)<<8 + uint16(m.reg[13])
data.FirstChar = uint16(m.reg[12]&0x3f)<<8 + uint16(m.reg[13])
data.charLines = (m.reg[9] + 1) & 0x1f
data.columns = m.reg[1]
data.lines = m.reg[6] & 0x7f
data.Columns = m.reg[1]
data.Lines = m.reg[6] & 0x7f
data.adjustLines = m.reg[5] & 0x1f

data.cursorPos = uint16(m.reg[14]&0x3f)<<8 + uint16(m.reg[15])
Expand All @@ -63,10 +63,10 @@ const (
)

type MC6845ImageData struct {
firstChar uint16 // 14 bits, address of the firt char on the first line
FirstChar uint16 // 14 bits, address of the firt char on the first line
charLines uint8 // 5 bits, lines par character
columns uint8 // 8 bits, chars per line
lines uint8 // 7 bits, char lines per screen
Columns uint8 // 8 bits, chars per line
Lines uint8 // 7 bits, char lines per screen
adjustLines uint8 // 5 bits, extra blank lines

cursorPos uint16 // 14 bits, address? of the cursor position
Expand All @@ -77,22 +77,22 @@ type MC6845ImageData struct {
}

func (data *MC6845ImageData) DisplayedWidthHeight(charWidth uint8) (int, int) {
return int(data.columns) * int(charWidth),
int(data.lines)*int(data.charLines) + int(data.adjustLines)
return int(data.Columns) * int(charWidth),
int(data.Lines)*int(data.charLines) + int(data.adjustLines)
}

type MC6845RasterCallBack func(address uint16, charLine uint8, // Lookup in char ROM
cursorMode uint8, displayEnable bool, // Modifiers
column uint8, y int) // Position in screen

func (data *MC6845ImageData) IterateScreen(callBack MC6845RasterCallBack) {
lineAddress := data.firstChar
lineAddress := data.FirstChar
y := 0
var address uint16
for line := uint8(0); line < data.lines; line++ {
for line := uint8(0); line < data.Lines; line++ {
for charLine := uint8(0); charLine < data.charLines; charLine++ {
address = lineAddress // Back to the first char of the line
for column := uint8(0); column < data.columns; column++ {
for column := uint8(0); column < data.Columns; column++ {
cursorMode := MC6845CursorNone
isCursor := (address == data.cursorPos) &&
(charLine >= data.cursorStart) &&
Expand All @@ -109,7 +109,7 @@ func (data *MC6845ImageData) IterateScreen(callBack MC6845RasterCallBack) {
lineAddress = address
}
for adjust := uint8(0); adjust <= data.adjustLines; adjust++ {
for column := uint8(0); column < data.columns; column++ {
for column := uint8(0); column < data.Columns; column++ {
callBack(0, 0, MC6845CursorNone, false, column, y) // lines with display not enabled
}
y++
Expand Down
Binary file not shown.

0 comments on commit 3813096

Please sign in to comment.