Skip to content

Commit

Permalink
gpgx - handle virtualwidth/virtualheight more modernly and add option…
Browse files Browse the repository at this point in the history
… to pad screen out to prevent window resizes
  • Loading branch information
zeromus committed Sep 17, 2015
1 parent ef5bfc4 commit de85a6f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 25 additions & 7 deletions BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ void update_audio()
int vwidth;
int vheight;
public int[] GetVideoBuffer() { return vidbuff; }
public int VirtualWidth { get { return BufferWidth; } } // TODO
public int VirtualHeight { get { return BufferHeight; } } // TODO
public int VirtualWidth { get { return 320; } }
public int VirtualHeight { get { return 224; } }
public int BufferWidth { get { return vwidth; } }
public int BufferHeight { get { return vheight; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
Expand All @@ -777,24 +777,37 @@ void update_video_initial()

unsafe void update_video()
{
int pitch = 0;
int gppitch, gpwidth, gpheight;
IntPtr src = IntPtr.Zero;

LibGPGX.gpgx_get_video(ref vwidth, ref vheight, ref pitch, ref src);
LibGPGX.gpgx_get_video(out gpwidth, out gpheight, out gppitch, ref src);

vwidth = gpwidth;
vheight = gpheight;

if (_Settings.PadScreen320 && vwidth == 256)
vwidth = 320;

int xpad = (vwidth - gpwidth) / 2;
int xpad2 = vwidth - gpwidth - xpad;

if (vidbuff.Length < vwidth * vheight)
vidbuff = new int[vwidth * vheight];

int rinc = (pitch / 4) - vwidth;
int rinc = (gppitch / 4) - gpwidth;
fixed (int* pdst_ = &vidbuff[0])
{
int* pdst = pdst_;
int* psrc = (int*)src;

for (int j = 0; j < vheight; j++)
for (int j = 0; j < gpheight; j++)
{
for (int i = 0; i < vwidth; i++)
for(int i=0;i<xpad;i++)
*pdst++ = unchecked((int)0xff000000);
for (int i = 0; i < gpwidth; i++)
*pdst++ = *psrc++;// | unchecked((int)0xff000000);
for (int i = 0; i < xpad2; i++)
*pdst++ = unchecked((int)0xff000000);
psrc += rinc;
}
}
Expand Down Expand Up @@ -839,6 +852,11 @@ public class GPGXSettings
[DefaultValue(true)]
public bool DrawBGW { get; set; }

[DisplayName("Pad screen to 320")]
[Description("Set to True to pads the screen out to be 320 when in 256 wide video modes")]
[DefaultValue(false)]
public bool PadScreen320 { get; set; }

public GPGXSettings()
{
SettingsUtil.SetDefaultValues(this);
Expand Down
2 changes: 1 addition & 1 deletion BizHawk.Emulation.Cores/Consoles/Sega/gpgx/LibGPGX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public static class LibGPGX
{
[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_get_video(ref int w, ref int h, ref int pitch, ref IntPtr buffer);
public static extern void gpgx_get_video(out int w, out int h, out int pitch, ref IntPtr buffer);

[DllImport("libgenplusgx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gpgx_get_audio(ref int n, ref IntPtr buffer);
Expand Down

0 comments on commit de85a6f

Please sign in to comment.