dev_basemynes #3

Merged
sin365 merged 4 commits from Alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes 2024-07-05 11:30:23 +08:00
62 changed files with 7226 additions and 6227 deletions
Showing only changes of commit 28e0071191 - Show all commits

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
namespace MyNes.Core namespace MyNes.Core
@ -8,35 +9,23 @@ namespace MyNes.Core
public class MyNesMain 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 RendererSettings RendererSettings { get; private set; }
public static IFileManager FileManager { get; private set; }
public static string AppPath { get; private set; }
public static string WorkingFolder { get; private set; } public static string WorkingFolder { get; private set; }
internal static List<Board> Boards { get; private set; } internal static List<Board> Boards { get; private set; }
public static List<IVideoProvider> VideoProviders { get; private set; }
public static List<IAudioProvider> AudioProviders { get; private set; }
public static IVideoProvider VideoProvider { get; private set; } public static IVideoProvider VideoProvider { get; private set; }
public static IAudioProvider AudioProvider { get; private set; } public static IAudioProvider AudioProvider { get; private set; }
public static WaveRecorder WaveRecorder { get; private set; } public static WaveRecorder WaveRecorder { get; private set; }
public static void Initialize(bool setupRenderers) public static void Initialize(IFileManager fileManager)
{ {
Tracer.WriteLine("Initializing My Nes Core ...."); Tracer.WriteLine("Initializing My Nes Core ....");
AppPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); FileManager = fileManager;
if (AppPath == "") WorkingFolder = fileManager.GetWorkingFolderPath();
{
AppPath = Path.GetFullPath(".\\");
}
WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes");
Directory.CreateDirectory(WorkingFolder);
Tracer.WriteLine("Loading emu settings ..."); Tracer.WriteLine("Loading emu settings ...");
EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini")); EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini"));
EmuSettings.LoadSettings(); EmuSettings.LoadSettings();
@ -48,25 +37,12 @@ namespace MyNes.Core
Tracer.WriteLine("Locating boards and providers ..."); Tracer.WriteLine("Locating boards and providers ...");
WaveRecorder = new WaveRecorder(); WaveRecorder = new WaveRecorder();
Boards = new List<Board>(); Boards = new List<Board>();
VideoProviders = new List<IVideoProvider>();
AudioProviders = new List<IAudioProvider>(); var allTypes = AppDomain.CurrentDomain
string[] files = Directory.GetFiles(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]), "*", SearchOption.AllDirectories); .GetAssemblies()
foreach (string text in files) .SelectMany(ass => ass.GetTypes());
{
try foreach (var type in allTypes)
{
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) if (type.IsSubclassOf(typeof(Board)) && !type.IsAbstract)
{ {
@ -74,35 +50,26 @@ namespace MyNes.Core
Boards.Add(board); Boards.Add(board);
Tracer.WriteLine("Board added: " + board.Name + " [ Mapper " + board.MapperNumber + "]"); Tracer.WriteLine("Board added: " + board.Name + " [ Mapper " + board.MapperNumber + "]");
} }
else if (type.GetInterface("MyNes.Core.IVideoProvider") != null) else if (VideoProvider == null && typeof(IVideoProvider).IsAssignableFrom(type) && !type.IsAbstract)
{ {
IVideoProvider videoProvider = Activator.CreateInstance(type) as IVideoProvider; IVideoProvider videoProvider = Activator.CreateInstance(type) as IVideoProvider;
VideoProviders.Add(videoProvider); VideoProvider = videoProvider;
Tracer.WriteLine("Video provider added: " + videoProvider.Name + " [" + videoProvider.ID + "]"); Tracer.WriteLine("Video provider setuped: " + videoProvider.Name + " [" + videoProvider.ID + "]");
} }
else if (type.GetInterface("MyNes.Core.IAudioProvider") != null) else if (typeof(IAudioProvider).IsAssignableFrom(type) && !type.IsAbstract)
{ {
IAudioProvider audioProvider = Activator.CreateInstance(type) as IAudioProvider; IAudioProvider audioProvider = Activator.CreateInstance(type) as IAudioProvider;
AudioProviders.Add(audioProvider); AudioProvider = audioProvider;
Tracer.WriteLine("Audio provider added: " + audioProvider.Name + " [" + audioProvider.ID + "]"); Tracer.WriteLine("Audio provider setuped: " + audioProvider.Name + " [" + audioProvider.ID + "]");
}
}
}
catch (Exception ex)
{
Tracer.WriteLine("ERROR: " + ex.ToString());
} }
} }
Tracer.WriteInformation("Done."); Tracer.WriteInformation("Done.");
Tracer.WriteInformation("Total of " + Boards.Count + " board found."); 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(); SetVideoProvider();
SetAudioProvider(); SetAudioProvider();
SetRenderingMethods(); SetRenderingMethods();
}
NesEmu.Initialize(); NesEmu.Initialize();
} }
@ -211,99 +178,20 @@ namespace MyNes.Core
return list.ToArray(); return list.ToArray();
} }
public static IVideoProvider GetVideoProvider(string id) static void SetVideoProvider()
{ {
foreach (IVideoProvider videoProvider in VideoProviders) if (VideoProvider != null) VideoProvider.Initialize();
{ else Tracer.WriteError("VideoProvider is null");
if (videoProvider.ID == id)
{
return videoProvider;
}
}
return null;
} }
public static IAudioProvider GetAudioProvider(string id) static void SetAudioProvider()
{
foreach (IAudioProvider audioProvider in AudioProviders)
{
if (audioProvider.ID == id)
{
return audioProvider;
}
}
return null;
}
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..."); Tracer.WriteLine("Looking for the audio provider that set in the settings...");
AudioProvider = GetAudioProvider(RendererSettings.Audio_ProviderID); if (AudioProvider != null) AudioProvider.Initialize();
if (AudioProvider == null) else Tracer.WriteError("AudioProvider is 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() static void SetRenderingMethods()
{ {
if (VideoProvider != null && AudioProvider != null) if (VideoProvider != null && AudioProvider != null)
{ {
@ -334,4 +222,10 @@ namespace MyNes.Core
} }
} }
} }
public interface IFileManager
{
string GetWorkingFolderPath();
public Stream OpenDatabaseFile();
public Stream OpenPaletteFile();
}
} }

