GBHawk: fix x-scroll latch and add some notes
This commit is contained in:
parent
8449f9fcb8
commit
7a4c5afce4
|
@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
|
||||||
public ulong TotalExecutedCycles;
|
public ulong TotalExecutedCycles;
|
||||||
|
|
||||||
private int EI_pending;
|
private int EI_pending;
|
||||||
private bool interrupts_enabled;
|
public bool interrupts_enabled;
|
||||||
|
|
||||||
// variables for executing instructions
|
// variables for executing instructions
|
||||||
public int instr_pntr = 0;
|
public int instr_pntr = 0;
|
||||||
|
|
|
@ -163,9 +163,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
scroll_x = value;
|
scroll_x = value;
|
||||||
break;
|
break;
|
||||||
case 0xFF44: // LY
|
case 0xFF44: // LY
|
||||||
// writing to LY has no effect on GBC (zen intergalactic ninja does this on initialization)
|
// writing to LY has no effect, confirmed by gambatte test roms
|
||||||
//LY = 0; /*reset*/
|
|
||||||
//LY_read = 0;
|
|
||||||
break;
|
break;
|
||||||
case 0xFF45: // LYC
|
case 0xFF45: // LYC
|
||||||
// tests indicate that latching writes to LYC should take place 4 cycles after the write
|
// tests indicate that latching writes to LYC should take place 4 cycles after the write
|
||||||
|
@ -597,15 +595,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
}
|
}
|
||||||
else if (!rendering_complete)
|
else if (!rendering_complete)
|
||||||
{
|
{
|
||||||
if (cycle == 85)
|
|
||||||
{
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
render(cycle - 85);
|
render(cycle - 85);
|
||||||
}
|
}
|
||||||
|
@ -658,12 +647,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
OAM_access_write = false;
|
OAM_access_write = false;
|
||||||
VRAM_access_read = false;
|
VRAM_access_read = false;
|
||||||
VRAM_access_write = false;
|
VRAM_access_write = false;
|
||||||
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
|
@ -1120,6 +1103,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
// here we set up rendering
|
// here we set up rendering
|
||||||
pre_render = false;
|
pre_render = false;
|
||||||
|
|
||||||
|
// x scroll is latched here
|
||||||
|
x_tile = scroll_x >> 3;
|
||||||
|
render_offset = scroll_offset = scroll_x % 8;
|
||||||
|
|
||||||
render_counter = 0;
|
render_counter = 0;
|
||||||
latch_counter = 0;
|
latch_counter = 0;
|
||||||
read_case = 0;
|
read_case = 0;
|
||||||
|
|
|
@ -159,9 +159,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
scroll_x = value;
|
scroll_x = value;
|
||||||
break;
|
break;
|
||||||
case 0xFF44: // LY
|
case 0xFF44: // LY
|
||||||
// writing to LY has no effect on GBC (zen intergalactic ninja does this on initialization)
|
// writing to LY has no effect, confirmed by gambatte test roms
|
||||||
//LY = 0; /*reset*/
|
|
||||||
//LY_read = 0;
|
|
||||||
break;
|
break;
|
||||||
case 0xFF45: // LYC
|
case 0xFF45: // LYC
|
||||||
// tests indicate that latching writes to LYC should take place 4 cycles after the write
|
// tests indicate that latching writes to LYC should take place 4 cycles after the write
|
||||||
|
@ -587,15 +585,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
}
|
}
|
||||||
else if (!rendering_complete)
|
else if (!rendering_complete)
|
||||||
{
|
{
|
||||||
if (cycle == 85)
|
|
||||||
{
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
render(cycle - 85);
|
render(cycle - 85);
|
||||||
}
|
}
|
||||||
|
@ -649,12 +638,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
OAM_access_write = false;
|
OAM_access_write = false;
|
||||||
VRAM_access_write = false;
|
VRAM_access_write = false;
|
||||||
VRAM_access_read = false;
|
VRAM_access_read = false;
|
||||||
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
|
@ -1075,6 +1058,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
// here we set up rendering
|
// here we set up rendering
|
||||||
pre_render = false;
|
pre_render = false;
|
||||||
|
|
||||||
|
// calculate the column number of the tile to start with
|
||||||
|
x_tile = scroll_x >> 3;
|
||||||
|
render_offset = scroll_offset = scroll_x % 8;
|
||||||
|
|
||||||
render_counter = 0;
|
render_counter = 0;
|
||||||
latch_counter = 0;
|
latch_counter = 0;
|
||||||
read_case = 0;
|
read_case = 0;
|
||||||
|
@ -1239,8 +1226,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
VRAM_access_write = true;
|
VRAM_access_write = true;
|
||||||
read_case = 18;
|
read_case = 18;
|
||||||
|
|
||||||
}
|
if (Core.double_speed)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
STAT &= 0xFC;
|
STAT &= 0xFC;
|
||||||
STAT |= 0x00;
|
STAT |= 0x00;
|
||||||
|
@ -1248,6 +1234,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
// the CPU has to be able to see the transition from mode 3 to mode 0 to start HDMA
|
// the CPU has to be able to see the transition from mode 3 to mode 0 to start HDMA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Core.double_speed)
|
||||||
|
{
|
||||||
|
STAT &= 0xFC;
|
||||||
|
STAT |= 0x00;
|
||||||
|
if (STAT.Bit(3)) { HBL_INT = true; }
|
||||||
|
// the CPU has to be able to see the transition from mode 3 to mode 0 to start HDMA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
|
|
|
@ -8,6 +8,8 @@ using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// TODO: mode1_disableint_gbc.gbc behaves differently between GBC and GBA, why?
|
// TODO: mode1_disableint_gbc.gbc behaves differently between GBC and GBA, why?
|
||||||
|
// TODO: oam_dma_start.gb does not behave as expected but test still passes through lucky coincidences / test deficiency
|
||||||
|
// TODO: LYC interrupt behaves differently in GBC and GB compat mode
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
case 0xFF41: // STAT
|
case 0xFF41: // STAT
|
||||||
// writing to STAT during mode 0 or 1 causes a STAT IRQ
|
// writing to STAT during mode 0 or 1 causes a STAT IRQ
|
||||||
// this appears to be a glitchy LYC compare
|
// this appears to be a glitchy LYC compare
|
||||||
|
if (!value.Bit(6)) { LYC_INT = false; }
|
||||||
|
|
||||||
if (LCDC.Bit(7))
|
if (LCDC.Bit(7))
|
||||||
{
|
{
|
||||||
if (((STAT & 3) == 0) || ((STAT & 3) == 1))
|
if (((STAT & 3) == 0) || ((STAT & 3) == 1))
|
||||||
|
@ -73,7 +75,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
}
|
}
|
||||||
STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80);
|
STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80);
|
||||||
|
|
||||||
//if (!STAT.Bit(6)) { LYC_INT = false; }
|
|
||||||
if (!STAT.Bit(4)) { VBL_INT = false; }
|
if (!STAT.Bit(4)) { VBL_INT = false; }
|
||||||
break;
|
break;
|
||||||
case 0xFF42: // SCY
|
case 0xFF42: // SCY
|
||||||
|
@ -83,8 +84,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
scroll_x = value;
|
scroll_x = value;
|
||||||
break;
|
break;
|
||||||
case 0xFF44: // LY
|
case 0xFF44: // LY
|
||||||
// writing to LY has no effect on GBC, not sure about GB (zen intergalactic ninja does this on initialization)
|
// writing to LY has no effect, confirmed by gambatte test roms
|
||||||
LY = 0; /*reset*/
|
|
||||||
break;
|
break;
|
||||||
case 0xFF45: // LYC
|
case 0xFF45: // LYC
|
||||||
LYC = value;
|
LYC = value;
|
||||||
|
@ -298,15 +298,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
}
|
}
|
||||||
else if (!rendering_complete)
|
else if (!rendering_complete)
|
||||||
{
|
{
|
||||||
if (cycle == 85)
|
|
||||||
{
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
render(cycle - 85);
|
render(cycle - 85);
|
||||||
}
|
}
|
||||||
|
@ -361,12 +352,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
OAM_INT = false;
|
OAM_INT = false;
|
||||||
OAM_access_write = false;
|
OAM_access_write = false;
|
||||||
VRAM_access_write = false;
|
VRAM_access_write = false;
|
||||||
|
|
||||||
// x-scroll is expected to be latched one cycle later
|
|
||||||
// this is fine since nothing has started in the rendering until the second cycle
|
|
||||||
// calculate the column number of the tile to start with
|
|
||||||
x_tile = scroll_x >> 3;
|
|
||||||
render_offset = scroll_offset = scroll_x % 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the screen and handle hblank
|
// render the screen and handle hblank
|
||||||
|
@ -734,6 +719,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
// here we set up rendering
|
// here we set up rendering
|
||||||
pre_render = false;
|
pre_render = false;
|
||||||
|
|
||||||
|
// x scroll is latched here
|
||||||
|
x_tile = scroll_x >> 3;
|
||||||
|
render_offset = scroll_offset = scroll_x % 8;
|
||||||
|
|
||||||
render_counter = 0;
|
render_counter = 0;
|
||||||
latch_counter = 0;
|
latch_counter = 0;
|
||||||
read_case = 0;
|
read_case = 0;
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
|
|
||||||
// Interrupt flags
|
// Interrupt flags
|
||||||
case 0xFF0F:
|
case 0xFF0F:
|
||||||
|
// TODO: Maybe some PPU bits are immediately visible, see 10spritesPrLine_10xposA7_m0irq_2_dmg08_cgb04c_out2.gbc
|
||||||
ret = REG_FF0F_OLD;
|
ret = REG_FF0F_OLD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue