Skip to content

Commit

Permalink
32x: uninitialised hInt vector should read 0 (tp)
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Berti committed Oct 10, 2023
1 parent 8701f49 commit ae0860d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/s32x/bus/S32xBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private int readHIntVector(int address, Size size) {
if (verboseMd) LOG.info("HINT vector read, rv {}, address: {}, {} {}", DmaFifo68k.rv,
th(address), th(res), size);
} else {
res = bios68k.readBuffer(address, size);
res = 0;
}
return res;
}
Expand Down
46 changes: 46 additions & 0 deletions src/test/java/s32x/HIntVectorRomTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package s32x;

import omegadrive.util.Size;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import s32x.dict.S32xDict;
import s32x.util.MarsLauncherHelper;

import static s32x.MarsRegTestUtil.*;
import static s32x.util.S32xUtil.CpuDeviceAccess.M68K;

/**
* Federico Berti
* <p>
* Copyright 2023
*/
public class HIntVectorRomTest {

private MarsLauncherHelper.Sh2LaunchContext lc;

@BeforeEach
public void before() {
lc = createTestInstance();
}

//testpico expects 0x70 to be 0 when the hintvector is not set, ie. it is not reading the data stored in the bios.
@Test
public void testVector() {
int addr = S32xDict.M68K_START_HINT_VECTOR_WRITEABLE;
//defaults to 0
checkAden(lc, 0);
//enable 32x, RV = 1
MarsRegTestUtil.setAdenMdSide(lc, 1);
setRv(lc, 1);
int res = readBus(lc, M68K, addr, Size.LONG);
Assertions.assertEquals(0, res);
int vector = 0xAABBCCDD;
writeBus(lc, M68K, addr, vector, Size.LONG);
res = readBus(lc, M68K, addr, Size.LONG);
Assertions.assertEquals(vector, res);
writeBus(lc, M68K, addr, 0, Size.LONG);
res = readBus(lc, M68K, addr, Size.LONG);
Assertions.assertEquals(0, res);
}
}

0 comments on commit ae0860d

Please sign in to comment.