Search in sources :

Example 1 with Memory

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

the class Mos6502CompilerTest method testAbsoluteAddressing.

@Test
public void testAbsoluteAddressing() {
    final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$1C STA $100 INC $100");
    Program program = compiler.compileProgram();
    final int[] programByte = program.getProgramAsByteArray();
    Memory memory = new SimpleMemory();
    Mos6502 processor = new Mos6502(memory);
    processor.reset();
    memory.setBlock(0, programByte);
    processor.step(3);
    assertEquals(0x1D, memory.getByte(0x100));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 2 with Memory

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

the class Mos6502CompilerTest method testIntegration.

@Test
public void testIntegration() {
    final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$14 ADC #$5 STA $20");
    Program program = compiler.compileProgram();
    final int[] programByte = program.getProgramAsByteArray();
    Memory memory = new SimpleMemory();
    Mos6502 processor = new Mos6502(memory);
    processor.reset();
    memory.setBlock(0, programByte);
    processor.step(3);
    Registers registers = processor.getRegisters();
    assertEquals(0x19, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0x19, memory.getByte(0x20));
    assertEquals(programByte.length, registers.getPC());
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 3 with Memory

use of com.rox.emu.mem.Memory 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 4 with Memory

use of com.rox.emu.mem.Memory 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 5 with Memory

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

the class Ricoh2C02RegistersTest method testSimpleWrite.

@Test
public void testSimpleWrite() {
    final Memory cpuMemory = mock(SimpleMemory.class);
    final Ricoh2C02Registers registers = new Ricoh2C02Registers(cpuMemory);
    registers.setRegister(CTRL_1, 99);
    verify(cpuMemory, times(1)).setByteAt(CTRL_1.getMemoryMappedLocation(), 99);
}
Also used : Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Test(org.junit.Test)

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