genesis: make the vram memory domain properly invalidate the tile cache and the vdp viewer properly regenerate the tile cache. may or may not fix issue 265.

This commit is contained in:
goyuken 2014-09-19 23:56:08 +00:00
parent ad16be7712
commit 489d69d20c
6 changed files with 63 additions and 2 deletions

View File

@ -591,8 +591,27 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
if (area == IntPtr.Zero || pname == IntPtr.Zero || size == 0)
continue;
string name = Marshal.PtrToStringAnsi(pname);
mm.Add(MemoryDomain.FromIntPtrSwap16(name, size, MemoryDomain.Endian.Big, area));
if (name == "VRAM")
{
byte* p = (byte*)area;
mm.Add(new MemoryDomain(name, size, MemoryDomain.Endian.Unknown,
delegate(int addr)
{
if (addr < 0 || addr >= 65536)
throw new ArgumentOutOfRangeException();
return p[addr];
},
delegate(int addr, byte val)
{
if (addr < 0 || addr >= 65536)
throw new ArgumentOutOfRangeException();
LibGPGX.gpgx_poke_vram(addr, val);
}));
}
else
{
mm.Add(MemoryDomain.FromIntPtrSwap16(name, size, MemoryDomain.Endian.Big, area));
}
}
MemoryDomains = new MemoryDomainList(mm, 0);
}
@ -619,6 +638,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public void UpdateVDPViewContext(LibGPGX.VDPView view)
{
LibGPGX.gpgx_get_vdp_view(view);
LibGPGX.gpgx_flush_vram(); // fully regenerate internal caches as needed
}
LibGPGX.mem_cb ExecCallback;

View File

@ -265,6 +265,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_get_vdp_view([Out] VDPView view);
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_poke_vram(int addr, byte value);
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_flush_vram();
[StructLayout(LayoutKind.Sequential)]
public struct RegisterInfo
{

View File

@ -307,6 +307,16 @@ GPGX_EX void gpgx_sram_commitwrite(void)
}
}
GPGX_EX void gpgx_poke_vram(int addr, uint8 val)
{
write_vram_byte(addr, val);
}
GPGX_EX void gpgx_flush_vram(void)
{
flush_vram_cache();
}
GPGX_EX const char* gpgx_get_memdom(int which, void **area, int *size)
{
if (!area || !size)

View File

@ -180,6 +180,28 @@ static void (*const dma_func[16])(unsigned int length) =
};
void write_vram_byte(int addr, uint8 val)
{
uint8 *p;
addr &= 0xffff;
p = &vram[addr];
if (*p != val)
{
int name;
*p = val;
MARK_BG_DIRTY(addr);
}
}
void flush_vram_cache(void)
{
if (bg_list_index)
{
update_bg_pattern_cache(bg_list_index);
bg_list_index = 0;
}
}
/*--------------------------------------------------------------------------*/
/* Init, reset, context functions */
/*--------------------------------------------------------------------------*/

View File

@ -102,4 +102,7 @@ extern unsigned int vdp_hvc_r(unsigned int cycles);
extern void vdp_test_w(unsigned int data);
extern int vdp_68k_irq_ack(int int_level);
void write_vram_byte(int addr, uint8 val);
void flush_vram_cache(void);
#endif /* _VDP_H_ */

Binary file not shown.