This commit is contained in:
ALIENJACK\alien 2024-07-04 21:06:41 +08:00
parent 4a7b6c1458
commit 28e0071191
62 changed files with 7226 additions and 6227 deletions

View File

@ -1,337 +1,231 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace MyNes.Core
{
public class MyNesMain
{
public static EmuSettings EmuSettings { get; private set; }
public static EmuSettings EmuSettings { get; private set; }
public static RendererSettings RendererSettings { get; private set; }
public static IFileManager FileManager { get; private set; }
public static string WorkingFolder { get; private set; }
public static RendererSettings RendererSettings { get; private set; }
internal static List<Board> Boards { get; private set; }
public static string AppPath { get; private set; }
public static IVideoProvider VideoProvider { get; private set; }
public static string WorkingFolder { get; private set; }
public static IAudioProvider AudioProvider { get; private set; }
internal static List<Board> Boards { get; private set; }
public static WaveRecorder WaveRecorder { get; private set; }
public static List<IVideoProvider> VideoProviders { get; private set; }
public static void Initialize(IFileManager fileManager)
{
Tracer.WriteLine("Initializing My Nes Core ....");
FileManager = fileManager;
WorkingFolder = fileManager.GetWorkingFolderPath();
Tracer.WriteLine("Loading emu settings ...");
EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini"));
EmuSettings.LoadSettings();
Tracer.WriteLine("Emu settings loaded successfully.");
Tracer.WriteLine("Loading renderer settings ...");
RendererSettings = new RendererSettings(Path.Combine(WorkingFolder, "renderersettings.ini"));
RendererSettings.LoadSettings();
Tracer.WriteLine("Renderer settings loaded successfully.");
Tracer.WriteLine("Locating boards and providers ...");
WaveRecorder = new WaveRecorder();
Boards = new List<Board>();
public static List<IAudioProvider> AudioProviders { get; private set; }
var allTypes = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(ass => ass.GetTypes());
public static IVideoProvider VideoProvider { get; private set; }
foreach (var type in allTypes)
{
if (type.IsSubclassOf(typeof(Board)) && !type.IsAbstract)
{
Board board = Activator.CreateInstance(type) as Board;
Boards.Add(board);
Tracer.WriteLine("Board added: " + board.Name + " [ Mapper " + board.MapperNumber + "]");
}
else if (VideoProvider == null && typeof(IVideoProvider).IsAssignableFrom(type) && !type.IsAbstract)
{
IVideoProvider videoProvider = Activator.CreateInstance(type) as IVideoProvider;
VideoProvider = videoProvider;
Tracer.WriteLine("Video provider setuped: " + videoProvider.Name + " [" + videoProvider.ID + "]");
}
else if (typeof(IAudioProvider).IsAssignableFrom(type) && !type.IsAbstract)
{
IAudioProvider audioProvider = Activator.CreateInstance(type) as IAudioProvider;
AudioProvider = audioProvider;
Tracer.WriteLine("Audio provider setuped: " + audioProvider.Name + " [" + audioProvider.ID + "]");
}
}
public static IAudioProvider AudioProvider { get; private set; }
Tracer.WriteInformation("Done.");
Tracer.WriteInformation("Total of " + Boards.Count + " board found.");
SetVideoProvider();
SetAudioProvider();
SetRenderingMethods();
public static WaveRecorder WaveRecorder { get; private set; }
NesEmu.Initialize();
}
public static void Initialize(bool setupRenderers)
{
Tracer.WriteLine("Initializing My Nes Core ....");
AppPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
if (AppPath == "")
{
AppPath = Path.GetFullPath(".\\");
}
WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes");
Directory.CreateDirectory(WorkingFolder);
Tracer.WriteLine("Loading emu settings ...");
EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini"));
EmuSettings.LoadSettings();
Tracer.WriteLine("Emu settings loaded successfully.");
Tracer.WriteLine("Loading renderer settings ...");
RendererSettings = new RendererSettings(Path.Combine(WorkingFolder, "renderersettings.ini"));
RendererSettings.LoadSettings();
Tracer.WriteLine("Renderer settings loaded successfully.");
Tracer.WriteLine("Locating boards and providers ...");
WaveRecorder = new WaveRecorder();
Boards = new List<Board>();
VideoProviders = new List<IVideoProvider>();
AudioProviders = new List<IAudioProvider>();
string[] files = Directory.GetFiles(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]), "*", SearchOption.AllDirectories);
foreach (string text in files)
{
try
{
if (!(Path.GetExtension(text).ToLower() == ".exe") && !(Path.GetExtension(text).ToLower() == ".dll"))
{
continue;
}
Tracer.WriteLine("Reading assembly: " + text);
Assembly assembly = Assembly.LoadFile(text);
if (!(assembly != null))
{
continue;
}
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsSubclassOf(typeof(Board)) && !type.IsAbstract)
{
Board board = Activator.CreateInstance(type) as Board;
Boards.Add(board);
Tracer.WriteLine("Board added: " + board.Name + " [ Mapper " + board.MapperNumber + "]");
}
else if (type.GetInterface("MyNes.Core.IVideoProvider") != null)
{
IVideoProvider videoProvider = Activator.CreateInstance(type) as IVideoProvider;
VideoProviders.Add(videoProvider);
Tracer.WriteLine("Video provider added: " + videoProvider.Name + " [" + videoProvider.ID + "]");
}
else if (type.GetInterface("MyNes.Core.IAudioProvider") != null)
{
IAudioProvider audioProvider = Activator.CreateInstance(type) as IAudioProvider;
AudioProviders.Add(audioProvider);
Tracer.WriteLine("Audio provider added: " + audioProvider.Name + " [" + audioProvider.ID + "]");
}
}
}
catch (Exception ex)
{
Tracer.WriteLine("ERROR: " + ex.ToString());
}
}
Tracer.WriteInformation("Done.");
Tracer.WriteInformation("Total of " + Boards.Count + " board found.");
Tracer.WriteInformation("Total of " + VideoProviders.Count + " video provider found.");
Tracer.WriteInformation("Total of " + AudioProviders.Count + " audio provider found.");
if (setupRenderers)
{
SetVideoProvider();
SetAudioProvider();
SetRenderingMethods();
}
NesEmu.Initialize();
}
public static void Shutdown()
{
if (NesEmu.ON)
{
NesEmu.ShutDown();
}
if (VideoProvider != null)
{
VideoProvider.ShutDown();
}
if (AudioProvider != null)
{
AudioProvider.ShutDown();
}
Tracer.WriteLine("Saving settings ...");
EmuSettings.SaveSettings();
RendererSettings.SaveSettings();
Tracer.WriteLine("Settings saved successfully.");
Tracer.WriteLine("Exiting My Nes.");
}
public static void Shutdown()
{
if (NesEmu.ON)
{
NesEmu.ShutDown();
}
if (VideoProvider != null)
{
VideoProvider.ShutDown();
}
if (AudioProvider != null)
{
AudioProvider.ShutDown();
}
Tracer.WriteLine("Saving settings ...");
EmuSettings.SaveSettings();
RendererSettings.SaveSettings();
Tracer.WriteLine("Settings saved successfully.");
Tracer.WriteLine("Exiting My Nes.");
}
internal static bool IsBoardExist(int mapper)
{
foreach (Board board in Boards)
{
if (board.MapperNumber == mapper)
{
return true;
}
}
return false;
}
internal static bool IsBoardExist(int mapper)
{
foreach (Board board in Boards)
{
if (board.MapperNumber == mapper)
{
return true;
}
}
return false;
}
internal static Board GetBoard(int mapper)
{
foreach (Board board in Boards)
{
if (board.MapperNumber == mapper)
{
return board;
}
}
return null;
}
internal static Board GetBoard(int mapper)
{
foreach (Board board in Boards)
{
if (board.MapperNumber == mapper)
{
return board;
}
}
return null;
}
public static void MakeWorkingFolder()
{
WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes");
Directory.CreateDirectory(WorkingFolder);
}
public static void MakeWorkingFolder()
{
WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes");
Directory.CreateDirectory(WorkingFolder);
}
public static BoardInfoObject[] GetBoardsList(bool includeUnsupportedMappers)
{
List<BoardInfoObject> list = new List<BoardInfoObject>();
if (includeUnsupportedMappers)
{
for (int i = 0; i < 256; i++)
{
bool flag = false;
foreach (Board board in Boards)
{
if (board.MapperNumber == i)
{
BoardInfoObject boardInfoObject = new BoardInfoObject();
boardInfoObject.Name = board.Name;
boardInfoObject.MapperNumber = board.MapperNumber;
boardInfoObject.IsSupported = true;
boardInfoObject.HasIssues = board.HasIssues;
boardInfoObject.Issues = board.Issues;
list.Add(boardInfoObject);
flag = true;
break;
}
}
if (!flag)
{
BoardInfoObject boardInfoObject2 = new BoardInfoObject();
boardInfoObject2.Name = "N/A";
boardInfoObject2.MapperNumber = i;
boardInfoObject2.IsSupported = false;
boardInfoObject2.HasIssues = false;
boardInfoObject2.Issues = "";
list.Add(boardInfoObject2);
}
}
}
else
{
foreach (Board board2 in Boards)
{
if (board2.MapperNumber >= 0)
{
BoardInfoObject boardInfoObject3 = new BoardInfoObject();
boardInfoObject3.Name = board2.Name;
boardInfoObject3.MapperNumber = board2.MapperNumber;
boardInfoObject3.IsSupported = true;
boardInfoObject3.HasIssues = board2.HasIssues;
boardInfoObject3.Issues = board2.Issues;
list.Add(boardInfoObject3);
}
}
}
return list.ToArray();
}
public static BoardInfoObject[] GetBoardsList(bool includeUnsupportedMappers)
{
List<BoardInfoObject> list = new List<BoardInfoObject>();
if (includeUnsupportedMappers)
{
for (int i = 0; i < 256; i++)
{
bool flag = false;
foreach (Board board in Boards)
{
if (board.MapperNumber == i)
{
BoardInfoObject boardInfoObject = new BoardInfoObject();
boardInfoObject.Name = board.Name;
boardInfoObject.MapperNumber = board.MapperNumber;
boardInfoObject.IsSupported = true;
boardInfoObject.HasIssues = board.HasIssues;
boardInfoObject.Issues = board.Issues;
list.Add(boardInfoObject);
flag = true;
break;
}
}
if (!flag)
{
BoardInfoObject boardInfoObject2 = new BoardInfoObject();
boardInfoObject2.Name = "N/A";
boardInfoObject2.MapperNumber = i;
boardInfoObject2.IsSupported = false;
boardInfoObject2.HasIssues = false;
boardInfoObject2.Issues = "";
list.Add(boardInfoObject2);
}
}
}
else
{
foreach (Board board2 in Boards)
{
if (board2.MapperNumber >= 0)
{
BoardInfoObject boardInfoObject3 = new BoardInfoObject();
boardInfoObject3.Name = board2.Name;
boardInfoObject3.MapperNumber = board2.MapperNumber;
boardInfoObject3.IsSupported = true;
boardInfoObject3.HasIssues = board2.HasIssues;
boardInfoObject3.Issues = board2.Issues;
list.Add(boardInfoObject3);
}
}
}
return list.ToArray();
}
static void SetVideoProvider()
{
if (VideoProvider != null) VideoProvider.Initialize();
else Tracer.WriteError("VideoProvider is null");
}
public static IVideoProvider GetVideoProvider(string id)
{
foreach (IVideoProvider videoProvider in VideoProviders)
{
if (videoProvider.ID == id)
{
return videoProvider;
}
}
return null;
}
static void SetAudioProvider()
{
Tracer.WriteLine("Looking for the audio provider that set in the settings...");
if (AudioProvider != null) AudioProvider.Initialize();
else Tracer.WriteError("AudioProvider is null");
}
public static IAudioProvider GetAudioProvider(string id)
{
foreach (IAudioProvider audioProvider in AudioProviders)
{
if (audioProvider.ID == id)
{
return audioProvider;
}
}
return null;
}
static void SetRenderingMethods()
{
if (VideoProvider != null && AudioProvider != null)
{
NesEmu.SetupRenderingMethods(VideoProvider.SubmitFrame, AudioProvider.SubmitSamples, AudioProvider.TogglePause, AudioProvider.GetIsPlaying);
}
else
{
Tracer.WriteError("ERROR: unable to setup rendering methods, one (or both) of the providers is not set (video and/or audio provider)");
}
}
public static void SetVideoProvider()
{
Tracer.WriteLine("Looking for the video provider that set in the settings...");
VideoProvider = GetVideoProvider(RendererSettings.Video_ProviderID);
if (VideoProvider == null)
{
Tracer.WriteError("ERROR: cannot find the video provider that set in the settings");
Tracer.WriteWarning("Deciding video provider");
if (VideoProviders.Count > 0)
{
RendererSettings.Video_ProviderID = VideoProviders[0].ID;
VideoProvider = VideoProviders[0];
if (VideoProvider != null)
{
Tracer.WriteInformation("Video provider set to " + VideoProvider.Name + " [" + VideoProvider.ID + "]");
VideoProvider.Initialize();
}
else
{
Tracer.WriteError("ERROR: cannot set video provider.");
}
}
else
{
Tracer.WriteError("ERROR: cannot set video provider, no video providers located.");
}
}
else
{
Tracer.WriteInformation("Video provider set to " + VideoProvider.Name + " [" + VideoProvider.ID + "]");
VideoProvider.Initialize();
}
}
public static void SetAudioProvider()
{
Tracer.WriteLine("Looking for the audio provider that set in the settings...");
AudioProvider = GetAudioProvider(RendererSettings.Audio_ProviderID);
if (AudioProvider == null)
{
Tracer.WriteError("ERROR: cannot find the audio provider that set in the settings");
Tracer.WriteWarning("Deciding audio provider");
if (AudioProviders.Count > 0)
{
RendererSettings.Audio_ProviderID = AudioProviders[0].ID;
AudioProvider = AudioProviders[0];
if (AudioProvider != null)
{
Tracer.WriteInformation("Audio provider set to " + AudioProvider.Name + " [" + AudioProvider.ID + "]");
AudioProvider.Initialize();
}
else
{
Tracer.WriteError("ERROR: cannot set audio provider.");
}
}
else
{
Tracer.WriteError("ERROR: cannot set audio provider, no audio providers located.");
}
}
else
{
Tracer.WriteInformation("Audio provider set to " + AudioProvider.Name + " [" + AudioProvider.ID + "]");
AudioProvider.Initialize();
}
}
public static void SetRenderingMethods()
{
if (VideoProvider != null && AudioProvider != null)
{
NesEmu.SetupRenderingMethods(VideoProvider.SubmitFrame, AudioProvider.SubmitSamples, AudioProvider.TogglePause, AudioProvider.GetIsPlaying);
}
else
{
Tracer.WriteError("ERROR: unable to setup rendering methods, one (or both) of the providers is not set (video and/or audio provider)");
}
}
public static void RecordWave()
{
if (NesEmu.ON && NesEmu.SoundEnabled)
{
string text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + ".wav");
int num = 0;
while (File.Exists(text))
{
text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + "_" + num + ".wav");
num++;
}
WaveRecorder.Record(text, 1, 16, RendererSettings.Audio_Frequency);
}
else if (VideoProvider != null)
{
VideoProvider.WriteErrorNotification("Cannot record sound when the emu is off/sound is not enabled.", instant: false);
}
}
public static void RecordWave()
{
if (NesEmu.ON && NesEmu.SoundEnabled)
{
string text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + ".wav");
int num = 0;
while (File.Exists(text))
{
text = Path.Combine(EmuSettings.WavesFolder, Path.GetFileNameWithoutExtension(NesEmu.CurrentFilePath) + "_" + num + ".wav");
num++;
}
WaveRecorder.Record(text, 1, 16, RendererSettings.Audio_Frequency);
}
else if (VideoProvider != null)
{
VideoProvider.WriteErrorNotification("Cannot record sound when the emu is off/sound is not enabled.", instant: false);
}
}
}
public interface IFileManager
{
string GetWorkingFolderPath();
public Stream OpenDatabaseFile();
public Stream OpenPaletteFile();
}
}

