mirror of
https://github.com/badvision/jace.git
synced 2024-11-23 23:32:59 +00:00
Fix for bit unit tests, add hayes micromodem rom
This commit is contained in:
parent
dad7632d62
commit
8397dfcc36
@ -1 +1 @@
|
||||
graalvm64-17.0.3
|
||||
23
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
|
BIN
src/main/resources/jace/data/hayes-micromodem-8308a271.rom
Normal file
BIN
src/main/resources/jace/data/hayes-micromodem-8308a271.rom
Normal file
Binary file not shown.
@ -18,9 +18,11 @@ package jace;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import jace.apple2e.RAM128k;
|
||||
import jace.core.CPU;
|
||||
import jace.core.Computer;
|
||||
import jace.core.Device;
|
||||
import jace.core.PagedMemory;
|
||||
import jace.core.RAM;
|
||||
import jace.core.RAMEvent.TYPE;
|
||||
import jace.core.Utility;
|
||||
@ -41,7 +43,8 @@ public class TestUtils {
|
||||
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];
|
||||
public byte read(int address, TYPE eventType, boolean triggerEvent, boolean requireSyncronization) {
|
||||
return memory[address & 0x0ffff];
|
||||
@ -92,6 +95,22 @@ public class TestUtils {
|
||||
@Override
|
||||
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) {
|
||||
|
@ -151,13 +151,12 @@ public class CpuUnitTest {
|
||||
ram.write(mem[0], (byte) mem[1], false, false);
|
||||
}
|
||||
// Step the CPU for each cycle
|
||||
for (List<String> c : t.cycles()) {
|
||||
for (@SuppressWarnings("unused") List<String> 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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user