Skip to content

Commit

Permalink
libsnes: Cache region from core once at start
Browse files Browse the repository at this point in the history
The region value in the comm struct is set once and then gets wiped out later.  I don't know what wipes it, but so many things have their hands on that, it's not surprising.  Someone knew about this and handled _mapper appropriately, but not _region.

Fixes #2503
  • Loading branch information
nattthebear committed Dec 15, 2020
1 parent a8e2a42 commit eeca40e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Expand Up @@ -11,6 +11,7 @@ public partial class LibsnesCore
private readonly List<MemoryDomain> _memoryDomainList = new List<MemoryDomain>();
private IMemoryDomains _memoryDomains;
private LibsnesApi.SNES_MAPPER? _mapper;
private LibsnesApi.SNES_REGION? _region;

// works for WRAM, garbage for anything else
private static int? FakeBusMap(int addr)
Expand Down
Expand Up @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
public partial class LibsnesCore : IRegionable
{
public DisplayType Region => Api.Region == LibsnesApi.SNES_REGION.NTSC
public DisplayType Region => _region == LibsnesApi.SNES_REGION.NTSC
? DisplayType.NTSC
: DisplayType.PAL;
}
Expand Down
Expand Up @@ -173,7 +173,7 @@ public unsafe partial class LibsnesCore : IEmulator, IVideoProvider, ISaveRam, I
}
}

if (Api.Region == LibsnesApi.SNES_REGION.NTSC)
if (_region == LibsnesApi.SNES_REGION.NTSC)
{
// similar to what aviout reports from snes9x and seems logical from bsnes first principles. bsnes uses that numerator (ntsc master clockrate) for sure.
VsyncNumerator = 21477272;
Expand Down Expand Up @@ -484,6 +484,7 @@ private bool LoadCurrent()
: Api.CMD_load_cartridge_super_game_boy(_currLoadParams.rom_xml, _currLoadParams.rom_data, _currLoadParams.rom_size, _currLoadParams.dmg_data);

_mapper = Api.Mapper;
_region = Api.Region;

return result;
}
Expand Down

1 comment on commit eeca40e

@YoshiRulz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapper field was added in 620c74e.

Please sign in to comment.