Compare commits

..

No commits in common. "62fbb6e11be46739e4d78c31330e17a696f8c3d8" and "d9a5f40190c58e404d5ba5be11e9a300f5d2a438" have entirely different histories.

41 changed files with 795 additions and 937 deletions

View File

@ -1,4 +1,3 @@
#if UNITY_EDITOR
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
@ -23,4 +22,3 @@ public class AxiPrefabCache_Com2GUID
public string ToGUID; public string ToGUID;
public MonoScript monoScript; public MonoScript monoScript;
} }
#endif

View File

@ -1,4 +1,3 @@
#if UNITY_EDITOR
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -87,7 +86,7 @@ public class AxiProjectTools : EditorWindow
static void LoopPrefabNode(string rootPath, GameObject trans, int depth) static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
{ {
string nodename = $"{rootPath}>{trans.name}"; string nodename = $"{rootPath}>{trans.name}";
#if UNITY_2018_4_OR_NEWER #if UNITY_5_4_OR_NEWER && !UNITY_2018_4_OR_NEWER
GameObject prefabRoot = trans.gameObject; GameObject prefabRoot = trans.gameObject;
int comCount = prefabRoot.GetComponentCount(); int comCount = prefabRoot.GetComponentCount();
for (int i = 0; i < comCount; i++) for (int i = 0; i < comCount; i++)
@ -96,6 +95,11 @@ public class AxiProjectTools : EditorWindow
if (com == null) if (com == null)
continue; continue;
if (com.name.Contains("VideoPlayer"))
{
}
MonoBehaviour monoCom = com as MonoBehaviour; MonoBehaviour monoCom = com as MonoBehaviour;
if (monoCom == null) if (monoCom == null)
continue; continue;
@ -258,13 +262,11 @@ public class AxiProjectTools : EditorWindow
} }
[MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")] [MenuItem("Axibug移植工具/[5]UnPack所有预制体")]
public static void UnpackPrefabs() public static void UnpackPrefabs()
{ {
#if UNITY_2018_4_OR_NEWER string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
GoTAxiProjectToolsSence();
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0; int prefabCount = 0;
foreach (string path in allAssetPaths) foreach (string path in allAssetPaths)
@ -276,41 +278,13 @@ public class AxiProjectTools : EditorWindow
prefabCount++; prefabCount++;
} }
} }
Debug.Log($"{prefabCount}个预制体Unpack"); Debug.Log($"Unpacked {prefabCount} prefabs.");
string[] sceneGuids = AssetDatabase.FindAssets("t:scene"); Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
foreach (string guid in sceneGuids) }
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
continue;
EditorSceneManager.OpenScene(path); static void UnpackPrefab(string prefabPath)
Scene currentScene = SceneManager.GetActiveScene();
GameObject[] rootObjects = currentScene.GetRootGameObjects();
foreach (GameObject rootObj in rootObjects)
{
// 遍历场景中的所有对象
TraverseHierarchy(rootObj);
}
// Save the scene // 获取当前打开的场景
currentScene = EditorSceneManager.GetActiveScene();
// 保存场景到文件(默认路径和名称)
bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path);
Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
}
GoTAxiProjectToolsSence();
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
#else
Debug.Log("低版本不要执行本函数");
#endif
}
static void UnpackPrefab(string prefabPath)
{ {
#if UNITY_2018_4_OR_NEWER
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath); GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
if (prefabInstance == null) if (prefabInstance == null)
{ {
@ -322,14 +296,10 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(obj); TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath); PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj); GameObject.DestroyImmediate(obj);
#else
Debug.Log("低版本不要执行本函数");
#endif
} }
static void TraverseHierarchy(GameObject obj) static void TraverseHierarchy(GameObject obj)
{ {
#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例 // 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj)) if (PrefabUtility.IsPartOfPrefabInstance(obj))
{ {
@ -343,9 +313,6 @@ public class AxiProjectTools : EditorWindow
{ {
TraverseHierarchy(obj.transform.GetChild(i).gameObject); TraverseHierarchy(obj.transform.GetChild(i).gameObject);
} }
#else
Debug.Log("低版本不要执行本函数");
#endif
} }
@ -413,4 +380,3 @@ public class AxiProjectTools : EditorWindow
} }
} }
} }
#endif

View File

@ -1,8 +1,6 @@
using AxibugEmuOnline.Client; using AxibugEmuOnline.Client;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
namespace AxibugEmuOnline.Editors namespace AxibugEmuOnline.Editors
{ {
[CustomEditor(typeof(CommandDispatcher))] [CustomEditor(typeof(CommandDispatcher))]
@ -15,8 +13,8 @@ namespace AxibugEmuOnline.Editors
if (!Application.isPlaying) return; if (!Application.isPlaying) return;
var dispacather = target as CommandDispatcher; var dispacather = target as CommandDispatcher;
IReadOnlyList<CommandExecuter> normal; IReadOnlyList<CommandExecuter> solo;
dispacather.GetRegisters(out normal, out solo); dispacather.GetRegisters(out var normal, out var solo);
EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField("NORMAL"); EditorGUILayout.LabelField("NORMAL");

View File

@ -60,7 +60,7 @@ namespace AxiReplay
if (!bNetInit) if (!bNetInit)
{ {
data = default(ReplayStep); data = default(ReplayStep);
frameDiff = default(int); frameDiff = default;
inputDiff = false; inputDiff = false;
return false; return false;
} }
@ -73,7 +73,7 @@ namespace AxiReplay
if (!bNetInit) if (!bNetInit)
{ {
data = default(ReplayStep); data = default(ReplayStep);
frameDiff = default(int); frameDiff = default;
inputDiff = false; inputDiff = false;
return false; return false;
} }

View File

@ -5,154 +5,152 @@ using System.Text;
namespace AxiReplay namespace AxiReplay
{ {
public class ReplayWriter : IReplayWriter public class ReplayWriter : IReplayWriter
{ {
public ReplayData.ReplayFormat mFormat { get; private set; } public ReplayData.ReplayFormat mFormat { get; private set; }
public Encoding TexEncoding { get; private set; } public Encoding TexEncoding { get; private set; }
ReplayHandler handler; ReplayHandler handler;
string mTitle; string mTitle;
string mNote; string mNote;
int mAllFrame; int mAllFrame;
int mAllTime; int mAllTime;
long mData; long mData;
int mSingleInputLenght; int mSingleInputLenght;
int mSingleDataLenght; int mSingleDataLenght;
MemoryStream mStream; MemoryStream mStream;
BinaryWriter mBinaryWriter; BinaryWriter mBinaryWriter;
int mCurrFrame; int mCurrFrame;
UInt64 mCurrInput; UInt64 mCurrInput;
ReplayStep wirteStep; ReplayStep wirteStep;
List<string> dbgList = new List<string>(); List<string> dbgList = new List<string>();
public ReplayWriter(string Title, string Note, ReplayData.ReplayFormat format, Encoding encoding) public ReplayWriter(string Title, string Note, ReplayData.ReplayFormat format, Encoding encoding)
{ {
mTitle = Title; mTitle = Title;
mNote = Note; mNote = Note;
TexEncoding = encoding; TexEncoding = encoding;
mFormat = format; mFormat = format;
switch (mFormat) switch (mFormat)
{ {
case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break; case ReplayData.ReplayFormat.FM32IP64: mSingleInputLenght = sizeof(UInt64); break;
case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break; case ReplayData.ReplayFormat.FM32IP32: mSingleInputLenght = sizeof(UInt32); break;
case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break; case ReplayData.ReplayFormat.FM32IP16: mSingleInputLenght = sizeof(UInt16); break;
case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break; case ReplayData.ReplayFormat.FM32IPBYTE: mSingleInputLenght = sizeof(byte); break;
} }
mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght; mSingleDataLenght = (sizeof(UInt32)) + mSingleInputLenght;
mStream = new MemoryStream(); mStream = new MemoryStream();
mBinaryWriter = new BinaryWriter(mStream); mBinaryWriter = new BinaryWriter(mStream);
mCurrFrame = -1; mCurrFrame = -1;
mCurrInput = int.MaxValue; mCurrInput = int.MaxValue;
wirteStep = new ReplayStep(); wirteStep = new ReplayStep();
dbgList.Clear(); dbgList.Clear();
} }
int byFrameIdx = 0; int byFrameIdx = 0;
/// <summary> /// <summary>
/// 往前推进帧的,指定帧下标 /// 往前推进帧的,指定帧下标
/// </summary> /// </summary>
/// <param name="frameInput"></param> /// <param name="frameInput"></param>
public void NextFramebyFrameIdx(int FrameID, UInt64 frameInput) public void NextFramebyFrameIdx(int FrameID, UInt64 frameInput)
{ {
TakeFrame(FrameID - byFrameIdx, frameInput); TakeFrame(FrameID - byFrameIdx, frameInput);
byFrameIdx = FrameID; byFrameIdx = FrameID;
} }
/// <summary> /// <summary>
/// 往前推进1帧的Input /// 往前推进1帧的Input
/// </summary> /// </summary>
/// <param name="frameInput"></param> /// <param name="frameInput"></param>
public void NextFrame(UInt64 frameInput) public void NextFrame(UInt64 frameInput)
{ {
TakeFrame(1, frameInput); TakeFrame(1, frameInput);
} }
/// <summary> /// <summary>
/// 往前推进指定帧数量的Input /// 往前推进指定帧数量的Input
/// </summary> /// </summary>
/// <param name="frameInput"></param> /// <param name="frameInput"></param>
public void TakeFrame(int addFrame, UInt64 frameInput) public void TakeFrame(int addFrame, UInt64 frameInput)
{ {
if (addFrame < 0) if (addFrame < 0)
{ {
} }
mCurrFrame += addFrame; mCurrFrame += addFrame;
if (mCurrInput == frameInput) if (mCurrInput == frameInput)
return; return;
mCurrInput = frameInput; mCurrInput = frameInput;
wirteStep.FrameStartID = mCurrFrame; wirteStep.FrameStartID = mCurrFrame;
wirteStep.InPut = mCurrInput; wirteStep.InPut = mCurrInput;
dbgList.Add($"{mCurrFrame} | {mCurrInput}"); dbgList.Add($"{mCurrFrame} | {mCurrInput}");
switch (mFormat) switch (mFormat)
{ {
case ReplayData.ReplayFormat.FM32IP64: case ReplayData.ReplayFormat.FM32IP64:
mBinaryWriter.Write(wirteStep.FrameStartID); mBinaryWriter.Write(wirteStep.FrameStartID);
mBinaryWriter.Write(wirteStep.InPut); mBinaryWriter.Write(wirteStep.InPut);
break; break;
case ReplayData.ReplayFormat.FM32IP32: case ReplayData.ReplayFormat.FM32IP32:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 4); mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 4);
break; break;
case ReplayData.ReplayFormat.FM32IP16: case ReplayData.ReplayFormat.FM32IP16:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 2); mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 2);
break; break;
case ReplayData.ReplayFormat.FM32IPBYTE: case ReplayData.ReplayFormat.FM32IPBYTE:
mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 1); mBinaryWriter.Write(BitConverter.GetBytes(wirteStep.All64Data), 0, 4 + 1);
break; break;
} }
} }
public void SaveData(string path, bool bWithDump = false, string dumppath = null) public void SaveData(string path, bool bWithDump = false, string dumppath = null)
{ {
byte[] titleData; int titleLenghtWithEnd; ReplayData.GetStringByteData(mTitle, out byte[] titleData, out int titleLenghtWithEnd, TexEncoding);
ReplayData.GetStringByteData(mTitle, out titleData, out titleLenghtWithEnd, TexEncoding); ReplayData.GetStringByteData(mNote, out byte[] noteData, out int noteLenghtWithEnd, TexEncoding);
byte[] noteData; int noteLenghtWithEnd;
ReplayData.GetStringByteData(mNote, out noteData, out noteLenghtWithEnd, TexEncoding);
ReplayHandler handler = new ReplayHandler(); ReplayHandler handler = new ReplayHandler();
handler.Format = (int)this.mFormat; handler.Format = (int)this.mFormat;
handler.DataOffset = ReplayData.HandlerLenght; handler.DataOffset = ReplayData.HandlerLenght;
handler.CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); handler.CreateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
handler.AllFrame = wirteStep.FrameStartID; handler.AllFrame = wirteStep.FrameStartID;
handler.SingleLenght = mSingleDataLenght; handler.SingleLenght = mSingleDataLenght;
using (FileStream fs = new FileStream(path, FileMode.Create)) using (FileStream fs = new FileStream(path, FileMode.Create))
{ {
using (BinaryWriter bw = new BinaryWriter(fs)) using (BinaryWriter bw = new BinaryWriter(fs))
{ {
//写入Handler //写入Handler
bw.Write(ReplayData.GetHandlerData(handler)); bw.Write(ReplayData.GetHandlerData(handler));
//写入Data //写入Data
bw.Write(mStream.ToArray()); bw.Write(mStream.ToArray());
} }
} }
if (bWithDump) if (bWithDump)
{ {
List<string> temp = new List<string>(); List<string> temp = new List<string>();
temp.Add($"Format => {handler.Format}"); temp.Add($"Format => {handler.Format}");
temp.Add($"DataOffset => {handler.DataOffset}"); temp.Add($"DataOffset => {handler.DataOffset}");
temp.Add($"CreateTime => {handler.CreateTime}"); temp.Add($"CreateTime => {handler.CreateTime}");
temp.Add($"AllFrame => {handler.AllFrame}"); temp.Add($"AllFrame => {handler.AllFrame}");
temp.Add($"SingleLenght => {handler.SingleLenght}"); temp.Add($"SingleLenght => {handler.SingleLenght}");
dbgList.InsertRange(0, temp); dbgList.InsertRange(0, temp);
File.WriteAllLines(dumppath, dbgList); File.WriteAllLines(dumppath, dbgList);
} }
} }
public void Dispose() public void Dispose()
{ {
mStream.Dispose(); mStream.Dispose();
mBinaryWriter.Dispose(); mBinaryWriter.Dispose();
//TODO //TODO
} }
} }
} }

View File

@ -1,92 +1,7 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: eb76ae7b43c117c449fe04e536cf3f34 guid: eb76ae7b43c117c449fe04e536cf3f34
PluginImporter: MonoAssemblyImporter:
externalObjects: {} serializedVersion: 1
serializedVersion: 2
iconMap: {} iconMap: {}
executionOrder: {} executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude PSP2: 0
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
PSP2: PSP2
second:
enabled: 1
settings: {}
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData: userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,396 +7,383 @@ using static AxibugEmuOnline.Client.FilterEffect;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client
{ {
public class FilterManager public class FilterManager
{ {
private List<Filter> m_filters; private List<Filter> m_filters;
private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>(); private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>();
private AlphaWraper m_previewFilterWraper; private AlphaWraper m_previewFilterWraper;
FilterRomSetting m_filterRomSetting; FilterRomSetting m_filterRomSetting;
/// <summary> /// <summary>
/// 滤镜列表 /// 滤镜列表
/// </summary> /// </summary>
public IReadOnlyList<Filter> Filters => m_filters; public IReadOnlyList<Filter> Filters => m_filters;
public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg)
{ {
#if UNITY_PSP2 m_filters = new List<Filter>
m_filters = new List<Filter>(); {
m_filterRomSetting = new FilterRomSetting(); new Filter(new FixingPixelArtGrille()),
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false); new Filter(new LCDPostEffect()),
return; new Filter(new MattiasCRT()),
#endif };
var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting();
m_filters = new List<Filter> m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false);
{ ShutDownFilterPreview();
new Filter(new FixingPixelArtGrille()), ShutDownFilter();
new Filter(new LCDPostEffect()), }
new Filter(new MattiasCRT()),
};
var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting();
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false); private RenderTexture result = null;
ShutDownFilterPreview(); public Texture ExecuteFilterRender(Texture src)
ShutDownFilter(); {
} if (result == null)
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
else if (result.width != Screen.width || result.height != Screen.height)
{
RenderTexture.ReleaseTemporary(result);
result = RenderTexture.GetTemporary(Screen.width, Screen.height);
}
private RenderTexture result = null; bool anyFilterEnable = false;
public Texture ExecuteFilterRender(Texture src) foreach (var filter in Filters)
{ {
if (result == null) if (!filter.m_setting.Enable.GetValue()) continue;
{ filter.m_setting.Render(src, result);
//result = RenderTexture.GetTemporary(Screen.width, Screen.height); anyFilterEnable = true;
result = Initer.instance.renderTest; }
}
else if (result.width != Screen.width || result.height != Screen.height) if (anyFilterEnable)
{ return result;
//RenderTexture.ReleaseTemporary(result); else
//result = RenderTexture.GetTemporary(Screen.width, Screen.height); return src;
result = Initer.instance.renderTest; }
}
/// <summary> 关闭滤镜预览 </summary>
public void ShutDownFilterPreview()
{
m_previewFilterWraper.On = false;
}
/// <summary> 开启滤镜预览 </summary>
public void EnableFilterPreview()
{
m_previewFilterWraper.On = true;
}
/// <summary>
/// 打开滤镜
/// </summary>
/// <param name="filter"></param>
public void EnableFilter(Filter filter)
{
foreach (var selfFiler in Filters)
{
if (selfFiler != filter) selfFiler.m_setting.Enable.Override(false);
else selfFiler.m_setting.Enable.Override(true);
}
}
/// <summary>
/// 关闭滤镜效果
/// </summary>
public void ShutDownFilter()
{
//关闭所有后处理效果
foreach (var filter in Filters)
filter.m_setting.Enable.Override(false);
}
/// <summary>
/// 为指定rom设置滤镜以及滤镜的预设
/// </summary>
/// <param name="rom">rom对象</param>
/// <param name="filter">滤镜</param>
/// <param name="preset">滤镜预设</param>
public void SetupFilter(RomFile rom, Filter filter, FilterPreset preset)
{
m_filterRomSetting.Setup(rom, filter, preset);
string json = m_filterRomSetting.ToJson();
PlayerPrefs.SetString(nameof(FilterRomSetting), json);
}
/// <summary>
/// 获得指定rom配置的滤镜设置
/// </summary>
/// <param name="rom">rom对象</param>
/// <returns>此元组任意内任意成员都有可能为空</returns>
public GetFilterSetting_result GetFilterSetting(RomFile rom)
{
var value = m_filterRomSetting.Get(rom);
Filter filter = null;
FilterPreset preset = null;
//filter = Filters.FirstOrDefault(f => f.Name == value.filterName);
//if (filter != null)
//{
// string presetName = value.presetName;
// preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
//}
filter = Filters.FirstOrDefault(f => f.Name == value.Item1);
if (filter != null)
{
string presetName = value.Item2;
preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
}
return new GetFilterSetting_result()
{
filter = filter,
preset = preset
};
}
public struct GetFilterSetting_result
{
public Filter filter;
public FilterPreset preset;
}
public class Filter
{
public string Name => m_setting.Name;
public IReadOnlyCollection<EditableParamerter> Paramerters => m_setting.EditableParam;
/// <summary> 滤镜预设 </summary>
public List<FilterPreset> Presets = new List<FilterPreset>();
/// <summary> 滤镜默认预设 </summary>
public FilterPreset DefaultPreset = new FilterPreset("DEFAULT");
internal FilterEffect m_setting;
public Filter(FilterEffect setting)
{
m_setting = setting;
loadPresets();
}
private void loadPresets()
{
var json = PlayerPrefs.GetString($"Filter_{Name}_PresetList", string.Empty);
var loadedPresets = JsonUtility.FromJson<FilterPresetList>(json);
if (loadedPresets == null) return;
else Presets = loadedPresets.presets;
}
public void SavePresets()
{
var json = JsonUtility.ToJson(new FilterPresetList(Presets));
PlayerPrefs.SetString($"Filter_{Name}_PresetList", json);
}
public MsgBool CreatePreset(string presetName, out FilterPreset newPreset)
{
newPreset = null;
if (string.IsNullOrWhiteSpace(presetName)) return "名称不能为空";
if (Presets.Count(p => p.Name == presetName) != 0) return "名称重复";
newPreset = new FilterPreset(presetName);
Presets.Add(newPreset);
SavePresets();
return true;
}
public void RemovePreset(FilterPreset preset)
{
if (!Presets.Remove(preset)) return;
SavePresets();
EventInvoker.RaiseFilterPresetRemoved(this, preset);
}
public void ResetPreset()
{
foreach (var param in Paramerters)
{
param.ResetToDefault();
}
}
public void ApplyPreset(FilterPreset preset)
{
foreach (var param in Paramerters)
{
var value = preset.GetParamValue(param.Name, param.ValueType);
if (value == null)
param.ResetToDefault();
else
param.Apply(value);
}
}
}
bool anyFilterEnable = false; [Serializable]
foreach (var filter in Filters) private class FilterPresetList
{ {
if (!filter.m_setting.Enable.GetValue()) continue; public List<FilterPreset> presets;
filter.m_setting.Render(src, result);
anyFilterEnable = true;
}
if (anyFilterEnable) public FilterPresetList(List<FilterPreset> presets)
return result; {
else this.presets = presets;
return src; foreach (var preset in presets)
} {
preset.ReadyForJson();
}
}
}
/// <summary> 关闭滤镜预览 </summary> [Serializable]
public void ShutDownFilterPreview() public class FilterPreset
{ {
m_previewFilterWraper.On = false; [SerializeField]
} public string Name;
[SerializeField]
private List<string> m_paramName = new List<string>();
[SerializeField]
private List<string> m_valueJson = new List<string>();
/// <summary> 开启滤镜预览 </summary> private bool m_cacheReady = false;
public void EnableFilterPreview() private Dictionary<string, string> m_paramName2ValueJson;
{ public FilterPreset(string presetName)
m_previewFilterWraper.On = true; {
} Name = presetName;
}
/// <summary> public void ReadyForJson()
/// 打开滤镜 {
/// </summary> prepareCache();
/// <param name="filter"></param>
public void EnableFilter(Filter filter)
{
foreach (var selfFiler in Filters)
{
if (selfFiler != filter) selfFiler.m_setting.Enable.Override(false);
else selfFiler.m_setting.Enable.Override(true);
}
}
/// <summary> m_paramName = m_paramName2ValueJson.Keys.ToList();
/// 关闭滤镜效果 m_valueJson = m_paramName2ValueJson.Values.ToList();
/// </summary> }
public void ShutDownFilter()
{
//关闭所有后处理效果
foreach (var filter in Filters)
filter.m_setting.Enable.Override(false);
}
/// <summary> public string GetParamValueJson(string paramName)
/// 为指定rom设置滤镜以及滤镜的预设 {
/// </summary> prepareCache();
/// <param name="rom">rom对象</param> string value;
/// <param name="filter">滤镜</param> m_paramName2ValueJson.TryGetValue(paramName, out value);
/// <param name="preset">滤镜预设</param> return value;
public void SetupFilter(RomFile rom, Filter filter, FilterPreset preset) }
{
m_filterRomSetting.Setup(rom, filter, preset);
string json = m_filterRomSetting.ToJson(); public object GetParamValue(string paramName, Type valueType)
PlayerPrefs.SetString(nameof(FilterRomSetting), json); {
} var rawStr = GetParamValueJson(paramName);
if (rawStr == null) return null;
/// <summary> if (valueType == typeof(float))
/// 获得指定rom配置的滤镜设置 {
/// </summary> float floatVal;
/// <param name="rom">rom对象</param> float.TryParse(rawStr, out floatVal);
/// <returns>此元组任意内任意成员都有可能为空</returns> return floatVal;
public GetFilterSetting_result GetFilterSetting(RomFile rom) }
{ else if (valueType.IsEnum)
var value = m_filterRomSetting.Get(rom); {
Filter filter = null; var names = Enum.GetNames(valueType);
FilterPreset preset = null; var values = Enum.GetValues(valueType);
//filter = Filters.FirstOrDefault(f => f.Name == value.filterName); for (int i = 0; i < names.Length; i++)
//if (filter != null) {
//{ if (names[i].Equals(rawStr))
// string presetName = value.presetName; {
// preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); return values.GetValue(i);
//} }
}
return null;
}
else
{
App.log.Error($"尚未支持的滤镜参数类型{valueType}");
return null;
}
}
filter = Filters.FirstOrDefault(f => f.Name == value.Item1); public void SetParamValue(string paramName, Type valueType, object value)
if (filter != null) {
{ prepareCache();
string presetName = value.Item2; m_paramName2ValueJson[paramName] = value.ToString();
preset = filter.Presets.FirstOrDefault(p => p.Name == presetName); }
}
return new GetFilterSetting_result() private void prepareCache()
{ {
filter = filter, if (m_cacheReady) return;
preset = preset
};
}
public struct GetFilterSetting_result m_paramName2ValueJson = new Dictionary<string, string>();
{ for (int i = 0; i < m_paramName.Count; i++)
public Filter filter; {
public FilterPreset preset; m_paramName2ValueJson[m_paramName[i]] = m_valueJson[i];
} }
public class Filter m_cacheReady = true;
{ }
public string Name => m_setting.Name; }
public IReadOnlyCollection<EditableParamerter> Paramerters => m_setting.EditableParam;
/// <summary> 滤镜预设 </summary>
public List<FilterPreset> Presets = new List<FilterPreset>();
/// <summary> 滤镜默认预设 </summary>
public FilterPreset DefaultPreset = new FilterPreset("DEFAULT");
internal FilterEffect m_setting; [Serializable]
public class FilterRomSetting
{
[SerializeField]
private List<int> m_romID;
[SerializeField]
private List<Item> m_items;
public Filter(FilterEffect setting) bool m_cacheReady = false;
{ Dictionary<int, Item> m_cache;
m_setting = setting;
loadPresets(); public void Setup(RomFile rom, Filter filter, FilterPreset preset)
} {
prepareCache();
private void loadPresets() if (filter == null)
{ m_cache.Remove(rom.ID);
var json = PlayerPrefs.GetString($"Filter_{Name}_PresetList", string.Empty); else
var loadedPresets = JsonUtility.FromJson<FilterPresetList>(json); m_cache[rom.ID] = new Item { FilterName = filter.Name, PresetName = preset != null ? preset.Name : null };
if (loadedPresets == null) return; }
else Presets = loadedPresets.presets;
}
public void SavePresets() public string ToJson()
{ {
var json = JsonUtility.ToJson(new FilterPresetList(Presets)); prepareCache();
PlayerPrefs.SetString($"Filter_{Name}_PresetList", json); m_romID = m_cache.Keys.ToList();
} m_items = m_cache.Values.ToList();
public MsgBool CreatePreset(string presetName, out FilterPreset newPreset) return JsonUtility.ToJson(this);
{ }
newPreset = null;
if (string.IsNullOrWhiteSpace(presetName)) return "名称不能为空";
if (Presets.Count(p => p.Name == presetName) != 0) return "名称重复";
newPreset = new FilterPreset(presetName); public ValueTuple<string, string> Get(RomFile rom)
Presets.Add(newPreset); {
prepareCache();
SavePresets(); Item item;
m_cache.TryGetValue(rom.ID, out item);
return new ValueTuple<string, string>(item.FilterName, item.PresetName);
}
return true; private void prepareCache()
} {
if (m_cacheReady) return;
public void RemovePreset(FilterPreset preset) if (m_items == null) m_items = new List<Item>();
{ if (m_romID == null) m_romID = new List<int>();
if (!Presets.Remove(preset)) return; m_cache = new Dictionary<int, Item>();
SavePresets(); for (int i = 0; i < m_romID.Count && i < m_items.Count; i++)
{
m_cache[m_romID[i]] = m_items[i];
}
EventInvoker.RaiseFilterPresetRemoved(this, preset); m_cacheReady = true;
} }
public void ResetPreset() [Serializable]
{ struct Item
foreach (var param in Paramerters) {
{ public string FilterName;
param.ResetToDefault(); public string PresetName;
} }
} }
}
public void ApplyPreset(FilterPreset preset)
{
foreach (var param in Paramerters)
{
var value = preset.GetParamValue(param.Name, param.ValueType);
if (value == null)
param.ResetToDefault();
else
param.Apply(value);
}
}
}
[Serializable]
private class FilterPresetList
{
public List<FilterPreset> presets;
public FilterPresetList(List<FilterPreset> presets)
{
this.presets = presets;
foreach (var preset in presets)
{
preset.ReadyForJson();
}
}
}
[Serializable]
public class FilterPreset
{
[SerializeField]
public string Name;
[SerializeField]
private List<string> m_paramName = new List<string>();
[SerializeField]
private List<string> m_valueJson = new List<string>();
private bool m_cacheReady = false;
private Dictionary<string, string> m_paramName2ValueJson;
public FilterPreset(string presetName)
{
Name = presetName;
}
public void ReadyForJson()
{
prepareCache();
m_paramName = m_paramName2ValueJson.Keys.ToList();
m_valueJson = m_paramName2ValueJson.Values.ToList();
}
public string GetParamValueJson(string paramName)
{
prepareCache();
string value;
m_paramName2ValueJson.TryGetValue(paramName, out value);
return value;
}
public object GetParamValue(string paramName, Type valueType)
{
var rawStr = GetParamValueJson(paramName);
if (rawStr == null) return null;
if (valueType == typeof(float))
{
float floatVal;
float.TryParse(rawStr, out floatVal);
return floatVal;
}
else if (valueType.IsEnum)
{
var names = Enum.GetNames(valueType);
var values = Enum.GetValues(valueType);
for (int i = 0; i < names.Length; i++)
{
if (names[i].Equals(rawStr))
{
return values.GetValue(i);
}
}
return null;
}
else
{
App.log.Error($"尚未支持的滤镜参数类型{valueType}");
return null;
}
}
public void SetParamValue(string paramName, Type valueType, object value)
{
prepareCache();
m_paramName2ValueJson[paramName] = value.ToString();
}
private void prepareCache()
{
if (m_cacheReady) return;
m_paramName2ValueJson = new Dictionary<string, string>();
for (int i = 0; i < m_paramName.Count; i++)
{
m_paramName2ValueJson[m_paramName[i]] = m_valueJson[i];
}
m_cacheReady = true;
}
}
[Serializable]
public class FilterRomSetting
{
[SerializeField]
private List<int> m_romID;
[SerializeField]
private List<Item> m_items;
bool m_cacheReady = false;
Dictionary<int, Item> m_cache;
public void Setup(RomFile rom, Filter filter, FilterPreset preset)
{
prepareCache();
if (filter == null)
m_cache.Remove(rom.ID);
else
m_cache[rom.ID] = new Item { FilterName = filter.Name, PresetName = preset != null ? preset.Name : null };
}
public string ToJson()
{
prepareCache();
m_romID = m_cache.Keys.ToList();
m_items = m_cache.Values.ToList();
return JsonUtility.ToJson(this);
}
public ValueTuple<string, string> Get(RomFile rom)
{
prepareCache();
Item item;
m_cache.TryGetValue(rom.ID, out item);
return new ValueTuple<string, string>(item.FilterName, item.PresetName);
}
private void prepareCache()
{
if (m_cacheReady) return;
if (m_items == null) m_items = new List<Item>();
if (m_romID == null) m_romID = new List<int>();
m_cache = new Dictionary<int, Item>();
for (int i = 0; i < m_romID.Count && i < m_items.Count; i++)
{
m_cache[m_romID[i]] = m_items[i];
}
m_cacheReady = true;
}
[Serializable]
struct Item
{
public string FilterName;
public string PresetName;
}
}
}
} }

