PicoDrive: Connect 32X bios files. These are not required by the emulator, but we'll require them for deterministic mode. Otherwise, they're used if available.

This commit is contained in:
nattthebear 2017-07-02 18:16:38 -04:00
parent 5fb8ef22b1
commit 45e0770d06
5 changed files with 51 additions and 3 deletions

View File

@ -112,6 +112,11 @@ namespace BizHawk.Emulation.Common
Option("GEN", "CD_BIOS_US", us_scd1_9210);
Option("GEN", "CD_BIOS_US", us_scd2_9303);
FirmwareAndOption("dbebd76a448447cb6e524ac3cb0fd19fc065d944", 256, "32X", "G", "32X_G_BIOS.BIN", "32x 68k BIOS");
FirmwareAndOption("1e5b0b2441a4979b6966d942b20cc76c413b8c5e", 2048, "32X", "M", "32X_M_BIOS.BIN", "32x SH2 MASTER BIOS");
FirmwareAndOption("4103668c1bbd66c5e24558e73d4f3f92061a109a", 1024, "32X", "S", "32X_S_BIOS.BIN", "32x SH2 SLAVE BIOS");
// SMS
var sms_us_13 = File("C315672807D8DDB8D91443729405C766DD95CAE7", 8192, "sms_us_1.3.sms", "SMS BIOS 1.3 (USA, Europe)");
var sms_jp_21 = File("A8C1B39A2E41137835EDA6A5DE6D46DD9FADBAF2", 8192, "sms_jp_2.1.sms", "SMS BIOS 2.1 (Japan)");

View File

@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive
private LibPicoDrive _core;
[CoreConstructor("GEN")]
public PicoDrive(CoreComm comm, byte[] rom)
public PicoDrive(CoreComm comm, byte[] rom, bool deterministic)
: base(comm, new Configuration
{
MaxSamples = 2048,
@ -26,6 +26,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive
SystemId = "GEN"
})
{
var biosg = comm.CoreFileProvider.GetFirmware("32X", "G", false);
var biosm = comm.CoreFileProvider.GetFirmware("32X", "M", false);
var bioss = comm.CoreFileProvider.GetFirmware("32X", "S", false);
var has32xBios = biosg != null && biosm != null && bioss != null;
if (deterministic && !has32xBios)
throw new InvalidOperationException("32X BIOS files are required for deterministic mode");
deterministic |= has32xBios;
_core = PreInit<LibPicoDrive>(new PeRunnerOptions
{
Filename = "picodrive.wbx",
@ -36,12 +44,29 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive
PlainHeapSizeKB = 4096,
});
if (has32xBios)
{
_exe.AddReadonlyFile(biosg, "32x.g");
_exe.AddReadonlyFile(biosm, "32x.m");
_exe.AddReadonlyFile(bioss, "32x.s");
Console.WriteLine("Using supplied 32x BIOS files");
}
_exe.AddReadonlyFile(rom, "romfile.md");
if (!_core.Init())
throw new InvalidOperationException("Core rejected the rom!");
_exe.RemoveReadonlyFile("romfile.md");
if (has32xBios)
{
_exe.RemoveReadonlyFile("32x.g");
_exe.RemoveReadonlyFile("32x.m");
_exe.RemoveReadonlyFile("32x.s");
}
PostInit();
ControllerDefinition = PicoDriveController;
DeterministicEmulation = deterministic;
}
public static readonly ControllerDefinition PicoDriveController = new ControllerDefinition

View File

@ -97,8 +97,26 @@ int mp3_get_bitrate(void *f, int size) { return 0; }
void mp3_start_play(void *f, int pos) {}
void mp3_update(int *buffer, int length, int stereo) {}
static const uint8_t* TryLoadBios(const char* name)
{
FILE *f = fopen(name, "rb");
if (!f)
return NULL;
fseek(f, 0, SEEK_END);
int size = ftell(f);
uint8_t* ret = alloc_sealed(size);
fseek(f, 0, SEEK_SET);
fread(ret, 1, size, f);
fclose(f);
return ret;
}
ECL_EXPORT int Init(void)
{
p32x_bios_g = TryLoadBios("32x.g");
p32x_bios_m = TryLoadBios("32x.m");
p32x_bios_s = TryLoadBios("32x.s");
PicoOpt = POPT_EN_FM | POPT_EN_PSG | POPT_EN_Z80 | POPT_EN_STEREO | POPT_ACC_SPRITES | POPT_DIS_32C_BORDER | POPT_EN_MCD_PCM | POPT_EN_MCD_CDDA | POPT_EN_MCD_GFX | POPT_EN_32X | POPT_EN_PWM;
PicoInit();

View File

@ -43,7 +43,7 @@
static const char str_mars[] = "MARS";
void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
const void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
struct Pico32xMem *Pico32xMem;
static void bank_switch(int b);

View File

@ -32,7 +32,7 @@ extern void emu_32x_startup(void);
// optional 32X BIOS, should be left NULL if not used
// must be 256, 2048, 1024 bytes
extern void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
extern const void *p32x_bios_g, *p32x_bios_m, *p32x_bios_s;
// Pico.c
#define POPT_EN_FM (1<< 0) // 00 000x