View File

@ -22,16 +22,13 @@ namespace MyNes.Core
public static List<NesCartDatabaseGameInfo> DatabaseRoms => _databaseRoms; public static List<NesCartDatabaseGameInfo> DatabaseRoms => _databaseRoms;
public static void LoadDatabase(string fileName, out bool success) public static void LoadDatabase(out bool success)
{ {
success = false; success = false;
Ready = false; Ready = false;
if (!File.Exists(fileName))
{
return;
}
_databaseRoms.Clear(); _databaseRoms.Clear();
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
var stream = MyNesMain.FileManager.OpenDatabaseFile();
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore; xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore;
xmlReaderSettings.IgnoreWhitespace = true; xmlReaderSettings.IgnoreWhitespace = true;

View File

@ -5097,11 +5097,8 @@ namespace MyNes.Core
internal static void Initialize() internal static void Initialize()
{ {
Tracer.WriteLine("Loading database file ..."); Tracer.WriteLine("Loading database file ...");
string text = Path.Combine(MyNesMain.AppPath, "database.xml"); NesCartDatabase.LoadDatabase(out bool success);
if (File.Exists(text))
{
bool success = false;
NesCartDatabase.LoadDatabase(text, out success);
if (success) if (success)
{ {
Tracer.WriteInformation("Nes Cart database file loaded successfully."); Tracer.WriteInformation("Nes Cart database file loaded successfully.");
@ -5110,11 +5107,7 @@ namespace MyNes.Core
{ {
Tracer.WriteError("Error loading Nes Cart database file."); Tracer.WriteError("Error loading Nes Cart database file.");
} }
}
else
{
Tracer.WriteWarning("Nes Cart database file cannot be located at " + text);
}
FrameLimiterEnabled = true; FrameLimiterEnabled = true;
CPUInitialize(); CPUInitialize();
PPUInitialize(); PPUInitialize();
@ -5523,15 +5516,16 @@ namespace MyNes.Core
case PaletteSelectSetting.File: case PaletteSelectSetting.File:
{ {
Tracer.WriteLine("Palette set to load from file."); Tracer.WriteLine("Palette set to load from file.");
string fullPath = Path.GetFullPath(MyNesMain.RendererSettings.Palette_CurrentPaletteFilePath);
if (File.Exists(fullPath)) var paletteFileStream = MyNesMain.FileManager.OpenPaletteFile();
if (paletteFileStream != null)
{ {
PaletteFileWrapper.LoadFile(fullPath, out var palette); PaletteFileWrapper.LoadFile(paletteFileStream, out var palette);
SetupPalette(palette); SetupPalette(palette);
Tracer.WriteLine("Palette set from file: " + fullPath); Tracer.WriteLine("Palette set from file");
break; break;
} }
Tracer.WriteError("Palette file: " + fullPath + " is not exist. Setting up palette from generators."); Tracer.WriteError("Palette from file is not exist is not exist. Setting up palette from generators.");
switch (Region) switch (Region)
{ {
case EmuRegion.NTSC: case EmuRegion.NTSC:

View File

@ -5,9 +5,9 @@ namespace MyNes.Core
{ {
public class PaletteFileWrapper 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) if (stream.Length == 192 || stream.Length == 1536)
{ {
int[] array = new int[512]; int[] array = new int[512];

View File

@ -96,8 +96,6 @@ namespace MyNes.Core
public int Palette_PaletteSetting; public int Palette_PaletteSetting;
public string Palette_CurrentPaletteFilePath = "default_ntsc.pal";
public float Palette_NTSC_brightness = 1.075f; public float Palette_NTSC_brightness = 1.075f;
public float Palette_NTSC_contrast = 1.016f; public float Palette_NTSC_contrast = 1.016f;
@ -122,15 +120,5 @@ namespace MyNes.Core
: base(path) : 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) public static void WriteLine(string message, TracerStatus status)
{ {
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status)); Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status));
switch (status)
{
case TracerStatus.Error: Debug.LogError(message); break;
case TracerStatus.Infromation:
case TracerStatus.Normal:
Debug.Log(message); Debug.Log(message);
break;
case TracerStatus.Warning:
Debug.LogWarning(message);
break;
}
} }
public static void WriteLine(string message, string category, TracerStatus status) public static void WriteLine(string message, string category, TracerStatus status)
{ {
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status)); Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", status));
Debug.Log($"{category}:{message}"); WriteLine($"{category}:{message}", status);
} }
public static void WriteError(string message) 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_UseDynamicScale: 0
m_BindMS: 0 m_BindMS: 0
m_EnableCompatibleFormat: 1 m_EnableCompatibleFormat: 1
m_EnableRandomWrite: 0
m_TextureSettings: m_TextureSettings:
serializedVersion: 2 serializedVersion: 2
m_FilterMode: 1 m_FilterMode: 1

View File

@ -151,7 +151,8 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 786008058}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &258485948 --- !u!114 &258485948
@ -166,6 +167,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ac8cd27a180bf3e489b2ca27c821bffe, type: 3} m_Script: {fileID: 11500000, guid: ac8cd27a180bf3e489b2ca27c821bffe, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
DrawImage: {fileID: 730321751}
DO: {fileID: 1379369700}
Fps: {fileID: 1680039028}
--- !u!1 &708549044 --- !u!1 &708549044
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -260,6 +264,182 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 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 --- !u!1 &1232273651
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -352,6 +532,314 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -359,3 +847,4 @@ SceneRoots:
- {fileID: 1232273654} - {fileID: 1232273654}
- {fileID: 708549046} - {fileID: 708549046}
- {fileID: 258485947} - {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 fileFormatVersion: 2
guid: ed2bba3664d14d840a5ed2847926614c guid: 765129d4fad76714191795975893ea9c
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 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 MyNes.Core;
using Palmmedia.ReportGenerator.Core;
using SevenZip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Threading; using UnityEngine;
namespace AxibugEmuOnline.Client.Manager 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() public void Init()
{ {
MyNesMain.Initialize(setupRenderers: false); MyNesMain.Initialize(this);
MyNesMain.SetVideoProvider(); NesEmu.LoadGame("E:/rzg4.nes", out var successed, true);
MyNesMain.SetAudioProvider(); UguiVideo = MyNesMain.VideoProvider as UguiVideoProvider;
MyNesMain.SetRenderingMethods(); 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 AxibugEmuOnline.Client.Manager;
using System.Collections; using MyNes.Core;
using System.Collections.Generic; using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client
{ {
public class NesCoreProxy : MonoBehaviour 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 AppEmu m_appEnum = new AppEmu();
private void Start() private void Start()
{ {
Instance = this;
m_appEnum.Init(); 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
}