2015-01-16 18:37:42 +00:00
using System ;
using System.ComponentModel ;
2017-04-25 15:42:11 +00:00
2015-01-16 18:37:42 +00:00
using Newtonsoft.Json ;
using BizHawk.Common ;
using BizHawk.Emulation.Common ;
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
public partial class Gameboy : ISettable < Gameboy . GambatteSettings , Gameboy . GambatteSyncSettings >
{
public GambatteSettings GetSettings ( )
{
return _settings . Clone ( ) ;
}
public bool PutSettings ( GambatteSettings o )
{
_settings = o ;
if ( IsCGBMode ( ) )
2017-04-25 15:42:11 +00:00
{
2015-01-16 18:37:42 +00:00
SetCGBColors ( _settings . CGBColors ) ;
2017-04-25 15:42:11 +00:00
}
2015-01-16 18:37:42 +00:00
else
2017-04-25 15:42:11 +00:00
{
2015-01-16 18:37:42 +00:00
ChangeDMGColors ( _settings . GBPalette ) ;
2017-04-25 15:42:11 +00:00
}
2015-01-16 18:37:42 +00:00
return false ;
}
public GambatteSyncSettings GetSyncSettings ( )
{
return _syncSettings . Clone ( ) ;
}
public bool PutSyncSettings ( GambatteSyncSettings o )
{
bool ret = GambatteSyncSettings . NeedsReboot ( _syncSettings , o ) ;
_syncSettings = o ;
return ret ;
}
private GambatteSettings _settings ;
private GambatteSyncSettings _syncSettings ;
public class GambatteSettings
{
2017-04-25 15:42:11 +00:00
private static readonly int [ ] DefaultPalette =
{
10798341 , 8956165 , 1922333 , 337157 ,
10798341 , 8956165 , 1922333 , 337157 ,
10798341 , 8956165 , 1922333 , 337157
} ;
2015-01-16 18:37:42 +00:00
public int [ ] GBPalette ;
public GBColors . ColorType CGBColors ;
2016-04-12 08:02:11 +00:00
public bool DisplayBG = true , DisplayOBJ = true , DisplayWindow = true ;
2016-02-08 08:18:24 +00:00
2015-01-16 18:37:42 +00:00
/// <summary>
/// true to mute all audio
/// </summary>
public bool Muted ;
public GambatteSettings ( )
{
GBPalette = ( int [ ] ) DefaultPalette . Clone ( ) ;
CGBColors = GBColors . ColorType . gambatte ;
}
2016-02-08 08:18:24 +00:00
2015-01-16 18:37:42 +00:00
public GambatteSettings Clone ( )
{
var ret = ( GambatteSettings ) MemberwiseClone ( ) ;
ret . GBPalette = ( int [ ] ) GBPalette . Clone ( ) ;
return ret ;
}
}
public class GambatteSyncSettings
{
2017-07-09 20:27:32 +00:00
public enum ConsoleModeType
2017-07-06 21:53:14 +00:00
{
2017-07-09 20:27:32 +00:00
Auto ,
GB ,
GBC
2017-07-06 21:53:14 +00:00
}
2017-07-09 20:27:32 +00:00
[DisplayName("Console Mode")]
[Description("Pick which console to run, 'Auto' chooses from ROM header, 'GB' and 'GBC' chooses the respective system")]
[DefaultValue(ConsoleModeType.Auto)]
public ConsoleModeType ConsoleMode { get ; set ; }
2015-01-16 18:37:42 +00:00
[DisplayName("CGB in GBA")]
[Description("Emulate GBA hardware running a CGB game, instead of CGB hardware. Relevant only for titles that detect the presense of a GBA, such as Shantae.")]
[DefaultValue(false)]
public bool GBACGB { get ; set ; }
[DisplayName("Multicart Compatibility")]
[Description("Use special compatibility hacks for certain multicart games. Relevant only for specific multicarts.")]
[DefaultValue(false)]
public bool MulticartCompat { get ; set ; }
[DisplayName("Realtime RTC")]
[Description("If true, the real time clock in MBC3 games will reflect real time, instead of emulated time. Ignored (treated as false) when a movie is recording.")]
[DefaultValue(false)]
public bool RealTimeRTC { get ; set ; }
[DisplayName("RTC Initial Time")]
[Description("Set the initial RTC time in terms of elapsed seconds. Only used when RealTimeRTC is false.")]
[DefaultValue(0)]
public int RTCInitialTime
{
get { return _RTCInitialTime ; }
set { _RTCInitialTime = Math . Max ( 0 , Math . Min ( 1024 * 24 * 60 * 60 , value ) ) ; }
}
[JsonIgnore]
2017-04-25 15:42:11 +00:00
private int _RTCInitialTime ;
2015-01-16 18:37:42 +00:00
[DisplayName("Equal Length Frames")]
[Description("When false, emulation frames sync to vblank. Only useful for high level TASing.")]
[DefaultValue(true)]
public bool EqualLengthFrames
{
2017-04-25 15:42:11 +00:00
get { return _equalLengthFrames ; }
set { _equalLengthFrames = value ; }
2015-01-16 18:37:42 +00:00
}
[JsonIgnore]
[DeepEqualsIgnore]
2017-04-25 15:42:11 +00:00
private bool _equalLengthFrames ;
2015-01-16 18:37:42 +00:00
public GambatteSyncSettings ( )
{
SettingsUtil . SetDefaultValues ( this ) ;
}
public GambatteSyncSettings Clone ( )
{
return ( GambatteSyncSettings ) MemberwiseClone ( ) ;
}
public static bool NeedsReboot ( GambatteSyncSettings x , GambatteSyncSettings y )
{
return ! DeepEquality . DeepEquals ( x , y ) ;
}
}
}
}