diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index ff2d5eb589..88eeb80cde 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -133,6 +133,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo { public int top = 8; public int bottom = 231; + public int left = 0; + public int right = 256; NES emu; public MyVideoProvider(NES emu) @@ -145,31 +147,46 @@ namespace BizHawk.Emulation.Consoles.Nintendo { int backdrop = emu.CoreInputComm.NES_BackdropColor; bool useBackdrop = (backdrop & 0xFF000000) != 0; + //TODO - we could recalculate this on the fly (and invalidate/recalculate it when the palette is changed) - for (int x = 0; x < 256; x++) + int width = right - left; + for (int x = left; x < right; x++) { for (int y = top; y < bottom; y++) { short pixel = emu.ppu.xbuf[(y*256) + x]; if ((pixel & 0x8000) != 0 && useBackdrop) { - pixels[((y-top)*256) + x] = backdrop; + pixels[((y-top)*width) + (x - left)] = backdrop; } - else pixels[((y-top)*256) + x] = emu.palette_compiled[pixel & 0x7FFF]; + else pixels[((y-top)*width) + (x - left)] = emu.palette_compiled[pixel & 0x7FFF]; } } return pixels; } - public int BufferWidth { get { return 256; } } + public int BufferWidth { get { return right - left; } } public int BufferHeight { get { return bottom - top; } } public int BackgroundColor { get { return 0; } } - public int Top { get { return top; } set { top = value; } } - public int Bottom { get { return bottom; } set { bottom = value; } } } public int FirstDrawLine { get { return videoProvider.top; } set { videoProvider.top = value; } } public int LastDrawLine { get { return videoProvider.bottom; } set { videoProvider.bottom = value; } } + public void SetClipLeftAndRight(bool clip) + { + if (clip) + { + videoProvider.left = 8; + videoProvider.right = 248; + } + else + { + videoProvider.left = 0; + videoProvider.right = 256; + } + } + + MyVideoProvider videoProvider; public IVideoProvider VideoProvider { get { return videoProvider; } } public ISoundProvider SoundProvider { get { return apu; } } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 2c96eaf322..b446a64e7d 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -1029,6 +1029,7 @@ namespace BizHawk.MultiClient NES nes = new NES(game, rom.FileData); nes.FirstDrawLine = Global.Config.NESTopLine; nes.LastDrawLine = Global.Config.NESBottomLine; + nes.SetClipLeftAndRight(Global.Config.NESClipLeftAndRight); Global.Game.Status = nes.RomStatus; nextEmulator = nes; if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 && diff --git a/BizHawk.MultiClient/NEStools/NESGraphicsConfig.Designer.cs b/BizHawk.MultiClient/NEStools/NESGraphicsConfig.Designer.cs index 8b279bc08b..11f76fa141 100644 --- a/BizHawk.MultiClient/NEStools/NESGraphicsConfig.Designer.cs +++ b/BizHawk.MultiClient/NEStools/NESGraphicsConfig.Designer.cs @@ -220,7 +220,6 @@ // ClipLeftAndRightCheckBox // this.ClipLeftAndRightCheckBox.AutoSize = true; - this.ClipLeftAndRightCheckBox.Enabled = false; this.ClipLeftAndRightCheckBox.Location = new System.Drawing.Point(143, 47); this.ClipLeftAndRightCheckBox.Name = "ClipLeftAndRightCheckBox"; this.ClipLeftAndRightCheckBox.Size = new System.Drawing.Size(186, 17); diff --git a/BizHawk.MultiClient/NEStools/NESGraphicsConfig.cs b/BizHawk.MultiClient/NEStools/NESGraphicsConfig.cs index e7c5f6c331..bd472c149f 100644 --- a/BizHawk.MultiClient/NEStools/NESGraphicsConfig.cs +++ b/BizHawk.MultiClient/NEStools/NESGraphicsConfig.cs @@ -93,6 +93,7 @@ namespace BizHawk.MultiClient nes.LastDrawLine = (int)LastLineNumeric.Value; Global.Config.NESAllowMoreThanEightSprites = AllowMoreSprites.Checked; Global.Config.NESClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; + nes.SetClipLeftAndRight(ClipLeftAndRightCheckBox.Checked); Global.Config.NESAutoLoadPalette = AutoLoadPalette.Checked; Global.Config.NESDispSprites = DispSprites.Checked; Global.Config.NESDispBackground = DispBackground.Checked;