[Gambatte] sync to upstream

This commit is contained in:
CasualPokePlayer 2021-08-01 22:38:36 -07:00 committed by James Groom
parent 036e349337
commit 87f0fd78fc
7 changed files with 21 additions and 18 deletions

3
.gitmodules vendored
View File

@ -27,8 +27,7 @@
url = https://github.com/TASVideos/mednafen.git
[submodule "submodules/gambatte"]
path = submodules/gambatte
url = https://github.com/TASVideos/gambatte-speedrun.git
branch = bizhawk
url = https://github.com/pokemon-speedrunning/gambatte-core.git
[submodule "waterbox/llvm-project"]
path = waterbox/llvm-project
url = https://github.com/llvm/llvm-project.git

Binary file not shown.

View File

@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
// runfor() always ends after creating a video frame, so sync-up is guaranteed
// when the display has been off, some frames can be markedly shorter than expected
samplesEmitted = TICKSINFRAME;
if (LibGambatte.gambatte_runfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
if (LibGambatte.gambatte_altrunfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
{
LibGambatte.gambatte_blitto(GambatteState, VideoBuffer, 160);
}
@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
// target number of samples to emit: length of 1 frame minus whatever overflow
samplesEmitted = TICKSINFRAME - frameOverflow;
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length);
if (LibGambatte.gambatte_runfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
if (LibGambatte.gambatte_altrunfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
{
LibGambatte.gambatte_blitto(GambatteState, VideoBuffer, 160);
}
@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
}
samplesEmitted = inputFrameLengthInt - frameOverflow;
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length);
if (LibGambatte.gambatte_runfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
if (LibGambatte.gambatte_altrunfor(GambatteState, _soundbuff, ref samplesEmitted) > 0)
{
LibGambatte.gambatte_blitto(GambatteState, VideoBuffer, 160);
}

View File

@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
_syncSettings = syncSettings ?? new GambatteSyncSettings();
LibGambatte.LoadFlags flags = 0;
LibGambatte.LoadFlags flags = LibGambatte.LoadFlags.READONLY_SAV;
switch (_syncSettings.ConsoleMode)
{
@ -99,9 +99,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
bios[0xFB] ^= 0x74;
}
}
if (LibGambatte.gambatte_loadbios(GambatteState, bios, (uint)bios.Length) != 0)
if (LibGambatte.gambatte_loadbiosbuf(GambatteState, bios, (uint)bios.Length) != 0)
{
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbios)}() returned non-zero (bios error)");
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbiosbuf)}() returned non-zero (bios error)");
}
}
else
@ -113,9 +113,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
flags |= LibGambatte.LoadFlags.NO_BIOS;
}
if (LibGambatte.gambatte_load(GambatteState, file, (uint)file.Length, flags) != 0)
if (LibGambatte.gambatte_loadbuf(GambatteState, file, (uint)file.Length, flags) != 0)
{
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_load)}() returned non-zero (is this not a gb or gbc rom?)");
throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbuf)}() returned non-zero (is this not a gb or gbc rom?)");
}
// set real default colors (before anyone mucks with them at all)

View File

@ -69,7 +69,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
while (nL < target)
{
uint nsamp = (uint)(target - nL);
if (LibGambatte.gambatte_runfor(L.GambatteState, leftsbuff + (nL * 2), ref nsamp) > 0)
if (LibGambatte.gambatte_altrunfor(L.GambatteState, leftsbuff + (nL * 2), ref nsamp) > 0)
{
LibGambatte.gambatte_blitto(L.GambatteState, leftvbuff, Pitch);
}
@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
while (nR < target)
{
uint nsamp = (uint)(target - nR);
if (LibGambatte.gambatte_runfor(R.GambatteState, rightsbuff + (nR * 2), ref nsamp) > 0)
if (LibGambatte.gambatte_altrunfor(R.GambatteState, rightsbuff + (nR * 2), ref nsamp) > 0)
{
LibGambatte.gambatte_blitto(R.GambatteState, rightvbuff, Pitch);
}

View File

@ -26,8 +26,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
GBA_FLAG = 2,
/// <summary>Use heuristics to detect and support some multicart MBCs disguised as MBC1.</summary>
MULTICART_COMPAT = 4,
/// <summary>Treat the ROM as having SGB support regardless of what its header advertises.</summary>
SGB_MODE = 8,
/// <summary>Prevent implicit saveSavedata calls for the ROM.</summary>
READONLY_SAV = 16,
/// <summary>Use heuristics to boot without a BIOS.</summary>
NO_BIOS = 8
NO_BIOS = 32
}
public enum CDLog_AddrType : int
@ -52,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
/// <param name="flags">ORed combination of LoadFlags.</param>
/// <returns>0 on success, negative value on failure.</returns>
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, LoadFlags flags);
public static extern int gambatte_loadbuf(IntPtr core, byte[] romdata, uint length, LoadFlags flags);
/// <summary>
/// Load GB(C) BIOS image.
@ -62,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
/// <param name="length">length of romdata in bytes</param>
/// <returns>0 on success, negative value on failure.</returns>
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gambatte_loadbios(IntPtr core, byte[] biosdata, uint length);
public static extern int gambatte_loadbiosbuf(IntPtr core, byte[] biosdata, uint length);
/// <summary>
/// Emulates until at least 'samples' stereo sound samples are produced in the supplied buffer,
@ -83,9 +87,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
/// <param name="samples">in: number of stereo samples to produce, out: actual number of samples produced</param>
/// <returns>sample number at which the video frame was produced. -1 means no frame was produced.</returns>
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gambatte_runfor(IntPtr core, short[] soundbuf, ref uint samples);
public static extern int gambatte_altrunfor(IntPtr core, short[] soundbuf, ref uint samples);
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe int gambatte_runfor(IntPtr core, short* soundbuf, ref uint samples);
public static extern unsafe int gambatte_altrunfor(IntPtr core, short* soundbuf, ref uint samples);
/// <summary>
/// blit from internal framebuffer to provided framebuffer

@ -1 +1 @@
Subproject commit 1fe731bd6f0ca40737aa2e577d791ea6b084829a
Subproject commit 6e475f769d69b1b7f2ad3e5af1d48fdb46ebbbe8