View File

@ -299,12 +299,6 @@ namespace AxibugEmuOnline.Client.Manager
void RecvRoomMyRoomStateChange(byte[] reqData) void RecvRoomMyRoomStateChange(byte[] reqData)
{ {
if (mineRoomMiniInfo == null)
{
App.log.Error("RecvRoomMyRoomStateChange 时 mineRoomMiniInfo 为空");
return;
}
Protobuf_Room_MyRoom_State_Change msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_MyRoom_State_Change>(reqData); Protobuf_Room_MyRoom_State_Change msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_MyRoom_State_Change>(reqData);
long[] oldRoomPlayer = GetRoom4PlayerUIDs(); long[] oldRoomPlayer = GetRoom4PlayerUIDs();
Protobuf_Room_GamePlaySlot[] oldslotArr = GetRoom4GameSlotMiniInfos(); Protobuf_Room_GamePlaySlot[] oldslotArr = GetRoom4GameSlotMiniInfos();

View File

@ -2,7 +2,6 @@ using AxibugEmuOnline.Client.ClientCore;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
@ -15,27 +14,7 @@ namespace AxibugEmuOnline.Client
public delegate void GetRomListAPI(Action<Resp_GameList> callback, int page, int pageSize = 10); public delegate void GetRomListAPI(Action<Resp_GameList> callback, int page, int pageSize = 10);
public delegate void SearchRomListAPI(Action<Resp_GameList> callback, string searchKey, int page, int pageSize = 10); public delegate void SearchRomListAPI(Action<Resp_GameList> callback, string searchKey, int page, int pageSize = 10);
public static string UrlEncode(string str)
{
StringBuilder sb = new StringBuilder();
foreach (char c in str)
{
if ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
c == '-' || c == '_' || c == '.' || c == '!' || c == '~' || c == '*' || c == '\'' || c == '(' || c == ')')
{
sb.Append(c);
}
else
{
sb.Append('%').Append(((int)c).ToString("X2"));
}
}
return sb.ToString();
}
public void GetNesRomList(Action<Resp_GameList> callback, int page, int pageSize = 10) public void GetNesRomList(Action<Resp_GameList> callback, int page, int pageSize = 10)
{ {
App.StartCoroutine(GetNesRomListFlow(page, pageSize, callback)); App.StartCoroutine(GetNesRomListFlow(page, pageSize, callback));
@ -47,13 +26,6 @@ namespace AxibugEmuOnline.Client
} }
private IEnumerator SearchNesRomListFlow(string searchKey, int page, int pageSize, Action<Resp_GameList> callback) private IEnumerator SearchNesRomListFlow(string searchKey, int page, int pageSize, Action<Resp_GameList> callback)
{ {
//避免特殊字符和个别文字编码问题
byte[] gb2312Bytes = Encoding.Default.GetBytes(searchKey);
byte[] utf8Bytes = Encoding.Convert(Encoding.Default, Encoding.UTF8, gb2312Bytes);
// 将UTF-8编码的字节数组转换回字符串此时是UTF-8编码的字符串
string utf8String = Encoding.UTF8.GetString(utf8Bytes);
searchKey = UrlEncode(utf8String);
App.log.Info($"search->{utf8String} ->{searchKey}");
AxiHttpProxy.SendWebRequestProxy request = AxiHttpProxy.Get($"{WebSiteApi}/NesRomList?Page={page}&PageSize={pageSize}&SearchKey={searchKey}"); AxiHttpProxy.SendWebRequestProxy request = AxiHttpProxy.Get($"{WebSiteApi}/NesRomList?Page={page}&PageSize={pageSize}&SearchKey={searchKey}");
yield return request.SendWebRequest; yield return request.SendWebRequest;

View File

@ -1,6 +1,4 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.Event;
using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Event;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -66,9 +64,7 @@ namespace AxibugEmuOnline.Client
else return null; else return null;
} }
//static HashSet<uint> s_temp = new HashSet<uint>(4); static HashSet<uint> s_temp = new HashSet<uint>(4);
//低版本不能这样初始化
static HashSet<uint> s_temp = new HashSet<uint>();
public uint? GetFreeSlotIndex() public uint? GetFreeSlotIndex()
{ {
s_temp.Clear(); s_temp.Clear();
@ -88,25 +84,14 @@ namespace AxibugEmuOnline.Client
public void LetControllerConnect(int conIndex, uint slotIndex) public void LetControllerConnect(int conIndex, uint slotIndex)
{ {
Controller targetController; var targetController = conIndex switch
switch (conIndex)
{ {
case 0: targetController = Controller0;break; 0 => Controller0,
case 1: targetController = Controller1; break; 1 => Controller1,
case 2: targetController = Controller2; break; 2 => Controller2,
case 3: targetController = Controller3; break; 3 => Controller3,
default: _ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}")
throw new System.Exception($"Not Allowed conIndex Range: {conIndex}"); };
break;
}
//var targetController = conIndex switch
//{
// 0 => Controller0,
// 1 => Controller1,
// 2 => Controller2,
// 3 => Controller3,
// _ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}")
//};
if (targetController.ConnectSlot.HasValue) return; if (targetController.ConnectSlot.HasValue) return;
@ -192,13 +177,6 @@ namespace AxibugEmuOnline.Client
public static KeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType) public static KeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType)
{ {
string configKey = $"NES_{controllerInput}_{nesConBtnType}"; string configKey = $"NES_{controllerInput}_{nesConBtnType}";
//PSV平台固定键值
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
{
return KeyListener.GetPSVitaKey(controllerInput, nesConBtnType);
}
if (PlayerPrefs.HasKey(configKey)) if (PlayerPrefs.HasKey(configKey))
{ {
return new KeyListener(PlayerPrefs.GetString(configKey)); return new KeyListener(PlayerPrefs.GetString(configKey));
@ -345,38 +323,6 @@ namespace AxibugEmuOnline.Client
return default(KeyListener); return default(KeyListener);
} }
public static KeyListener GetPSVitaKey(int controllerIndex, EnumButtonType nesConBtnType)
{
switch (controllerIndex)
{
case 0:
switch (nesConBtnType)
{
case EnumButtonType.LEFT:
return new KeyListener(PSVitaKey.Left);
case EnumButtonType.RIGHT:
return new KeyListener(PSVitaKey.Right);
case EnumButtonType.UP:
return new KeyListener(PSVitaKey.Up);
case EnumButtonType.DOWN:
return new KeyListener(PSVitaKey.Down);
case EnumButtonType.START:
return new KeyListener(PSVitaKey.Start);
case EnumButtonType.SELECT:
return new KeyListener(PSVitaKey.Select);
case EnumButtonType.A:
return new KeyListener(PSVitaKey.Circle);
case EnumButtonType.B:
return new KeyListener(PSVitaKey.Cross);
case EnumButtonType.MIC:
return new KeyListener(PSVitaKey.Block);
}
break;
}
return default(KeyListener);
}
} }
} }
} }

