NDS Lua Functions; update style input display to use them
This commit is contained in:
parent
600ee6c913
commit
1ddbada5e4
Assets/Lua/NDS
src
BizHawk.Client.Common
BizHawk.Emulation.Cores/Consoles/Nintendo/NDS
|
@ -6,10 +6,6 @@ local dotColor = 'blue'
|
|||
|
||||
client.setwindowsize(client.getwindowsize()) -- assert a sane resolution
|
||||
|
||||
invert = false
|
||||
-- FIXME: No idea how to get lua to detect inverted screens, set this to true if inverted screens are active
|
||||
-- (typing "invert = true" without the quotes in the console works)
|
||||
|
||||
function Draw(x, y, maxX, maxY, isDown)
|
||||
color = upColor
|
||||
if isDown then
|
||||
|
@ -49,16 +45,18 @@ while true do
|
|||
btns = movie.getinput(emu.framecount() - 1)
|
||||
end
|
||||
|
||||
local invert = nds.getscreeninvert()
|
||||
local wsz = client.getwindowsize()
|
||||
local w = client.screenwidth() / wsz
|
||||
local xo = 0
|
||||
local yo = 0
|
||||
|
||||
if w == 512 then -- horizontal
|
||||
if nds.getscreenlayout() == "Horizontal" then
|
||||
if invert then
|
||||
xo = xo - 256
|
||||
else
|
||||
error("Non-inverted horizontal screens are unsupported")
|
||||
console.writeline("Non-inverted horizontal screens are unsupported, switching to inverted screens")
|
||||
nds.setscreeninvert(true)
|
||||
xo = xo - 256
|
||||
end
|
||||
else -- vertical
|
||||
if invert then
|
||||
|
|
|
@ -7,6 +7,7 @@ using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
|||
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
|
||||
using BizHawk.Emulation.Cores.Nintendo.BSNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.NDS;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
using BizHawk.Emulation.Cores.PCEngine;
|
||||
using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
||||
|
@ -193,6 +194,7 @@ namespace BizHawk.Client.Common
|
|||
GPGX gpgx => gpgx.GetSettings(),
|
||||
LibsnesCore snes => snes.GetSettings(),
|
||||
NES nes => nes.GetSettings(),
|
||||
NDS nds => nds.GetSettings(),
|
||||
PCEngine pce => pce.GetSettings(),
|
||||
QuickNES quickNes => quickNes.GetSettings(),
|
||||
SMS sms => sms.GetSettings(),
|
||||
|
@ -205,6 +207,7 @@ namespace BizHawk.Client.Common
|
|||
GPGX gpgx => gpgx.PutSettings((GPGX.GPGXSettings) settings),
|
||||
LibsnesCore snes => snes.PutSettings((LibsnesCore.SnesSettings) settings),
|
||||
NES nes => nes.PutSettings((NES.NESSettings) settings),
|
||||
NDS nds => nds.PutSettings((NDS.NDSSettings) settings),
|
||||
PCEngine pce => pce.PutSettings((PCEngine.PCESettings) settings),
|
||||
QuickNES quickNes => quickNes.PutSettings((QuickNES.QuickNESSettings) settings),
|
||||
SMS sms => sms.PutSettings((SMS.SmsSettings) settings),
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.NDS;
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
[Description("Functions specific to NDSHawk (functions may not run when an NDS game is not loaded)")]
|
||||
public sealed class NDSLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public NDSLuaLibrary(IPlatformLuaLibEnv luaLibsImpl, ApiContainer apiContainer, Action<string> logOutputCallback)
|
||||
: base(luaLibsImpl, apiContainer, logOutputCallback) {}
|
||||
|
||||
public override string Name => "nds";
|
||||
|
||||
private NDS.NDSSettings Settings
|
||||
{
|
||||
get => APIs.Emulation.GetSettings() as NDS.NDSSettings ?? new NDS.NDSSettings();
|
||||
set => APIs.Emulation.PutSettings(value);
|
||||
}
|
||||
|
||||
[LuaMethodExample("if ( nds.getscreenlayout( ) ) then\r\n\tconsole.log( \"Returns which screen layout is active\" );\r\nend;")]
|
||||
[LuaMethod("getscreenlayout", "Returns which screen layout is active")]
|
||||
public string GetScreenLayout() => Settings.ScreenLayout.ToString();
|
||||
|
||||
[LuaMethodExample("if ( nds.getscreeninvert( ) ) then\r\n\tconsole.log( \"Returns whether screens are inverted\" );\r\nend;")]
|
||||
[LuaMethod("getscreeninvert", "Returns whether screens are inverted")]
|
||||
public bool GetScreenInvert() => Settings.ScreenInvert;
|
||||
|
||||
[LuaMethodExample("if ( nds.getscreenrotation( ) ) then\r\n\tconsole.log( \"Returns how screens are rotated\" );\r\nend;")]
|
||||
[LuaMethod("getscreenrotation", "Returns how screens are rotated")]
|
||||
public string GetScreenRotation() => Settings.ScreenRotation.ToString();
|
||||
|
||||
[LuaMethodExample("if ( nds.getscreengap( ) ) then\r\n\tconsole.log( \"Returns the gap between the screens\" );\r\nend;")]
|
||||
[LuaMethod("getscreengap", "Returns the gap between the screens")]
|
||||
public int GetScreenGap() => Settings.ScreenGap;
|
||||
|
||||
[LuaMethodExample("if ( nds.getaccurateaudiobitrate( ) ) then\r\n\tconsole.log( \"Returns whether the audio bitrate is set to accurate mode\" );\r\nend;")]
|
||||
[LuaMethod("getaccurateaudiobitrate", "Returns whether the audio bitrate is in accurate mode")]
|
||||
public bool GetAccurateAudioBitrate() => Settings.AccurateAudioBitrate;
|
||||
|
||||
[LuaMethodExample("nds.setscreenlayout( \"Vertical\" );")]
|
||||
[LuaMethod("setscreenlayout", "Sets which screen layout is active")]
|
||||
public void SetScreenLayout(string value)
|
||||
{
|
||||
var s = Settings;
|
||||
s.ScreenLayout = (NDS.ScreenLayoutKind)Enum.Parse(typeof(NDS.ScreenLayoutKind), value, true);
|
||||
Settings = s;
|
||||
}
|
||||
|
||||
[LuaMethodExample("nds.setscreeninvert( false );")]
|
||||
[LuaMethod("setscreeninvert", "Sets whether screens are inverted")]
|
||||
public void SetScreenInvert(bool value)
|
||||
{
|
||||
var s = Settings;
|
||||
s.ScreenInvert = value;
|
||||
Settings = s;
|
||||
}
|
||||
|
||||
[LuaMethodExample("nds.setscreenrotation( \"Rotate0\" );")]
|
||||
[LuaMethod("setscreenrotation", "Sets how screens are rotated")]
|
||||
public void SetScreenRotation(string value)
|
||||
{
|
||||
var s = Settings;
|
||||
s.ScreenRotation = (NDS.ScreenRotationKind)Enum.Parse(typeof(NDS.ScreenRotationKind), value, true);
|
||||
Settings = s;
|
||||
}
|
||||
|
||||
[LuaMethodExample("nds.setscreengap( 0 );")]
|
||||
[LuaMethod("setscreengap", "Sets the gap between the screens")]
|
||||
public void GetScreenGap(int value)
|
||||
{
|
||||
var s = Settings;
|
||||
s.ScreenGap = value;
|
||||
Settings = s;
|
||||
}
|
||||
|
||||
[LuaMethodExample("nds.setaccurateaudiobitrate( true );")]
|
||||
[LuaMethod("setaccurateaudiobitrate", "Sets whether the audio bitrate is in accurate mode")]
|
||||
public void SetAccurateAudioBitrate(bool value)
|
||||
{
|
||||
var s = Settings;
|
||||
s.AccurateAudioBitrate = value;
|
||||
Settings = s;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
Result.Movie.HeaderEntries[HeaderKeys.Platform] = "NDS";
|
||||
|
||||
var syncSettings = new NDS.SyncSettings();
|
||||
var syncSettings = new NDS.NDSSyncSettings();
|
||||
|
||||
using var sr = SourceFile.OpenText();
|
||||
string line;
|
||||
|
@ -41,7 +41,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line.StartsWith("firmFavColour"))
|
||||
{
|
||||
syncSettings.FirmwareFavouriteColour = (NDS.SyncSettings.Color)byte.Parse(ParseHeader(line, "firmFavColour"));
|
||||
syncSettings.FirmwareFavouriteColour = (NDS.NDSSyncSettings.Color)byte.Parse(ParseHeader(line, "firmFavColour"));
|
||||
}
|
||||
else if (line.StartsWith("firmBirthDay"))
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line.StartsWith("firmBirthMonth"))
|
||||
{
|
||||
syncSettings.FirmwareBirthdayMonth = (NDS.SyncSettings.Month)byte.Parse(ParseHeader(line, "firmBirthMonth"));
|
||||
syncSettings.FirmwareBirthdayMonth = (NDS.NDSSyncSettings.Month)byte.Parse(ParseHeader(line, "firmBirthMonth"));
|
||||
}
|
||||
else if (line.StartsWith("rtcStartNew"))
|
||||
{
|
||||
|
|
|
@ -56,10 +56,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
{
|
||||
public IntPtr FirmwareUsername; // max 10 length (then terminator)
|
||||
public int FirmwareUsernameLength;
|
||||
public NDS.SyncSettings.Language FirmwareLanguage;
|
||||
public NDS.SyncSettings.Month FirmwareBirthdayMonth;
|
||||
public NDS.NDSSyncSettings.Language FirmwareLanguage;
|
||||
public NDS.NDSSyncSettings.Month FirmwareBirthdayMonth;
|
||||
public int FirmwareBirthdayDay;
|
||||
public NDS.SyncSettings.Color FirmwareFavouriteColour;
|
||||
public NDS.NDSSyncSettings.Color FirmwareFavouriteColour;
|
||||
public IntPtr FirmwareMessage; // max 26 length (then terminator)
|
||||
public int FirmwareMessageLength;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
||||
{
|
||||
partial class NDS : ISettable<NDS.Settings, NDS.SyncSettings>
|
||||
partial class NDS : ISettable<NDS.NDSSettings, NDS.NDSSyncSettings>
|
||||
{
|
||||
private Settings _settings;
|
||||
private SyncSettings _syncSettings;
|
||||
private NDSSettings _settings;
|
||||
private NDSSyncSettings _syncSettings;
|
||||
|
||||
public enum ScreenLayoutKind
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
Rotate270
|
||||
}
|
||||
|
||||
public class Settings
|
||||
public class NDSSettings
|
||||
{
|
||||
[DisplayName("Screen Layout")]
|
||||
[Description("Adjusts the layout of the screens")]
|
||||
|
@ -64,17 +64,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
[DefaultValue(true)]
|
||||
public bool AccurateAudioBitrate { get; set; }
|
||||
|
||||
public Settings Clone()
|
||||
public NDSSettings Clone()
|
||||
{
|
||||
return (Settings)MemberwiseClone();
|
||||
return (NDSSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static bool NeedsReboot(Settings x, Settings y)
|
||||
public static bool NeedsReboot(NDSSettings x, NDSSettings y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public Settings()
|
||||
public NDSSettings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
private static readonly DateTime minDate = new DateTime(2000, 1, 1);
|
||||
private static readonly DateTime maxDate = new DateTime(2099, 12, 31, 23, 59, 59);
|
||||
|
||||
public class SyncSettings
|
||||
public class NDSSyncSettings
|
||||
{
|
||||
[JsonIgnore]
|
||||
private DateTime _initaltime;
|
||||
|
@ -250,60 +250,60 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
set => _firmwaremessage = value.Substring(0, Math.Min(26, value.Length));
|
||||
}
|
||||
|
||||
public SyncSettings Clone()
|
||||
public NDSSyncSettings Clone()
|
||||
{
|
||||
return (SyncSettings)MemberwiseClone();
|
||||
return (NDSSyncSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static bool NeedsReboot(SyncSettings x, SyncSettings y)
|
||||
public static bool NeedsReboot(NDSSyncSettings x, NDSSyncSettings y)
|
||||
{
|
||||
return !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
|
||||
public SyncSettings()
|
||||
public NDSSyncSettings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Settings GetSettings()
|
||||
public NDSSettings GetSettings()
|
||||
{
|
||||
return _settings.Clone();
|
||||
}
|
||||
|
||||
public SyncSettings GetSyncSettings()
|
||||
public NDSSyncSettings GetSyncSettings()
|
||||
{
|
||||
return _syncSettings.Clone();
|
||||
}
|
||||
|
||||
public PutSettingsDirtyBits PutSettings(Settings o)
|
||||
public PutSettingsDirtyBits PutSettings(NDSSettings o)
|
||||
{
|
||||
var ret = Settings.NeedsReboot(_settings, o);
|
||||
var ret = NDSSettings.NeedsReboot(_settings, o);
|
||||
_settings = o;
|
||||
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
|
||||
}
|
||||
|
||||
public PutSettingsDirtyBits PutSyncSettings(SyncSettings o)
|
||||
public PutSettingsDirtyBits PutSyncSettings(NDSSyncSettings o)
|
||||
{
|
||||
var ret = SyncSettings.NeedsReboot(_syncSettings, o);
|
||||
var ret = NDSSyncSettings.NeedsReboot(_syncSettings, o);
|
||||
_syncSettings = o;
|
||||
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
|
||||
}
|
||||
|
||||
private static int SanitizeBirthdayDay(int day, SyncSettings.Month fwMonth)
|
||||
private static int SanitizeBirthdayDay(int day, NDSSyncSettings.Month fwMonth)
|
||||
{
|
||||
int maxdays;
|
||||
switch (fwMonth)
|
||||
{
|
||||
case SyncSettings.Month.February:
|
||||
case NDSSyncSettings.Month.February:
|
||||
{
|
||||
maxdays = 29;
|
||||
break;
|
||||
}
|
||||
case SyncSettings.Month.April:
|
||||
case SyncSettings.Month.June:
|
||||
case SyncSettings.Month.September:
|
||||
case SyncSettings.Month.November:
|
||||
case NDSSyncSettings.Month.April:
|
||||
case NDSSyncSettings.Month.June:
|
||||
case NDSSyncSettings.Month.September:
|
||||
case NDSSyncSettings.Month.November:
|
||||
{
|
||||
maxdays = 30;
|
||||
break;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
private SpeexResampler _resampler;
|
||||
|
||||
[CoreConstructor("NDS")]
|
||||
public NDS(CoreLoadParameters<Settings, SyncSettings> lp)
|
||||
public NDS(CoreLoadParameters<NDSSettings, NDSSyncSettings> lp)
|
||||
: base(lp.Comm, new Configuration
|
||||
{
|
||||
DefaultWidth = 256,
|
||||
|
@ -54,8 +54,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
SkipMemoryConsistencyCheck = CoreComm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
|
||||
}, new Delegate[] { _tracecb });
|
||||
|
||||
_syncSettings = lp.SyncSettings ?? new SyncSettings();
|
||||
_settings = lp.Settings ?? new Settings();
|
||||
_syncSettings = lp.SyncSettings ?? new NDSSyncSettings();
|
||||
_settings = lp.Settings ?? new NDSSettings();
|
||||
|
||||
var bios7 = _syncSettings.UseRealBIOS
|
||||
? CoreComm.CoreFileProvider.GetFirmwareOrThrow(new("NDS", "bios7"))
|
||||
|
@ -86,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
|||
var name = Encoding.UTF8.GetBytes(_syncSettings.FirmwareUsername);
|
||||
fwSettings.FirmwareUsernameLength = name.Length;
|
||||
fwSettings.FirmwareLanguage = _syncSettings.FirmwareLanguage;
|
||||
if (_syncSettings.FirmwareStartUp == SyncSettings.StartUp.AutoBoot) fwSettings.FirmwareLanguage |= (SyncSettings.Language)0x40;
|
||||
if (_syncSettings.FirmwareStartUp == NDSSyncSettings.StartUp.AutoBoot) fwSettings.FirmwareLanguage |= (NDSSyncSettings.Language)0x40;
|
||||
fwSettings.FirmwareBirthdayMonth = _syncSettings.FirmwareBirthdayMonth;
|
||||
fwSettings.FirmwareBirthdayDay = _syncSettings.FirmwareBirthdayDay;
|
||||
fwSettings.FirmwareFavouriteColour = _syncSettings.FirmwareFavouriteColour;
|
||||
|
|
Loading…
Reference in New Issue