예제 #1
0
        public void Tick_Tick227Lines_InVBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 227, 0);

            Assert.Equal(PpuState.VBlank, ppu.State);
        }
예제 #2
0
        public void Tick_Tick159Lines_InRender()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 159, 0);

            Assert.Equal(PpuState.Render, ppu.State);
        }
예제 #3
0
        public void Tick_Tick160LinesAnd240Dots_InVBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 160, 240);

            Assert.Equal(PpuState.VBlank, ppu.State);
        }
예제 #4
0
        public void Tick_Tick239Dots_InRender()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 0, 239);

            Assert.Equal(PpuState.Render, ppu.State);
        }
예제 #5
0
        public void Tick_Tick307Dots_InHBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 0, 307);

            Assert.Equal(PpuState.HBlank, ppu.State);
        }
예제 #6
0
        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
        }
예제 #7
0
        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
        }
예제 #8
0
        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
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }