gpgx: custom backdrop color.

This commit is contained in:
feos 2016-02-28 20:52:35 +03:00
parent 050fa6d86b
commit 9e3d57341f
6 changed files with 153 additions and 115 deletions

View File

@ -118,6 +118,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
[DefaultValue((short)1)]
public short HighGain { get; set; }
[DeepEqualsIgnore]
[JsonIgnore]
private bool _Backdrop;
[DisplayName("Use custom backdrop color")]
[Description("Filler when layers are off")]
[DefaultValue((bool)false)]
public bool Backdrop { get { return _Backdrop; } set { _Backdrop = value; } }
[DisplayName("Custom backdrop color")]
[Description("Magic pink (0xffff00ff) by default")]
[DefaultValue((uint)0xffff00ff)]
public uint BackdropColor { get; set; }
public GPGXSettings()
{
SettingsUtil.SetDefaultValues(this);
@ -135,6 +149,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
if (DrawBGB) ret |= LibGPGX.DrawMask.BGB;
if (DrawBGW) ret |= LibGPGX.DrawMask.BGW;
if (DrawObj) ret |= LibGPGX.DrawMask.Obj;
if (Backdrop) ret |= LibGPGX.DrawMask.Backdrop;
return ret;
}
@ -153,7 +168,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
HighFreq = HighFreq,
LowGain = LowGain,
MidGain = MidGain,
HighGain = HighGain
HighGain = HighGain,
BackdropColor = BackdropColor
};
}
}

View File

@ -45,6 +45,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public short LowGain;
public short MidGain;
public short HighGain;
public uint BackdropColor;
}
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
@ -334,7 +335,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
BGA = 1,
BGB = 2,
BGW = 4,
Obj = 8
Obj = 8,
Backdrop = 16
}
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]

View File

