Search in sources :

Example 6 with Memory

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));
}
Also used : Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Test(org.junit.Test)

Example 7 with Memory

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);
}
Also used : Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) InesRom(com.rox.emu.rom.InesRom) FileInputStream(java.io.FileInputStream)

Example 8 with Memory

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)));
    }
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Theory(org.junit.experimental.theories.Theory)

Aggregations

Memory (com.rox.emu.mem.Memory)8 SimpleMemory (com.rox.emu.mem.SimpleMemory)8 Test (org.junit.Test)4 Property (com.pholser.junit.quickcheck.Property)2 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)2 Program (com.rox.emu.processor.mos6502.util.Program)2 InesRom (com.rox.emu.rom.InesRom)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Theory (org.junit.experimental.theories.Theory)1