snes-try and determine whether game is snes based on libsnes's internal heuristics, and use .SFC for it anyway
This commit is contained in:
parent
2ef33fbfec
commit
caed262122
|
@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||
{
|
||||
//TODO - wrap around some kind of library-accessing interface so that it doesnt malfunction if the dll is unavailable
|
||||
public unsafe static class LibsnesDll
|
||||
{
|
||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
@ -52,6 +53,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
|||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void snes_set_audio_sample(snes_audio_sample_t audio_sample);
|
||||
|
||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.U1)]
|
||||
public static extern bool snes_check_cartridge(
|
||||
[MarshalAs(UnmanagedType.LPArray)] byte[] rom_data,
|
||||
int rom_size);
|
||||
|
||||
public enum Device : uint
|
||||
{
|
||||
None,
|
||||
|
|
|
@ -1309,20 +1309,31 @@ namespace BizHawk.MultiClient
|
|||
rom = new RomGame(file);
|
||||
game = rom.GameInfo;
|
||||
|
||||
//use some heuristics to figure out what game type it might be
|
||||
if (game.NotInDatabase)
|
||||
{
|
||||
//try to load based on extension
|
||||
switch (file.Extension.ToUpper())
|
||||
//try asking the snes core
|
||||
if (LibsnesDll.snes_check_cartridge(rom.FileData, rom.FileData.Length))
|
||||
game.System = "SNES";
|
||||
else
|
||||
{
|
||||
case ".SMC":
|
||||
nextEmulator = new BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesCore(rom.FileData);
|
||||
game.System = "SNES";
|
||||
break;
|
||||
//try and use the extension
|
||||
switch (file.Extension.ToUpper())
|
||||
{
|
||||
case ".SFC":
|
||||
case ".SMC":
|
||||
game.System = "SNES";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (game.System)
|
||||
{
|
||||
case "SNES":
|
||||
nextEmulator = new LibsnesCore(rom.FileData);
|
||||
game.System = "SNES";
|
||||
break;
|
||||
case "SMS":
|
||||
case "SG":
|
||||
if (Global.Config.SmsEnableFM) game.AddOption("UseFM");
|
||||
|
@ -1380,10 +1391,10 @@ namespace BizHawk.MultiClient
|
|||
SMS c = new SMS(game, rom.RomData);//new ColecoVision(game, rom.FileData);
|
||||
nextEmulator = c;
|
||||
break;
|
||||
case "INTV":
|
||||
Intellivision intv = new Intellivision(game, rom.RomData);
|
||||
nextEmulator = intv;
|
||||
break;
|
||||
case "INTV":
|
||||
Intellivision intv = new Intellivision(game, rom.RomData);
|
||||
nextEmulator = intv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -209,6 +209,14 @@ void snes_cheat_set(unsigned index, bool enable, const char *code) {
|
|||
SNES::cheat.synchronize();
|
||||
}
|
||||
|
||||
//zeromus additions
|
||||
bool snes_check_cartridge(const uint8_t *rom_data, unsigned rom_size)
|
||||
{
|
||||
//tries to determine whether this rom is a snes rom
|
||||
SnesCartridge temp(rom_data, rom_size);
|
||||
return temp.type != SnesCartridge::TypeUnknown && temp.type != SnesCartridge::TypeGameBoy;
|
||||
}
|
||||
|
||||
bool snes_load_cartridge_normal(
|
||||
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size
|
||||
) {
|
||||
|
|
|
@ -128,7 +128,8 @@ bool snes_get_region(void);
|
|||
uint8_t* snes_get_memory_data(unsigned id);
|
||||
unsigned snes_get_memory_size(unsigned id);
|
||||
|
||||
//zeromus additions (TBD)
|
||||
//zeromus additions
|
||||
bool snes_check_cartridge(const uint8_t *rom_data, unsigned rom_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue