From b2bc602398f907c5cd567326db06ad9d99167e46 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Wed, 22 Nov 2017 14:42:12 -0500 Subject: [PATCH] GBHawk: Add ROM domain, add Green palette option --- .../Nintendo/GBHawk/GBHawk.IEmulator.cs | 22 ++++++++++++++++++- .../Nintendo/GBHawk/GBHawk.IMemoryDomains.cs | 7 ++++++ .../Nintendo/GBHawk/GBHawk.ISettable.cs | 12 ++++++++++ .../Consoles/Nintendo/GBHawk/PPU.cs | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index 2bac7a73e8..4d2080d2d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -20,6 +20,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { //Console.WriteLine("-----------------------FRAME-----------------------"); + //Update the color palette if a setting changed + if(_settings.Palette == GBSettings.PaletteType.BW) + { + color_palette[0] = color_palette_BW[0]; + color_palette[1] = color_palette_BW[1]; + color_palette[2] = color_palette_BW[2]; + color_palette[3] = color_palette_BW[3]; + } + else + { + color_palette[0] = color_palette_Gr[0]; + color_palette[1] = color_palette_Gr[1]; + color_palette[2] = color_palette_Gr[2]; + color_palette[3] = color_palette_Gr[3]; + } + + if (_tracer.Enabled) { cpu.TraceCallback = s => _tracer.Put(s); @@ -165,7 +182,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public int VsyncNumerator => _frameHz; public int VsyncDenominator => 1; - public static readonly uint[] color_palette = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_BW = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 }; + + public uint[] color_palette = new uint[4]; #endregion } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs index 971b3c3c2d..162b39b6c2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs @@ -34,6 +34,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk MemoryDomain.Endian.Little, addr => PeekSystemBus(addr), (addr, value) => PokeSystemBus(addr, value), + 1), + new MemoryDomainDelegate( + "ROM", + _rom.Length, + MemoryDomain.Endian.Little, + addr => _rom[addr], + (addr, value) => ZP_RAM[addr] = value, 1) }; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs index 55d2cc130e..94a534d6a1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs @@ -38,6 +38,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public class GBSettings { + public enum PaletteType + { + BW, + Gr + } + + [DisplayName("Console Mode")] + [Description("Pick which console to run, 'Auto' chooses from ROM header, 'GB' and 'GBC' chooses the respective system")] + [DefaultValue(PaletteType.BW)] + public PaletteType Palette { get; set; } + + public GBSettings Clone() { return (GBSettings)MemberwiseClone(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs index 02de5b6d7d..6504a49d9c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -720,7 +720,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } // based on sprite priority and pixel values, pick a final pixel color - Core._vidbuffer[LY * 160 + pixel_counter] = (int)GBHawk.color_palette[pixel]; + Core._vidbuffer[LY * 160 + pixel_counter] = (int)Core.color_palette[pixel]; pixel_counter++; if (pixel_counter == 160)