View File

@ -6,325 +6,322 @@ namespace MyNes.Core
{
public class NesCartDatabase
{
private static List<NesCartDatabaseGameInfo> _databaseRoms = new List<NesCartDatabaseGameInfo>();
private static List<NesCartDatabaseGameInfo> _databaseRoms = new List<NesCartDatabaseGameInfo>();
public static string DBVersion = "";
public static string DBVersion = "";
public static string DBConformance = "";
public static string DBConformance = "";
public static string DBAgent = "";
public static string DBAgent = "";
public static string DBAuthor = "";
public static string DBAuthor = "";
public static string DBTimeStamp = "";
public static string DBTimeStamp = "";
public static bool Ready = false;
public static bool Ready = false;
public static List<NesCartDatabaseGameInfo> DatabaseRoms => _databaseRoms;
public static List<NesCartDatabaseGameInfo> DatabaseRoms => _databaseRoms;
public static void LoadDatabase(string fileName, out bool success)
{
success = false;
Ready = false;
if (!File.Exists(fileName))
{
return;
}
_databaseRoms.Clear();
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore;
xmlReaderSettings.IgnoreWhitespace = true;
XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings);
NesCartDatabaseGameInfo nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo);
nesCartDatabaseGameInfo.Cartridges = new List<NesCartDatabaseCartridgeInfo>();
nesCartDatabaseGameInfo.Game_AltName = "";
nesCartDatabaseGameInfo.Game_Catalog = "";
nesCartDatabaseGameInfo.Game_Class = "";
nesCartDatabaseGameInfo.Game_Developer = "";
nesCartDatabaseGameInfo.Game_Name = "";
nesCartDatabaseGameInfo.Game_Players = "";
nesCartDatabaseGameInfo.Game_Publisher = "";
nesCartDatabaseGameInfo.Game_Region = "";
nesCartDatabaseGameInfo.Game_ReleaseDate = "";
while (xmlReader.Read())
{
if ((xmlReader.Name == "xml") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("version"))
{
DBVersion = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("conformance"))
{
DBConformance = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("agent"))
{
DBAgent = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("author"))
{
DBAuthor = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("timestamp"))
{
DBTimeStamp = xmlReader.Value;
}
}
else
{
if (!((xmlReader.Name == "game") & xmlReader.IsStartElement()))
{
continue;
}
nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo);
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseGameInfo.Game_Name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("altname"))
{
nesCartDatabaseGameInfo.Game_AltName = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("class"))
{
nesCartDatabaseGameInfo.Game_Class = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("catalog"))
{
nesCartDatabaseGameInfo.Game_Catalog = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("publisher"))
{
nesCartDatabaseGameInfo.Game_Publisher = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("developer"))
{
nesCartDatabaseGameInfo.Game_Developer = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("region"))
{
nesCartDatabaseGameInfo.Game_Region = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("players"))
{
nesCartDatabaseGameInfo.Game_Players = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("date"))
{
nesCartDatabaseGameInfo.Game_ReleaseDate = xmlReader.Value;
}
NesCartDatabaseCartridgeInfo nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo();
nesCartDatabaseCartridgeInfo.PAD_h = "";
nesCartDatabaseCartridgeInfo.PAD_v = "";
nesCartDatabaseCartridgeInfo.PRG_crc = "";
nesCartDatabaseCartridgeInfo.PRG_name = "";
nesCartDatabaseCartridgeInfo.PRG_sha1 = "";
nesCartDatabaseCartridgeInfo.PRG_size = "";
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
nesCartDatabaseCartridgeInfo.CHR_crc = "";
nesCartDatabaseCartridgeInfo.CHR_name = "";
nesCartDatabaseCartridgeInfo.CHR_sha1 = "";
nesCartDatabaseCartridgeInfo.CHR_size = "";
nesCartDatabaseCartridgeInfo.CIC_type = "";
nesCartDatabaseCartridgeInfo.Board_Mapper = "";
nesCartDatabaseCartridgeInfo.Board_Pcb = "";
nesCartDatabaseCartridgeInfo.Board_Type = "";
nesCartDatabaseCartridgeInfo.VRAM_sizes = new List<string>();
nesCartDatabaseCartridgeInfo.WRAMBanks = new List<SRAMBankInfo>();
while (xmlReader.Read())
{
if ((xmlReader.Name == "game") & !xmlReader.IsStartElement())
{
_databaseRoms.Add(nesCartDatabaseGameInfo);
break;
}
if ((xmlReader.Name == "cartridge") & xmlReader.IsStartElement())
{
if (nesCartDatabaseGameInfo.Cartridges == null)
{
nesCartDatabaseGameInfo.Cartridges = new List<NesCartDatabaseCartridgeInfo>();
}
nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo();
nesCartDatabaseCartridgeInfo.PAD_h = "";
nesCartDatabaseCartridgeInfo.PAD_v = "";
nesCartDatabaseCartridgeInfo.PRG_crc = "";
nesCartDatabaseCartridgeInfo.PRG_name = "";
nesCartDatabaseCartridgeInfo.PRG_sha1 = "";
nesCartDatabaseCartridgeInfo.PRG_size = "";
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
nesCartDatabaseCartridgeInfo.CHR_crc = "";
nesCartDatabaseCartridgeInfo.CHR_name = "";
nesCartDatabaseCartridgeInfo.CHR_sha1 = "";
nesCartDatabaseCartridgeInfo.CHR_size = "";
nesCartDatabaseCartridgeInfo.CIC_type = "";
nesCartDatabaseCartridgeInfo.Board_Mapper = "";
nesCartDatabaseCartridgeInfo.Board_Pcb = "";
nesCartDatabaseCartridgeInfo.Board_Type = "";
nesCartDatabaseCartridgeInfo.VRAM_sizes = new List<string>();
nesCartDatabaseCartridgeInfo.WRAMBanks = new List<SRAMBankInfo>();
if (xmlReader.MoveToAttribute("system"))
{
nesCartDatabaseCartridgeInfo.System = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.CRC = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.SHA1 = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("dump"))
{
nesCartDatabaseCartridgeInfo.Dump = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("dumper"))
{
nesCartDatabaseCartridgeInfo.Dumper = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("datedumped"))
{
nesCartDatabaseCartridgeInfo.DateDumped = xmlReader.Value;
}
}
else if ((xmlReader.Name == "cartridge") & !xmlReader.IsStartElement())
{
nesCartDatabaseGameInfo.Cartridges.Add(nesCartDatabaseCartridgeInfo);
}
else if ((xmlReader.Name == "board") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
nesCartDatabaseCartridgeInfo.Board_Type = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("pcb"))
{
nesCartDatabaseCartridgeInfo.Board_Pcb = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("mapper"))
{
nesCartDatabaseCartridgeInfo.Board_Mapper = xmlReader.Value;
}
}
else if ((xmlReader.Name == "prg") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseCartridgeInfo.PRG_name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.PRG_size = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.PRG_crc = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.PRG_sha1 = xmlReader.Value;
}
}
else if ((xmlReader.Name == "chr") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseCartridgeInfo.CHR_name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.CHR_size = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.CHR_crc = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.CHR_sha1 = xmlReader.Value;
}
}
else if ((xmlReader.Name == "vram") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.VRAM_sizes.Add(xmlReader.Value);
}
}
else if ((xmlReader.Name == "wram") & xmlReader.IsStartElement())
{
string sIZE = "";
bool bATTERY = false;
int result = 0;
if (xmlReader.MoveToAttribute("size"))
{
sIZE = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("battery"))
{
bATTERY = xmlReader.Value == "1";
}
if (xmlReader.MoveToAttribute("id"))
{
int.TryParse(xmlReader.Value, out result);
}
nesCartDatabaseCartridgeInfo.WRAMBanks.Add(new SRAMBankInfo(result, sIZE, bATTERY));
}
else if ((xmlReader.Name == "chip") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
if (nesCartDatabaseCartridgeInfo.chip_type == null)
{
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
}
nesCartDatabaseCartridgeInfo.chip_type.Add(xmlReader.Value);
}
}
else if ((xmlReader.Name == "cic") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
nesCartDatabaseCartridgeInfo.CIC_type = xmlReader.Value;
}
}
else if ((xmlReader.Name == "pad") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("h"))
{
nesCartDatabaseCartridgeInfo.PAD_h = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("v"))
{
nesCartDatabaseCartridgeInfo.PAD_v = xmlReader.Value;
}
}
}
}
}
Ready = true;
success = true;
xmlReader.Close();
stream.Close();
}
public static void LoadDatabase(out bool success)
{
success = false;
Ready = false;
_databaseRoms.Clear();
public static NesCartDatabaseGameInfo Find(string Cart_sha1, out bool found)
{
found = false;
foreach (NesCartDatabaseGameInfo databaseRom in _databaseRoms)
{
foreach (NesCartDatabaseCartridgeInfo cartridge in databaseRom.Cartridges)
{
if (cartridge.SHA1.ToLower() == Cart_sha1.ToLower())
{
found = true;
return databaseRom;
}
}
}
return default(NesCartDatabaseGameInfo);
}
var stream = MyNesMain.FileManager.OpenDatabaseFile();
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore;
xmlReaderSettings.IgnoreWhitespace = true;
XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings);
NesCartDatabaseGameInfo nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo);
nesCartDatabaseGameInfo.Cartridges = new List<NesCartDatabaseCartridgeInfo>();
nesCartDatabaseGameInfo.Game_AltName = "";
nesCartDatabaseGameInfo.Game_Catalog = "";
nesCartDatabaseGameInfo.Game_Class = "";
nesCartDatabaseGameInfo.Game_Developer = "";
nesCartDatabaseGameInfo.Game_Name = "";
nesCartDatabaseGameInfo.Game_Players = "";
nesCartDatabaseGameInfo.Game_Publisher = "";
nesCartDatabaseGameInfo.Game_Region = "";
nesCartDatabaseGameInfo.Game_ReleaseDate = "";
while (xmlReader.Read())
{
if ((xmlReader.Name == "xml") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("version"))
{
DBVersion = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("conformance"))
{
DBConformance = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("agent"))
{
DBAgent = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("author"))
{
DBAuthor = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("timestamp"))
{
DBTimeStamp = xmlReader.Value;
}
}
else
{
if (!((xmlReader.Name == "game") & xmlReader.IsStartElement()))
{
continue;
}
nesCartDatabaseGameInfo = default(NesCartDatabaseGameInfo);
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseGameInfo.Game_Name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("altname"))
{
nesCartDatabaseGameInfo.Game_AltName = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("class"))
{
nesCartDatabaseGameInfo.Game_Class = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("catalog"))
{
nesCartDatabaseGameInfo.Game_Catalog = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("publisher"))
{
nesCartDatabaseGameInfo.Game_Publisher = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("developer"))
{
nesCartDatabaseGameInfo.Game_Developer = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("region"))
{
nesCartDatabaseGameInfo.Game_Region = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("players"))
{
nesCartDatabaseGameInfo.Game_Players = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("date"))
{
nesCartDatabaseGameInfo.Game_ReleaseDate = xmlReader.Value;
}
NesCartDatabaseCartridgeInfo nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo();
nesCartDatabaseCartridgeInfo.PAD_h = "";
nesCartDatabaseCartridgeInfo.PAD_v = "";
nesCartDatabaseCartridgeInfo.PRG_crc = "";
nesCartDatabaseCartridgeInfo.PRG_name = "";
nesCartDatabaseCartridgeInfo.PRG_sha1 = "";
nesCartDatabaseCartridgeInfo.PRG_size = "";
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
nesCartDatabaseCartridgeInfo.CHR_crc = "";
nesCartDatabaseCartridgeInfo.CHR_name = "";
nesCartDatabaseCartridgeInfo.CHR_sha1 = "";
nesCartDatabaseCartridgeInfo.CHR_size = "";
nesCartDatabaseCartridgeInfo.CIC_type = "";
nesCartDatabaseCartridgeInfo.Board_Mapper = "";
nesCartDatabaseCartridgeInfo.Board_Pcb = "";
nesCartDatabaseCartridgeInfo.Board_Type = "";
nesCartDatabaseCartridgeInfo.VRAM_sizes = new List<string>();
nesCartDatabaseCartridgeInfo.WRAMBanks = new List<SRAMBankInfo>();
while (xmlReader.Read())
{
if ((xmlReader.Name == "game") & !xmlReader.IsStartElement())
{
_databaseRoms.Add(nesCartDatabaseGameInfo);
break;
}
if ((xmlReader.Name == "cartridge") & xmlReader.IsStartElement())
{
if (nesCartDatabaseGameInfo.Cartridges == null)
{
nesCartDatabaseGameInfo.Cartridges = new List<NesCartDatabaseCartridgeInfo>();
}
nesCartDatabaseCartridgeInfo = new NesCartDatabaseCartridgeInfo();
nesCartDatabaseCartridgeInfo.PAD_h = "";
nesCartDatabaseCartridgeInfo.PAD_v = "";
nesCartDatabaseCartridgeInfo.PRG_crc = "";
nesCartDatabaseCartridgeInfo.PRG_name = "";
nesCartDatabaseCartridgeInfo.PRG_sha1 = "";
nesCartDatabaseCartridgeInfo.PRG_size = "";
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
nesCartDatabaseCartridgeInfo.CHR_crc = "";
nesCartDatabaseCartridgeInfo.CHR_name = "";
nesCartDatabaseCartridgeInfo.CHR_sha1 = "";
nesCartDatabaseCartridgeInfo.CHR_size = "";
nesCartDatabaseCartridgeInfo.CIC_type = "";
nesCartDatabaseCartridgeInfo.Board_Mapper = "";
nesCartDatabaseCartridgeInfo.Board_Pcb = "";
nesCartDatabaseCartridgeInfo.Board_Type = "";
nesCartDatabaseCartridgeInfo.VRAM_sizes = new List<string>();
nesCartDatabaseCartridgeInfo.WRAMBanks = new List<SRAMBankInfo>();
if (xmlReader.MoveToAttribute("system"))
{
nesCartDatabaseCartridgeInfo.System = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.CRC = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.SHA1 = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("dump"))
{
nesCartDatabaseCartridgeInfo.Dump = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("dumper"))
{
nesCartDatabaseCartridgeInfo.Dumper = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("datedumped"))
{
nesCartDatabaseCartridgeInfo.DateDumped = xmlReader.Value;
}
}
else if ((xmlReader.Name == "cartridge") & !xmlReader.IsStartElement())
{
nesCartDatabaseGameInfo.Cartridges.Add(nesCartDatabaseCartridgeInfo);
}
else if ((xmlReader.Name == "board") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
nesCartDatabaseCartridgeInfo.Board_Type = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("pcb"))
{
nesCartDatabaseCartridgeInfo.Board_Pcb = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("mapper"))
{
nesCartDatabaseCartridgeInfo.Board_Mapper = xmlReader.Value;
}
}
else if ((xmlReader.Name == "prg") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseCartridgeInfo.PRG_name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.PRG_size = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.PRG_crc = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.PRG_sha1 = xmlReader.Value;
}
}
else if ((xmlReader.Name == "chr") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("name"))
{
nesCartDatabaseCartridgeInfo.CHR_name = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.CHR_size = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("crc"))
{
nesCartDatabaseCartridgeInfo.CHR_crc = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("sha1"))
{
nesCartDatabaseCartridgeInfo.CHR_sha1 = xmlReader.Value;
}
}
else if ((xmlReader.Name == "vram") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("size"))
{
nesCartDatabaseCartridgeInfo.VRAM_sizes.Add(xmlReader.Value);
}
}
else if ((xmlReader.Name == "wram") & xmlReader.IsStartElement())
{
string sIZE = "";
bool bATTERY = false;
int result = 0;
if (xmlReader.MoveToAttribute("size"))
{
sIZE = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("battery"))
{
bATTERY = xmlReader.Value == "1";
}
if (xmlReader.MoveToAttribute("id"))
{
int.TryParse(xmlReader.Value, out result);
}
nesCartDatabaseCartridgeInfo.WRAMBanks.Add(new SRAMBankInfo(result, sIZE, bATTERY));
}
else if ((xmlReader.Name == "chip") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
if (nesCartDatabaseCartridgeInfo.chip_type == null)
{
nesCartDatabaseCartridgeInfo.chip_type = new List<string>();
}
nesCartDatabaseCartridgeInfo.chip_type.Add(xmlReader.Value);
}
}
else if ((xmlReader.Name == "cic") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("type"))
{
nesCartDatabaseCartridgeInfo.CIC_type = xmlReader.Value;
}
}
else if ((xmlReader.Name == "pad") & xmlReader.IsStartElement())
{
if (xmlReader.MoveToAttribute("h"))
{
nesCartDatabaseCartridgeInfo.PAD_h = xmlReader.Value;
}
if (xmlReader.MoveToAttribute("v"))
{
nesCartDatabaseCartridgeInfo.PAD_v = xmlReader.Value;
}
}
}
}
}
Ready = true;
success = true;
xmlReader.Close();
stream.Close();
}
public static NesCartDatabaseGameInfo Find(string Cart_sha1, out bool found)
{
found = false;
foreach (NesCartDatabaseGameInfo databaseRom in _databaseRoms)
{
foreach (NesCartDatabaseCartridgeInfo cartridge in databaseRom.Cartridges)
{
if (cartridge.SHA1.ToLower() == Cart_sha1.ToLower())
{
found = true;
return databaseRom;
}
}
}
return default(NesCartDatabaseGameInfo);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,9 @@ namespace MyNes.Core
{
public class PaletteFileWrapper
{
public static bool LoadFile(string file, out int[] palette)
public static bool LoadFile(Stream fileStream, out int[] palette)
{
Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read);
Stream stream = fileStream;
if (stream.Length == 192 || stream.Length == 1536)
{
int[] array = new int[512];

View File

@ -96,8 +96,6 @@ namespace MyNes.Core
public int Palette_PaletteSetting;
public string Palette_CurrentPaletteFilePath = "default_ntsc.pal";
public float Palette_NTSC_brightness = 1.075f;
public float Palette_NTSC_contrast = 1.016f;
@ -122,15 +120,5 @@ namespace MyNes.Core
: base(path)
{
}
public override void LoadSettings()
{
base.LoadSettings();
if (Palette_CurrentPaletteFilePath == "default_ntsc.pal" || Palette_CurrentPaletteFilePath == "" || !File.Exists(Palette_CurrentPaletteFilePath))
{
Palette_CurrentPaletteFilePath = Path.Combine(MyNesMain.AppPath, "Palettes");
Palette_CurrentPaletteFilePath = Path.Combine(Palette_CurrentPaletteFilePath, "default_ntsc.pal");
}
}
}
}

View File

@ -23,13 +23,24 @@ namespace MyNes.Core
public static void WriteLine(string message, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status));
Debug.Log(message);
switch (status)
{
case TracerStatus.Error: Debug.LogError(message); break;
case TracerStatus.Infromation:
case TracerStatus.Normal:
Debug.Log(message);
break;
case TracerStatus.Warning:
Debug.LogWarning(message);
break;
}
}
public static void WriteLine(string message, string category, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status));
Debug.Log($"{category}:{message}");
WriteLine($"{category}:{message}", status);
}
public static void WriteError(string message)

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e2c2fc792e914ba4da5671edcb233994
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e5e5b73f8ff71745806799d6c3a97b6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 66c9b7bb9e78e2149a8c6b884e7814dc
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e7c963ec91faede48bdbc4c837d184c1
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f90e9c85a73ad3649a73f6b5c66ee21c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 79fd9783decf96349b1bbdf3cd49d01e
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cffbaa9e5c24d7b4aa3e27fcbe59a880
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4a281e2c6edff1f4a8574e1429fef097
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: acc05b5c291ed1c4fb812b7be20b8113
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: eae5c00585ff5ad4da5ff743aa7cb388
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dbea537bf3d26ef469d311366274b854
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: af0c6ae054b9b8b4eb1e950615e9666d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c87310fabe238424d8bc9b8cf5e06a1a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cd2c5883bfccfea41adc9d73a6f509de
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3e8bf825b3645ab47a1e3db5f98d65f0
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ac166adb93cefee48bf472799c28f078
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a4866a9e921def74f88bc9c76182d4bf
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db03b2f58578ecb4c8af8c69a62cc6e4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ae891fd90c634b64aa8d3bed26c9a130
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9a6da4c0ffb86d749b681f8a9d4403fd
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f1d9aa9ac67469d49b197ce086e00b86
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1dc183e92926f564a90573e275d7b470
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c53b7ab773a22634bbe5c6a1ac794f54
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -26,6 +26,7 @@ RenderTexture:
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_EnableRandomWrite: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1

View File

@ -151,7 +151,8 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 786008058}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &258485948
@ -166,6 +167,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ac8cd27a180bf3e489b2ca27c821bffe, type: 3}
m_Name:
m_EditorClassIdentifier:
DrawImage: {fileID: 730321751}
DO: {fileID: 1379369700}
Fps: {fileID: 1680039028}
--- !u!1 &708549044
GameObject:
m_ObjectHideFlags: 0
@ -260,6 +264,182 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &730321748
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 730321749}
- component: {fileID: 730321752}
- component: {fileID: 730321751}
m_Layer: 5
m_Name: video
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &730321749
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730321748}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: -1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 786008058}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &730321751
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730321748}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &730321752
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730321748}
m_CullTransparentMesh: 1
--- !u!1 &786008057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 786008058}
- component: {fileID: 786008061}
- component: {fileID: 786008060}
- component: {fileID: 786008059}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &786008058
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 786008057}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 730321749}
- {fileID: 1680039031}
- {fileID: 1379369698}
m_Father: {fileID: 258485947}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &786008059
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 786008057}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &786008060
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 786008057}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &786008061
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 786008057}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!1 &1232273651
GameObject:
m_ObjectHideFlags: 0
@ -352,6 +532,314 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1359344831
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1359344834}
- component: {fileID: 1359344833}
- component: {fileID: 1359344832}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1359344832
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1359344831}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1359344833
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1359344831}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1359344834
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1359344831}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1379369697
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1379369698}
- component: {fileID: 1379369699}
- component: {fileID: 1379369700}
m_Layer: 5
m_Name: Audio
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1379369698
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379369697}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: -1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 786008058}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!82 &1379369699
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379369697}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &1379369700
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379369697}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f25db9f5a7339c34f94e6e978be38c82, type: 3}
m_Name:
m_EditorClassIdentifier:
Gain: 0.05
--- !u!1 &1680039027
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1680039031}
- component: {fileID: 1680039030}
- component: {fileID: 1680039028}
- component: {fileID: 1680039029}
m_Layer: 5
m_Name: fps
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1680039028
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1680039027}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 12324234
--- !u!114 &1680039029
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1680039027}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 2
--- !u!222 &1680039030
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1680039027}
m_CullTransparentMesh: 1
--- !u!224 &1680039031
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1680039027}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 786008058}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 1, y: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
@ -359,3 +847,4 @@ SceneRoots:
- {fileID: 1232273654}
- {fileID: 708549046}
- {fileID: 258485947}
- {fileID: 1359344834}

