gpgx waterbox: move bg_pattern_cache to alloc_invisible

This commit is contained in:
nattthebear 2016-03-23 21:10:18 -04:00
parent 06f9d78452
commit 92e708d011
6 changed files with 58 additions and 31 deletions

View File

@ -40,6 +40,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
Core.gpgx_set_input_callback(InputCallback);
RefreshMemCallbacks();
Core.gpgx_set_cdd_callback(cd_callback_handle);
Core.gpgx_invalidate_pattern_cache();
UpdateVideo();
}

View File

@ -304,9 +304,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
[BizImport(CallingConvention.Cdecl)]
public abstract void gpgx_poke_vram(int addr, byte value);
[BizImport(CallingConvention.Cdecl)]
/// <summary>
/// regenerate whatever portions of the bg pattern cache are currently dirty.
/// </summary>
[BizImport(CallingConvention.Cdecl)] // the core will handle this itself; you only need to call this when using the cache for your own purposes
public abstract void gpgx_flush_vram();
/// <summary>
/// mark the bg pattern cache as dirty
/// </summary>
[BizImport(CallingConvention.Cdecl)]
public abstract void gpgx_invalidate_pattern_cache();
[StructLayout(LayoutKind.Sequential)]
public struct RegisterInfo
{

View File

@ -211,7 +211,7 @@ typedef struct
} vdpview_t;
extern uint8 bg_pattern_cache[];
extern uint8 *bg_pattern_cache;
extern uint32 pixel[];
GPGX_EX void gpgx_get_vdp_view(vdpview_t *view)
@ -509,6 +509,7 @@ GPGX_EX int gpgx_init(const char *feromextension, ECL_ENTRY int (*feload_archive
bitmap.pitch = 1024 * 4;
bitmap.data = alloc_invisible(2 * 1024 * 1024);
tempsram = alloc_invisible(24 * 1024);
bg_pattern_cache = alloc_invisible(0x80000);
ext.md_cart.rom = alloc_sealed(32 * 1024 * 1024);
scd.bootrom = malloc(0x20000); // FIXME: this should be sealed, but that crashes. huh?
@ -617,6 +618,11 @@ GPGX_EX void gpgx_set_draw_mask(int mask)
color_update_m5(0x00, *(uint16 *)&cram[border << 1]);
}
GPGX_EX void gpgx_invalidate_pattern_cache(void)
{
vdp_invalidate_full_cache();
}
typedef struct
{
unsigned int value;

View File

@ -203,6 +203,16 @@ void flush_vram_cache(void)
}
}
void vdp_invalidate_full_cache(void)
{
bg_list_index = 0x800;
for (int i=0;i<bg_list_index;i++)
{
bg_name_list[i] = i;
bg_name_dirty[i] = 0xFF;
}
}
/*--------------------------------------------------------------------------*/
/* Init, reset, context functions */
/*--------------------------------------------------------------------------*/

View File

@ -104,5 +104,6 @@ extern int vdp_68k_irq_ack(int int_level);
void write_vram_byte(int addr, uint8 val);
void flush_vram_cache(void);
void vdp_invalidate_full_cache(void);
#endif /* _VDP_H_ */

View File

@ -560,7 +560,7 @@ static const uint32 tms_palette[16] =
#endif
/* Cached and flipped patterns */
uint8 bg_pattern_cache[0x80000];
uint8 *bg_pattern_cache;
/* Sprite pattern name offset look-up table (Mode 5) */
static uint8 name_lut[0x400];