nitpick cleanup

This commit is contained in:
adelikat 2020-04-02 17:36:03 -05:00
parent ced37c45c3
commit 0422b9b1de
7 changed files with 30 additions and 24 deletions

View File

@ -1,8 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Drawing;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
@ -96,7 +94,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
ControllerDefinition.AxisRanges.Add(new ControllerDefinition.AxisRange(0, 96, 191));
CoreComm = comm;
resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);
_resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);
SetUpFiles();
if (!Init())

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
@ -11,8 +7,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
partial class MelonDS : IInputPollable
{
public int LagCount { get => GetLagFrameCount(); set => throw new NotImplementedException(); }
public bool IsLagFrame { get => _IsLagFrame(); set => throw new NotImplementedException(); }
public int LagCount
{
get => GetLagFrameCount();
set => throw new NotImplementedException();
}
public bool IsLagFrame
{
get => _IsLagFrame();
set => throw new NotImplementedException();
}
public IInputCallbackSystem InputCallbacks => throw new NotImplementedException();

View File

@ -1,9 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;

View File

@ -35,6 +35,5 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
private static extern void GetSRAM(byte* dst, int length);
[DllImport(dllPath)]
private static extern void SetSRAM(byte* src, int length);
}
}

View File

@ -1,7 +1,5 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Text;
using System.Runtime.InteropServices;
@ -14,19 +12,19 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
private MelonSettings _settings = new MelonSettings();
public MelonSettings GetSettings()
{
return _settings;
}
public MelonSettings GetSettings() => _settings;
public MelonSyncSettings GetSyncSettings()
{
MelonSyncSettings ret = new MelonSyncSettings();
var ret = new MelonSyncSettings();
fixed (byte* ptr = ret.UserSettings)
{
if (!GetUserSettings(ptr))
{
return null;
}
}
ret.BootToFirmware = !GetDirectBoot();
ret.TimeAtBoot = GetTimeAtBoot();
return ret;
@ -60,6 +58,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
[DllImport(dllPath)]
private static extern bool GetUserSettings(byte* dst);
[DllImport(dllPath)]
private static extern int GetUserSettingsLength();
@ -70,11 +69,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
[DllImport(dllPath)]
private static extern bool GetDirectBoot();
[DllImport(dllPath)]
private static extern void SetDirectBoot(bool value);
[DllImport(dllPath)]
private static extern void SetTimeAtBoot(uint value);
[DllImport(dllPath)]
private static extern uint GetTimeAtBoot();
@ -155,7 +156,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
// I do not know how an actual NDS would handle characters that require more than 2 bytes to encode.
// They can't be input normally, so I will ignore attempts to set a nickname that uses them.
if (Encoding.Unicode.GetBytes(value, 0, value.Length, nick, 0) != value.Length * 2)
{
return;
}
// The extra 2 bytes on the end will overwrite nickname length, which is set immediately after
nick.CopyTo(UserSettings, 6);
UserSettings[0x1A] = (byte)value.Length;

View File

@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
unsafe partial class MelonDS : ISoundProvider
{
SpeexResampler resampler;
private readonly SpeexResampler _resampler;
public bool CanProvideAsync => false;
@ -32,8 +32,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
GetSamples(data, nsamp);
}
// BizHawk requires a sample rate of 44100 Hz.
resampler.EnqueueSamples(samples, nsamp);
resampler.GetSamplesSync(out samples, out nsamp);
_resampler.EnqueueSamples(samples, nsamp);
_resampler.GetSamplesSync(out samples, out nsamp);
}
public void SetSyncMode(SyncSoundMode mode)

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
public void LoadStateBinary(BinaryReader reader)
{
MemoryStream mStream = new MemoryStream();
var mStream = new MemoryStream();
reader.BaseStream.CopyTo(mStream);
LoadStateByteArray(mStream.GetBuffer(), (int)mStream.Length);
@ -33,6 +33,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
GetSavestateData(ptr, len);
}
return ret;
}
@ -44,8 +45,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
[DllImport(dllPath)]
private static extern bool UseSavestate(byte* data, int len);
[DllImport(dllPath)]
private static extern int GetSavestateSize();
[DllImport(dllPath)]
private static extern void GetSavestateData(byte* data, int size);
}