dev_basemynes #3

Merged
sin365 merged 4 commits from Alienjack/AxibugEmuOnline:dev_basemynes into dev_basemynes 2024-07-05 11:30:23 +08:00
67 changed files with 7366 additions and 6411 deletions

View File

@ -25,5 +25,7 @@ namespace MyNes.Core
void SignalToggle(bool started);
void SetVolume(int Vol);
void Update();
}
}

View File

@ -37,5 +37,7 @@ namespace MyNes.Core
void ToggleFPS(bool show_fps);
void ApplyFilter();
void Update();
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace MyNes.Core
@ -8,35 +9,23 @@ namespace MyNes.Core
public class MyNesMain
{
public static EmuSettings EmuSettings { get; private set; }
public static RendererSettings RendererSettings { get; private set; }
public static string AppPath { get; private set; }
public static IFileManager FileManager { get; private set; }
public static string WorkingFolder { 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 IAudioProvider AudioProvider { 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 ....");
AppPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
if (AppPath == "")
{
AppPath = Path.GetFullPath(".\\");
}
WorkingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MyNes");
Directory.CreateDirectory(WorkingFolder);
FileManager = fileManager;
WorkingFolder = fileManager.GetWorkingFolderPath();
Tracer.WriteLine("Loading emu settings ...");
EmuSettings = new EmuSettings(Path.Combine(WorkingFolder, "emusettings.ini"));
EmuSettings.LoadSettings();
@ -48,25 +37,12 @@ namespace MyNes.Core
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)
var allTypes = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(ass => ass.GetTypes());
foreach (var type in allTypes)
{
if (type.IsSubclassOf(typeof(Board)) && !type.IsAbstract)
{
@ -74,35 +50,26 @@ namespace MyNes.Core
Boards.Add(board);
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;
VideoProviders.Add(videoProvider);
Tracer.WriteLine("Video provider added: " + videoProvider.Name + " [" + videoProvider.ID + "]");
VideoProvider = videoProvider;
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;
AudioProviders.Add(audioProvider);
Tracer.WriteLine("Audio provider added: " + audioProvider.Name + " [" + audioProvider.ID + "]");
}
}
}
catch (Exception ex)
{
Tracer.WriteLine("ERROR: " + ex.ToString());
AudioProvider = audioProvider;
Tracer.WriteLine("Audio provider setuped: " + audioProvider.Name + " [" + audioProvider.ID + "]");
}
}
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();
}
@ -211,99 +178,20 @@ namespace MyNes.Core
return list.ToArray();
}
public static IVideoProvider GetVideoProvider(string id)
static void SetVideoProvider()
{
foreach (IVideoProvider videoProvider in VideoProviders)
{
if (videoProvider.ID == id)
{
return videoProvider;
}
}
return null;
if (VideoProvider != null) VideoProvider.Initialize();
else Tracer.WriteError("VideoProvider is null");
}
public static IAudioProvider GetAudioProvider(string id)
{
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()
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();
}
if (AudioProvider != null) AudioProvider.Initialize();
else Tracer.WriteError("AudioProvider is null");
}
public static void SetRenderingMethods()
static void SetRenderingMethods()
{
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 void LoadDatabase(string fileName, out bool success)
public static void LoadDatabase(out bool success)
{
success = false;
Ready = false;
if (!File.Exists(fileName))
{
return;
}
_databaseRoms.Clear();
Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
var stream = MyNesMain.FileManager.OpenDatabaseFile();
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Ignore;
xmlReaderSettings.IgnoreWhitespace = true;

View File

@ -5097,11 +5097,8 @@ namespace MyNes.Core
internal static void Initialize()
{
Tracer.WriteLine("Loading database file ...");
string text = Path.Combine(MyNesMain.AppPath, "database.xml");
if (File.Exists(text))
{
bool success = false;
NesCartDatabase.LoadDatabase(text, out success);
NesCartDatabase.LoadDatabase(out bool success);
if (success)
{
Tracer.WriteInformation("Nes Cart database file loaded successfully.");
@ -5110,11 +5107,7 @@ namespace MyNes.Core
{
Tracer.WriteError("Error loading Nes Cart database file.");
}
}
else
{
Tracer.WriteWarning("Nes Cart database file cannot be located at " + text);
}
FrameLimiterEnabled = true;
CPUInitialize();
PPUInitialize();
@ -5523,15 +5516,16 @@ namespace MyNes.Core
case PaletteSelectSetting.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);
Tracer.WriteLine("Palette set from file: " + fullPath);
Tracer.WriteLine("Palette set from file");
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)
{
case EmuRegion.NTSC:

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

@ -1,6 +1,6 @@
#define TRACE
using System;
using System.Diagnostics;
using UnityEngine;
namespace MyNes.Core
{
@ -11,25 +11,36 @@ namespace MyNes.Core
public static void WriteLine(string message)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, TracerStatus.Normal));
Trace.WriteLine(message);
Debug.Log(message);
}
public static void WriteLine(string message, string category)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs($"{category}: {message}", TracerStatus.Normal));
Trace.WriteLine($"{category}: {message}");
Debug.Log(message);
}
public static void WriteLine(string message, TracerStatus status)
{
Tracer.EventRaised?.Invoke(null, new TracerEventArgs(message, status));
Trace.WriteLine(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));
Trace.WriteLine($"{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

@ -122,6 +122,55 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &258485946
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 258485947}
- component: {fileID: 258485948}
m_Layer: 0
m_Name: NesCoreProxy
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &258485947
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 258485946}
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:
- {fileID: 786008058}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &258485948
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 258485946}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ac8cd27a180bf3e489b2ca27c821bffe, type: 3}
m_Name:
m_EditorClassIdentifier:
AS: {fileID: 1379369699}
DrawImage: {fileID: 730321751}
DO: {fileID: 0}
Fps: {fileID: 1680039028}
--- !u!1 &708549044
GameObject:
m_ObjectHideFlags: 0
@ -216,6 +265,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
@ -308,9 +533,305 @@ 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}
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!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
m_Roots:
- {fileID: 1232273654}
- {fileID: 708549046}
- {fileID: 258485947}
- {fileID: 1359344834}

