Gambatte: Palette selection for GB mode

This commit is contained in:
alyosha-tas 2018-02-02 18:42:09 -05:00
parent b3b41fb75f
commit 2cc092270d
4 changed files with 14 additions and 3 deletions

View File

@ -38,6 +38,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
writer.Write(Frame);
writer.Write(frameOverflow);
writer.Write(_cycleCount);
writer.Write(IsCgb);
}
public void LoadStateBinary(BinaryReader reader)
@ -61,6 +62,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
Frame = reader.ReadInt32();
frameOverflow = reader.ReadUInt32();
_cycleCount = reader.ReadUInt64();
IsCgb = reader.ReadBoolean();
}
public byte[] SaveStateBinary()
@ -84,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
private void NewSaveCoreSetBuff()
{
_savebuff = new byte[LibGambatte.gambatte_newstatelen(GambatteState)];
_savebuff2 = new byte[_savebuff.Length + 4 + 21];
_savebuff2 = new byte[_savebuff.Length + 4 + 21 + 1];
}
private readonly JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented };
@ -97,6 +99,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public bool IsLagFrame;
public ulong _cycleCount;
public uint frameOverflow;
public bool IsCgb;
}
internal TextState<TextStateData> SaveState()
@ -110,6 +113,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
s.ExtraData.Frame = Frame;
s.ExtraData.frameOverflow = frameOverflow;
s.ExtraData._cycleCount = _cycleCount;
s.ExtraData.IsCgb = IsCgb;
return s;
}
@ -123,6 +127,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
Frame = s.ExtraData.Frame;
frameOverflow = s.ExtraData.frameOverflow;
_cycleCount = s.ExtraData._cycleCount;
IsCgb = s.ExtraData.IsCgb;
}
}
}

View File

@ -97,6 +97,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
byte[] Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load");
IsCgb = false;
if (LibGambatte.gambatte_loaddmgbios(GambatteState, Bios) != 0)
{
throw new InvalidOperationException("gambatte_loaddmgbios() returned non-zero (bios error)");
@ -106,6 +108,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
byte[] Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load");
IsCgb = true;
if (LibGambatte.gambatte_loadgbcbios(GambatteState, Bios) != 0)
{
throw new InvalidOperationException("gambatte_loadgbcbios() returned non-zero (bios error)");
@ -228,6 +232,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public int LagCount { get; set; }
public bool IsLagFrame { get; set; }
public bool IsCgb { get; set; }
// all cycle counts are relative to a 2*1024*1024 mhz refclock
@ -270,7 +275,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
/// </summary>
public bool IsCGBMode()
{
return LibGambatte.gambatte_iscgb(GambatteState);
//return LibGambatte.gambatte_iscgb(GambatteState);
return IsCgb;
}
private InputCallbackSystem _inputCallbacks = new InputCallbackSystem();

View File

@ -72,7 +72,7 @@ GBEXPORT void gambatte_reset(GB *g, long long now)
GBEXPORT void gambatte_setdmgpalettecolor(GB *g, unsigned palnum, unsigned colornum, unsigned rgb32)
{
//g->setDmgPaletteColor(palnum, colornum, rgb32);
g->setDmgPaletteColor(palnum, colornum, rgb32);
}
GBEXPORT void gambatte_setcgbpalette(GB *g, unsigned *lut)

Binary file not shown.