View File

@ -212,10 +212,12 @@ namespace AxibugEmuOnline.Client
EditorUtility.SetDirty(db); EditorUtility.SetDirty(db);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
} }
#endif
public IControllerSetuper GetControllerSetuper() public IControllerSetuper GetControllerSetuper()
{ {
return ControllerMapper; return ControllerMapper;
} }
#endif
} }
} }

View File

@ -18,11 +18,9 @@ public class SonyVitaCommonDialog : MonoBehaviour
Sony.Vita.Dialog.Ime.ImeDialogParams info = new Sony.Vita.Dialog.Ime.ImeDialogParams(); Sony.Vita.Dialog.Ime.ImeDialogParams info = new Sony.Vita.Dialog.Ime.ImeDialogParams();
// Set supported languages, 'or' flags together or set to 0 to support all languages. // Set supported languages, 'or' flags together or set to 0 to support all languages.
info.supportedLanguages = Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_SIMPLIFIED_CHINESE | info.supportedLanguages = Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_JAPANESE |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_JAPANESE |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_ENGLISH_GB | Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_ENGLISH_GB |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_TRADITIONAL_CHINESE; Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_DANISH;
info.languagesForced = true; info.languagesForced = true;
info.type = Sony.Vita.Dialog.Ime.EnumImeDialogType.TYPE_DEFAULT; info.type = Sony.Vita.Dialog.Ime.EnumImeDialogType.TYPE_DEFAULT;
@ -46,7 +44,7 @@ public class SonyVitaCommonDialog : MonoBehaviour
Debug.Log("IME text: " + result.text); Debug.Log("IME text: " + result.text);
if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK) if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK)
{ {
resultAct.Invoke(result.text); resultAct.Invoke(result);
resultAct = null; resultAct = null;
} }
} }

View File

