fix loading of non-snes games, and try to make snes core reset a little more reliable by reconstructing more

This commit is contained in:
zeromus 2012-09-04 18:04:06 +00:00
parent c8aa937f4f
commit 76cfbc47c1
4 changed files with 17 additions and 13 deletions

View File

@ -18,9 +18,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern string snes_library_id(); public static extern string snes_library_id();
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern uint snes_library_revision_major(); public static extern int snes_library_revision_major();
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern uint snes_library_revision_minor(); public static extern int snes_library_revision_minor();
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void snes_init(); public static extern void snes_init();
@ -138,11 +138,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public unsafe class LibsnesCore : IEmulator, IVideoProvider, ISoundProvider public unsafe class LibsnesCore : IEmulator, IVideoProvider, ISoundProvider
{ {
static LibsnesCore()
{
LibsnesDll.snes_init();
}
public void Dispose() public void Dispose()
{ {
LibsnesDll.snes_term(); LibsnesDll.snes_term();
@ -154,6 +149,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public LibsnesCore(byte[] romData) public LibsnesCore(byte[] romData)
{ {
LibsnesDll.snes_init();
var vidcb = new LibsnesDll.snes_video_refresh_t(snes_video_refresh); var vidcb = new LibsnesDll.snes_video_refresh_t(snes_video_refresh);
_gc_snes_video_refresh = GCHandle.Alloc(vidcb); _gc_snes_video_refresh = GCHandle.Alloc(vidcb);
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_video_refresh(vidcb); BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_video_refresh(vidcb);

View File

@ -1312,10 +1312,13 @@ namespace BizHawk.MultiClient
//use some heuristics to figure out what game type it might be //use some heuristics to figure out what game type it might be
if (game.NotInDatabase) if (game.NotInDatabase)
{ {
//try asking the snes core //try asking the snes core - on second thought, dont. because it detects everything as snes.
if (LibsnesDll.snes_check_cartridge(rom.FileData, rom.FileData.Length)) //maybe we'll try improving this later, but probably not
game.System = "SNES"; //if (LibsnesDll.snes_check_cartridge(rom.FileData, rom.FileData.Length))
else //{
// game.System = "SNES";
//}
//else
{ {
//try and use the extension //try and use the extension
switch (file.Extension.ToUpper()) switch (file.Extension.ToUpper())

Binary file not shown.

View File

@ -116,6 +116,9 @@ void snes_set_cartridge_basename(const char *basename) {
} }
void snes_init(void) { void snes_init(void) {
//zero 04-sep-2012 - reset harder
new(&interface) Interface();
SNES::interface = &interface; SNES::interface = &interface;
SNES::system.init(); SNES::system.init();
SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad); SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad);
@ -209,10 +212,11 @@ void snes_cheat_set(unsigned index, bool enable, const char *code) {
SNES::cheat.synchronize(); SNES::cheat.synchronize();
} }
//zeromus additions
//zero 03-sep-2012
bool snes_check_cartridge(const uint8_t *rom_data, unsigned rom_size) bool snes_check_cartridge(const uint8_t *rom_data, unsigned rom_size)
{ {
//tries to determine whether this rom is a snes rom //tries to determine whether this rom is a snes rom - BUT THIS TRIES TO ACCEPT EVERYTHING! so we cant really use it
SnesCartridge temp(rom_data, rom_size); SnesCartridge temp(rom_data, rom_size);
return temp.type != SnesCartridge::TypeUnknown && temp.type != SnesCartridge::TypeGameBoy; return temp.type != SnesCartridge::TypeUnknown && temp.type != SnesCartridge::TypeGameBoy;
} }