use of com.rox.emu.mem.Memory in project emuRox by rossdrew.
the class Ricoh2C02RegistersTest method testSimpleRead.
@Test
public void testSimpleRead() {
final Memory cpuMemory = mock(SimpleMemory.class);
final Ricoh2C02Registers registers = new Ricoh2C02Registers(cpuMemory);
when(cpuMemory.getByte(CTRL_1.getMemoryMappedLocation())).thenReturn(42);
assertEquals(42, registers.getRegister(CTRL_1));
}
use of com.rox.emu.mem.Memory in project emuRox by rossdrew.
the class DebuggerWindow method getProgramFromFile.
private int[] getProgramFromFile() {
final File file = new File("src" + File.separator + "main" + File.separator + "resources" + File.separator + "rom" + File.separator + "SMB1.NES");
System.out.println("Loading '" + file.getAbsolutePath() + "'...");
final FileInputStream fis;
byte[] fileContent = {};
try {
fis = new FileInputStream(file);
fileContent = new byte[(int) file.length()];
fis.read(fileContent);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
final InesRom rom = InesRom.from(fileContent);
Memory prgRom = rom.getProgramRom();
return prgRom.getBlock(0, prgRom.getSize() - 1);
}
use of com.rox.emu.mem.Memory in project emuRox by rossdrew.
the class Ricoh2C02Theories method testGetControlRegister.
@Theory
public void testGetControlRegister(int byteValue) {
assumeThat(byteValue, is(both(greaterThanOrEqualTo(0)).and(lessThanOrEqualTo(255))));
final Memory vRam = new SimpleMemory();
final Memory sprRam = mock(Memory.class);
final Memory cpuRam = mock(Memory.class);
final Ricoh2C02 ppu = new Ricoh2C02(vRam, sprRam, cpuRam);
for (Ricoh2C02Registers.Register register : Ricoh2C02Registers.Register.values()) {
when(cpuRam.getByte(register.getMemoryMappedLocation())).thenReturn(byteValue);
assertThat(byteValue, equalTo(ppu.getRegister(register)));
}
}
Aggregations