From 8397dfcc365ccf0c5e17843fd36340d3f8e2eb4f Mon Sep 17 00:00:00 2001 From: Badvision Date: Wed, 6 Nov 2024 14:56:13 -0600 Subject: [PATCH] Fix for bit unit tests, add hayes micromodem rom --- .java-version | 2 +- .../jace/hardware/CardHayesMicromodem.java | 20 ++++++++--- src/main/java/jace/hardware/CardSSC.java | 31 ++++++++++-------- .../jace/data/hayes-micromodem-8308a271.rom | Bin 0 -> 1024 bytes src/test/java/jace/TestUtils.java | 21 +++++++++++- src/test/java/jace/apple2e/CpuUnitTest.java | 3 +- src/test/java/jace/apple2e/Full65C02Test.java | 12 +++---- 7 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 src/main/resources/jace/data/hayes-micromodem-8308a271.rom diff --git a/.java-version b/.java-version index c7464da..4099407 100644 --- a/.java-version +++ b/.java-version @@ -1 +1 @@ -graalvm64-17.0.3 +23 diff --git a/src/main/java/jace/hardware/CardHayesMicromodem.java b/src/main/java/jace/hardware/CardHayesMicromodem.java index e5fbbfb..8bef799 100644 --- a/src/main/java/jace/hardware/CardHayesMicromodem.java +++ b/src/main/java/jace/hardware/CardHayesMicromodem.java @@ -17,6 +17,8 @@ package jace.hardware; import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -55,6 +57,19 @@ public class CardHayesMicromodem extends CardSSC { 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 public void clientConnected() { 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 */ diff --git a/src/main/java/jace/hardware/CardSSC.java b/src/main/java/jace/hardware/CardSSC.java index 79eeb07..f0a3eb7 100644 --- a/src/main/java/jace/hardware/CardSSC.java +++ b/src/main/java/jace/hardware/CardSSC.java @@ -110,7 +110,7 @@ public class CardSSC extends Card { @Override public void setSlot(int slot) { try { - loadRom("/jace/data/SSC.rom"); + loadRom(); } catch (IOException ex) { Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE, null, ex); } @@ -173,22 +173,25 @@ public class CardSSC extends Card { 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 // CF00-CFFF are unused by the SSC - InputStream romFile = CardSSC.class.getResourceAsStream(path); - final int cxRomLength = 0x0100; - final int c8RomLength = 0x0700; - byte[] romxData = new byte[cxRomLength]; - byte[] rom8Data = new byte[c8RomLength]; - if (romFile.read(rom8Data) != c8RomLength) { - throw new IOException("Bad SSC rom size"); + try (InputStream romFile = CardSSC.class.getResourceAsStream(path)) { + final int cxRomLength = 0x0100; + final int c8RomLength = 0x0700; + byte[] romxData = new byte[cxRomLength]; + byte[] rom8Data = new byte[c8RomLength]; + if (romFile.read(rom8Data) != c8RomLength) { + throw new IOException("Bad SSC rom size"); + } + getC8Rom().loadData(rom8Data); + if (romFile.read(romxData) != cxRomLength) { + throw new IOException("Bad SSC rom size"); + } + getCxRom().loadData(romxData); } - getC8Rom().loadData(rom8Data); - if (romFile.read(romxData) != cxRomLength) { - throw new IOException("Bad SSC rom size"); - } - getCxRom().loadData(romxData); } @Override diff --git a/src/main/resources/jace/data/hayes-micromodem-8308a271.rom b/src/main/resources/jace/data/hayes-micromodem-8308a271.rom new file mode 100644 index 0000000000000000000000000000000000000000..b15320902070c9c3f711a377e471cb062ee4d00a GIT binary patch literal 1024 zcmXX^U1%It6yEG+W_K35jIn_&t@WTK?vzkNq;Z19WKGu0#AG*aQw#-V3jR#NhrStK zOngWzOGh^NU{YBv!C>yv)GZ}+vamQ$ZSM>v7i!TWmI_hZh+(WxI+u7TgTVf0OtO=E+)u?S=ESOM>0L`X?L?*ewj9b8Hp1 zuCeQ+AM8Mc8T>h|pU3bJo)1Jqn@IRYfZo{w?fL<;;g2mRT*pqB5AOtQiM#?|`eZ*A zfeBH^%vN045(QiMfB-tn-=hxir6vBZ;9Eta69KK)4&3{u3@l2L)!~I1kIcjJLvluV zAE4*6&BY^dJRqS(Iz{az#4r}$63VsmXV*UVRw5qu9_=D?`e^?N z7WRc^9FrzfBi-5j%N`hI}u*Q;xl%%Z4_^Q?Tim726Tgulj~PY+WfJLA6OgV(nxcVH{O3 zRv+LhVsCF(jPjefXIDqw4!3#nqXOqKmKN~kHiS;nZvHdvVDk3KzoPvpzkzDt3)5Zf z84<7YeLLs>kPkx2t+2bZ zr|0L|cBe|oNPi?*{949w{ z5Sf=;iKXZzodu+wZITm+mbPdLgC`!Ilac72>wfQde#Mp3>`TQX#`+C+Ke{^je%MZb^G3VvnkeP?^ sTyfON c : t.cycles()) { + for (@SuppressWarnings("unused") List c : t.cycles()) { if (BREAK_ON_FAIL) { cpu.traceLength = 100; cpu.setTraceEnabled(true); } cpu.doTick(); - // TODO: Check the memory accesses } // Check the final state boolean passed = true; diff --git a/src/test/java/jace/apple2e/Full65C02Test.java b/src/test/java/jace/apple2e/Full65C02Test.java index 6fb9bd8..d174894 100644 --- a/src/test/java/jace/apple2e/Full65C02Test.java +++ b/src/test/java/jace/apple2e/Full65C02Test.java @@ -400,18 +400,18 @@ public class Full65C02Test { new TestProgram() .add("LDA #$FF") .add("STA $FF") - .assertTimed("BIT #0", 2) - .assertFlags(IS_ZERO, POSITIVE, OVERFLOW_CLEAR) - .assertTimed("BIT #$FF", 2) + .assertTimed("BIT #0", 3) + .assertFlags(IS_ZERO, NEGATIVE, OVERFLOW_CLEAR) + .assertTimed("BIT #$FF", 3) .assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_CLEAR) .assertTimed("BIT $FF", 3) .assertFlags(NOT_ZERO, NEGATIVE, OVERFLOW_SET) .add("CLV") .add("LDA #$40") - .assertTimed("BIT #$40", 2) + .assertTimed("BIT #$40", 3) .assertFlags(NOT_ZERO, POSITIVE, OVERFLOW_CLEAR) - .assertTimed("BIT #$80", 2) - .assertFlags(IS_ZERO, NEGATIVE, OVERFLOW_CLEAR) + .assertTimed("BIT #$80", 3) + .assertFlags(IS_ZERO, POSITIVE, OVERFLOW_CLEAR) .assertTimed("BIT $1000", 4) .assertTimed("BIT $1000,x", 4) .assertTimed("BIT $00,X", 4)