rework NES palette config in new core config system

This commit is contained in:
goyuken 2013-12-22 06:55:34 +00:00
parent a5cdee3780
commit 0cd5af1843
7 changed files with 434 additions and 423 deletions

View File

@ -336,11 +336,11 @@ namespace BizHawk.Client.Common
// NES Graphics settings // NES Graphics settings
//public bool NESAllowMoreThanEightSprites = false; //public bool NESAllowMoreThanEightSprites = false;
//public bool NESClipLeftAndRight = false; //public bool NESClipLeftAndRight = false;
public bool NESAutoLoadPalette = true; //public bool NESAutoLoadPalette = true;
//public bool NESDispBackground = true; //public bool NESDispBackground = true;
//public bool NESDispSprites = true; //public bool NESDispSprites = true;
//public int NESBackgroundColor = 0; //public int NESBackgroundColor = 0;
public string NESPaletteFile = ""; //public string NESPaletteFile = "";
//public int NTSC_NESTopLine = 8; //public int NTSC_NESTopLine = 8;
//public int NTSC_NESBottomLine = 231; //public int NTSC_NESBottomLine = 231;
//public int PAL_NESTopLine = 8; //public int PAL_NESTopLine = 8;

View File

@ -3433,14 +3433,7 @@ namespace BizHawk.Client.EmuHawk
case "NES": case "NES":
{ {
var nes = new NES(nextComm, game, rom.FileData, Global.MovieSession.Movie.Header.BoardProperties); var nes = new NES(nextComm, game, rom.FileData, Global.MovieSession.Movie.Header.BoardProperties);
nextEmulator = nes; nextEmulator = nes;
if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 &&
HawkFile.ExistsAt(Global.Config.NESPaletteFile))
{
nes.SetPalette(
NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(Global.Config.NESPaletteFile)));
}
} }
break; break;
case "GB": case "GB":

View File

@ -123,9 +123,9 @@
this.AutoLoadPalette.CheckState = System.Windows.Forms.CheckState.Checked; this.AutoLoadPalette.CheckState = System.Windows.Forms.CheckState.Checked;
this.AutoLoadPalette.Location = new System.Drawing.Point(6, 66); this.AutoLoadPalette.Location = new System.Drawing.Point(6, 66);
this.AutoLoadPalette.Name = "AutoLoadPalette"; this.AutoLoadPalette.Name = "AutoLoadPalette";
this.AutoLoadPalette.Size = new System.Drawing.Size(135, 17); this.AutoLoadPalette.Size = new System.Drawing.Size(129, 17);
this.AutoLoadPalette.TabIndex = 10; this.AutoLoadPalette.TabIndex = 10;
this.AutoLoadPalette.Text = "Load this file on startup"; this.AutoLoadPalette.Text = "Change to this palette";
this.AutoLoadPalette.UseVisualStyleBackColor = true; this.AutoLoadPalette.UseVisualStyleBackColor = true;
// //
// label1 // label1
@ -431,7 +431,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel; this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(373, 409); this.ClientSize = new System.Drawing.Size(381, 409);
this.Controls.Add(this.RestoreDefaultsButton); this.Controls.Add(this.RestoreDefaultsButton);
this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);

View File

