Search in sources :

Example 6 with SimpleMemory

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

the class Mos6502Theories method testValidStartup.

@Theory
public void testValidStartup(@FromDataPoints("validBytes") int memHi, @FromDataPoints("validBytes") int memLo) {
    assumeThat(memHi, is(both(greaterThanOrEqualTo(0)).and(lessThanOrEqualTo(255))));
    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]
    assertThat(memHi, equalTo(registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI)));
    // ...
    assertThat(memLo, equalTo(registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW)));
    // Status flags reset
    assertThat(registers.getRegister(Registers.Register.STATUS_FLAGS), equalTo(0x34));
    // Stack Pointer at top of stack
    assertThat(registers.getRegister(Registers.Register.STATUS_FLAGS), equalTo(0x34));
    // All cleared
    assertThat(registers.getRegister(Registers.Register.STACK_POINTER_HI), equalTo(0xFF));
    assertThat(registers.getRegister(Registers.Register.ACCUMULATOR), equalTo(0));
    assertThat(registers.getRegister(Registers.Register.X_INDEX), equalTo(0));
    assertThat(registers.getRegister(Registers.Register.Y_INDEX), equalTo(0));
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory)

Example 7 with SimpleMemory

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

the class Ricoh2C02Properties method testCreation.

@Test
public void testCreation() {
    final Ricoh2C02 ppu = new Ricoh2C02(new SimpleMemory(), new SimpleMemory(), new SimpleMemory());
    assertNotNull(ppu);
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Test(org.junit.Test)

Example 8 with SimpleMemory

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

the class Ricoh2C02Properties method testSetControlRegister.

@Property(trials = 10)
public void testSetControlRegister(@InRange(min = "0", max = "255") int byteValue) {
    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()) {
        ppu.setRegister(register, byteValue);
        verify(cpuRam, times(1)).setByteAt(register.getMemoryMappedLocation(), byteValue);
    }
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Property(com.pholser.junit.quickcheck.Property)

Example 9 with SimpleMemory

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

the class Ricoh2C02Properties method testGetControlRegister.

@Property(trials = 10)
public void testGetControlRegister(@InRange(min = "0", max = "255") int byteValue) {
    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);
        assertEquals(byteValue, ppu.getRegister(register));
    }
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Property(com.pholser.junit.quickcheck.Property)

Example 10 with SimpleMemory

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

the class DebuggerWindow method init.

private void init() {
    memory = new SimpleMemory();
    processor = new Mos6502(memory);
    newRegisterPanel = new Registers6502(processor.getRegisters());
}
Also used : Registers6502(com.rox.emu.processor.mos6502.dbg.ui.component.Registers6502) SimpleMemory(com.rox.emu.mem.SimpleMemory) Mos6502(com.rox.emu.processor.mos6502.Mos6502)

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