Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
fix tests (#1)
Browse files Browse the repository at this point in the history
* gh: test fixes
  • Loading branch information
fedex81 authored Mar 15, 2022
1 parent 428920d commit 0b41118
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
with:
java-version: 1.11
- name: Build with Gradle
#./gradlew --stacktrace --debug packageDistribution
run: ./gradlew packageDistribution
- uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 22.0315-SNAPSHOT
* implement sh2 cache
* add FM, RV bit handling
* fix joypad detection

## 22.0223-SNAPSHOT
* more stuff working, lots broken still

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/sh2/BiosHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public BiosHolder(Path sh2m, Path sh2s, Path m68k) {
init();
}

public BiosHolder(ByteBuffer[] biosData) {
this.biosData = biosData;
}

private void init() {
assert sh2m.toFile().exists();
assert sh2s.toFile().exists();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/sh2/MarsLauncherHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public static BiosHolder initBios() {
}

public static Sh2LaunchContext setupRom(S32xBus bus, Path romFile) {
return setupRom(bus, ByteBuffer.wrap(FileUtil.readBinaryFile(romFile, SystemLoader.s32xBinaryTypes)));
return setupRom(bus, ByteBuffer.wrap(FileUtil.readBinaryFile(romFile, SystemLoader.s32xBinaryTypes)), initBios());
}

public static Sh2LaunchContext setupRom(S32xBus bus, ByteBuffer rom) {
public static Sh2LaunchContext setupRom(S32xBus bus, ByteBuffer rom, BiosHolder biosHolder) {
Sh2LaunchContext ctx = new Sh2LaunchContext();
ctx.masterCtx = new Sh2Context(MASTER);
ctx.masterCtx.debug = masterDebug;
ctx.slaveCtx = new Sh2Context(SLAVE);
ctx.slaveCtx.debug = slaveDebug;
ctx.biosHolder = initBios();
ctx.biosHolder = biosHolder;
ctx.bus = bus;
ctx.rom = rom;
ctx.s32XMMREG = new S32XMMREG();
Expand Down
17 changes: 12 additions & 5 deletions src/test/java/s32x/MarsRegTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
import omegadrive.util.Util;
import org.junit.jupiter.api.Assertions;
import s32x.util.SystemTestUtil;
import sh2.MarsLauncherHelper;
import sh2.*;
import sh2.MarsLauncherHelper.Sh2LaunchContext;
import sh2.Md32xRuntimeData;
import sh2.S32XMMREG;
import sh2.S32xBus;
import sh2.S32xUtil.CpuDeviceAccess;
import sh2.dict.S32xDict;

Expand Down Expand Up @@ -65,7 +62,7 @@ public static Sh2LaunchContext createTestInstance() {
public static Sh2LaunchContext createTestInstance(byte[] brom) {
Md32xRuntimeData.releaseInstance();
Md32xRuntimeData.newInstance();
Sh2LaunchContext lc = MarsLauncherHelper.setupRom(new S32xBus(), ByteBuffer.wrap(brom));
Sh2LaunchContext lc = MarsLauncherHelper.setupRom(new S32xBus(), ByteBuffer.wrap(brom), createTestBiosHolder());

int[] irom = Util.toSignedIntArray(brom);
IMemoryProvider mp = MemoryProvider.createGenesisInstance();
Expand All @@ -74,6 +71,16 @@ public static Sh2LaunchContext createTestInstance(byte[] brom) {
return lc;
}

private static BiosHolder createTestBiosHolder() {
ByteBuffer[] biosData = new ByteBuffer[CpuDeviceAccess.values().length];
ByteBuffer data = ByteBuffer.allocate(0x1000);

biosData[0] = data;
biosData[1] = data;
biosData[2] = data;
return new BiosHolder(biosData);
}

public static int readBus(Sh2LaunchContext lc, CpuDeviceAccess sh2Access, int reg, Size size) {
Md32xRuntimeData.setAccessTypeExt(sh2Access);
if (sh2Access == M68K) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/sh2/J2CoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class J2CoreTest {
static String binName = "j2tests.bin";
static ByteBuffer rom;
private static boolean done = false;
private static boolean sh2Debug = true;
private static boolean sh2Debug = false;

public static Path baseDataFolder = Paths.get(new File(".").getAbsolutePath(),
"src", "test", "resources");
Expand Down

0 comments on commit 0b41118

Please sign in to comment.