snes-load firmware files from a CoreInputComm path, which must be named exactly right; show the requisite filename in a messagebox if it's missing; but theres no GUI for the firmware path hooked up yet.
This commit is contained in:
parent
14126723c0
commit
d9a55fed37
|
@ -37,6 +37,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_unload_cartridge();
|
||||
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_set_cartridge_basename(string basename);
|
||||
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool snes_load_cartridge_normal(
|
||||
|
@ -72,6 +75,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
public delegate void snes_audio_sample_t(ushort left, ushort right);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void snes_scanlineStart_t(int line);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate string snes_path_request_t(int slot, string hint);
|
||||
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_set_video_refresh(snes_video_refresh_t video_refresh);
|
||||
|
@ -85,6 +90,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
public static extern void snes_set_audio_sample(snes_audio_sample_t audio_sample);
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_set_scanlineStart(snes_scanlineStart_t scanlineStart);
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_set_path_request(snes_path_request_t scanlineStart);
|
||||
|
||||
[DllImport("libsneshawk.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
|
@ -323,7 +330,30 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
ScanlineHookManager.HandleScanline(line);
|
||||
}
|
||||
|
||||
public LibsnesCore(GameInfo game, byte[] romData, byte[] sgbRomData = null)
|
||||
string snes_path_request_t(int slot, string hint)
|
||||
{
|
||||
//every rom requests this byuu homemade rom
|
||||
if (hint == "msu1.rom") return "";
|
||||
|
||||
//build romfilename
|
||||
string test = Path.Combine(CoreInputComm.SNES_FirmwarePath ?? "", hint);
|
||||
|
||||
//does it exist?
|
||||
if (!File.Exists(test))
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("libsneshawk is requesting a firmware file which could not be found. make sure it's in your snes firmwares folder. the name is: " + hint);
|
||||
return "";
|
||||
}
|
||||
|
||||
//return the path we built
|
||||
return test;
|
||||
}
|
||||
|
||||
public LibsnesCore()
|
||||
{
|
||||
}
|
||||
|
||||
public void Load(GameInfo game, byte[] romData, byte[] sgbRomData)
|
||||
{
|
||||
//attach this core as the current
|
||||
if(CurrLibsnesCore != null)
|
||||
|
@ -334,6 +364,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
|
||||
LibsnesDll.snes_init();
|
||||
|
||||
//LibsnesDll.snes_set_cartridge_basename(@);
|
||||
|
||||
vidcb = new LibsnesDll.snes_video_refresh_t(snes_video_refresh);
|
||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_video_refresh(vidcb);
|
||||
|
||||
|
@ -349,6 +381,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
soundcb = new LibsnesDll.snes_audio_sample_t(snes_audio_sample);
|
||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_audio_sample(soundcb);
|
||||
|
||||
pathRequest_cb = new LibsnesDll.snes_path_request_t(snes_path_request_t);
|
||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_path_request(pathRequest_cb);
|
||||
|
||||
|
||||
scanlineStart_cb = new LibsnesDll.snes_scanlineStart_t(snes_scanlineStart);
|
||||
|
||||
// start up audio resampler
|
||||
|
@ -386,6 +422,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
LibsnesDll.snes_input_notify_t notifycb;
|
||||
LibsnesDll.snes_audio_sample_t soundcb;
|
||||
LibsnesDll.snes_scanlineStart_t scanlineStart_cb;
|
||||
LibsnesDll.snes_path_request_t pathRequest_cb;
|
||||
|
||||
ushort snes_input_state(int port, int device, int index, int id)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
public bool PCE_ShowBG1, PCE_ShowOBJ1, PCE_ShowBG2, PCE_ShowOBJ2;
|
||||
public bool SMS_ShowBG, SMS_ShowOBJ;
|
||||
|
||||
public string SNES_FirmwarePath;
|
||||
public bool SNES_ShowBG1_0, SNES_ShowBG2_0, SNES_ShowBG3_0, SNES_ShowBG4_0;
|
||||
public bool SNES_ShowBG1_1, SNES_ShowBG2_1, SNES_ShowBG3_1, SNES_ShowBG4_1;
|
||||
public bool SNES_ShowOBJ_0, SNES_ShowOBJ_1, SNES_ShowOBJ_2, SNES_ShowOBJ_3;
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace BizHawk.MultiClient
|
|||
public string PathSNESSaveRAM = Path.Combine(".", "SaveRAM");
|
||||
public string PathSNESScreenshots = Path.Combine(".", "Screenshots");
|
||||
public string PathSNESCheats = Path.Combine(".", "Cheats");
|
||||
public string PathSNESFirmware = Path.Combine(".", "Firmware");
|
||||
|
||||
public string BaseSMS = Path.Combine(".", "SMS");
|
||||
public string PathSMSROMs = ".";
|
||||
|
|
|
@ -1380,8 +1380,13 @@ namespace BizHawk.MultiClient
|
|||
switch (game.System)
|
||||
{
|
||||
case "SNES":
|
||||
game.System = "SNES";
|
||||
nextEmulator = new LibsnesCore(game, rom.FileData);
|
||||
{
|
||||
game.System = "SNES";
|
||||
var snes = new LibsnesCore();
|
||||
nextEmulator = snes;
|
||||
nextEmulator.CoreInputComm = Global.CoreInputComm;
|
||||
snes.Load(game, rom.FileData, null);
|
||||
}
|
||||
break;
|
||||
case "SMS":
|
||||
case "SG":
|
||||
|
@ -1457,7 +1462,9 @@ namespace BizHawk.MultiClient
|
|||
byte[] sgbrom = File.ReadAllBytes(PathManager.MakeAbsolutePath(Global.Config.PathSGBRom, "SGB"));
|
||||
game.AddOption("SGB");
|
||||
game.System = "SGB";
|
||||
nextEmulator = new LibsnesCore(game, rom.FileData, sgbrom);
|
||||
var snes = new LibsnesCore();
|
||||
nextEmulator = snes;
|
||||
snes.Load(game, rom.FileData, sgbrom);
|
||||
}
|
||||
break;
|
||||
case "COLV":
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -14,6 +14,7 @@ struct Interface : public SNES::Interface {
|
|||
snes_input_poll_t pinput_poll;
|
||||
snes_input_state_t pinput_state;
|
||||
snes_input_notify_t pinput_notify;
|
||||
snes_path_request_t ppath_request;
|
||||
string basename;
|
||||
uint32_t *buffer;
|
||||
uint32_t *palette;
|
||||
|
@ -67,11 +68,18 @@ struct Interface : public SNES::Interface {
|
|||
messages.push(text);
|
||||
}
|
||||
|
||||
string path(SNES::Cartridge::Slot slot, const string &hint) {
|
||||
string path(SNES::Cartridge::Slot slot, const string &hint)
|
||||
{
|
||||
if(ppath_request)
|
||||
{
|
||||
const char* path = ppath_request((int)slot, (const char*)hint);
|
||||
return path;
|
||||
}
|
||||
return { basename, hint };
|
||||
|
||||
}
|
||||
|
||||
Interface() : pvideo_refresh(0), paudio_sample(0), pinput_poll(0), pinput_state(0), pinput_notify(0) {
|
||||
Interface() : pvideo_refresh(0), paudio_sample(0), pinput_poll(0), pinput_state(0), pinput_notify(0), ppath_request(0) {
|
||||
buffer = new uint32_t[512 * 480];
|
||||
palette = new uint32_t[16 * 32768];
|
||||
|
||||
|
@ -143,6 +151,11 @@ void snes_set_input_notify(snes_input_notify_t input_notify) {
|
|||
interface.pinput_notify = input_notify;
|
||||
}
|
||||
|
||||
void snes_set_path_request(snes_path_request_t path_request)
|
||||
{
|
||||
interface.ppath_request = path_request;
|
||||
}
|
||||
|
||||
void snes_set_controller_port_device(bool port, unsigned device) {
|
||||
SNES::input.connect(port, (SNES::Input::Device)device);
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ void snes_set_scanlineStart(snes_scanlineStart_t);
|
|||
int snes_poll_message();
|
||||
//give us a buffer of messagelength and we'll dequeue a message into it. you better take care of the null pointer
|
||||
void snes_dequeue_message(char* buffer);
|
||||
typedef const char* (*snes_path_request_t)(int slot, const char* hint);
|
||||
void snes_set_path_request(snes_path_request_t path_request);
|
||||
|
||||
//$2105
|
||||
#define SNES_REG_BG_MODE 0
|
||||
|
|
Loading…
Reference in New Issue