pull in latest sameboy master, add stub camera pixel callback to prevent nondeterminism, wire disabling joypad bounce as a sync setting, various cleanup
This commit is contained in:
parent
e2a36c7242
commit
cb468ba806
Binary file not shown.
Binary file not shown.
|
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
}
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract IntPtr sameboy_create(byte[] romdata, int romlength, byte[] biosdata, int bioslength, Sameboy.SameboySyncSettings.GBModel model, bool realtime);
|
||||
public abstract IntPtr sameboy_create(byte[] romdata, int romlength, byte[] biosdata, int bioslength, Sameboy.SameboySyncSettings.GBModel model, bool realtime, bool nobounce);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void sameboy_destroy(IntPtr core);
|
||||
|
|
|
@ -151,11 +151,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
_customPal = new[] { 0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000, 0x00ffffff, };
|
||||
}
|
||||
|
||||
public SameboySettings Clone() => MemberwiseClone() as SameboySettings;
|
||||
public SameboySettings Clone()
|
||||
=> (SameboySettings)MemberwiseClone();
|
||||
|
||||
public int[] GetCustomPalette() => _customPal.Clone() as int[];
|
||||
public int[] GetCustomPalette()
|
||||
=> (int[])_customPal.Clone();
|
||||
|
||||
public void SetCustomPalette(int[] pal) => _customPal = pal.Clone() as int[];
|
||||
public void SetCustomPalette(int[] pal)
|
||||
=> _customPal = (int[])pal.Clone();
|
||||
}
|
||||
|
||||
public class SameboySyncSettings
|
||||
|
@ -210,11 +213,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
[DefaultValue(0)]
|
||||
public int RTCDivisorOffset { get; set; }
|
||||
|
||||
public SameboySyncSettings() => SettingsUtil.SetDefaultValues(this);
|
||||
[DisplayName("Disable Joypad Bounce")]
|
||||
[Description("Disables emulation of the bounce from a physical joypad.")]
|
||||
[DefaultValue(true)]
|
||||
public bool NoJoypadBounce { get; set; }
|
||||
|
||||
public SameboySyncSettings Clone() => MemberwiseClone() as SameboySyncSettings;
|
||||
public SameboySyncSettings()
|
||||
=> SettingsUtil.SetDefaultValues(this);
|
||||
|
||||
public static bool NeedsReboot(SameboySyncSettings x, SameboySyncSettings y) => !DeepEquality.DeepEquals(x, y);
|
||||
public SameboySyncSettings Clone()
|
||||
=> (SameboySyncSettings)MemberwiseClone();
|
||||
|
||||
public static bool NeedsReboot(SameboySyncSettings x, SameboySyncSettings y)
|
||||
=> !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
/// <summary>
|
||||
/// a gameboy/gameboy color emulator wrapped around native C libsameboy
|
||||
/// </summary>
|
||||
[PortedCore(CoreNames.Sameboy, "LIJI32", "0.14.7", "https://github.com/LIJI32/SameBoy")]
|
||||
[PortedCore(CoreNames.Sameboy, "LIJI32", "0.15.1", "https://github.com/LIJI32/SameBoy")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||
public partial class Sameboy : ICycleTiming, IInputPollable, ILinkable, IRomInfo, IBoardInfo, IGameboyCommon
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Sameboy
|
|||
DeterministicEmulation = true;
|
||||
}
|
||||
|
||||
SameboyState = LibSameboy.sameboy_create(file, file.Length, bios, bios.Length, model, realtime);
|
||||
SameboyState = LibSameboy.sameboy_create(file, file.Length, bios, bios.Length, model, realtime, _syncSettings.NoJoypadBounce);
|
||||
|
||||
InitMemoryDomains();
|
||||
InitMemoryCallbacks();
|
||||
|
|
|
@ -29,7 +29,6 @@ typedef struct
|
|||
GB_gameboy_t gb;
|
||||
blip_t* blip_l;
|
||||
blip_t* blip_r;
|
||||
GB_sample_t sampleBuf[1024 * 8];
|
||||
GB_sample_t sampleLatch;
|
||||
u32 nsamps;
|
||||
u32 vbuf[256 * 224];
|
||||
|
@ -57,8 +56,19 @@ static u8 PeekIO(biz_t* biz, u8 addr)
|
|||
static void sample_cb(GB_gameboy_t *gb, GB_sample_t* sample)
|
||||
{
|
||||
biz_t* biz = (biz_t*)gb;
|
||||
biz->sampleBuf[biz->nsamps].left = sample->left;
|
||||
biz->sampleBuf[biz->nsamps].right = sample->right;
|
||||
|
||||
if (biz->sampleLatch.left != sample->left)
|
||||
{
|
||||
blip_add_delta(biz->blip_l, biz->nsamps, biz->sampleLatch.left - sample->left);
|
||||
biz->sampleLatch.left = sample->left;
|
||||
}
|
||||
|
||||
if (biz->sampleLatch.right != sample->right)
|
||||
{
|
||||
blip_add_delta(biz->blip_r, biz->nsamps, biz->sampleLatch.right - sample->right);
|
||||
biz->sampleLatch.right = sample->right;
|
||||
}
|
||||
|
||||
biz->nsamps++;
|
||||
}
|
||||
|
||||
|
@ -72,6 +82,12 @@ static void vblank_cb(GB_gameboy_t *gb, GB_vblank_type_t type)
|
|||
((biz_t*)gb)->vblank_occured = true;
|
||||
}
|
||||
|
||||
static u8 camera_pixel_cb(GB_gameboy_t *gb, u8 x, u8 y)
|
||||
{
|
||||
// stub for now (also needed for determinism)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 ReadCallbackRelay(GB_gameboy_t* gb, u16 addr, u8 data)
|
||||
{
|
||||
((biz_t*)gb)->read_cb(addr);
|
||||
|
@ -111,7 +127,7 @@ static void ScanlineCallbackRelay(GB_gameboy_t* gb, u8 line)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT biz_t* sameboy_create(u8* romdata, u32 romlen, u8* biosdata, u32 bioslen, GB_model_t model, bool realtime)
|
||||
EXPORT biz_t* sameboy_create(u8* romdata, u32 romlen, u8* biosdata, u32 bioslen, GB_model_t model, bool realtime, bool nobounce)
|
||||
{
|
||||
biz_t* biz = calloc(1, sizeof (biz_t));
|
||||
GB_random_seed(0);
|
||||
|
@ -122,7 +138,10 @@ EXPORT biz_t* sameboy_create(u8* romdata, u32 romlen, u8* biosdata, u32 bioslen,
|
|||
GB_apu_set_sample_callback(&biz->gb, sample_cb);
|
||||
GB_set_rgb_encode_callback(&biz->gb, rgb_cb);
|
||||
GB_set_vblank_callback(&biz->gb, vblank_cb);
|
||||
GB_set_camera_get_pixel_callback(&biz->gb, camera_pixel_cb);
|
||||
GB_set_pixels_output(&biz->gb, biz->vbuf);
|
||||
GB_set_rtc_mode(&biz->gb, realtime ? GB_RTC_MODE_SYNC_TO_HOST : GB_RTC_MODE_ACCURATE);
|
||||
GB_set_emulate_joypad_bouncing(&biz->gb, !nobounce);
|
||||
GB_set_allow_illegal_inputs(&biz->gb, true);
|
||||
biz->blip_l = blip_new(1024);
|
||||
biz->blip_r = blip_new(1024);
|
||||
|
@ -156,7 +175,6 @@ EXPORT void sameboy_frameadvance(biz_t* biz, GB_key_mask_t keys, u16 x, u16 y, s
|
|||
{
|
||||
GB_set_accelerometer_values(&biz->gb, FromRawToG(x), FromRawToG(y));
|
||||
}
|
||||
GB_set_pixels_output(&biz->gb, biz->vbuf);
|
||||
GB_set_border_mode(&biz->gb, border ? GB_BORDER_ALWAYS : GB_BORDER_NEVER);
|
||||
GB_set_rendering_disabled(&biz->gb, !render);
|
||||
|
||||
|
@ -182,20 +200,6 @@ EXPORT void sameboy_frameadvance(biz_t* biz, GB_key_mask_t keys, u16 x, u16 y, s
|
|||
}
|
||||
while (!biz->vblank_occured && cycles < 35112);
|
||||
|
||||
for (u32 i = 0; i < biz->nsamps; i++)
|
||||
{
|
||||
if (biz->sampleLatch.left != biz->sampleBuf[i].left)
|
||||
{
|
||||
blip_add_delta(biz->blip_l, i, biz->sampleLatch.left - biz->sampleBuf[i].left);
|
||||
biz->sampleLatch.left = biz->sampleBuf[i].left;
|
||||
}
|
||||
if (biz->sampleLatch.right != biz->sampleBuf[i].right)
|
||||
{
|
||||
blip_add_delta(biz->blip_r, i, biz->sampleLatch.right - biz->sampleBuf[i].right);
|
||||
biz->sampleLatch.right = biz->sampleBuf[i].right;
|
||||
}
|
||||
}
|
||||
|
||||
blip_end_frame(biz->blip_l, biz->nsamps);
|
||||
blip_end_frame(biz->blip_r, biz->nsamps);
|
||||
biz->nsamps = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1b38e8c9321522d8211c834a548d55fb6e4c79cc
|
||||
Subproject commit 03f4f03661d10a366c2302a4299362878d1aea91
|
Loading…
Reference in New Issue