snes9xHawk which is totally not a thing: connect audio

This commit is contained in:
nattthebear 2017-05-27 14:32:12 -04:00
parent 9bcd693910
commit b737959d11
5 changed files with 45 additions and 30 deletions

View File

@ -19,10 +19,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
[StructLayout(LayoutKind.Sequential)]
public class frame_info
{
public IntPtr ptr;
public int pitch;
public int width;
public int height;
public IntPtr vptr;
public int vpitch;
public int vwidth;
public int vheight;
public IntPtr sptr;
public int slen;
};
@ -44,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public abstract void biz_run([In, Out] frame_info frame);
[BizImport(CC)]
public abstract bool biz_is_ntsc();
[BizImport(CC, Compatibility = true)]
[BizImport(CC)]
public abstract void biz_get_memory_area(int which, [In, Out] memory_area mem);
}
}

View File

@ -2,6 +2,7 @@
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
using BizHawk.Common.BizInvoke;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
{
@ -12,7 +13,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
private LibSnes9x _core;
private PeRunner _exe;
[CoreConstructor("SNES")]
public Snes9x(CoreComm comm, byte[] rom)
{
@ -23,10 +23,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
{
Path = comm.CoreFileProvider.DllPath(),
Filename = "snes9x.exe",
NormalHeapSizeKB = 32 * 1024,
SealedHeapSizeKB = 32 * 1024,
InvisibleHeapSizeKB = 32 * 1024,
SpecialHeapSizeKB = 1024
NormalHeapSizeKB = 1024,
SealedHeapSizeKB = 12 * 1024,
InvisibleHeapSizeKB = 6 * 1024,
SpecialHeapSizeKB = 64
});
try
@ -40,6 +40,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
{
throw new InvalidOperationException("LoadRom() failed");
}
if (_core.biz_is_ntsc())
{
Console.WriteLine("NTSC rom loaded");
VsyncNumerator = 21477272;
VsyncDenominator = 357366;
}
else
{
Console.WriteLine("PAL rom loaded");
VsyncNumerator = 21281370;
VsyncDenominator = 425568;
}
}
catch
{
@ -78,6 +91,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
_core.biz_run(frame);
Blit(frame);
Sblit(frame);
}
public int Frame { get; private set; }
@ -95,19 +109,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
private unsafe void Blit(LibSnes9x.frame_info frame)
{
BufferWidth = frame.width;
BufferHeight = frame.height;
BufferWidth = frame.vwidth;
BufferHeight = frame.vheight;
int vinc = frame.pitch / sizeof(ushort) - frame.width;
int vinc = frame.vpitch / sizeof(ushort) - frame.vwidth;
ushort* src = (ushort*)frame.ptr;
ushort* src = (ushort*)frame.vptr;
fixed (int* _dst = _vbuff)
{
byte* dst = (byte*)_dst;
for (int j = 0; j < frame.height; j++)
for (int j = 0; j < frame.vheight; j++)
{
for (int i = 0; i < frame.width; i++)
for (int i = 0; i < frame.vwidth; i++)
{
var c = *src++;
@ -132,32 +146,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public int VsyncNumerator
{
[FeatureNotImplemented]
get
{
return NullVideo.DefaultVsyncNum;
}
get;
}
public int VsyncDenominator
{
[FeatureNotImplemented]
get
{
return NullVideo.DefaultVsyncDen;
}
get;
}
#endregion
#region ISoundProvider
private void Sblit(LibSnes9x.frame_info frame)
{
Marshal.Copy(frame.sptr, _sbuff, 0, frame.slen * 2);
_nsamp = frame.slen;
}
private int _nsamp;
private short[] _sbuff = new short[2048];
public void GetSamplesSync(out short[] samples, out int nsamp)
{
samples = _sbuff;
nsamp = 735;
nsamp = _nsamp;
}
public void DiscardSamples()

View File

@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
ulong ret = Memory.Start + Used;
Memory.Protect(ret, newused - Used, MemoryBlock.Protection.RW);
Used = newused;
Console.WriteLine("Allocated {0} bytes on {1}", size, Name);
Console.WriteLine($"Allocated {size} bytes on {Name}, utilization {Used}/{Memory.Size} ({100.0 * Used / Memory.Size:0.#}%)");
return ret;
}

View File

@ -4,7 +4,7 @@ libc.so, libgcc_s.so, libstdc++.so.6, and the waterbox executables are built wit
The makefiles for the cores only support the cross compilation setup (build from whatever linux box you built midipix
from).
The mmglue portion of the midipix project is modified; get the correct version from <insert git repo here>.
The mmglue portion of the midipix project is modified; get the correct version from <ssh://git@github.com/nattthebear/mmglue.git>.
gpgx: This is a modified version of our gpgx core
snes9x: Based off of snes9x 1.54.

@ -1 +1 @@
Subproject commit 33c4a7ce3760cad10f2ed132d73d8197fc845061
Subproject commit ba009bc83960ee39f9eb24ae1724a67d9b87f51e