View File

@ -0,0 +1,72 @@
using MyNes.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.Profiling;
namespace AxibugEmuOnline.Client
{
public class AudioProvider : IAudioProvider
{
public string Name => nameof(AudioProvider);
public string ID => Name.GetHashCode().ToString();
public bool AllowBufferChange => true;
public bool AllowFrequencyChange => true;
private bool m_isPlaying;
private int samples_added;
private Queue<(float[], int)> queues = new Queue<(float[], int)>();
public void Initialize()
{
}
public void SubmitSamples(ref short[] buffer, ref int samples_a)
{
NesCoreProxy.Instance.DO.Play(buffer.Take(samples_a).SelectMany(s => toBytes(s)).ToArray());
}
public byte[] toBytes(short value)
{
byte[] temp = new byte[2];
//temp[0] = (byte)(value >> 8);
temp[0] = temp[1] = (byte)((uint)value & 0xFFu);
return temp;
}
public void TogglePause(bool paused)
{
m_isPlaying = !paused;
}
public void GetIsPlaying(out bool playing)
{
playing = m_isPlaying;
}
public void ShutDown()
{
}
public void Reset()
{
}
public void SignalToggle(bool started)
{
}
public void SetVolume(int Vol)
{
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ed2bba3664d14d840a5ed2847926614c
guid: 765129d4fad76714191795975893ea9c
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class DefaultAudioOutput : MonoBehaviour
{
public float Gain = 0.05f;
private int _samplesAvailable;
private PipeStream _pipeStream;
private byte[] _buffer;
void Awake()
{
// Get Unity Buffer size
int bufferLength = 0, numBuffers = 0;
AudioSettings.GetDSPBufferSize(out bufferLength, out numBuffers);
_samplesAvailable = bufferLength;
// Prepare our buffer
_pipeStream = new PipeStream();
_pipeStream.MaxBufferLength = _samplesAvailable * 2 * 2;
_buffer = new byte[_samplesAvailable * 2];
}
List<byte> waveBytes = new List<byte>();
void OnAudioFilterRead(float[] data, int channels)
{
// This method is not called if you don't own Unity PRO.
if (_buffer.Length != data.Length)
{
Debug.Log("Does DSPBufferSize or speakerMode changed? Audio disabled.");
return;
}
int r = _pipeStream.Read(_buffer, 0, data.Length);
for (int i = 0; i < r; ++i)
{
var normalize = (sbyte)(_buffer[i]) / 127f;
data[i] = Gain * normalize;
waveBytes.Add(_buffer[i]);
}
}
private void OnDestroy()
{
File.WriteAllBytes("e:/wav.wav", waveBytes.ToArray());
}
public int GetOutputSampleRate()
{
return AudioSettings.outputSampleRate;
}
public int GetSamplesAvailable()
{
return _samplesAvailable;
}
public void Play(byte[] data)
{
_pipeStream.Write(data, 0, data.Length);
}
private class PipeStream : Stream
{
private readonly Queue<byte> _buffer = new Queue<byte>();
private long _maxBufferLength = 8192;
public long MaxBufferLength
{
get { return _maxBufferLength; }
set { _maxBufferLength = value; }
}
public new void Dispose()
{
_buffer.Clear();
}
public override void Flush()
{
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
if (offset != 0)
throw new NotImplementedException("Offsets with value of non-zero are not supported");
if (buffer == null)
throw new ArgumentException("Buffer is null");
if (offset + count > buffer.Length)
throw new ArgumentException("The sum of offset and count is greater than the buffer length. ");
if (offset < 0 || count < 0)
throw new ArgumentOutOfRangeException("offset", "offset or count is negative.");
if (count == 0)
return 0;
int readLength = 0;
lock (_buffer)
{
// fill the read buffer
for (; readLength < count && Length > 0; readLength++)
{
buffer[readLength] = _buffer.Dequeue();
}
}
return readLength;
}
private bool ReadAvailable(int count)
{
return (Length >= count);
}
public override void Write(byte[] buffer, int offset, int count)
{
if (buffer == null)
throw new ArgumentException("Buffer is null");
if (offset + count > buffer.Length)
throw new ArgumentException("The sum of offset and count is greater than the buffer length. ");
if (offset < 0 || count < 0)
throw new ArgumentOutOfRangeException("offset", "offset or count is negative.");
if (count == 0)
return;
lock (_buffer)
{
while (Length >= _maxBufferLength)
return;
// queue up the buffer data
foreach (byte b in buffer)
{
_buffer.Enqueue(b);
}
}
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{
get { return true; }
}
public override long Length
{
get { return _buffer.Count; }
}
public override long Position
{
get { return 0; }
set { throw new NotImplementedException(); }
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f25db9f5a7339c34f94e6e978be38c82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,111 @@
using MyNes.Core;
using System;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
public class UguiVideoProvider : IVideoProvider
{
public string Name => "Unity UI Video";
public string ID => nameof(UguiVideoProvider).GetHashCode().ToString();
private int[] m_texRawBuffer = new int[256 * 240];
private Texture2D m_rawBufferWarper = new Texture2D(256, 240);
private RawImage m_image;
private RenderTexture m_drawRT;
public void Initialize()
{
m_image = NesCoreProxy.Instance.DrawImage;
m_image.texture = RenderTexture.GetTemporary(256, 240, 0, UnityEngine.Experimental.Rendering.GraphicsFormat.B8G8R8A8_UNorm);
}
public Color GetColor(uint value)
{
var r = 0xFF0000 & value;
r >>= 16;
var b = 0xFF & value;
var g = 0xFF00 & value;
g >>= 8;
var color = new Color(r / 255f, g / 255f, b / 255f);
return color;
}
public void Draw()
{
var colors = m_texRawBuffer.Select(w => GetColor((uint)w)).ToArray();
m_rawBufferWarper.SetPixels(colors);
m_rawBufferWarper.Apply();
Graphics.Blit(m_rawBufferWarper, m_image.texture as RenderTexture);
}
public void WriteErrorNotification(string message, bool instant)
{
}
public void WriteInfoNotification(string message, bool instant)
{
}
public void WriteWarningNotification(string message, bool instant)
{
}
public void TakeSnapshotAs(string path, string format)
{
}
public void TakeSnapshot()
{
}
public void ShutDown()
{
}
public void SignalToggle(bool started)
{
}
public void SubmitFrame(ref int[] buffer)
{
Array.Copy(buffer, m_texRawBuffer, m_texRawBuffer.Length);
}
public void ResizeBegin()
{
}
public void ResizeEnd()
{
}
public void ApplyRegionChanges()
{
}
public void Resume()
{
}
public void ToggleAspectRatio(bool keep_aspect)
{
}
public void ToggleFPS(bool show_fps)
{
}
public void ApplyFilter()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2632911774df3c488ec24b39651c4de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,100 +0,0 @@
using System.Reflection;
using MyNes.Core;
namespace AxibugEmuOnline.Client
{
public class WINSettings : ISettings
{
public string App_Version = "";
public int Win_Location_X = 10;
public int Win_Location_Y = 10;
public int Win_Size_W = 768;
public int Win_Size_H = 743;
public bool Win_StartInFullscreen;
public string[] Misc_RecentFiles = new string[0];
public bool PauseEmuWhenFocusLost = true;
public bool ShowGettingStarted = true;
public string InterfaceLanguage = "English";
public bool ShutdowOnEscapePress = true;
public bool LoadStateOpenRecent;
public string Database_FilePath = "";
public string[] Database_FoldersSnapshots;
public string[] Database_FoldersCovers;
public string[] Database_FoldersInfos;
public string[] Database_FoldersScanned;
public bool LauncherRememberLastSelection = true;
public int LauncherLatestSelection;
public int LauncherLocationX = 10;
public int LauncherLocationY = 10;
public int LauncherSizeW = 1480;
public int LauncherSizeH = 920;
public int LauncherSpliter1 = 807;
public int LauncherSpliter2 = 420;
public int LauncherSpliter3 = 308;
public int LauncherSpliter4 = 271;
public bool LauncherAutoMinimize = true;
public bool LauncherAutoCycleImagesInGameTab = true;
public bool LauncherShowAyAppStart;
public int SnapsView_ImageMode = 1;
public bool SnapsView_ShowBar = true;
public bool SnapsView_ShowStatus = true;
public bool SnapsView_AutoCycle = true;
public int CoversView_ImageMode = 1;
public bool CoversView_ShowBar = true;
public bool CoversView_ShowStatus = true;
public bool CoversView_AutoCycle = true;
public WINSettings(string path)
: base(path)
{
}
public override void LoadSettings()
{
base.LoadSettings();
if (App_Version != Assembly.GetExecutingAssembly().GetName().Version.ToString())
{
ShowGettingStarted = true;
App_Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
}
}

View File

@ -1,22 +1,55 @@
using MyNes.Core;
using Palmmedia.ReportGenerator.Core;
using SevenZip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Threading;
using UnityEngine;
namespace AxibugEmuOnline.Client.Manager
{
public class AppEmu
{
public class AppEmu : IFileManager
{
public UguiVideoProvider UguiVideo { get; private set; }
public AudioProvider Audio { get; private set; }
public void Init()
{
MyNesMain.Initialize(setupRenderers: false);
MyNesMain.SetVideoProvider();
MyNesMain.SetAudioProvider();
MyNesMain.SetRenderingMethods();
}
MyNesMain.Initialize(this);
NesEmu.LoadGame("E:/rzg4.nes", out var successed, true);
UguiVideo = MyNesMain.VideoProvider as UguiVideoProvider;
Audio = MyNesMain.AudioProvider as AudioProvider;
var fps_nes_missle = 1.0 / 59.0;
NesEmu.SetFramePeriod(ref fps_nes_missle);
}
public void Update()
{
UguiVideo.Draw();
double t = Time.deltaTime;
NesEmu.SetFramePeriod(ref t);
}
public void Dispose()
{
MyNesMain.Shutdown();
}
public Stream OpenDatabaseFile()
{
var databaseFile = Resources.Load<TextAsset>("NesCoreRes/database");
MemoryStream ms = new MemoryStream(databaseFile.bytes);
return ms;
}
public Stream OpenPaletteFile()
{
var defaultPalett = Resources.Load<TextAsset>("NesCoreRes/Palettes/default_ntsc.pal");
MemoryStream ms = new MemoryStream(defaultPalett.bytes);
return ms;
}
public string GetWorkingFolderPath()
{
return $"{Application.persistentDataPath}/MyNes";
}
}
}

View File

@ -1,17 +1,36 @@
using AxibugEmuOnline.Client.Manager;
using System.Collections;
using System.Collections.Generic;
using MyNes.Core;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
public class NesCoreProxy : MonoBehaviour
{
public static NesCoreProxy Instance { get; private set; }
public RawImage DrawImage;
public DefaultAudioOutput DO;
public Text Fps;
private AppEmu m_appEnum = new AppEmu();
private void Start()
{
Instance = this;
m_appEnum.Init();
}
private void Update()
{
m_appEnum.Update();
}
private void OnDestroy()
{
Instance = null;
m_appEnum.Dispose();
}
}
}

View File

@ -0,0 +1,121 @@
{
"templatePinStates": [],
"dependencyTypeInfos": [
{
"userAdded": false,
"type": "UnityEngine.AnimationClip",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.Animations.AnimatorController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.AnimatorOverrideController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.Audio.AudioMixerController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.ComputeShader",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Cubemap",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.GameObject",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.LightingDataAsset",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.LightingSettings",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Material",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.MonoScript",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.PhysicMaterial",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.PhysicsMaterial2D",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.VolumeProfile",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.SceneAsset",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Shader",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.ShaderVariantCollection",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Texture",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Texture2D",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Timeline.TimelineAsset",
"defaultInstantiationMode": 0
}
],
"defaultDependencyTypeInfo": {
"userAdded": false,
"type": "<default_scene_template_dependencies>",
"defaultInstantiationMode": 1
},
"newSceneOverride": 0
}