GBHawk: Implement frame draw delay

This commit is contained in:
alyosha-tas 2017-12-03 19:09:33 -05:00
parent b7689dfe29
commit e951439bed
2 changed files with 22 additions and 4 deletions

View File

@ -116,7 +116,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
while (!vblank_rise && (ticker < 100000)) while (!vblank_rise)
{ {
audio.tick(); audio.tick();
timer.tick_1(); timer.tick_1();
@ -133,7 +133,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
vblank_rise = true; vblank_rise = true;
} }
ticker++; ticker++;
if (ticker > 10000000) { throw new Exception("ERROR: Unable to Resolve Frame"); }
in_vblank_old = in_vblank; in_vblank_old = in_vblank;
} }
@ -183,7 +186,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public int[] GetVideoBuffer() public int[] GetVideoBuffer()
{ {
return _vidbuffer; if (ppu.blank_frame)
{
for (int i = 0; i < _vidbuffer.Length; i++)
{
_vidbuffer[i] = (int)color_palette[0];
}
ppu.blank_frame = false;
}
return _vidbuffer;
} }
public int VirtualWidth => 160; public int VirtualWidth => 160;

View File

@ -79,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public int index_used; public int index_used;
public int sprite_ordered_index; public int sprite_ordered_index;
public int bottom_index; public int bottom_index;
public bool blank_frame;
// windowing state // windowing state
public int window_counter; public int window_counter;
@ -126,6 +127,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
OAM_access_write = true; OAM_access_write = true;
} }
if (!LCDC.Bit(7) && value.Bit(7))
{
// don't draw for one frame after turning on
blank_frame = true;
}
LCDC = value; LCDC = value;
break; break;
case 0xFF41: // STAT case 0xFF41: // STAT
@ -176,7 +183,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
case 0xFF4B: // WX case 0xFF4B: // WX
window_x = value; window_x = value;
break; break;
} }
} }
public void tick() public void tick()
@ -233,7 +240,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
} }
cycle = 0; cycle = 0;
LY += LY_inc; LY += LY_inc;
//Console.WriteLine(Core.cpu.TotalExecutedCycles); //Console.WriteLine(Core.cpu.TotalExecutedCycles);
@ -1232,6 +1238,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
ser.Sync("index_used", ref index_used); ser.Sync("index_used", ref index_used);
ser.Sync("sprite_ordered_index", ref sprite_ordered_index); ser.Sync("sprite_ordered_index", ref sprite_ordered_index);
ser.Sync("bottom_index", ref bottom_index); ser.Sync("bottom_index", ref bottom_index);
ser.Sync("blank_frame", ref blank_frame);
ser.Sync("window_counter", ref window_counter); ser.Sync("window_counter", ref window_counter);
ser.Sync("window_pre_render", ref window_pre_render); ser.Sync("window_pre_render", ref window_pre_render);