Exemplo n.º 1
0
        public void Tick_Tick160LinesAnd240Dots_InVBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 160, 240);

            Assert.Equal(PpuState.VBlank, ppu.State);
        }
Exemplo n.º 2
0
        public void Tick_Tick227Lines_InVBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 227, 0);

            Assert.Equal(PpuState.VBlank, ppu.State);
        }
Exemplo n.º 3
0
        public void Tick_Tick307Dots_InHBlank()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 0, 307);

            Assert.Equal(PpuState.HBlank, ppu.State);
        }
Exemplo n.º 4
0
        public void Tick_Tick159Lines_InRender()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 159, 0);

            Assert.Equal(PpuState.Render, ppu.State);
        }
Exemplo n.º 5
0
        public void Tick_Tick239Dots_InRender()
        {
            AgbPpu ppu = PpuUtil.CreatePpu();

            PpuUtil.TickPpuByAmount(ppu, 0, 239);

            Assert.Equal(PpuState.Render, ppu.State);
        }
Exemplo n.º 6
0
        public static void TickPpuByAmount(AgbPpu ppu, int lines, int dots)
        {
            int totalDots = (lines * 308) + dots;

            for (int i = 0; i < totalDots; i++)
            {
                ppu.Tick();
            }
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
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
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
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
        }
Exemplo n.º 12
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
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public static AgbPpu CreatePpu(AgbMemoryMap memoryMap, AgbCpu cpu = null)
        {
            AgbPpu ppu = new AgbPpu(memoryMap, cpu);

            return(ppu);
        }