Fix for bit unit tests, add hayes micromodem rom

This commit is contained in:
Badvision 2024-11-06 14:56:13 -06:00
parent dad7632d62
commit 8397dfcc36
7 changed files with 60 additions and 29 deletions

View File

@ -1 +1 @@
graalvm64-17.0.3 23

View File

@ -17,6 +17,8 @@
package jace.hardware; package jace.hardware;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -55,6 +57,19 @@ public class CardHayesMicromodem extends CardSSC {
TRANS_IRQ_ENABLED = false; TRANS_IRQ_ENABLED = false;
} }
@Override
public void loadRom() throws IOException {
String path = "/jace/data/hayes-micromodem-8308a271.rom";
// Load rom file, first 0x0FF bytes are CX rom, next 0x0800 bytes are C8 rom
try (InputStream romFile = CardSSC.class.getResourceAsStream(path)) {
final int cxRomLength = 0x0100;
final int c8RomLength = 0x0800;
byte[] rom8Data = new byte[c8RomLength];
getC8Rom().loadData(rom8Data);
getCxRom().loadData(Arrays.copyOf(rom8Data, cxRomLength));
}
}
@Override @Override
public void clientConnected() { public void clientConnected() {
setRingIndicator(true); setRingIndicator(true);
@ -105,11 +120,6 @@ public class CardHayesMicromodem extends CardSSC {
} }
} }
@Override
public void loadRom(String path) throws IOException {
// Do nothing -- there is no rom for this card right now.
}
/** /**
* @return the ringIndicator * @return the ringIndicator
*/ */

View File

@ -110,7 +110,7 @@ public class CardSSC extends Card {
@Override @Override
public void setSlot(int slot) { public void setSlot(int slot) {
try { try {
loadRom("/jace/data/SSC.rom"); loadRom();
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE, null, ex);
} }
@ -173,10 +173,12 @@ public class CardSSC extends Card {
System.out.println("Client disconnected"); System.out.println("Client disconnected");
} }
public void loadRom(String path) throws IOException { public void loadRom() throws IOException {
System.out.println("Loading SSC rom");
String path = "/jace/data/SSC.rom";
// Load rom file, first 0x0700 bytes are C8 rom, last 0x0100 bytes are CX rom // Load rom file, first 0x0700 bytes are C8 rom, last 0x0100 bytes are CX rom
// CF00-CFFF are unused by the SSC // CF00-CFFF are unused by the SSC
InputStream romFile = CardSSC.class.getResourceAsStream(path); try (InputStream romFile = CardSSC.class.getResourceAsStream(path)) {
final int cxRomLength = 0x0100; final int cxRomLength = 0x0100;
final int c8RomLength = 0x0700; final int c8RomLength = 0x0700;
byte[] romxData = new byte[cxRomLength]; byte[] romxData = new byte[cxRomLength];
@ -190,6 +192,7 @@ public class CardSSC extends Card {
} }
getCxRom().loadData(romxData); getCxRom().loadData(romxData);
} }
}
@Override @Override
public void reset() { public void reset() {

View File

@ -18,9 +18,11 @@ package jace;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import jace.apple2e.RAM128k;
import jace.core.CPU; import jace.core.CPU;
import jace.core.Computer; import jace.core.Computer;
import jace.core.Device; import jace.core.Device;
import jace.core.PagedMemory;
import jace.core.RAM; import jace.core.RAM;
import jace.core.RAMEvent.TYPE; import jace.core.RAMEvent.TYPE;
import jace.core.Utility; import jace.core.Utility;
@ -41,7 +43,8 @@ public class TestUtils {
Emulator.withComputer(Computer::reconfigure); Emulator.withComputer(Computer::reconfigure);
} }
public static class FakeRAM extends RAM { public static class FakeRAM extends RAM128k {
PagedMemory fakeMemory = new PagedMemory(0x0, PagedMemory.Type.RAM);
byte[] memory = new byte[65536]; byte[] memory = new byte[65536];
public byte read(int address, TYPE eventType, boolean triggerEvent, boolean requireSyncronization) { public byte read(int address, TYPE eventType, boolean triggerEvent, boolean requireSyncronization) {
return memory[address & 0x0ffff]; return memory[address & 0x0ffff];
@ -92,6 +95,22 @@ public class TestUtils {
@Override @Override
public void resetState() { public void resetState() {
} }
@Override
public PagedMemory getAuxVideoMemory() {
return fakeMemory;
}
@Override
public PagedMemory getAuxMemory() {
return fakeMemory;
}
@Override
public PagedMemory getAuxLanguageCard() {
return fakeMemory;
}
@Override
public PagedMemory getAuxLanguageCard2() {
return fakeMemory;
}
} }
public static void clearFakeRam(RAM ram) { public static void clearFakeRam(RAM ram) {

View File

@ -151,13 +151,12 @@ public class CpuUnitTest {
ram.write(mem[0], (byte) mem[1], false, false); ram.write(mem[0], (byte) mem[1], false, false);
} }
// Step the CPU for each cycle // Step the CPU for each cycle
for (List<String> c : t.cycles()) { for (@SuppressWarnings("unused") List<String> c : t.cycles()) {
if (BREAK_ON_FAIL) { if (BREAK_ON_FAIL) {
cpu.traceLength = 100; cpu.traceLength = 100;
cpu.setTraceEnabled(true); cpu.setTraceEnabled(true);
} }
cpu.doTick(); cpu.doTick();
// TODO: Check the memory accesses
} }
// Check the final state // Check the final state
boolean passed = true; boolean passed = true;

View File

@ -400,18 +400,18 @@ public class Full65C02Test {
new TestProgram() new TestProgram()
.add("LDA #$FF") .add("LDA #$FF")
.add("STA $FF") .add("STA $FF")
.assertTimed("BIT #0", 2) .assertTimed("BIT #0", 3)
.assertFlags(IS_ZERO, POSITIVE, OVERFLOW_CLEAR) .assertFlags(IS_ZERO, NEGATIVE, OVERFLOW_CLEAR)
.assertTimed("BIT #$FF", 2) .assertTimed("BIT #$FF", 3)
.assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_CLEAR) .assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_CLEAR)
.assertTimed("BIT $FF", 3) .assertTimed("BIT $FF", 3)
.assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_SET) .assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_SET)
.add("CLV") .add("CLV")
.add("LDA #$40") .add("LDA #$40")
.assertTimed("BIT #$40", 2) .assertTimed("BIT #$40", 3)
.assertFlags(NOT_ZERO, POSITIVE, OVERFLOW_CLEAR) .assertFlags(NOT_ZERO, POSITIVE, OVERFLOW_CLEAR)
.assertTimed("BIT #$80", 2) .assertTimed("BIT #$80", 3)
.assertFlags(IS_ZERO, NEGATIVE, OVERFLOW_CLEAR) .assertFlags(IS_ZERO, POSITIVE, OVERFLOW_CLEAR)
.assertTimed("BIT $1000", 4) .assertTimed("BIT $1000", 4)
.assertTimed("BIT $1000,x", 4) .assertTimed("BIT $1000,x", 4)
.assertTimed("BIT $00,X", 4) .assertTimed("BIT $00,X", 4)