Search in sources :

Example 11 with SimpleMemory

use of com.rox.emu.mem.SimpleMemory in project emuRox by rossdrew.

the class Mos6502Properties method setUp.

@Before
public void setUp() {
    memory = new SimpleMemory();
    memory.setByteAt(0x0, 0xFFFC);
    memory.setByteAt(0x0, 0xFFFD);
    processor = new Mos6502(memory);
    processor.reset();
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Before(org.junit.Before)

Example 12 with SimpleMemory

use of com.rox.emu.mem.SimpleMemory in project emuRox by rossdrew.

the class Mos6502Properties method testValidStartup.

@Property(trials = 100)
public void testValidStartup(@InRange(min = "0", max = "255") int memHi, @InRange(min = "0", max = "255") int memLo) {
    memory = new SimpleMemory();
    memory.setByteAt(0xFFFC, memHi);
    memory.setByteAt(0xFFFD, memLo);
    processor = new Mos6502(memory);
    processor.reset();
    Registers registers = processor.getRegisters();
    // PC Set to location pointed to by mem[FFFC:FFFD]
    assertEquals(memHi, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
    // ...
    assertEquals(memLo, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
    // Status flags reset
    assertEquals(0x34, registers.getRegister(Registers.Register.STATUS_FLAGS));
    // Stack Pointer at top of stack
    assertEquals(0xFF, registers.getRegister(Registers.Register.STACK_POINTER_HI));
    // All cleared
    assertEquals(0, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0, registers.getRegister(Registers.Register.X_INDEX));
    assertEquals(0, registers.getRegister(Registers.Register.Y_INDEX));
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Property(com.pholser.junit.quickcheck.Property)

Example 13 with SimpleMemory

use of com.rox.emu.mem.SimpleMemory 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

SimpleMemory (com.rox.emu.mem.SimpleMemory)13 Memory (com.rox.emu.mem.Memory)5 Test (org.junit.Test)4 Property (com.pholser.junit.quickcheck.Property)3 Before (org.junit.Before)3 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)2 Program (com.rox.emu.processor.mos6502.util.Program)2 Mos6502 (com.rox.emu.processor.mos6502.Mos6502)1 Registers6502 (com.rox.emu.processor.mos6502.dbg.ui.component.Registers6502)1 Theory (org.junit.experimental.theories.Theory)1