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
|
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
|
public unsafe static class LibsnesDll
|
||||||
{
|
{
|
||||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
@ -52,6 +53,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_set_audio_sample(snes_audio_sample_t audio_sample);
|
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
|
public enum Device : uint
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -1309,20 +1309,31 @@ namespace BizHawk.MultiClient
|
||||||
rom = new RomGame(file);
|
rom = new RomGame(file);
|
||||||
game = rom.GameInfo;
|
game = rom.GameInfo;
|
||||||
|
|
||||||
|
//use some heuristics to figure out what game type it might be
|
||||||
if (game.NotInDatabase)
|
if (game.NotInDatabase)
|
||||||
{
|
{
|
||||||
//try to load based on extension
|
//try asking the snes core
|
||||||
switch (file.Extension.ToUpper())
|
if (LibsnesDll.snes_check_cartridge(rom.FileData, rom.FileData.Length))
|
||||||
|
game.System = "SNES";
|
||||||
|
else
|
||||||
{
|
{
|
||||||
case ".SMC":
|
//try and use the extension
|
||||||
nextEmulator = new BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesCore(rom.FileData);
|
switch (file.Extension.ToUpper())
|
||||||
game.System = "SNES";
|
{
|
||||||
break;
|
case ".SFC":
|
||||||
|
case ".SMC":
|
||||||
|
game.System = "SNES";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (game.System)
|
switch (game.System)
|
||||||
{
|
{
|
||||||
|
case "SNES":
|
||||||
|
nextEmulator = new LibsnesCore(rom.FileData);
|
||||||
|
game.System = "SNES";
|
||||||
|
break;
|
||||||
case "SMS":
|
case "SMS":
|
||||||
case "SG":
|
case "SG":
|
||||||
if (Global.Config.SmsEnableFM) game.AddOption("UseFM");
|
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);
|
SMS c = new SMS(game, rom.RomData);//new ColecoVision(game, rom.FileData);
|
||||||
nextEmulator = c;
|
nextEmulator = c;
|
||||||
break;
|
break;
|
||||||
case "INTV":
|
case "INTV":
|
||||||
Intellivision intv = new Intellivision(game, rom.RomData);
|
Intellivision intv = new Intellivision(game, rom.RomData);
|
||||||
nextEmulator = intv;
|
nextEmulator = intv;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -209,6 +209,14 @@ void snes_cheat_set(unsigned index, bool enable, const char *code) {
|
||||||
SNES::cheat.synchronize();
|
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(
|
bool snes_load_cartridge_normal(
|
||||||
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size
|
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);
|
uint8_t* snes_get_memory_data(unsigned id);
|
||||||
unsigned snes_get_memory_size(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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue