Refactor gpgx init method to use fewer arguments
Upcoming waterbox changes will likely limit the number of arguments a function can take to 6, which should be enough for anybody
This commit is contained in:
parent
c64eff6baf
commit
2ee3125724
Binary file not shown.
|
@ -288,7 +288,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
[DefaultValue((uint)0xffff00ff)]
|
||||
public uint BackdropColor { get; set; }
|
||||
|
||||
public LibGPGX.InitSettings GetNativeSettings()
|
||||
public LibGPGX.InitSettings GetNativeSettings(GameInfo game)
|
||||
{
|
||||
return new LibGPGX.InitSettings
|
||||
{
|
||||
|
@ -299,7 +299,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
LowGain = (short)(LowGain * 100),
|
||||
MidGain = (short)(MidGain * 100),
|
||||
HighGain = (short)(HighGain * 100),
|
||||
BackdropColor = BackdropColor
|
||||
BackdropColor = BackdropColor,
|
||||
SixButton = UseSixButton,
|
||||
InputSystemA = SystemForSystem(ControlTypeLeft),
|
||||
InputSystemB = SystemForSystem(ControlTypeRight),
|
||||
Region = Region,
|
||||
ForceSram = game["sram"],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
LibGPGX.INPUT_SYSTEM system_a = SystemForSystem(_syncSettings.ControlTypeLeft);
|
||||
LibGPGX.INPUT_SYSTEM system_b = SystemForSystem(_syncSettings.ControlTypeRight);
|
||||
|
||||
var initResult = Core.gpgx_init(
|
||||
romextension,
|
||||
LoadCallback, _syncSettings.UseSixButton, system_a, system_b, _syncSettings.Region, game["sram"],
|
||||
_syncSettings.GetNativeSettings());
|
||||
var initResult = Core.gpgx_init(romextension, LoadCallback, _syncSettings.GetNativeSettings(game));
|
||||
|
||||
if (!initResult)
|
||||
throw new Exception($"{nameof(Core.gpgx_init)}() failed");
|
||||
|
|
|
@ -33,6 +33,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class InitSettings
|
||||
{
|
||||
public uint BackdropColor;
|
||||
public Region Region;
|
||||
public ushort LowPassRange;
|
||||
public short LowFreq;
|
||||
public short HighFreq;
|
||||
public short LowGain;
|
||||
public short MidGain;
|
||||
public short HighGain;
|
||||
public enum FilterType : byte
|
||||
{
|
||||
None = 0,
|
||||
|
@ -40,20 +48,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
ThreeBand = 2
|
||||
}
|
||||
public FilterType Filter;
|
||||
public ushort LowPassRange;
|
||||
public short LowFreq;
|
||||
public short HighFreq;
|
||||
public short LowGain;
|
||||
public short MidGain;
|
||||
public short HighGain;
|
||||
public uint BackdropColor;
|
||||
public INPUT_SYSTEM InputSystemA;
|
||||
public INPUT_SYSTEM InputSystemB;
|
||||
public bool SixButton;
|
||||
public bool ForceSram;
|
||||
}
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract bool gpgx_init(
|
||||
string feromextension,
|
||||
load_archive_cb feload_archive_cb,
|
||||
bool sixbutton, INPUT_SYSTEM system_a, INPUT_SYSTEM system_b, Region region, bool forcesram,
|
||||
[In]InitSettings settings);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
|
|
|
@ -490,25 +490,28 @@ GPGX_EX unsigned gpgx_peek_s68k_bus(unsigned addr)
|
|||
|
||||
struct InitSettings
|
||||
{
|
||||
uint8_t Filter;
|
||||
uint32_t BackdropColor;
|
||||
int Region;
|
||||
uint16_t LowPassRange;
|
||||
int16_t LowFreq;
|
||||
int16_t HighFreq;
|
||||
int16_t LowGain;
|
||||
int16_t MidGain;
|
||||
int16_t HighGain;
|
||||
uint32_t BackdropColor;
|
||||
uint8_t Filter;
|
||||
char InputSystemA;
|
||||
char InputSystemB;
|
||||
char SixButton;
|
||||
char ForceSram;
|
||||
};
|
||||
|
||||
GPGX_EX int gpgx_init(
|
||||
const char *feromextension,
|
||||
GPGX_EX int gpgx_init(const char* feromextension,
|
||||
ECL_ENTRY int (*feload_archive_cb)(const char *filename, unsigned char *buffer, int maxsize),
|
||||
int sixbutton, char system_a, char system_b, int region, int forcesram,
|
||||
struct InitSettings *settings)
|
||||
{
|
||||
_debug_puts("Initializing GPGX native...");
|
||||
|
||||
cinterface_force_sram = forcesram;
|
||||
cinterface_force_sram = settings->ForceSram;
|
||||
|
||||
memset(&bitmap, 0, sizeof(bitmap));
|
||||
|
||||
|
@ -551,7 +554,7 @@ GPGX_EX int gpgx_init(
|
|||
|
||||
/* system options */
|
||||
config.system = 0; /* AUTO */
|
||||
config.region_detect = region; // see loadrom.c
|
||||
config.region_detect = settings->Region; // see loadrom.c
|
||||
config.vdp_mode = 0; /* AUTO */
|
||||
config.master_clock = 0; /* AUTO */
|
||||
config.force_dtack = 0;
|
||||
|
@ -571,8 +574,8 @@ GPGX_EX int gpgx_init(
|
|||
// everything else is auto or master system only
|
||||
// XEA1P is port 1 only
|
||||
// WAYPLAY is both ports at same time only
|
||||
input.system[0] = system_a;
|
||||
input.system[1] = system_b;
|
||||
input.system[0] = settings->InputSystemA;
|
||||
input.system[1] = settings->InputSystemB;
|
||||
|
||||
cinterface_custom_backdrop_color = settings->BackdropColor;
|
||||
|
||||
|
@ -581,7 +584,7 @@ GPGX_EX int gpgx_init(
|
|||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_INPUTS; i++)
|
||||
config.input[i].padtype = sixbutton ? DEVICE_PAD6B : DEVICE_PAD3B;
|
||||
config.input[i].padtype = settings->SixButton ? DEVICE_PAD6B : DEVICE_PAD3B;
|
||||
}
|
||||
|
||||
if (!load_rom("PRIMARY_ROM"))
|
||||
|
|
Loading…
Reference in New Issue