@ -39,8 +39,6 @@ namespace BizHawk.Client.EmuHawk
PAL_LastLineNumeric.Value = settings.PAL_BottomLine; PAL_LastLineNumeric.Value = settings.PAL_BottomLine;
AllowMoreSprites.Checked = settings.AllowMoreThanEightSprites; AllowMoreSprites.Checked = settings.AllowMoreThanEightSprites;
ClipLeftAndRightCheckBox.Checked = settings.ClipLeftAndRight; ClipLeftAndRightCheckBox.Checked = settings.ClipLeftAndRight;
AutoLoadPalette.Checked = settings.AutoLoadPalette;
PalettePath.Text = Global.Config.NESPaletteFile;
DispSprites.Checked = settings.DispSprites; DispSprites.Checked = settings.DispSprites;
DispBackground.Checked = settings.DispBackground; DispBackground.Checked = settings.DispBackground;
BGColorDialog.Color = Color.FromArgb(unchecked(settings.BackgroundColor | (int)0xFF000000)); BGColorDialog.Color = Color.FromArgb(unchecked(settings.BackgroundColor | (int)0xFF000000));
@ -67,6 +65,8 @@ namespace BizHawk.Client.EmuHawk
} }
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{
if (AutoLoadPalette.Checked)
{ {
if (PalettePath.Text.Length > 0) if (PalettePath.Text.Length > 0)
{ {
@ -74,20 +74,17 @@ namespace BizHawk.Client.EmuHawk
if (palette != null && palette.Exists) if (palette != null && palette.Exists)
{ {
if (Global.Config.NESPaletteFile != palette.Name) var data = NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name));
{ settings.Palette = data;
Global.Config.NESPaletteFile = palette.Name;
nes.SetPalette(NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)));
GlobalWin.OSD.AddMessage("Palette file loaded: " + palette.Name); GlobalWin.OSD.AddMessage("Palette file loaded: " + palette.Name);
} }
} }
}
else else
{ {
Global.Config.NESPaletteFile = ""; settings.Palette = (int[,])NES.Palettes.FCEUX_Standard.Clone();
nes.SetPalette(NES.Palettes.FCEUX_Standard);
GlobalWin.OSD.AddMessage("Standard Palette set"); GlobalWin.OSD.AddMessage("Standard Palette set");
} }
}
settings.NTSC_TopLine = (int)NTSC_FirstLineNumeric.Value; settings.NTSC_TopLine = (int)NTSC_FirstLineNumeric.Value;
settings.NTSC_BottomLine = (int)NTSC_LastLineNumeric.Value; settings.NTSC_BottomLine = (int)NTSC_LastLineNumeric.Value;
@ -95,7 +92,6 @@ namespace BizHawk.Client.EmuHawk
settings.PAL_BottomLine = (int)PAL_LastLineNumeric.Value; settings.PAL_BottomLine = (int)PAL_LastLineNumeric.Value;
settings.AllowMoreThanEightSprites = AllowMoreSprites.Checked; settings.AllowMoreThanEightSprites = AllowMoreSprites.Checked;
settings.ClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; settings.ClipLeftAndRight = ClipLeftAndRightCheckBox.Checked;
settings.AutoLoadPalette = AutoLoadPalette.Checked;
settings.DispSprites = DispSprites.Checked; settings.DispSprites = DispSprites.Checked;
settings.DispBackground = DispBackground.Checked; settings.DispBackground = DispBackground.Checked;
settings.BackgroundColor = BGColorDialog.Color.ToArgb(); settings.BackgroundColor = BGColorDialog.Color.ToArgb();

View File

@ -63,6 +63,10 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\BizHawk.MultiClient\output\dll\EMU7800.dll</HintPath> <HintPath>..\BizHawk.MultiClient\output\dll\EMU7800.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

@ -432,7 +432,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary> /// <summary>
/// sets the provided palette as current /// sets the provided palette as current
/// </summary> /// </summary>
public void SetPalette(int[,] pal) private void SetPalette(int[,] pal)
{ {
Array.Copy(pal,palette,64*3); Array.Copy(pal,palette,64*3);
for(int i=0;i<64*8;i++) for(int i=0;i<64*8;i++)

View File

@ -890,6 +890,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
} }
CoreComm.ScreenLogicalOffsetX = videoProvider.left; CoreComm.ScreenLogicalOffsetX = videoProvider.left;
CoreComm.ScreenLogicalOffsetY = DisplayType == DisplayType.NTSC ? Settings.NTSC_TopLine : Settings.PAL_TopLine; CoreComm.ScreenLogicalOffsetY = DisplayType == DisplayType.NTSC ? Settings.NTSC_TopLine : Settings.PAL_TopLine;
SetPalette(Settings.Palette);
return false; return false;
} }
@ -897,7 +899,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public bool AllowMoreThanEightSprites = false; public bool AllowMoreThanEightSprites = false;
public bool ClipLeftAndRight = false; public bool ClipLeftAndRight = false;
public bool AutoLoadPalette = true;
public bool DispBackground = true; public bool DispBackground = true;
public bool DispSprites = true; public bool DispSprites = true;
public int BackgroundColor = 0; public int BackgroundColor = 0;
@ -907,10 +908,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public int PAL_TopLine = 0; public int PAL_TopLine = 0;
public int PAL_BottomLine = 239; public int PAL_BottomLine = 239;
public int[,] Palette;
public NESSettings Clone() public NESSettings Clone()
{ {
return (NESSettings)MemberwiseClone(); return (NESSettings)MemberwiseClone();
} }
public NESSettings()
{
Palette = (int[,])Palettes.FCEUX_Standard.Clone();
}
[Newtonsoft.Json.JsonConstructor]
public NESSettings(int[,] Palette)
{
if (Palette == null)
// only needed for SVN purposes
this.Palette = (int[,])Palettes.FCEUX_Standard.Clone();
else
this.Palette = Palette;
}
} }
} }
} }