quicknes: implement the crop settings
This commit is contained in:
parent
db386e4dee
commit
adf7f01102
|
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
/// <param name="dest">rgb32 256x240 packed</param>
|
||||
/// <param name="colors">rgb 24 colors, red first, 512 of them (1536 bytes)</param>
|
||||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void qn_blit(IntPtr e, IntPtr dest, byte[] colors);
|
||||
public static extern void qn_blit(IntPtr e, IntPtr dest, byte[] colors, int cropleft, int croptop, int cropright, int cropbottom);
|
||||
/// <summary>
|
||||
/// get quicknes's default palette
|
||||
/// </summary>
|
||||
|
|
|
@ -470,6 +470,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
{
|
||||
Settings = (QuickNESSettings)o;
|
||||
LibQuickNES.qn_set_sprite_limit(Context, Settings.NumSprites);
|
||||
RecalculateCrops();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -506,6 +507,19 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
GCHandle VideoInputH;
|
||||
GCHandle VideoOutputH;
|
||||
|
||||
int cropleft = 0;
|
||||
int cropright = 0;
|
||||
int croptop = 0;
|
||||
int cropbottom = 0;
|
||||
|
||||
void RecalculateCrops()
|
||||
{
|
||||
cropright = cropleft = Settings.ClipLeftAndRight ? 8 : 0;
|
||||
cropbottom = croptop = Settings.ClipTopAndBottom ? 8 : 0;
|
||||
BufferWidth = 256 - cropleft - cropright;
|
||||
BufferHeight = 240 - croptop - cropbottom;
|
||||
}
|
||||
|
||||
void InitVideo()
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
|
@ -519,14 +533,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
|
||||
void Blit()
|
||||
{
|
||||
LibQuickNES.qn_blit(Context, VideoOutputH.AddrOfPinnedObject(), Settings.Palette);
|
||||
LibQuickNES.qn_blit(Context, VideoOutputH.AddrOfPinnedObject(), Settings.Palette, cropleft, croptop, cropright, cropbottom);
|
||||
}
|
||||
|
||||
public IVideoProvider VideoProvider { get { return this; } }
|
||||
public int[] GetVideoBuffer() { return VideoOutput; }
|
||||
public int VirtualWidth { get { return 292; } } // probably different on pal
|
||||
public int BufferWidth { get { return 256; } }
|
||||
public int BufferHeight { get { return 240; } }
|
||||
public int VirtualWidth { get { return (int)(BufferWidth * 1.14); } }
|
||||
public int BufferWidth { get; private set; }
|
||||
public int BufferHeight { get; private set; }
|
||||
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
|
||||
|
||||
#endregion
|
||||
|
|
Binary file not shown.
|
@ -67,20 +67,25 @@ EXPORT const char *qn_emulate_frame(Nes_Emu *e, int pad1, int pad2)
|
|||
return e->emulate_frame(pad1, pad2);
|
||||
}
|
||||
|
||||
EXPORT void qn_blit(Nes_Emu *e, char *dest, const Nes_Emu::rgb_t *colors)
|
||||
EXPORT void qn_blit(Nes_Emu *e, char *dest, const Nes_Emu::rgb_t *colors, int cropleft, int croptop, int cropright, int cropbottom)
|
||||
{
|
||||
// what is the point of the 256 color bitmap and the dynamic color allocation to it?
|
||||
// why not just render directly to a 512 color bitmap with static palette positions?
|
||||
|
||||
const unsigned char *src = e->frame().pixels;
|
||||
const int srcpitch = e->frame().pitch;
|
||||
const unsigned char *srcend = src + e->image_height * srcpitch;
|
||||
const unsigned char *src = e->frame().pixels;
|
||||
const unsigned char *const srcend = src + (e->image_height - cropbottom) * srcpitch;
|
||||
|
||||
const short *lut = e->frame().palette;
|
||||
|
||||
const int rowlen = 256 - cropleft - cropright;
|
||||
|
||||
src += cropleft;
|
||||
src += croptop * srcpitch;
|
||||
|
||||
for (; src < srcend; src += srcpitch)
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
for (int i = 0; i < rowlen; i++)
|
||||
{
|
||||
const Nes_Emu::rgb_t *c = colors + lut[src[i]];
|
||||
*dest++ = c->blue;
|
||||
|
|
Loading…
Reference in New Issue