Update sameboy, expose audio channel enable/disabling, cleanup settings to go through a single call/struct
This commit is contained in:
parent
7f8b4b8c87
commit
0c6f0523a0
Binary file not shown.
Binary file not shown.
|
@ -125,28 +125,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
[BizImport(cc)]
|
||||
public abstract void sameboy_setscanlinecallback(IntPtr core, ScanlineCallback callback, int sl);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setpalette(IntPtr core, Sameboy.SameboySettings.GBPaletteType which, int[] custompal);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setcolorcorrection(IntPtr core, Sameboy.SameboySettings.ColorCorrectionMode which);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setlighttemperature(IntPtr core, int temperature);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_sethighpassfilter(IntPtr core, Sameboy.SameboySettings.HighPassFilterMode which);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setinterferencevolume(IntPtr core, int volume);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setrtcdivisoroffset(IntPtr core, int offset);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setbgwinenabled(IntPtr core, bool enabled);
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NativeSettings
|
||||
{
|
||||
public Sameboy.SameboySettings.GBPaletteType Palette;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
||||
public int[] CustomPalette;
|
||||
public Sameboy.SameboySettings.ColorCorrectionMode ColorCorrectionMode;
|
||||
public int LightTemperature;
|
||||
public Sameboy.SameboySettings.HighPassFilterMode HighPassFilter;
|
||||
public int InterferenceVolume;
|
||||
public int ChannelMask;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool BackgroundEnabled;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public bool ObjectsEnabled;
|
||||
}
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_setobjenabled(IntPtr core, bool enabled);
|
||||
[BizImport(cc, Compatibility = true)]
|
||||
public abstract void sameboy_setsettings(IntPtr core, ref NativeSettings settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
|
||||
public PutSettingsDirtyBits PutSettings(SameboySettings o)
|
||||
{
|
||||
LibSameboy.sameboy_setpalette(SameboyState, o.GBPalette, o.GetCustomPalette());
|
||||
LibSameboy.sameboy_setcolorcorrection(SameboyState, o.ColorCorrection);
|
||||
LibSameboy.sameboy_setlighttemperature(SameboyState, o.LightTemperature);
|
||||
LibSameboy.sameboy_sethighpassfilter(SameboyState, o.HighPassFilter);
|
||||
LibSameboy.sameboy_setinterferencevolume(SameboyState, o.InterferenceVolume);
|
||||
LibSameboy.sameboy_setbgwinenabled(SameboyState, o.EnableBGWIN);
|
||||
LibSameboy.sameboy_setobjenabled(SameboyState, o.EnableOBJ);
|
||||
var settings = new LibSameboy.NativeSettings
|
||||
{
|
||||
Palette = o.GBPalette,
|
||||
CustomPalette = o.GetCustomPalette(),
|
||||
ColorCorrectionMode = o.ColorCorrection,
|
||||
LightTemperature = o.LightTemperature,
|
||||
HighPassFilter = o.HighPassFilter,
|
||||
InterferenceVolume = o.InterferenceVolume,
|
||||
ChannelMask = o.GetChannelMask(),
|
||||
BackgroundEnabled = o.EnableBGWIN,
|
||||
ObjectsEnabled = o.EnableOBJ,
|
||||
};
|
||||
LibSameboy.sameboy_setsettings(SameboyState, ref settings);
|
||||
_disassembler.UseRGBDSSyntax = o.UseRGBDSSyntax;
|
||||
_settings = o;
|
||||
return PutSettingsDirtyBits.None;
|
||||
|
@ -132,6 +138,29 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
set => _interferencevolume = Math.Max(0, Math.Min(100, value));
|
||||
}
|
||||
|
||||
[DisplayName("Enable Channel 1")]
|
||||
[Description("")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableCH1 { get; set; }
|
||||
|
||||
[DisplayName("Enable Channel 2")]
|
||||
[Description("")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableCH2 { get; set; }
|
||||
|
||||
[DisplayName("Enable Channel 3")]
|
||||
[Description("")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableCH3 { get; set; }
|
||||
|
||||
[DisplayName("Enable Channel 4")]
|
||||
[Description("")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableCH4 { get; set; }
|
||||
|
||||
public int GetChannelMask()
|
||||
=> (EnableCH1 ? 1 : 0) | (EnableCH2 ? 2 : 0) | (EnableCH3 ? 4 : 0) | (EnableCH4 ? 8 : 0);
|
||||
|
||||
[DisplayName("Enable Background/Window")]
|
||||
[Description("")]
|
||||
[DefaultValue(true)]
|
||||
|
|
|
@ -504,6 +504,25 @@ EXPORT void sameboy_setscanlinecallback(biz_t* biz, scanline_callback_t callback
|
|||
GB_set_lcd_line_callback(&biz->gb, callback ? ScanlineCallbackRelay : NULL);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setrtcdivisoroffset(biz_t* biz, int offset)
|
||||
{
|
||||
double base = GB_get_unmultiplied_clock_rate(&biz->gb) * 2.0;
|
||||
GB_set_rtc_multiplier(&biz->gb, (base + offset) / base);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 palette;
|
||||
u32 custom_palette[5];
|
||||
GB_color_correction_mode_t color_correction_mode;
|
||||
s32 light_temperature;
|
||||
GB_highpass_mode_t highpass_filter;
|
||||
s32 interference_volume;
|
||||
u32 channel_mask;
|
||||
bool background_enabled;
|
||||
bool objects_enabled;
|
||||
} settings_t;
|
||||
|
||||
static inline struct GB_color_s argb_to_rgb(u32 argb)
|
||||
{
|
||||
struct GB_color_s ret;
|
||||
|
@ -513,16 +532,16 @@ static inline struct GB_color_s argb_to_rgb(u32 argb)
|
|||
return ret;
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setpalette(biz_t* biz, u32 which, u32* custom_pal)
|
||||
EXPORT void sameboy_setsettings(biz_t* biz, settings_t* settings)
|
||||
{
|
||||
for (u32 i = 0; i < 4; i++)
|
||||
{
|
||||
biz->custom_pal.colors[3 - i] = argb_to_rgb(custom_pal[i]);
|
||||
biz->custom_pal.colors[3 - i] = argb_to_rgb(settings->custom_palette[i]);
|
||||
}
|
||||
|
||||
biz->custom_pal.colors[4] = argb_to_rgb(custom_pal[4]);
|
||||
biz->custom_pal.colors[4] = argb_to_rgb(settings->custom_palette[4]);
|
||||
|
||||
switch (which)
|
||||
switch (settings->palette)
|
||||
{
|
||||
case 0:
|
||||
GB_set_palette(&biz->gb, &GB_PALETTE_GREY);
|
||||
|
@ -540,40 +559,16 @@ EXPORT void sameboy_setpalette(biz_t* biz, u32 which, u32* custom_pal)
|
|||
GB_set_palette(&biz->gb, &biz->custom_pal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setcolorcorrection(biz_t* biz, GB_color_correction_mode_t which)
|
||||
{
|
||||
GB_set_color_correction_mode(&biz->gb, which);
|
||||
}
|
||||
for (u32 i = 0; i < GB_N_CHANNELS; i++)
|
||||
{
|
||||
GB_set_channel_muted(&biz->gb, i, !(settings->channel_mask >> i & 1));
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setlighttemperature(biz_t* biz, int temperature)
|
||||
{
|
||||
GB_set_light_temperature(&biz->gb, temperature / 10.0);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_sethighpassfilter(biz_t* biz, GB_highpass_mode_t which)
|
||||
{
|
||||
GB_set_highpass_filter_mode(&biz->gb, which);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setinterferencevolume(biz_t* biz, int volume)
|
||||
{
|
||||
GB_set_interference_volume(&biz->gb, volume / 100.0);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setrtcdivisoroffset(biz_t* biz, int offset)
|
||||
{
|
||||
double base = GB_get_unmultiplied_clock_rate(&biz->gb) * 2.0;
|
||||
GB_set_rtc_multiplier(&biz->gb, (base + offset) / base);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setbgwinenabled(biz_t* biz, bool enabled)
|
||||
{
|
||||
GB_set_background_rendering_disabled(&biz->gb, !enabled);
|
||||
}
|
||||
|
||||
EXPORT void sameboy_setobjenabled(biz_t* biz, bool enabled)
|
||||
{
|
||||
GB_set_object_rendering_disabled(&biz->gb, !enabled);
|
||||
GB_set_color_correction_mode(&biz->gb, settings->color_correction_mode);
|
||||
GB_set_light_temperature(&biz->gb, settings->light_temperature / 10.0);
|
||||
GB_set_highpass_filter_mode(&biz->gb, settings->highpass_filter);
|
||||
GB_set_interference_volume(&biz->gb, settings->interference_volume / 100.0);
|
||||
GB_set_background_rendering_disabled(&biz->gb, !settings->background_enabled);
|
||||
GB_set_object_rendering_disabled(&biz->gb, !settings->objects_enabled);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7efd26c548f3ce1f1969a53c7ce5b1ed96a42f7b
|
||||
Subproject commit 55507274d6efdf3a511eceabf9c89d7a096702b3
|
Loading…
Reference in New Issue