vba next: coreside work for alternate palettes

This commit is contained in:
goyuken 2014-08-17 20:05:56 +00:00
parent 9c24c180f2
commit d7f39ca831
5 changed files with 37 additions and 11 deletions

View File

@ -101,9 +101,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
/// <param name="videobuffer">240x160 packed argb32</param> /// <param name="videobuffer">240x160 packed argb32</param>
/// <param name="audiobuffer">buffer to recieve stereo audio</param> /// <param name="audiobuffer">buffer to recieve stereo audio</param>
/// <param name="numsamp">number of samples created</param> /// <param name="numsamp">number of samples created</param>
/// <param name="videopalette"></param>
/// <returns>true if lagged</returns> /// <returns>true if lagged</returns>
[DllImport(dllname, CallingConvention = cc)] [DllImport(dllname, CallingConvention = cc)]
public static extern bool FrameAdvance(IntPtr g, Buttons input, int[] videobuffer, short[] audiobuffer, out int numsamp); public static extern bool FrameAdvance(IntPtr g, Buttons input, int[] videobuffer, short[] audiobuffer, out int numsamp, int[] videopalette);
[DllImport(dllname, CallingConvention = cc)] [DllImport(dllname, CallingConvention = cc)]
public static extern int BinStateSize(IntPtr g); public static extern int BinStateSize(IntPtr g);

View File

@ -74,6 +74,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
savebuff = new byte[LibVBANext.BinStateSize(Core)]; savebuff = new byte[LibVBANext.BinStateSize(Core)];
savebuff2 = new byte[savebuff.Length + 13]; savebuff2 = new byte[savebuff.Length + 13];
InitMemoryDomains(); InitMemoryDomains();
// todo: hook me up as a setting
SetupColors();
} }
catch catch
{ {
@ -89,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
if (Controller["Power"]) if (Controller["Power"])
LibVBANext.Reset(Core); LibVBANext.Reset(Core);
IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(), videobuff, soundbuff, out numsamp); IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(), videobuff, soundbuff, out numsamp, videopalette);
if (IsLagFrame) if (IsLagFrame)
LagCount++; LagCount++;
@ -430,6 +433,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
#region VideoProvider #region VideoProvider
int[] videobuff = new int[240 * 160]; int[] videobuff = new int[240 * 160];
int[] videopalette = new int[65536];
public IVideoProvider VideoProvider { get { return this; } } public IVideoProvider VideoProvider { get { return this; } }
public int[] GetVideoBuffer() { return videobuff; } public int[] GetVideoBuffer() { return videobuff; }
@ -439,6 +443,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public int BufferHeight { get { return 160; } } public int BufferHeight { get { return 160; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }
void SetupColors()
{
int[] tmp = BizHawk.Emulation.Cores.Nintendo.Gameboy.GBColors.GetLut(Gameboy.GBColors.ColorType.vivid);
// reorder
for (int i = 0; i < 32768; i++)
{
int j = i & 0x3e0 | (i & 0x1f) << 10 | i >> 10 & 0x1f;
videopalette[i] = tmp[j];
}
// duplicate
Array.Copy(videopalette, 0, videopalette, 32768, 32768);
}
#endregion #endregion
#region SoundProvider #region SoundProvider

View File

@ -126,6 +126,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
}; };
public static int[] GetLut(ColorType c) public static int[] GetLut(ColorType c)
{
int[] ret = new int[32768];
GetLut(c, ret);
return ret;
}
public static void GetLut(ColorType c, int[] dest, int offset = 0)
{ {
Func<Triple, Triple> f = null; Func<Triple, Triple> f = null;
switch (c) switch (c)
@ -137,13 +144,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
case ColorType.vbabgbold: f = OldVBAColor; break; case ColorType.vbabgbold: f = OldVBAColor; break;
case ColorType.gba: f = GBAColor; break; case ColorType.gba: f = GBAColor; break;
} }
int[] ret = new int[32768];
int i = 0; int i = 0;
for (int b = 0; b < 32; b++) for (int b = 0; b < 32; b++)
for (int g = 0; g < 32; g++) for (int g = 0; g < 32; g++)
for (int r = 0; r < 32; r++) for (int r = 0; r < 32; r++)
ret[i++] = f(new Triple(r, g, b)).ToARGB32(); dest[offset + i++] = f(new Triple(r, g, b)).ToARGB32();
return ret;
} }
} }
} }

Binary file not shown.

View File

@ -12935,6 +12935,7 @@ void Gigazoid_Init()
} }
u32 *systemVideoFrameDest; u32 *systemVideoFrameDest;
u32 *systemVideoFramePalette;
s16 *systemAudioFrameDest; s16 *systemAudioFrameDest;
int *systemAudioFrameSamp; int *systemAudioFrameSamp;
bool lagged; bool lagged;
@ -12948,18 +12949,19 @@ void systemDrawScreen (void)
for (int i = 0; i < 240 * 160; i++) for (int i = 0; i < 240 * 160; i++)
{ {
u32 input = pix[i]; u32 input = pix[i];
/*
u32 output = 0xff000000 | u32 output = 0xff000000 |
input << 9 & 0xf80000 | input << 9 & 0xf80000 |
input << 6 & 0xf800 | input << 6 & 0xf800 |
input << 3 & 0xf8; input << 3 & 0xf8;
*/
u32 output = systemVideoFramePalette[input];
systemVideoFrameDest[i] = output; systemVideoFrameDest[i] = output;
} }
systemVideoFrameDest = nullptr; systemVideoFrameDest = nullptr;
systemVideoFramePalette = nullptr;
} }
// TODO: fix up RTC so this is used
//uint32_t systemGetClock (void) { return 0; }
// called at regular intervals on sound clock // called at regular intervals on sound clock
void systemOnWriteDataToSoundBuffer(int16_t * finalWave, int length) void systemOnWriteDataToSoundBuffer(int16_t * finalWave, int length)
{ {
@ -13313,10 +13315,11 @@ template<bool isReader>bool SyncBatteryRam(NewState *ns)
CPUReset(); CPUReset();
} }
bool FrameAdvance(int input, u32 *videobuffer, s16 *audiobuffer, int *numsamp) bool FrameAdvance(int input, u32 *videobuffer, s16 *audiobuffer, int *numsamp, u32 *videopalette)
{ {
joy = input; joy = input;
systemVideoFrameDest = videobuffer; systemVideoFrameDest = videobuffer;
systemVideoFramePalette = videopalette;
systemAudioFrameDest = audiobuffer; systemAudioFrameDest = audiobuffer;
systemAudioFrameSamp = numsamp; systemAudioFrameSamp = numsamp;
lagged = true; lagged = true;
@ -13397,9 +13400,9 @@ EXPORT void Reset(Gigazoid *g)
g->Reset(); g->Reset();
} }
EXPORT int FrameAdvance(Gigazoid *g, int input, u32 *videobuffer, s16 *audiobuffer, int *numsamp) EXPORT int FrameAdvance(Gigazoid *g, int input, u32 *videobuffer, s16 *audiobuffer, int *numsamp, u32 *videopalette)
{ {
return g->FrameAdvance(input, videobuffer, audiobuffer, numsamp); return g->FrameAdvance(input, videobuffer, audiobuffer, numsamp, videopalette);
} }
EXPORT int SaveRamSize(Gigazoid *g) EXPORT int SaveRamSize(Gigazoid *g)