public void Tick_Tick160LinesAnd240Dots_InVBlank() { AgbPpu ppu = PpuUtil.CreatePpu(); PpuUtil.TickPpuByAmount(ppu, 160, 240); Assert.Equal(PpuState.VBlank, ppu.State); }
public void Tick_Tick227Lines_InVBlank() { AgbPpu ppu = PpuUtil.CreatePpu(); PpuUtil.TickPpuByAmount(ppu, 227, 0); Assert.Equal(PpuState.VBlank, ppu.State); }
public void Tick_Tick307Dots_InHBlank() { AgbPpu ppu = PpuUtil.CreatePpu(); PpuUtil.TickPpuByAmount(ppu, 0, 307); Assert.Equal(PpuState.HBlank, ppu.State); }
public void Tick_Tick159Lines_InRender() { AgbPpu ppu = PpuUtil.CreatePpu(); PpuUtil.TickPpuByAmount(ppu, 159, 0); Assert.Equal(PpuState.Render, ppu.State); }
public void Tick_Tick239Dots_InRender() { AgbPpu ppu = PpuUtil.CreatePpu(); PpuUtil.TickPpuByAmount(ppu, 0, 239); Assert.Equal(PpuState.Render, ppu.State); }
public static void TickPpuByAmount(AgbPpu ppu, int lines, int dots) { int totalDots = (lines * 308) + dots; for (int i = 0; i < totalDots; i++) { ppu.Tick(); } }
public void Dispstat_SetAllConfigurableBitsWithMemoryMap_AllConfigurableBitsSet() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap); memoryMap.WriteU16(0x4000004, 0xFF38); memoryMap.FlushMmio(); Assert.Equal(0xFF38, memoryMap.ReadU16(0x4000004)); }
public void Vcount_TickPpuToLine100_VcountCorrect() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap); PpuUtil.TickPpuByAmount(ppu, 100, 0); memoryMap.UpdateMmio(); Assert.Equal(0x0064, memoryMap.ReadU16(0x4000006)); // V-Count flag }
public void Dispcnt_SetAllBitsWithMemoryMap_AllBitsSet() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap); memoryMap.WriteU16(0x4000000, 0xFFFF); memoryMap.FlushMmio(); Assert.Equal(0xFFFF, memoryMap.ReadU16(0x4000000)); }
public AgbDevice() { MemoryMap = new AgbMemoryMap(); Cpu = new AgbCpu(MemoryMap); Ppu = new AgbPpu(MemoryMap, Cpu); Controller = new AgbController(MemoryMap, Cpu); MemoryMap.RegisterRegion(new InternalWramRegion()); MemoryMap.RegisterRegion(new ExternalWramRegion()); PostBootFlag = 0; MemoryMap.RegisterMmio(0x4000300, () => PostBootFlag, (x) => PostBootFlag = x); }
public void Dispstat_SetVCountAndTickUntilVCountLine_VCountFlagSet() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap); memoryMap.WriteU16(0x4000004, 0x6400); // VCount = line 100 memoryMap.FlushMmio(); PpuUtil.TickPpuByAmount(ppu, 100, 0); memoryMap.UpdateMmio(); Assert.Equal(0x6404, memoryMap.ReadU16(0x4000004)); // V-Count flag }
public void Dispstat_TickUntilHBlankPeriodInVBlank_HBlankFlagSet() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap); memoryMap.WriteU16(0x4000004, 0xFF00); // VCount = line 255 (impossible) memoryMap.FlushMmio(); PpuUtil.TickPpuByAmount(ppu, 160, 240); memoryMap.UpdateMmio(); Assert.Equal(0xFF03, memoryMap.ReadU16(0x4000004)); // H-Blank and V-Blank flags }
public void Dispstat_SetVCountAndEnableVCountIrqAndTickUntilVCountLine_InterruptRequested() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbCpu cpu = new AgbCpu(memoryMap); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap, cpu); memoryMap.WriteU32(0x4000208, 0x01); // Interrupt Master Enable memoryMap.WriteU16(0x4000200, 0x0004); // IE = V-Count IRQ enabled memoryMap.WriteU16(0x4000004, 0x6420); // DISPSTAT = V-Blank IRQ enabled, VCount = line 100 memoryMap.FlushMmio(); PpuUtil.TickPpuByAmount(ppu, 100, 0); memoryMap.UpdateMmio(); Assert.Equal(0x6424, memoryMap.ReadU16(0x4000004)); // V-Count flag, V-Count IRQ enabled Assert.Equal(0x0004, memoryMap.ReadU16(0x4000202)); // IF = V-Count Assert.Equal(CpuMode.Irq, cpu.CurrentStatus.Mode); }
public void Dispstat_EnableHBlankIrqAndTickUntilHBlank_InterruptRequested() { AgbMemoryMap memoryMap = new AgbMemoryMap(); AgbCpu cpu = new AgbCpu(memoryMap); AgbPpu ppu = PpuUtil.CreatePpu(memoryMap, cpu); memoryMap.WriteU32(0x4000208, 0x01); // Interrupt Master Enable memoryMap.WriteU16(0x4000200, 0x0002); // IE = H-Blank IRQ enabled memoryMap.WriteU16(0x4000004, 0xFF10); // DISPSTAT = H-Blank IRQ enabled, VCount = line 255 memoryMap.FlushMmio(); PpuUtil.TickPpuByAmount(ppu, 0, 240); memoryMap.UpdateMmio(); Assert.Equal(0xFF12, memoryMap.ReadU16(0x4000004)); // H-Blank flag, H-Blank IRQ enabled Assert.Equal(0x0002, memoryMap.ReadU16(0x4000202)); // IF = H-Count Assert.Equal(CpuMode.Irq, cpu.CurrentStatus.Mode); }
public static AgbPpu CreatePpu(AgbMemoryMap memoryMap, AgbCpu cpu = null) { AgbPpu ppu = new AgbPpu(memoryMap, cpu); return(ppu); }