@ -37,7 +37,10 @@ static int nsamples;
int cinterface_render_bga = 1;
int cinterface_render_bgb = 1;
int cinterface_render_bgw = 1;
int cinterface_render_obj = 0;
int cinterface_render_obj = 1;
uint8 cinterface_custom_backdrop = 0;
uint32 cinterface_custom_backdrop_color = 0xffff00ff; // pink
extern uint8 border;
#define GPGX_EX __declspec(dllexport)
@ -493,6 +496,7 @@ struct InitSettings
int16_t LowGain;
int16_t MidGain;
int16_t HighGain;
uint32_t BackdropColor;
};
GPGX_EX int gpgx_init(const char *feromextension, int (*feload_archive_cb)(const char *filename, unsigned char *buffer, int maxsize), int sixbutton, char system_a, char system_b, int region, struct InitSettings *settings)
@ -553,6 +557,8 @@ GPGX_EX int gpgx_init(const char *feromextension, int (*feload_archive_cb)(const
input.system[0] = system_a;
input.system[1] = system_b;
cinterface_custom_backdrop_color = settings->BackdropColor;
// apparently, the only part of config.input used is the padtype identifier,
// and that's used only for choosing pad type when system_md
{
@ -600,6 +606,11 @@ GPGX_EX void gpgx_set_draw_mask(int mask)
cinterface_render_bgb = !!(mask & 2);
cinterface_render_bgw = !!(mask & 4);
cinterface_render_obj = !!(mask & 8);
cinterface_custom_backdrop = !!(mask & 16);
if (cinterface_custom_backdrop)
color_update_m5(0, 0);
else
color_update_m5(0x00, *(uint16 *)&cram[border << 1]);
}
typedef struct

View File

@ -125,7 +125,7 @@ static const uint8 shift_table[] = { 6, 7, 0, 8 };
static const uint8 col_mask_table[] = { 0x0F, 0x1F, 0x0F, 0x3F };
static const uint16 row_mask_table[] = { 0x0FF, 0x1FF, 0x2FF, 0x3FF };
static uint8 border; /* Border color index */
uint8 border; /* Border color index */
static uint8 pending; /* Pending write flag */
static uint8 code; /* Code register */
static uint8 dma_type; /* DMA mode */

View File

@ -48,6 +48,8 @@ extern int cinterface_render_bga;
extern int cinterface_render_bgb;
extern int cinterface_render_bgw;
extern int cinterface_render_obj;
extern uint8 cinterface_custom_backdrop;
extern uint32 cinterface_custom_backdrop_color;
/*** NTSC Filters ***/
extern md_ntsc_t *md_ntsc;
@ -1123,22 +1125,29 @@ void color_update_m5(int index, unsigned int data)
data &= 0x49;
}
if(reg[12] & 0x08)
if (index == 0 && cinterface_custom_backdrop)
{
/* Mode 5 (Shadow/Normal/Highlight) */
pixel[0x00 | index] = pixel_lut[0][data];
pixel[0x40 | index] = pixel_lut[1][data];
pixel[0x80 | index] = pixel_lut[2][data];
pixel[0x00] = pixel[0x40] = pixel[0x80] = cinterface_custom_backdrop_color;
}
else
{
/* Mode 5 (Normal) */
data = pixel_lut[1][data];
/* Input pixel: xxiiiiii */
pixel[0x00 | index] = data;
pixel[0x40 | index] = data;
pixel[0x80 | index] = data;
if(reg[12] & 0x08)
{
/* Mode 5 (Shadow/Normal/Highlight) */
pixel[0x00 | index] = pixel_lut[0][data];
pixel[0x40 | index] = pixel_lut[1][data];
pixel[0x80 | index] = pixel_lut[2][data];
}
else
{
/* Mode 5 (Normal) */
data = pixel_lut[1][data];
/* Input pixel: xxiiiiii */
pixel[0x00 | index] = data;
pixel[0x40 | index] = data;
pixel[0x80 | index] = data;
}
}
}
@ -1707,47 +1716,47 @@ void render_bg_m5_vs(int line)
if (cinterface_render_bgb)
{
if(shift)
{
/* Plane B vertical scroll */
v_line = (line + yscroll) & pf_row_mask;
if(shift)
{
/* Plane B vertical scroll */
v_line = (line + yscroll) & pf_row_mask;
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (v_line & 7) << 3;
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (v_line & 7) << 3;
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
for(column = 0; column < end; column++, index++)
{
/* Plane B vertical scroll */
for(column = 0; column < end; column++, index++)
{
/* Plane B vertical scroll */
#ifdef LSB_FIRST
v_line = (line + (vs[column] >> 16)) & pf_row_mask;
v_line = (line + (vs[column] >> 16)) & pf_row_mask;
#else
v_line = (line + vs[column]) & pf_row_mask;
v_line = (line + vs[column]) & pf_row_mask;
#endif
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (v_line & 7) << 3;
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN(atbuf, v_line)
}
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (v_line & 7) << 3;
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN(atbuf, v_line)
}
}
else
{
@ -1902,30 +1911,30 @@ void render_bg_m5_im2(int line)
uint32 *nt;
if (cinterface_render_bgb)
{
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
if(shift)
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
for(column = 0; column < end; column++, index++)
{
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
if(shift)
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
for(column = 0; column < end; column++, index++)
{
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
}
else
{
@ -2073,47 +2082,47 @@ void render_bg_m5_im2_vs(int line)
if (cinterface_render_bgb)
{
if(shift)
{
/* Plane B vertical scroll */
v_line = (line + yscroll) & pf_row_mask;
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
for(column = 0; column < end; column++, index++)
{
/* Plane B vertical scroll */
if(shift)
{
/* Plane B vertical scroll */
v_line = (line + yscroll) & pf_row_mask;
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x10 + shift];
atbuf = nt[(index - 1) & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
else
{
/* Plane B line buffer */
dst = (uint32 *)&linebuf[0][0x20];
}
for(column = 0; column < end; column++, index++)
{
/* Plane B vertical scroll */
#ifdef LSB_FIRST
v_line = (line + (vs[column] >> 17)) & pf_row_mask;
v_line = (line + (vs[column] >> 17)) & pf_row_mask;
#else
v_line = (line + (vs[column] >> 1)) & pf_row_mask;
v_line = (line + (vs[column] >> 1)) & pf_row_mask;
#endif
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
/* Plane B name table */
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
/* Pattern row index */
v_line = (((v_line & 7) << 1) | odd) << 3;
atbuf = nt[index & pf_col_mask];
DRAW_COLUMN_IM2(atbuf, v_line)
}
}
else
{

Binary file not shown.