Update snes9x to 1.62.3 (#3729)
* Update snes9x to 1.62.3 * Update snes9x submodule * Implement msu1 for snes9x * do less bullshit initialization * Update snes9x submodule
This commit is contained in:
parent
abc5ddcc6e
commit
e1fb97dee6
Binary file not shown.
|
@ -200,7 +200,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
public delegate void snes_write_hook_t(uint address, byte value);
|
||||
public delegate void snes_exec_hook_t(uint address);
|
||||
public delegate long snes_time_t();
|
||||
public delegate void snes_msu_open_t(ushort track_id);
|
||||
public delegate bool snes_msu_open_t(ushort track_id);
|
||||
public delegate void snes_msu_seek_t(long offset, bool relative);
|
||||
public delegate byte snes_msu_read_t();
|
||||
public delegate bool snes_msu_end_t();
|
||||
|
|
|
@ -6,6 +6,7 @@ using BizHawk.Emulation.Common;
|
|||
using BizHawk.Emulation.Common.Base_Implementations;
|
||||
using BizHawk.Emulation.Cores.Components.W65816;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
||||
// http://wiki.superfamicom.org/snes/show/Backgrounds
|
||||
|
||||
|
@ -29,6 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
_syncSettings = loadParameters.SyncSettings ?? new SnesSyncSettings();
|
||||
SystemId = loadParameters.Game.System;
|
||||
_isSGB = SystemId == VSystemID.Raw.SGB;
|
||||
_currentMsuTrack = new ProxiedFile();
|
||||
|
||||
byte[] sgbRomData = null;
|
||||
if (_isSGB)
|
||||
|
@ -57,10 +59,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
writeHookCb = WriteHook,
|
||||
execHookCb = ExecHook,
|
||||
timeCb = snes_time,
|
||||
msuOpenCb = msu_open,
|
||||
msuSeekCb = msu_seek,
|
||||
msuReadCb = msu_read,
|
||||
msuEndCb = msu_end
|
||||
msuOpenCb = MsuOpenAudio,
|
||||
msuSeekCb = _currentMsuTrack.Seek,
|
||||
msuReadCb = _currentMsuTrack.ReadByte,
|
||||
msuEndCb = _currentMsuTrack.AtEnd
|
||||
};
|
||||
|
||||
Api = new BsnesApi(CoreComm.CoreFileProvider.DllPath(), CoreComm, callbacks.AllDelegatesInMemoryOrder());
|
||||
|
@ -149,6 +151,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
|
||||
private readonly BsnesControllers _controllers;
|
||||
private readonly ITraceable _tracer;
|
||||
private readonly ProxiedFile _currentMsuTrack;
|
||||
|
||||
private IController _controller;
|
||||
private SimpleSyncSoundProvider _soundProvider;
|
||||
|
@ -361,35 +364,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
}
|
||||
}
|
||||
|
||||
private long snes_time()
|
||||
=> DeterministicEmulation ? _clockTime : (long)(DateTime.Now - _epoch).TotalSeconds;
|
||||
private bool MsuOpenAudio(ushort trackId) => _currentMsuTrack.OpenMsuTrack(_romPath, trackId);
|
||||
|
||||
private FileStream _currentMsuTrack;
|
||||
|
||||
private void msu_seek(long offset, bool relative)
|
||||
{
|
||||
_currentMsuTrack?.Seek(offset, relative ? SeekOrigin.Current : SeekOrigin.Begin);
|
||||
}
|
||||
private byte msu_read()
|
||||
{
|
||||
return (byte) (_currentMsuTrack?.ReadByte() ?? 0);
|
||||
}
|
||||
|
||||
private void msu_open(ushort trackId)
|
||||
{
|
||||
_currentMsuTrack?.Dispose();
|
||||
try
|
||||
{
|
||||
_currentMsuTrack = File.OpenRead($"{_romPath}-{trackId}.pcm");
|
||||
}
|
||||
catch
|
||||
{
|
||||
_currentMsuTrack = null;
|
||||
}
|
||||
}
|
||||
private bool msu_end()
|
||||
{
|
||||
return _currentMsuTrack.Position == _currentMsuTrack.Length;
|
||||
}
|
||||
private long snes_time() => DeterministicEmulation ? _clockTime : (long)(DateTime.Now - _epoch).TotalSeconds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
Justifier = 5
|
||||
}
|
||||
|
||||
public delegate bool OpenAudio(ushort trackId);
|
||||
public delegate void SeekAudio(long offset, bool relative);
|
||||
public delegate byte ReadAudio();
|
||||
public delegate bool AudioEnd();
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract void SetMsu1Callbacks(OpenAudio openAudio, SeekAudio seekAudio, ReadAudio readAudio, AudioEnd audioEnd);
|
||||
[BizImport(CC)]
|
||||
public abstract void SetButtons(short[] buttons);
|
||||
[BizImport(CC)]
|
||||
|
|
|
@ -7,16 +7,16 @@ using BizHawk.Common;
|
|||
|
||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
||||
{
|
||||
[PortedCore(CoreNames.Snes9X, "", "5e0319ab3ef9611250efb18255186d0dc0d7e125", "https://github.com/snes9xgit/snes9x")]
|
||||
[PortedCore(CoreNames.Snes9X, "", "e49165c5607011f4d95adcb7b5983140ab5a75f1", "https://github.com/snes9xgit/snes9x")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public class Snes9x : WaterboxCore,
|
||||
public class Snes9x : WaterboxCore,
|
||||
ISettable<Snes9x.Settings, Snes9x.SyncSettings>, IRegionable
|
||||
{
|
||||
private readonly LibSnes9x _core;
|
||||
|
||||
[CoreConstructor(VSystemID.Raw.SNES)]
|
||||
public Snes9x(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings)
|
||||
:base(comm, new Configuration
|
||||
public Snes9x(CoreLoadParameters<Settings, SyncSettings> loadParameters)
|
||||
:base(loadParameters.Comm, new Configuration
|
||||
{
|
||||
DefaultWidth = 256,
|
||||
DefaultHeight = 224,
|
||||
|
@ -26,23 +26,40 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
SystemId = VSystemID.Raw.SNES,
|
||||
})
|
||||
{
|
||||
settings ??= new Settings();
|
||||
syncSettings ??= new SyncSettings();
|
||||
this._romPath = Path.ChangeExtension(loadParameters.Roms[0].RomPath, null);
|
||||
this._currentMsuTrack = new ProxiedFile();
|
||||
|
||||
LibSnes9x.OpenAudio openAudioCb = MsuOpenAudio;
|
||||
LibSnes9x.SeekAudio seekAudioCb = _currentMsuTrack.Seek;
|
||||
LibSnes9x.ReadAudio readAudioCb = _currentMsuTrack.ReadByte;
|
||||
LibSnes9x.AudioEnd audioEndCb = _currentMsuTrack.AtEnd;
|
||||
_core = PreInit<LibSnes9x>(new WaterboxOptions
|
||||
{
|
||||
Filename = "snes9x.wbx",
|
||||
SbrkHeapSizeKB = 1024,
|
||||
SealedHeapSizeKB = 12 * 1024,
|
||||
InvisibleHeapSizeKB = 6 * 1024,
|
||||
PlainHeapSizeKB = 12 * 1024,
|
||||
SkipCoreConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
|
||||
SkipMemoryConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
|
||||
});
|
||||
InvisibleHeapSizeKB = 5 * 1024,
|
||||
MmapHeapSizeKB = 1024,
|
||||
PlainHeapSizeKB = 13 * 1024,
|
||||
SkipCoreConsistencyCheck = loadParameters.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
|
||||
SkipMemoryConsistencyCheck = loadParameters.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
|
||||
}, new Delegate[] { openAudioCb, seekAudioCb, readAudioCb, audioEndCb });
|
||||
|
||||
if (!_core.biz_init())
|
||||
throw new InvalidOperationException("Init() failed");
|
||||
if (!_core.biz_load_rom(rom, rom.Length))
|
||||
|
||||
// add msu data file if it exists
|
||||
try
|
||||
{
|
||||
// "msu1.rom" is hardcoded in the core
|
||||
_exe.AddReadonlyFile(File.ReadAllBytes($"{_romPath}.msu"), "msu1.rom");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
_core.SetMsu1Callbacks(openAudioCb, seekAudioCb, readAudioCb, audioEndCb);
|
||||
|
||||
if (!_core.biz_load_rom(loadParameters.Roms[0].RomData, loadParameters.Roms[0].RomData.Length))
|
||||
throw new InvalidOperationException("LoadRom() failed");
|
||||
|
||||
PostInit();
|
||||
|
@ -62,9 +79,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
Region = DisplayType.PAL;
|
||||
}
|
||||
|
||||
_syncSettings = syncSettings;
|
||||
_syncSettings = loadParameters.SyncSettings ?? new SyncSettings();
|
||||
InitControllers();
|
||||
PutSettings(settings);
|
||||
PutSettings(loadParameters.Settings ?? new Settings());
|
||||
}
|
||||
|
||||
private readonly ProxiedFile _currentMsuTrack;
|
||||
private bool _disposed;
|
||||
|
||||
private bool MsuOpenAudio(ushort trackId) => _currentMsuTrack.OpenMsuTrack(_romPath, trackId);
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
_disposed = true;
|
||||
_currentMsuTrack?.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void InitControllers()
|
||||
|
@ -102,6 +133,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
|
||||
private Settings _settings;
|
||||
private SyncSettings _syncSettings;
|
||||
private readonly string _romPath;
|
||||
|
||||
public Settings GetSettings()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Waterbox
|
||||
{
|
||||
public class ProxiedFile : IDisposable
|
||||
{
|
||||
private FileStream? _fileStream;
|
||||
|
||||
public bool OpenMsuTrack(string romPath, ushort id) => Open($"{romPath}-{id}.pcm");
|
||||
|
||||
public bool Open(string path)
|
||||
{
|
||||
_fileStream?.Dispose();
|
||||
try
|
||||
{
|
||||
_fileStream = File.OpenRead(path);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_fileStream = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Seek(long offset, bool relative)
|
||||
{
|
||||
_fileStream?.Seek(offset, relative ? SeekOrigin.Current : SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public byte ReadByte()
|
||||
{
|
||||
return (byte)(_fileStream?.ReadByte() ?? 0);
|
||||
}
|
||||
|
||||
public bool AtEnd()
|
||||
{
|
||||
return _fileStream?.Position == _fileStream?.Length;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_fileStream?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 1887cd256785fc69646d417ca4956fe03e7c2a87
|
||||
Subproject commit 825db67a623e83c30efc3f31187f05e2dd5bbc10
|
Loading…
Reference in New Issue