GBHawk: Some timing fixes for Oh! and GBvideoplayer

This commit is contained in:
alyosha-tas 2018-10-13 14:21:06 -05:00
parent 0c2c2dcb7c
commit 595c88960d
2 changed files with 53 additions and 30 deletions

View File

@ -109,8 +109,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
LCDC = value; LCDC = value;
Console.WriteLine(value);
break; break;
case 0xFF41: // STAT case 0xFF41: // STAT
// writing to STAT during mode 0 or 2 causes a STAT IRQ // writing to STAT during mode 0 or 2 causes a STAT IRQ
@ -131,8 +129,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
break; break;
case 0xFF43: // SCX case 0xFF43: // SCX
scroll_x = value; scroll_x = value;
// calculate the column number of the tile to start with
x_tile = (int)Math.Floor((float)(scroll_x) / 8);
break; break;
case 0xFF44: // LY case 0xFF44: // LY
LY = 0; /*reset*/ LY = 0; /*reset*/
@ -530,17 +527,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if ((cycle >= 80) && (LY < 144)) else if ((cycle >= 80) && (LY < 144))
{ {
if (cycle == 84) if (cycle >= 84)
{ {
STAT &= 0xFC; if (cycle == 84)
STAT |= 0x03; {
OAM_INT = false; STAT &= 0xFC;
OAM_access_write = false; STAT |= 0x03;
VRAM_access_write = false; OAM_INT = false;
} OAM_access_write = false;
VRAM_access_write = false;
}
// render the screen and handle hblank // render the screen and handle hblank
render(cycle - 80); render(cycle - 84);
}
else if (cycle == 80)
{
OAM_access_read = false;
OAM_access_write = true;
VRAM_access_read = false;
}
} }
} }
} }
@ -627,13 +633,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// i.e. just keeping track of the lowest x-value sprite // i.e. just keeping track of the lowest x-value sprite
if (render_cycle == 0) if (render_cycle == 0)
{ {
/*
OAM_access_read = false; OAM_access_read = false;
OAM_access_write = true; OAM_access_write = true;
VRAM_access_read = false; VRAM_access_read = false;
*/
// window X is latched for the scanline, mid-line changes have no effect // window X is latched for the scanline, mid-line changes have no effect
window_x_latch = window_x; window_x_latch = window_x;
// calculate the column number of the tile to start with
x_tile = (int)Math.Floor((float)(scroll_x) / 8);
render_offset = scroll_x % 8;
OAM_scan_index = 0; OAM_scan_index = 0;
read_case = 0; read_case = 0;
internal_cycle = 0; internal_cycle = 0;
@ -831,7 +842,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
if (pixel_counter == 160) if (pixel_counter == 160)
{ {
read_case = 8; read_case = 8;
hbl_countdown = 5; hbl_countdown = 1;
} }
} }
else if (pixel_counter < 0) else if (pixel_counter < 0)
@ -963,7 +974,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
// here we set up rendering // here we set up rendering
pre_render = false; pre_render = false;
render_offset = scroll_x % 8;
render_counter = 0; render_counter = 0;
latch_counter = 0; latch_counter = 0;
read_case = 0; read_case = 0;

View File

@ -70,8 +70,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
break; break;
case 0xFF43: // SCX case 0xFF43: // SCX
scroll_x = value; scroll_x = value;
// calculate the column number of the tile to start with
x_tile = (int)Math.Floor((float)(scroll_x) / 8);
break; break;
case 0xFF44: // LY case 0xFF44: // LY
LY = 0; /*reset*/ LY = 0; /*reset*/
@ -303,17 +301,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
} }
else if ((cycle >= 80) && (LY < 144)) else if ((cycle >= 80) && (LY < 144))
{ {
if (cycle == 84) if (cycle >= 84)
{ {
STAT &= 0xFC; if (cycle == 84)
STAT |= 0x03; {
OAM_INT = false; STAT &= 0xFC;
OAM_access_write = false; STAT |= 0x03;
VRAM_access_write = false; OAM_INT = false;
} OAM_access_write = false;
VRAM_access_write = false;
}
// render the screen and handle hblank // render the screen and handle hblank
render(cycle - 80); render(cycle - 84);
}
else if (cycle == 80)
{
OAM_access_read = false;
OAM_access_write = true;
VRAM_access_read = false;
}
} }
} }
} }
@ -400,13 +407,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
// i.e. just keeping track of the lowest x-value sprite // i.e. just keeping track of the lowest x-value sprite
if (render_cycle == 0) if (render_cycle == 0)
{ {
/*
OAM_access_read = false; OAM_access_read = false;
OAM_access_write = true; OAM_access_write = true;
VRAM_access_read = false; VRAM_access_read = false;
*/
// window X is latched for the scanline, mid-line changes have no effect // window X is latched for the scanline, mid-line changes have no effect
window_x_latch = window_x; window_x_latch = window_x;
// calculate the column number of the tile to start with
x_tile = (int)Math.Floor((float)(scroll_x) / 8);
render_offset = scroll_x % 8;
OAM_scan_index = 0; OAM_scan_index = 0;
read_case = 0; read_case = 0;
internal_cycle = 0; internal_cycle = 0;
@ -553,7 +565,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
if (pixel_counter == 160) if (pixel_counter == 160)
{ {
read_case = 8; read_case = 8;
hbl_countdown = 5; hbl_countdown = 1;
} }
} }
else if (pixel_counter < 0) else if (pixel_counter < 0)
@ -675,7 +687,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{ {
// here we set up rendering // here we set up rendering
pre_render = false; pre_render = false;
render_offset = scroll_x % 8;
render_counter = 0; render_counter = 0;
latch_counter = 0; latch_counter = 0;
read_case = 0; read_case = 0;