View File

@ -1,6 +1,6 @@
{
"name": "AxibugEmuOnline.Client",
"rootNamespace": "",
"rootNamespace": "AxibugEmuOnline.Client",
"references": [
"GUID:0c194730510bd1b4fad0398ccfe4235b"
],

View File

@ -0,0 +1,96 @@
using MyNes.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Threading;
using UnityEditor.PackageManager.UI;
using UnityEngine;
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 AudioSource m_as;
private int samples_added;
private Queue<float> _buffer = new Queue<float>();
public void Initialize()
{
m_as = NesCoreProxy.Instance.AS;
m_as.clip = AudioClip.Create("nes wav", 48000 * 2, 1, 48000, true, OnAudioFilterRead);
m_as.loop = true;
m_as.playOnAwake = false;
m_as.spatialBlend = 0f;
m_as.Play();
}
public void Update() { }
private void OnAudioFilterRead(float[] data)
{
lock (_buffer)
{
for (int i = 0; i < data.Length; i++)
{
data[i] = _buffer.Count > 0 ? _buffer.Dequeue() : 0;
}
}
}
public void SubmitSamples(ref short[] buffer, ref int samples_a)
{
lock (_buffer)
{
foreach (var a in buffer.Take(samples_a).ToArray())
{
var floatData = (float)a / 124;
_buffer.Enqueue(floatData);
}
}
}
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,183 @@
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);
}
}
public 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 Update()
{
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,156 +1,57 @@
using MyNes.Core;
using Palmmedia.ReportGenerator.Core;
using SevenZip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using MyNes;
using MyNes.Core;
using System.IO;
using System.Threading;
using UnityEngine;
namespace AxibugEmuOnline.Client.Manager
{
public class AppEmu
public class AppEmu : IFileManager
{
INes _nes;
public static WINSettings Settings { get; private set; }
private bool isMaxing;
private bool isMoving;
private bool pausedByMainWindow;
private bool isMouseVisible;
private int mouseHiderCounter;
private const int mouseHiderReload = 1;
private bool gameLoaded;
private IContainer components;
public AppEmu()
{
}
public IVideoProvider UguiVideo { get; private set; }
public IAudioProvider Audio { get; private set; }
public void Init()
{
_nes = new INes();
MyNesMain.Initialize(this);
NesEmu.LoadGame("E:/rzg4.nes", out var successed, true);
UguiVideo = MyNesMain.VideoProvider;
Audio = MyNesMain.AudioProvider;
var fps_nes_missle = 1.0 / 59.0;
NesEmu.SetFramePeriod(ref fps_nes_missle);
}
internal void LoadGame(string filePath)
public void Update()
{
bool success = false;
switch (Path.GetExtension(filePath).ToLower())
{
case ".nes":
NesEmu.LoadGame(filePath, out success);
break;
case ".7z":
case ".zip":
case ".rar":
case ".gzip":
case ".tar":
case ".bzip2":
case ".xz":
{
string text = filePath;
string text2 = Path.GetTempPath() + "\\MYNES\\";
SevenZipExtractor sevenZipExtractor;
try
{
sevenZipExtractor = new SevenZipExtractor(text);
}
catch (Exception ex)
{
MessageBox.Show(Resources.Message35 + ": \n" + ex.Message);
return;
}
if (sevenZipExtractor.ArchiveFileData.Count == 1)
{
if (sevenZipExtractor.ArchiveFileData[0].FileName.Substring(sevenZipExtractor.ArchiveFileData[0].FileName.Length - 4, 4).ToLower() == ".nes")
{
sevenZipExtractor.ExtractArchive(text2);
text = text2 + sevenZipExtractor.ArchiveFileData[0].FileName;
}
}
else
{
List<string> list = new List<string>();
foreach (ArchiveFileInfo archiveFileDatum in sevenZipExtractor.ArchiveFileData)
{
list.Add(archiveFileDatum.FileName);
}
FormFilesList formFilesList = new FormFilesList(list.ToArray());
if (formFilesList.ShowDialog(this) != DialogResult.OK)
{
return;
}
string[] fileNames = new string[1] { formFilesList.SelectedRom };
sevenZipExtractor.ExtractFiles(text2, fileNames);
text = text2 + formFilesList.SelectedRom;
UguiVideo.Update();
Audio.Update();
double t = Time.deltaTime;
NesEmu.SetFramePeriod(ref t);
}
NesEmu.LoadGame(text, out success);
break;
}
}
if (success)
public void Dispose()
{
if (Settings.Misc_RecentFiles == null)
{
Settings.Misc_RecentFiles = new string[0];
}
List<string> list2 = new List<string>(Settings.Misc_RecentFiles);
if (list2.Contains(filePath))
{
list2.Remove(filePath);
}
list2.Insert(0, filePath);
if (list2.Count > 19)
{
list2.RemoveAt(list2.Count - 1);
}
Settings.Misc_RecentFiles = list2.ToArray();
gameLoaded = true;
if (Settings.Win_StartInFullscreen)
{
if (base.WindowState != FormWindowState.Maximized)
{
MyNesMain.VideoProvider.ResizeBegin();
Thread.Sleep(100);
MyNesMain.RendererSettings.Vid_Fullscreen = true;
base.FormBorderStyle = FormBorderStyle.None;
menuStrip1.Visible = false;
base.WindowState = FormWindowState.Maximized;
MyNesMain.VideoProvider.ResizeEnd();
}
}
else if (MyNesMain.RendererSettings.Vid_AutoStretch)
{
ApplyStretch(applyRegion: true);
}
}
ApplyWindowTitle();
MyNesMain.Shutdown();
}
#region Setting
internal void LoadSettings()
public Stream OpenDatabaseFile()
{
base.Location = new Point(Program.Settings.Win_Location_X, Program.Settings.Win_Location_Y);
base.Size = new Size(Program.Settings.Win_Size_W, Program.Settings.Win_Size_H);
for (int i = 0; i < Program.SupportedLanguages.Length / 3; i++)
var databaseFile = Resources.Load<TextAsset>("NesCoreRes/database");
MemoryStream ms = new MemoryStream(databaseFile.bytes);
return ms;
}
public Stream OpenPaletteFile()
{
ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
toolStripMenuItem.Text = Program.SupportedLanguages[i, 2];
toolStripMenuItem.Checked = Program.SupportedLanguages[i, 0] == Program.Settings.InterfaceLanguage;
interfaceLanguageToolStripMenuItem.DropDownItems.Add(toolStripMenuItem);
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";
}
#endregion
}
}

View File

@ -0,0 +1,37 @@
using AxibugEmuOnline.Client.Manager;
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 AudioSource AS;
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,11 @@
fileFormatVersion: 2
guid: ac8cd27a180bf3e489b2ca27c821bffe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Network
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Performance.Profile-Analyzer.Editor", "Unity.Performance.Profile-Analyzer.Editor.csproj", "{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugEmuOnline.Client", "AxibugEmuOnline.Client.csproj", "{59C211A4-B928-7505-AF2E-6C604DAB3622}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Scheduler", "Unity.Services.Core.Scheduler.csproj", "{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.VSCode.Editor", "Unity.VSCode.Editor.csproj", "{5A8F066D-8FFA-AFC1-1E8E-0DE9AEAE676F}"
@ -71,8 +73,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.TestTools.CodeCoverag
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Settings.Editor", "Unity.Settings.Editor.csproj", "{541572F4-E051-F4F8-9B39-87BFA550E13A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugEmuOnline.Client", "AxibugEmuOnline.Client.csproj", "{59C211A4-B928-7505-AF2E-6C604DAB3622}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Registration", "Unity.Services.Core.Registration.csproj", "{A5C76622-FE9B-BD41-A430-5208CCE95FDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Telemetry", "Unity.Services.Core.Telemetry.csproj", "{7F93B805-8A3C-D81B-FEE7-A4CE542AB2D2}"
@ -219,6 +219,10 @@ Global
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Release|Any CPU.Build.0 = Release|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.Build.0 = Release|Any CPU
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -235,10 +239,6 @@ Global
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Release|Any CPU.Build.0 = Release|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.Build.0 = Release|Any CPU
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Release|Any CPU.ActiveCfg = Release|Any CPU

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
}