@ -23,7 +23,7 @@ namespace AxibugEmuOnline.Client
public static void Input(Action<string> callback, string placeHolder, string defaultText) public static void Input(Action<string> callback, string placeHolder, string defaultText)
{ {
#if UNITY_PSP2 && !UNITY_EDITOR #if UNITY_PSP2
App.sonyVitaCommonDialog.ShowPSVitaIME(callback, placeHolder, defaultText); App.sonyVitaCommonDialog.ShowPSVitaIME(callback, placeHolder, defaultText);
#else #else
s_ins.m_InputUI.Show(new ValueTuple<Action<string>, string, string>(callback, placeHolder, defaultText)); s_ins.m_InputUI.Show(new ValueTuple<Action<string>, string, string>(callback, placeHolder, defaultText));

View File

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

View File

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

View File

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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 41cd7684d8de61f4499c3aa27a6c5b3a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 50dfce75937af2a44bafd221a0163501
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 091b4306faaa8fc4084836c5237b76c8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

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

View File

@ -51,25 +51,9 @@ namespace VirtualNes.Core
public override int GetHashCode() public override int GetHashCode()
{ {
//return CombineHashCode(raw0, raw1, raw2, raw3, valid);
return HashCode.Combine(raw0, raw1, raw2, raw3, valid); return HashCode.Combine(raw0, raw1, raw2, raw3, valid);
} }
/// <summary>
/// .NetStandard2.0编译备用函数
/// </summary>
/// <param name="raw0"></param>
/// <param name="raw1"></param>
/// <param name="raw2"></param>
/// <param name="raw3"></param>
/// <param name="valid"></param>
/// <returns></returns>
static int CombineHashCode(uint raw0, uint raw1, uint raw2, uint raw3, bool valid)
{
uint validUInt = valid ? 1u : 0u;
uint combinedHash = (raw0 * 31 + raw1) * 31 + raw2 * 31 + raw3 * 31 + validUInt;
return (int)combinedHash;
}
public static bool operator ==(ControllerState left, ControllerState right) public static bool operator ==(ControllerState left, ControllerState right)
{ {
return return

View File

@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugEmuOnline.Web", "Axib
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugEmuOnline.Server", "AxibugEmuOnline.Server\AxibugEmuOnline.Server.csproj", "{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugEmuOnline.Server", "AxibugEmuOnline.Server\AxibugEmuOnline.Server.csproj", "{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualNes.Core", "Core\VirtualNes.Core\VirtualNes.Core.csproj", "{637EB35A-4D1A-41EA-9A7B-459E17E93981}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualNes.Core", "VirtualNes.Core\VirtualNes.Core.csproj", "{8A4771D6-74B9-453C-9932-6B774280E325}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -23,10 +23,10 @@ Global
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Debug|Any CPU.Build.0 = Debug|Any CPU {9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.Build.0 = Release|Any CPU {9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.Build.0 = Release|Any CPU
{637EB35A-4D1A-41EA-9A7B-459E17E93981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8A4771D6-74B9-453C-9932-6B774280E325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{637EB35A-4D1A-41EA-9A7B-459E17E93981}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A4771D6-74B9-453C-9932-6B774280E325}.Debug|Any CPU.Build.0 = Debug|Any CPU
{637EB35A-4D1A-41EA-9A7B-459E17E93981}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A4771D6-74B9-453C-9932-6B774280E325}.Release|Any CPU.ActiveCfg = Release|Any CPU
{637EB35A-4D1A-41EA-9A7B-459E17E93981}.Release|Any CPU.Build.0 = Release|Any CPU {8A4771D6-74B9-453C-9932-6B774280E325}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -73,7 +73,7 @@ namespace VirtualNes.Core
public void Process(ISoundDataBuffer lpBuffer, uint dwSize) public void Process(ISoundDataBuffer lpBuffer, uint dwSize)
{ {
int nBits = Supporter.S.Config.sound.nBits; int nBits = Supporter.Config.sound.nBits;
uint dwLength = (uint)(dwSize / (nBits / 8)); uint dwLength = (uint)(dwSize / (nBits / 8));
int output; int output;
QUEUEDATA q = new QUEUEDATA(); QUEUEDATA q = new QUEUEDATA();
@ -82,11 +82,11 @@ namespace VirtualNes.Core
var pSoundBuf = m_SoundBuffer; var pSoundBuf = m_SoundBuffer;
int nCcount = 0; int nCcount = 0;
int nFilterType = Supporter.S.Config.sound.nFilterType; int nFilterType = Supporter.Config.sound.nFilterType;
if (!Supporter.S.Config.sound.bEnable) if (!Supporter.Config.sound.bEnable)
{ {
byte empty = (byte)(Supporter.S.Config.sound.nRate == 8 ? 128 : 0); byte empty = (byte)(Supporter.Config.sound.nRate == 8 ? 128 : 0);
for (int i = 0; i < dwSize; i++) for (int i = 0; i < dwSize; i++)
lpBuffer.WriteByte(empty); lpBuffer.WriteByte(empty);
return; return;
@ -108,7 +108,7 @@ namespace VirtualNes.Core
MemoryUtility.ZEROMEMORY(vol, vol.Length); MemoryUtility.ZEROMEMORY(vol, vol.Length);
var bMute = m_bMute; var bMute = m_bMute;
var nVolume = Supporter.S.Config.sound.nVolume; var nVolume = Supporter.Config.sound.nVolume;
int nMasterVolume = bMute[0] ? nVolume[0] : 0; int nMasterVolume = bMute[0] ? nVolume[0] : 0;
@ -151,7 +151,7 @@ namespace VirtualNes.Core
vol[23] = (int)(bMute[8] ? (FME7_VOL * nVolume[11] * nMasterVolume) / (100 * 100) : 0); vol[23] = (int)(bMute[8] ? (FME7_VOL * nVolume[11] * nMasterVolume) / (100 * 100) : 0);
// double cycle_rate = ((double)FRAME_CYCLES*60.0/12.0)/(double)Config.sound.nRate; // double cycle_rate = ((double)FRAME_CYCLES*60.0/12.0)/(double)Config.sound.nRate;
double cycle_rate = (nes.nescfg.FrameCycles * 60.0 / 12.0) / Supporter.S.Config.sound.nRate; double cycle_rate = (nes.nescfg.FrameCycles * 60.0 / 12.0) / Supporter.Config.sound.nRate;
// CPUサイクル数がループしてしまった時の対策処理 // CPUサイクル数がループしてしまった時の対策処理
if (elapsed_time > nes.cpu.GetTotalCycles()) if (elapsed_time > nes.cpu.GetTotalCycles())
@ -253,7 +253,7 @@ namespace VirtualNes.Core
// DC成分のカット(HPF TEST) // DC成分のカット(HPF TEST)
{ {
// static double cutoff = (2.0*3.141592653579*40.0/44100.0); // static double cutoff = (2.0*3.141592653579*40.0/44100.0);
double cutoff = cutofftemp / Supporter.S.Config.sound.nRate; double cutoff = cutofftemp / Supporter.Config.sound.nRate;
double @in, @out; double @in, @out;
@in = output; @in = output;
@ -436,7 +436,7 @@ namespace VirtualNes.Core
public void SoundSetup() public void SoundSetup()
{ {
float fClock = nes.nescfg.CpuClock; float fClock = nes.nescfg.CpuClock;
int nRate = Supporter.S.Config.sound.nRate; int nRate = Supporter.Config.sound.nRate;
@internal.Setup(fClock, nRate); @internal.Setup(fClock, nRate);
vrc6.Setup(fClock, nRate); vrc6.Setup(fClock, nRate);
@ -460,7 +460,7 @@ namespace VirtualNes.Core
elapsed_time = 0; elapsed_time = 0;
float fClock = nes.nescfg.CpuClock; float fClock = nes.nescfg.CpuClock;
int nRate = Supporter.S.Config.sound.nRate; int nRate = Supporter.Config.sound.nRate;
@internal.Reset(fClock, nRate); @internal.Reset(fClock, nRate);
vrc6.Reset(fClock, nRate); vrc6.Reset(fClock, nRate);

View File

@ -1,4 +1,4 @@

using System; using System;
namespace VirtualNes.Core namespace VirtualNes.Core
@ -184,15 +184,15 @@ namespace VirtualNes.Core
Setup(fClock, nRate); Setup(fClock, nRate);
// $4011は初期化しない // $4011反場ヽ趙仄卅中
ushort addr; ushort addr;
for (addr = 0x4000; addr <= 0x4010; addr++) for (addr = 0x4000; addr <= 0x4010; addr++)
{ {
Write(addr, 0x00); Write(addr, 0x00);
SyncWrite(addr, 0x00); SyncWrite(addr, 0x00);
} }
// Write( 0x4001, 0x08 ); // Reset時はincモードになる? // Write( 0x4001, 0x08 ); // Reset媆反inc乒奈玉卞卅月?
// Write( 0x4005, 0x08 ); // Reset時はincモードになる? // Write( 0x4005, 0x08 ); // Reset媆反inc乒奈玉卞卅月?
Write(0x4012, 0x00); Write(0x4012, 0x00);
Write(0x4013, 0x00); Write(0x4013, 0x00);
Write(0x4015, 0x00); Write(0x4015, 0x00);
@ -200,7 +200,7 @@ namespace VirtualNes.Core
SyncWrite(0x4013, 0x00); SyncWrite(0x4013, 0x00);
SyncWrite(0x4015, 0x00); SyncWrite(0x4015, 0x00);
// $4017は書き込みで初期化しない(初期モードが0であるのを期待したソフトがある為) // $4017反𤩸五煋心匹場ヽ趙仄卅中(場ヽ乒奈玉互0匹丐月及毛ヽ渾仄凶末白玄互丐月鮋)
FrameIRQ = 0xC0; FrameIRQ = 0xC0;
FrameCycle = 0; FrameCycle = 0;
FrameIRQoccur = 0; FrameIRQoccur = 0;
@ -301,7 +301,7 @@ namespace VirtualNes.Core
case 0x4017: case 0x4017:
break; break;
// VirtuaNES固有ポート // VirtuaNES嘐衄禾奈玄
case 0x4018: case 0x4018:
UpdateRectangle(ch0, data); UpdateRectangle(ch0, data);
UpdateRectangle(ch1, data); UpdateRectangle(ch1, data);
@ -635,7 +635,7 @@ namespace VirtualNes.Core
} }
} }
// インチキ臭いプチノイズカット(TEST) // 奶件民平堪中皿民用奶朮市永玄(TEST)
ch4.dpcm_output_real = ((ch4.reg[1] & 0x01) + ch4.dpcm_value * 2) - 0x40; ch4.dpcm_output_real = ((ch4.reg[1] & 0x01) + ch4.dpcm_value * 2) - 0x40;
if (Math.Abs(ch4.dpcm_output_real - ch4.dpcm_output_fake) <= 8) if (Math.Abs(ch4.dpcm_output_real - ch4.dpcm_output_fake) <= 8)
{ {
@ -712,7 +712,7 @@ namespace VirtualNes.Core
private int RenderTriangle() private int RenderTriangle()
{ {
int vol; int vol;
if (Supporter.S.Config.sound.bDisableVolumeEffect) if (Supporter.Config.sound.bDisableVolumeEffect)
{ {
vol = 256; vol = 256;
} }
@ -731,7 +731,7 @@ namespace VirtualNes.Core
return ch2.nowvolume * vol / 256; return ch2.nowvolume * vol / 256;
} }
if (!(Supporter.S.Config.sound.bChangeTone && ChannelTone[2, 0] != 0)) if (!(Supporter.Config.sound.bChangeTone && ChannelTone[2, 0] != 0))
{ {
ch2.phaseacc -= cycle_rate; ch2.phaseacc -= cycle_rate;
if (ch2.phaseacc >= 0) if (ch2.phaseacc >= 0)
@ -756,7 +756,7 @@ namespace VirtualNes.Core
return ch2.nowvolume * vol / 256; return ch2.nowvolume * vol / 256;
} }
// 加重平均 // 樓笭ⅸ歙
int num_times, total; int num_times, total;
num_times = total = 0; num_times = total = 0;
while (ch2.phaseacc < 0) while (ch2.phaseacc < 0)
@ -799,7 +799,7 @@ namespace VirtualNes.Core
return ch2.nowvolume * vol / 256; return ch2.nowvolume * vol / 256;
} }
// 加重平均 // 樓笭ⅸ歙
int num_times, total; int num_times, total;
num_times = total = 0; num_times = total = 0;
while (ch2.phaseacc < 0) while (ch2.phaseacc < 0)
@ -832,9 +832,9 @@ namespace VirtualNes.Core
} }
int volume = ch.nowvolume; int volume = ch.nowvolume;
if (!(Supporter.S.Config.sound.bChangeTone && (ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6]) != 0)) if (!(Supporter.Config.sound.bChangeTone && (ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6]) != 0))
{ {
// 補間処理 // 娗嶲<EFBFBD>
double total; double total;
double sample_weight = ch.phaseacc; double sample_weight = ch.phaseacc;
if (sample_weight > cycle_rate) if (sample_weight > cycle_rate)
@ -864,7 +864,7 @@ namespace VirtualNes.Core
int x = ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6] - 1; int x = ChannelTone[(ch.complement == 0) ? 0 : 1, ch.reg[0] >> 6] - 1;
int pTone = 0; int pTone = 0;
// 更新無し // 載陔剠仄
ch.phaseacc -= cycle_rate * 2; ch.phaseacc -= cycle_rate * 2;
if (ch.phaseacc >= 0) if (ch.phaseacc >= 0)
{ {
@ -872,7 +872,7 @@ namespace VirtualNes.Core
return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2); return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2);
} }
// 1ステップだけ更新 // 1旦氾永皿分仃載陔
int freq = INT2FIX(ch.freq + 1); int freq = INT2FIX(ch.freq + 1);
if (freq > cycle_rate * 2) if (freq > cycle_rate * 2)
{ {
@ -882,7 +882,7 @@ namespace VirtualNes.Core
return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2); return temp * volume / ((1 << RECTANGLE_VOL_SHIFT) / 2);
} }
// 加重平均 // 樓笭ⅸ歙
int num_times, total; int num_times, total;
num_times = total = 0; num_times = total = 0;
while (ch.phaseacc < 0) while (ch.phaseacc < 0)
@ -1015,7 +1015,7 @@ namespace VirtualNes.Core
SyncWrite4017(data); SyncWrite4017(data);
break; break;
// VirtuaNES屌桳億乕僩 // VirtuaNES娚葲<EFBFBD><EFBFBD><EFBFBD>
case 0x4018: case 0x4018:
SyncUpdateRectangle(ch0, data); SyncUpdateRectangle(ch0, data);
SyncUpdateRectangle(ch1, data); SyncUpdateRectangle(ch1, data);

View File

@ -1110,7 +1110,7 @@ namespace VirtualNes.Core
case 0xD2: /* JAM */ case 0xD2: /* JAM */
case 0xF2: /* JAM */ case 0xF2: /* JAM */
default: default:
if (!Supporter.S.Config.emulator.bIllegalOp) if (!Supporter.Config.emulator.bIllegalOp)
{ {
throw new Exception("IllegalOp"); throw new Exception("IllegalOp");
} }

View File

@ -40,7 +40,7 @@ namespace VirtualNes.Core
Debuger.Log($"SOUND CODE:{addr & 0x1F:X2}"); Debuger.Log($"SOUND CODE:{addr & 0x1F:X2}");
// OSDにするべきか… // OSDにするべきか…
if (Supporter.S.Config.sound.bExtraSoundEnable) if (Supporter.Config.sound.bExtraSoundEnable)
{ {
//TODO : 似乎VirtuaNES有直接播放某个音频文件的功能 //TODO : 似乎VirtuaNES有直接播放某个音频文件的功能
//DirectSound.EsfAllStop(); //DirectSound.EsfAllStop();

View File

@ -43,7 +43,7 @@ namespace VirtualNes.Core
} }
// OSDにするべきか… // OSDにするべきか…
if (Supporter.S.Config.sound.bExtraSoundEnable) if (Supporter.Config.sound.bExtraSoundEnable)
{ {
//TODO : 似乎VirtuaNES有直接播放某个音频文件的功能 //TODO : 似乎VirtuaNES有直接播放某个音频文件的功能
//DirectSound.EsfAllStop(); //DirectSound.EsfAllStop();

View File

@ -57,7 +57,7 @@ namespace VirtualNes.Core
9,10, 8,11,13,12,14,15 }; 9,10, 8,11,13,12,14,15 };
// OSDにするべきか… // OSDにするべきか…
if (Supporter.S.Config.sound.bExtraSoundEnable) if (Supporter.Config.sound.bExtraSoundEnable)
{ {
//TODO : 似乎VirtuaNES有直接播放某个音频文件的功能 //TODO : 似乎VirtuaNES有直接播放某个音频文件的功能
Debuger.Log($"CODE {data:X2}"); Debuger.Log($"CODE {data:X2}");

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
@ -249,7 +249,7 @@ namespace VirtualNes.Core
LoadDISK(); LoadDISK();
{ {
// Padクラス内だと初期化タイミングが遅いのでここで // Pad・ッ・鬣ケトレ、タ、ネウ<EFBFBD>レサッ・ソ・、・゚・<EFBFBD>ー、ャ゚W、、、ホ、ヌ、ウ、ウ、ヌ
uint crc = rom.GetPROM_CRC(); uint crc = rom.GetPROM_CRC();
if ( if (
crc == 0xe792de94 // Best Play - Pro Yakyuu (New) (J) crc == 0xe792de94 // Best Play - Pro Yakyuu (New) (J)
@ -275,7 +275,7 @@ namespace VirtualNes.Core
LoadTurboFile(); LoadTurboFile();
// VS-Unisystemのデフォルト設定 // VS-Unisystem、ホ・ヌ・ユ・ゥ・<EFBFBD>ネヤOカィ
if (rom.IsVSUNISYSTEM()) if (rom.IsVSUNISYSTEM())
{ {
uint crc = rom.GetPROM_CRC(); uint crc = rom.GetPROM_CRC();
@ -286,13 +286,13 @@ namespace VirtualNes.Core
Reset(); Reset();
// ゲーム固有のデフォルトオプションを設定(設定戻す時に使う為) // ・イゥ`・犹フモミ、ホ・ヌ・ユ・ゥ・<EFBDA9>ネ・ェ・ラ・キ・逾<EFBDA5><E980BE>Oカィ(ヤOカィ諾、ケ瓶、ヒハケ、ヲ樣)
GameOption.defRenderMethod = (int)GetRenderMethod(); GameOption.defRenderMethod = (int)GetRenderMethod();
GameOption.defIRQtype = GetIrqType(); GameOption.defIRQtype = GetIrqType();
GameOption.defFrameIRQ = GetFrameIRQmode(); GameOption.defFrameIRQ = GetFrameIRQmode();
GameOption.defVideoMode = GetVideoMode(); GameOption.defVideoMode = GetVideoMode();
// 設定をロードして設定する(エントリが無ければデフォルトが入る) // ヤOカィ、<EFBFBD>愰`・ノ、キ、ニヤOカィ、ケ、<EFBDB9>(・ィ・<EFBDA8>ネ・熙ャ殪、ア、<EFBDB1>ミ・ヌ・ユ・ゥ・<EFBDA9>ネ、ャネ<EFBDAC><EFBE88>)
if (rom.GetMapperNo() != 20) if (rom.GetMapperNo() != 20)
{ {
GameOption.Load(rom.GetPROM_CRC()); GameOption.Load(rom.GetPROM_CRC());
@ -326,17 +326,17 @@ namespace VirtualNes.Core
if (pad.GetExController() != (int)EXCONTROLLER.EXCONTROLLER_TURBOFILE) if (pad.GetExController() != (int)EXCONTROLLER.EXCONTROLLER_TURBOFILE)
return; return;
var fp = Supporter.S.OpenFile(Supporter.S.Config.path.szSavePath, "TurboFile.vtf"); var fp = Supporter.OpenFile(Supporter.Config.path.szSavePath, "TurboFile.vtf");
try try
{ {
if (fp == null) if (fp == null)
{ {
// xxx ファイルを開けません // xxx ・ユ・。・、・<EFBFBD><EFBFBD>_、ア、゙、サ、<EFBFBD>
throw new Exception($"Can Not Open File [TurboFile.vtf]"); throw new Exception($"Can Not Open File [TurboFile.vtf]");
} }
long size = fp.Length; long size = fp.Length;
// ファイルサイズ取得 // ・ユ・。・、・<EFBFBD>オ・、・コネ。オテ
if (size > 32 * 1024) if (size > 32 * 1024)
{ {
size = 32 * 1024; size = 32 * 1024;
@ -354,7 +354,7 @@ namespace VirtualNes.Core
private void LoadDISK() private void LoadDISK()
{ {
//todo : 磁碟机读取支持 //todo : エナオ忞巐チネ。ヨァウヨ
} }
private void LoadSRAM() private void LoadSRAM()
@ -367,10 +367,10 @@ namespace VirtualNes.Core
if (!rom.IsSAVERAM()) if (!rom.IsSAVERAM())
return; return;
var saveFileDir = Supporter.S.Config.path.szSavePath; var saveFileDir = Supporter.Config.path.szSavePath;
var saveFileName = $"{rom.GetRomName()}.sav"; var saveFileName = $"{rom.GetRomName()}.sav";
var fp = Supporter.S.OpenFile(saveFileDir, saveFileName); var fp = Supporter.OpenFile(saveFileDir, saveFileName);
try try
{ {
@ -400,7 +400,7 @@ namespace VirtualNes.Core
{ {
int i; int i;
// 儊儌儕僋儕傾 // メモリクリア
MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length); MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length);
MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length); MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length);
MemoryUtility.ZEROMEMORY(MMU.DRAM, MMU.DRAM.Length); MemoryUtility.ZEROMEMORY(MMU.DRAM, MMU.DRAM.Length);
@ -420,11 +420,11 @@ namespace VirtualNes.Core
MMU.PROM = MMU.VROM = null; MMU.PROM = MMU.VROM = null;
// 0 彍嶼杊巭懳嶔 // 0 除算防止対策
MMU.PROM_8K_SIZE = MMU.PROM_16K_SIZE = MMU.PROM_32K_SIZE = 1; MMU.PROM_8K_SIZE = MMU.PROM_16K_SIZE = MMU.PROM_32K_SIZE = 1;
MMU.VROM_1K_SIZE = MMU.VROM_2K_SIZE = MMU.VROM_4K_SIZE = MMU.VROM_8K_SIZE = 1; MMU.VROM_1K_SIZE = MMU.VROM_2K_SIZE = MMU.VROM_4K_SIZE = MMU.VROM_8K_SIZE = 1;
// 僨僼僅儖僩僶儞僋愝掕 // デフォルトバンク設定
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
MMU.CPU_MEM_BANK[i] = null; MMU.CPU_MEM_BANK[i] = null;
@ -432,11 +432,11 @@ namespace VirtualNes.Core
MMU.CPU_MEM_PAGE[i] = 0; MMU.CPU_MEM_PAGE[i] = 0;
} }
// 撪憻RAM/WRAM // 内臓RAM/WRAM
MMU.SetPROM_Bank(0, MMU.RAM, MMU.BANKTYPE_RAM); MMU.SetPROM_Bank(0, MMU.RAM, MMU.BANKTYPE_RAM);
MMU.SetPROM_Bank(3, MMU.WRAM, MMU.BANKTYPE_RAM); MMU.SetPROM_Bank(3, MMU.WRAM, MMU.BANKTYPE_RAM);
// 僟儈乕 // ダミー
MMU.SetPROM_Bank(1, MMU.XRAM, MMU.BANKTYPE_ROM); MMU.SetPROM_Bank(1, MMU.XRAM, MMU.BANKTYPE_ROM);
MMU.SetPROM_Bank(2, MMU.XRAM, MMU.BANKTYPE_ROM); MMU.SetPROM_Bank(2, MMU.XRAM, MMU.BANKTYPE_ROM);
@ -502,13 +502,13 @@ namespace VirtualNes.Core
EmulationCPU(nescfg.ScanlineCycles); EmulationCPU(nescfg.ScanlineCycles);
if (bDraw) if (bDraw)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
else else
{ {
if (pad.IsZapperMode() && scanline == ZapperY) if (pad.IsZapperMode() && scanline == ZapperY)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
else else
{ {
@ -518,11 +518,11 @@ namespace VirtualNes.Core
} }
else else
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
} }
} }
ppu.ScanlineNext(); // 偙傟偺埵抲偱儔僗僞乕宯偼夋柺偑堘偆 ppu.ScanlineNext(); // これの位置でラスター系は画面が違う
if (RenderMethod == EnumRenderMethod.PRE_ALL_RENDER) if (RenderMethod == EnumRenderMethod.PRE_ALL_RENDER)
EmulationCPU(nescfg.ScanlineCycles); EmulationCPU(nescfg.ScanlineCycles);
@ -535,13 +535,13 @@ namespace VirtualNes.Core
EmulationCPU(nescfg.HDrawCycles); EmulationCPU(nescfg.HDrawCycles);
if (bDraw) if (bDraw)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
else else
{ {
if (pad.IsZapperMode() && scanline == ZapperY) if (pad.IsZapperMode() && scanline == ZapperY)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
else else
{ {
@ -551,7 +551,7 @@ namespace VirtualNes.Core
} }
else else
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
} }
} }
} }
@ -583,7 +583,7 @@ namespace VirtualNes.Core
{ {
pad.VSync(); pad.VSync();
// VBLANK婜娫 // VBLANK期間
if (scanline == nescfg.TotalScanlines - 1) if (scanline == nescfg.TotalScanlines - 1)
{ {
ppu.VBlankEnd(); ppu.VBlankEnd();
@ -642,7 +642,7 @@ namespace VirtualNes.Core
if (scanline == 0) if (scanline == 0)
{ {
// 僟儈乕僗僉儍儞儔僀儞 // ダミースキャンライン
// H-Draw (4fetches*32) // H-Draw (4fetches*32)
EmulationCPU(FETCH_CYCLES * 128); EmulationCPU(FETCH_CYCLES * 128);
ppu.FrameStart(); ppu.FrameStart();
@ -655,10 +655,10 @@ namespace VirtualNes.Core
} }
else if (scanline < 240) else if (scanline < 240)
{ {
// 僗僋儕乕儞昤夋(Scanline 1乣239) // スクリーン描画(Scanline 1239)
if (bDraw) if (bDraw)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
ppu.ScanlineNext(); ppu.ScanlineNext();
EmulationCPU(FETCH_CYCLES * 10); EmulationCPU(FETCH_CYCLES * 10);
mapper.HSync(scanline); mapper.HSync(scanline);
@ -670,7 +670,7 @@ namespace VirtualNes.Core
{ {
if (pad.IsZapperMode() && scanline == ZapperY) if (pad.IsZapperMode() && scanline == ZapperY)
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
ppu.ScanlineNext(); ppu.ScanlineNext();
EmulationCPU(FETCH_CYCLES * 10); EmulationCPU(FETCH_CYCLES * 10);
mapper.HSync(scanline); mapper.HSync(scanline);
@ -694,7 +694,7 @@ namespace VirtualNes.Core
} }
else else
{ {
ppu.Scanline(scanline, Supporter.S.Config.graphics.bAllSprite, Supporter.S.Config.graphics.bLeftClip); ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
ppu.ScanlineNext(); ppu.ScanlineNext();
EmulationCPU(FETCH_CYCLES * 10); EmulationCPU(FETCH_CYCLES * 10);
mapper.HSync(scanline); mapper.HSync(scanline);
@ -707,7 +707,7 @@ namespace VirtualNes.Core
} }
else if (scanline == 240) else if (scanline == 240)
{ {
// 僟儈乕僗僉儍儞儔僀儞 (Scanline 240) // ダミースキャンライン (Scanline 240)
mapper.VSync(); mapper.VSync();
EmulationCPU(nescfg.HDrawCycles); EmulationCPU(nescfg.HDrawCycles);
@ -720,7 +720,7 @@ namespace VirtualNes.Core
{ {
pad.VSync(); pad.VSync();
// VBLANK婜娫 // VBLANK期間
if (scanline == nescfg.TotalScanlines - 1) if (scanline == nescfg.TotalScanlines - 1)
{ {
ppu.VBlankEnd(); ppu.VBlankEnd();
@ -864,7 +864,7 @@ namespace VirtualNes.Core
MMU.VROM_4K_SIZE = rom.GetVROM_SIZE() * 2; MMU.VROM_4K_SIZE = rom.GetVROM_SIZE() * 2;
MMU.VROM_8K_SIZE = rom.GetVROM_SIZE(); MMU.VROM_8K_SIZE = rom.GetVROM_SIZE();
// 僨僼僅儖僩僶儞僋 // デフォルトバンク
if (MMU.VROM_8K_SIZE != 0) if (MMU.VROM_8K_SIZE != 0)
{ {
MMU.SetVROM_8K_Bank(0); MMU.SetVROM_8K_Bank(0);
@ -874,7 +874,7 @@ namespace VirtualNes.Core
MMU.SetCRAM_8K_Bank(0); MMU.SetCRAM_8K_Bank(0);
} }
// 儈儔乕 // ミラー
if (rom.Is4SCREEN()) if (rom.Is4SCREEN())
{ {
MMU.SetVRAM_Mirror(MMU.VRAM_MIRROR4); MMU.SetVRAM_Mirror(MMU.VRAM_MIRROR4);
@ -976,13 +976,13 @@ namespace VirtualNes.Core
reg.S = 0xFF; reg.S = 0xFF;
reg.P = CPU.Z_FLAG | CPU.R_FLAG | CPU.I_FLAG; reg.P = CPU.Z_FLAG | CPU.R_FLAG | CPU.I_FLAG;
// 埨慡懳嶔傪寭偹偰偁偊偰儖乕僾偵(1昩暘) // 安全対策を兼ねてあえてループに(1秒分)
for (int i = 0; i < nescfg.TotalScanlines * 60; i++) for (int i = 0; i < nescfg.TotalScanlines * 60; i++)
{ {
EmulationCPU(nescfg.ScanlineCycles); EmulationCPU(nescfg.ScanlineCycles);
cpu.GetContext(ref reg); cpu.GetContext(ref reg);
// 柍尷儖乕僾偵擖偭偨偙偲傪妋擣偟偨傜敳偗傞 // 無限ループに入ったことを確認したら抜ける
if (reg.PC == 0x4700) if (reg.PC == 0x4700)
{ {
break; break;
@ -993,7 +993,7 @@ namespace VirtualNes.Core
} }
cpu.GetContext(ref reg); cpu.GetContext(ref reg);
// 柍尷儖乕僾偵擖偭偰偄偨傜嵞愝掕偡傞 // 無限ループに入っていたら再設定する
if (reg.PC == 0x4700) if (reg.PC == 0x4700)
{ {
reg.PC = 0x4720; // Play Address reg.PC = 0x4720; // Play Address
@ -1009,7 +1009,7 @@ namespace VirtualNes.Core
else else
{ {
cpu.GetContext(ref reg); cpu.GetContext(ref reg);
reg.PC = 0x4700; // 柍尷儖乕僾 reg.PC = 0x4700; // 無限ループ
reg.S = 0xFF; reg.S = 0xFF;
EmulationCPU(nescfg.ScanlineCycles * nescfg.TotalScanlines); EmulationCPU(nescfg.ScanlineCycles * nescfg.TotalScanlines);
@ -1095,7 +1095,7 @@ namespace VirtualNes.Core
Debuger.Log($"Saving SAVERAM...[{romName}]"); Debuger.Log($"Saving SAVERAM...[{romName}]");
Supporter.S.SaveSRAMToFile(MMU.WRAM, romName); Supporter.SaveSRAMToFile(MMU.WRAM, romName);
} }
} }
@ -1143,7 +1143,7 @@ namespace VirtualNes.Core
} }
} }
Supporter.S.SaveDISKToFile(contents.ToArray(), rom.GetRomName()); Supporter.SaveDISKToFile(contents.ToArray(), rom.GetRomName());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -1168,7 +1168,7 @@ namespace VirtualNes.Core
{ {
Debuger.Log("Saving TURBOFILE..."); Debuger.Log("Saving TURBOFILE...");
Supporter.S.SaveFile(MMU.ERAM, Supporter.S.Config.path.szSavePath, "TurboFile.vtf"); Supporter.SaveFile(MMU.ERAM, Supporter.Config.path.szSavePath, "TurboFile.vtf");
} }
} }
@ -1186,7 +1186,7 @@ namespace VirtualNes.Core
if (m_BarcodeCycles > 1000) if (m_BarcodeCycles > 1000)
{ {
m_BarcodeCycles = 0; m_BarcodeCycles = 0;
// 掆巭丠 // 停止?
if (m_BarcodeData[m_BarcodePtr] != 0xFF) if (m_BarcodeData[m_BarcodePtr] != 0xFF)
{ {
m_BarcodeOut = m_BarcodeData[m_BarcodePtr++]; m_BarcodeOut = m_BarcodeData[m_BarcodePtr++];
@ -1227,7 +1227,7 @@ namespace VirtualNes.Core
return; return;
m_TapeCycles += (nescfg.CpuClock / 32000.0); m_TapeCycles += (nescfg.CpuClock / 32000.0);
// m_TapeCycles += (nescfg.CpuClock / 22050.0); // 抶偡偓偰僟儊偭傐偄 // m_TapeCycles += (nescfg.CpuClock / 22050.0); // 遅すぎてダメっぽい
if (m_bTapePlay) if (m_bTapePlay)
{ {
@ -1293,7 +1293,7 @@ namespace VirtualNes.Core
return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF];
} }
return 0x00; // Warning梊杊 return 0x00; // Warning予防
} }
private byte ReadReg(ushort addr) private byte ReadReg(ushort addr)
@ -1504,7 +1504,7 @@ namespace VirtualNes.Core
pad.Write(addr, data); pad.Write(addr, data);
apu.Write(addr, data); apu.Write(addr, data);
break; break;
// VirtuaNES屌桳億乕僩 // VirtuaNES固有ポート
case 0x18: case 0x18:
apu.Write(addr, data); apu.Write(addr, data);
break; break;
@ -1596,7 +1596,7 @@ namespace VirtualNes.Core
ref state.reg.cpureg.FrameIRQ_type, ref state.reg.cpureg.FrameIRQ_type,
ref state.reg.cpureg.FrameIRQ, ref state.reg.cpureg.FrameIRQ,
ref state.reg.cpureg.FrameIRQ_occur); ref state.reg.cpureg.FrameIRQ_occur);
state.reg.cpureg.FrameIRQ_cycles = cycles; // 参照がINTな為 state.reg.cpureg.FrameIRQ_cycles = cycles; // イホユユ、ャINT、ハ樣」ィ、ゥ
state.reg.cpureg.DMA_cycles = cpu.GetDmaCycles(); state.reg.cpureg.DMA_cycles = cpu.GetDmaCycles();
state.reg.cpureg.emul_cycles = emul_cycles; state.reg.cpureg.emul_cycles = emul_cycles;
@ -1625,7 +1625,7 @@ namespace VirtualNes.Core
MemoryUtility.memcpy(state.ram.SPPAL, MMU.SPPAL, state.ram.SPPAL.Length); MemoryUtility.memcpy(state.ram.SPPAL, MMU.SPPAL, state.ram.SPPAL.Length);
MemoryUtility.memcpy(state.ram.SPRAM, MMU.SPRAM, state.ram.SPRAM.Length); MemoryUtility.memcpy(state.ram.SPRAM, MMU.SPRAM, state.ram.SPRAM.Length);
// S-RAM STATE(使用/未使用に関わらず存在すればセーブする) // S-RAM STATE(ハケモテ/ホエハケモテ、ヒ騅、<E9A885>鬢コエ贇レ、ケ、<EFBDB9>ミ・サゥ`・ヨ、ケ、<EFBDB9>)
if (rom.IsSAVERAM()) if (rom.IsSAVERAM())
{ {
size = (uint)SAVERAM_SIZE; size = (uint)SAVERAM_SIZE;
@ -1649,9 +1649,9 @@ namespace VirtualNes.Core
uint size = 0; uint size = 0;
// SAVE CPU MEMORY BANK DATA // SAVE CPU MEMORY BANK DATA
// BANK0,1,2はバンクセーブに関係なし // BANK0,1,2、マ・ミ・<EFBFBD>ッ・サゥ`・ヨ、ヒ騅4、ハ、キ
// VirtuaNES0.30から // VirtuaNES0.30、ォ、<EFBFBD>
// バンクはSRAM使用に関わらずセーブ // ・ミ・<EFBFBD>ッ」ウ、マSRAMハケモテ、ヒ騅、<EFBFBD>鬢コ・サゥ`・ヨ
for (int i = 3; i < 8; i++) for (int i = 3; i < 8; i++)
{ {
state.mmu.CPU_MEM_TYPE[i] = MMU.CPU_MEM_TYPE[i]; state.mmu.CPU_MEM_TYPE[i] = MMU.CPU_MEM_TYPE[i];
@ -1696,7 +1696,7 @@ namespace VirtualNes.Core
} }
} }
// WRITE VRAM MEMORY(常に4K分すべて書き込む) // WRITE VRAM MEMORY(ウ」、ヒ4Kキヨ、ケ、ル、ニ抱、ュ゙z、<EFBFBD>)
state.VRAM = new byte[4 * 1024]; state.VRAM = new byte[4 * 1024];
Array.Copy(MMU.VRAM, state.VRAM, state.VRAM.Length); Array.Copy(MMU.VRAM, state.VRAM, state.VRAM.Length);
@ -1764,7 +1764,7 @@ namespace VirtualNes.Core
int DiskSize = 16 + 65500 * rom.GetDiskNo(); int DiskSize = 16 + 65500 * rom.GetDiskNo();
// 相違数をカウント // マ珀`ハ<><EFBFBD>ォ・ヲ・<EFBDA6>
for (int i = 16; i < DiskSize; i++) for (int i = 16; i < DiskSize; i++)
{ {
if (lpWrite[i] != 0) if (lpWrite[i] != 0)
@ -1874,9 +1874,9 @@ namespace VirtualNes.Core
//BANK STATE //BANK STATE
{ {
// SAVE CPU MEMORY BANK DATA // SAVE CPU MEMORY BANK DATA
// BANK0,1,2はバンクセーブに関係なし // BANK0,1,2、マ・ミ・<EFBFBD>ッ・サゥ`・ヨ、ヒ騅4、ハ、キ
// VirtuaNES0.30から // VirtuaNES0.30、ォ、<EFBFBD>
// バンクはSRAM使用に関わらずセーブ // ・ミ・<EFBFBD>ッ」ウ、マSRAMハケモテ、ヒ騅、<EFBFBD>鬢コ・サゥ`・ヨ
for (byte i = 3; i < 8; i++) for (byte i = 3; i < 8; i++)
{ {
MMU.CPU_MEM_TYPE[i] = state.mmu.CPU_MEM_TYPE[i]; MMU.CPU_MEM_TYPE[i] = state.mmu.CPU_MEM_TYPE[i];

View File

@ -181,7 +181,7 @@ namespace VirtualNes.Core
} }
else else
{ {
if (Supporter.S.Config.emulator.bFourPlayer) if (Supporter.Config.emulator.bFourPlayer)
{ {
// NES type // NES type
pad1bit = padbitsync[0] | ((uint)padbitsync[2] << 8) | 0x00080000; pad1bit = padbitsync[0] | ((uint)padbitsync[2] << 8) | 0x00080000;

View File

@ -50,7 +50,7 @@ namespace VirtualNes.Core
try try
{ {
fp = Supporter.S.OpenRom(fname); fp = Supporter.OpenRom(fname);
if (fp == null) if (fp == null)
{ {
throw new System.Exception($"Open Rom Failed:[{fname}]"); throw new System.Exception($"Open Rom Failed:[{fname}]");
@ -167,7 +167,7 @@ namespace VirtualNes.Core
lpPRG[3] = 0x1A; lpPRG[3] = 0x1A;
lpPRG[4] = (byte)diskno; lpPRG[4] = (byte)diskno;
fp = Supporter.S.OpenFile_DISKSYS(); fp = Supporter.OpenFile_DISKSYS();
if (fp == null) if (fp == null)
{ {
throw new Exception($"Not found DISKSYS.ROM for [{fname}]"); throw new Exception($"Not found DISKSYS.ROM for [{fname}]");
@ -217,7 +217,7 @@ namespace VirtualNes.Core
throw new Exception($"Unsupport format:[{fname}]"); throw new Exception($"Unsupport format:[{fname}]");
} }
Supporter.S.GetRomPathInfo(fname, out fullpath, out path); Supporter.GetFilePathInfo(fname, out fullpath, out path);
name = Path.GetFileNameWithoutExtension(fullpath); name = Path.GetFileNameWithoutExtension(fullpath);
if (!bNSF) if (!bNSF)
{ {
@ -244,7 +244,7 @@ namespace VirtualNes.Core
FileNameCheck(fname); FileNameCheck(fname);
if (Supporter.S.TryGetMapperNo(this, out int mapperNo)) if (Supporter.TryGetMapperNo(this, out int mapperNo))
{ {
Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}"); Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}");
mapper = mapperNo; mapper = mapperNo;

View File

@ -2,7 +2,7 @@
namespace VirtualNes.Core namespace VirtualNes.Core
{ {
public struct ControllerState : IEquatable<ControllerState> public struct ControllerState
{ {
public uint raw0; public uint raw0;
public uint raw1; public uint raw1;
@ -11,57 +11,19 @@ namespace VirtualNes.Core
public bool valid; public bool valid;
public ControllerState(EnumButtonType[] states) public ControllerState(
EnumButtonType player0_buttons,
EnumButtonType player1_buttons,
EnumButtonType player2_buttons,
EnumButtonType player3_buttons)
{ {
raw0 = (uint)states[0]; raw0 = (uint)player0_buttons;
raw1 = (uint)states[1]; raw1 = (uint)player1_buttons;
raw2 = (uint)states[2]; raw2 = (uint)player2_buttons;
raw3 = (uint)states[3]; raw3 = (uint)player3_buttons;
valid = true; valid = true;
} }
public bool HasButton(int player, EnumButtonType button)
{
uint raw = player switch
{
0 => raw0,
1 => raw1,
2 => raw2,
3 => raw3,
_ => 0
};
return (raw & (uint)button) == (uint)button;
}
public override string ToString()
{
return $"{raw0}|{raw1}|{raw2}|{raw3}";
}
#region Impl_Equals
public bool Equals(ControllerState other)
{
return raw0 == other.raw0 && raw1 == other.raw1 && raw2 == other.raw2 && raw3 == other.raw3 && valid == other.valid;
}
public override bool Equals(object obj)
{
return obj is ControllerState other && Equals(other);
}
public override int GetHashCode()
{
return CombineHashCode(raw0, raw1, raw2, raw3, valid);
//return HashCode.Combine(raw0, raw1, raw2, raw3, valid);
}
static int CombineHashCode(uint raw0, uint raw1, uint raw2, uint raw3, bool valid)
{
uint validUInt = valid ? 1u : 0u;
uint combinedHash = (raw0 * 31 + raw1) * 31 + raw2 * 31 + raw3 * 31 + validUInt;
return (int)combinedHash;
}
public static bool operator ==(ControllerState left, ControllerState right) public static bool operator ==(ControllerState left, ControllerState right)
{ {
return return
@ -75,7 +37,24 @@ namespace VirtualNes.Core
{ {
return !(left == right); return !(left == right);
} }
#endregion
public override string ToString()
{
return $"{raw0}|{raw1}|{raw2}|{raw3}";
}
public bool HasButton(int player, EnumButtonType button)
{
uint raw = 0;
switch (player)
{
case 0: raw = raw0; break;
case 1: raw = raw1; break;
case 2: raw = raw2; break;
case 3: raw = raw3; break;
}
return (raw & (uint)button) == (uint)button;
}
} }
[Flags] [Flags]

View File

@ -1,16 +1,70 @@
using System.IO; using System.IO;
namespace VirtualNes.Core namespace VirtualNes.Core
{ {
public static class Supporter public static class Supporter
{ {
private static ISupporterImpl s_support; private static ISupporterImpl s_support;
internal static ISupporterImpl S => s_support;
public static void Setup(ISupporterImpl supporter) public static void Setup(ISupporterImpl supporter)
{ {
s_support = supporter; s_support = supporter;
} }
public static Stream OpenRom(string fname)
{
return s_support.OpenRom(fname);
}
public static void GetFilePathInfo(string fname, out string fullPath, out string directPath)
{
s_support.GetRomPathInfo(fname, out fullPath, out directPath);
}
public static Stream OpenFile_DISKSYS()
{
return s_support.OpenFile_DISKSYS();
}
public static void SaveSRAMToFile(byte[] sramContent, string romName)
{
s_support.SaveSRAMToFile(sramContent, romName);
}
public static void SaveDISKToFile(byte[] diskFileContent, string romName)
{
s_support.SaveDISKToFile(diskFileContent, romName);
}
public static void PrepareDirectory(string directPath)
{
s_support.PrepareDirectory(directPath);
}
public static void SaveFile(byte[] fileData, string directPath, string fileName)
{
s_support.SaveFile(fileData, directPath, fileName);
}
public static Stream OpenFile(string directPath, string fileName)
{
return s_support.OpenFile(directPath, fileName);
}
public static bool TryGetMapperNo(ROM rom, out int mapperNo)
{
return s_support.TryGetMapperNo(rom, out mapperNo);
}
public static ControllerState GetControllerState()
{
return s_support.GetControllerState();
}
public static void SampleInput(uint frameCount)
{
s_support.SampleInput(frameCount);
}
public static EmulatorConfig Config => s_support.Config;
} }
public interface ISupporterImpl public interface ISupporterImpl
@ -21,6 +75,7 @@ namespace VirtualNes.Core
void SaveSRAMToFile(byte[] sramContent, string romName); void SaveSRAMToFile(byte[] sramContent, string romName);
void SaveDISKToFile(byte[] diskFileContent, string romName); void SaveDISKToFile(byte[] diskFileContent, string romName);
EmulatorConfig Config { get; } EmulatorConfig Config { get; }
void PrepareDirectory(string directPath); void PrepareDirectory(string directPath);
void SaveFile(byte[] fileData, string directPath, string fileName); void SaveFile(byte[] fileData, string directPath, string fileName);
Stream OpenFile(string directPath, string fileName); Stream OpenFile(string directPath, string fileName);