Compare commits

...

8 Commits

41 changed files with 937 additions and 795 deletions

View File

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

View File

@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.IO;
@ -86,7 +87,7 @@ public class AxiProjectTools : EditorWindow
static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
{
string nodename = $"{rootPath}>{trans.name}";
#if UNITY_5_4_OR_NEWER && !UNITY_2018_4_OR_NEWER
#if UNITY_2018_4_OR_NEWER
GameObject prefabRoot = trans.gameObject;
int comCount = prefabRoot.GetComponentCount();
for (int i = 0; i < comCount; i++)
@ -95,11 +96,6 @@ public class AxiProjectTools : EditorWindow
if (com == null)
continue;
if (com.name.Contains("VideoPlayer"))
{
}
MonoBehaviour monoCom = com as MonoBehaviour;
if (monoCom == null)
continue;
@ -262,11 +258,13 @@ public class AxiProjectTools : EditorWindow
}
[MenuItem("Axibug移植工具/[5]UnPack所有预制体")]
[MenuItem("Axibug移植工具/[5]UnPack所有嵌套预制体和场景中的预制体")]
public static void UnpackPrefabs()
{
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
#if UNITY_2018_4_OR_NEWER
GoTAxiProjectToolsSence();
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0;
foreach (string path in allAssetPaths)
@ -278,13 +276,41 @@ public class AxiProjectTools : EditorWindow
prefabCount++;
}
}
Debug.Log($"Unpacked {prefabCount} prefabs.");
Debug.Log($"{prefabCount}个预制体Unpack");
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
}
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
continue;
static void UnpackPrefab(string prefabPath)
EditorSceneManager.OpenScene(path);
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);
if (prefabInstance == null)
{
@ -296,10 +322,14 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj);
#else
Debug.Log("低版本不要执行本函数");
#endif
}
static void TraverseHierarchy(GameObject obj)
{
#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj))
{
@ -313,6 +343,9 @@ public class AxiProjectTools : EditorWindow
{
TraverseHierarchy(obj.transform.GetChild(i).gameObject);
}
#else
Debug.Log("低版本不要执行本函数");
#endif
}
@ -379,4 +412,5 @@ public class AxiProjectTools : EditorWindow
textureImporter.SaveAndReimport();
}
}
}
}
#endif

View File

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

View File

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

View File

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

View File

@ -1,7 +1,92 @@
fileFormatVersion: 2
guid: eb76ae7b43c117c449fe04e536cf3f34
MonoAssemblyImporter:
serializedVersion: 1
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
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:
assetBundleName:
assetBundleVariant:

View File

@ -6,384 +6,397 @@ using UnityEngine;
using static AxibugEmuOnline.Client.FilterEffect;
namespace AxibugEmuOnline.Client
{
public class FilterManager
{
private List<Filter> m_filters;
private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>();
private AlphaWraper m_previewFilterWraper;
FilterRomSetting m_filterRomSetting;
/// <summary>
/// 滤镜列表
/// </summary>
public IReadOnlyList<Filter> Filters => m_filters;
public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg)
{
m_filters = new List<Filter>
{
new Filter(new FixingPixelArtGrille()),
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);
ShutDownFilterPreview();
ShutDownFilter();
}
private RenderTexture result = null;
public Texture ExecuteFilterRender(Texture src)
{
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);
}
bool anyFilterEnable = false;
foreach (var filter in Filters)
{
if (!filter.m_setting.Enable.GetValue()) continue;
filter.m_setting.Render(src, result);
anyFilterEnable = true;
}
if (anyFilterEnable)
return result;
else
return src;
}
/// <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);
}
}
}
[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;
}
}
}
{
public class FilterManager
{
private List<Filter> m_filters;
private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>();
private AlphaWraper m_previewFilterWraper;
FilterRomSetting m_filterRomSetting;
/// <summary>
/// 滤镜列表
/// </summary>
public IReadOnlyList<Filter> Filters => m_filters;
public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg)
{
#if UNITY_PSP2
m_filters = new List<Filter>();
m_filterRomSetting = new FilterRomSetting();
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false);
return;
#endif
m_filters = new List<Filter>
{
new Filter(new FixingPixelArtGrille()),
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);
ShutDownFilterPreview();
ShutDownFilter();
}
private RenderTexture result = null;
public Texture ExecuteFilterRender(Texture src)
{
if (result == null)
{
//result = RenderTexture.GetTemporary(Screen.width, Screen.height);
result = Initer.instance.renderTest;
}
else if (result.width != Screen.width || result.height != Screen.height)
{
//RenderTexture.ReleaseTemporary(result);
//result = RenderTexture.GetTemporary(Screen.width, Screen.height);
result = Initer.instance.renderTest;
}
bool anyFilterEnable = false;
foreach (var filter in Filters)
{
if (!filter.m_setting.Enable.GetValue()) continue;
filter.m_setting.Render(src, result);
anyFilterEnable = true;
}
if (anyFilterEnable)
return result;
else
return src;
}
/// <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);
}
}
}
[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,6 +299,12 @@ namespace AxibugEmuOnline.Client.Manager
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);
long[] oldRoomPlayer = GetRoom4PlayerUIDs();
Protobuf_Room_GamePlaySlot[] oldslotArr = GetRoom4GameSlotMiniInfos();

View File

@ -2,6 +2,7 @@ using AxibugEmuOnline.Client.ClientCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
@ -14,7 +15,27 @@ namespace AxibugEmuOnline.Client
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 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)
{
App.StartCoroutine(GetNesRomListFlow(page, pageSize, callback));
@ -26,6 +47,13 @@ namespace AxibugEmuOnline.Client
}
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}");
yield return request.SendWebRequest;

View File

@ -1,4 +1,6 @@
using AxibugEmuOnline.Client.Event;
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Event;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@ -64,7 +66,9 @@ namespace AxibugEmuOnline.Client
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()
{
s_temp.Clear();
@ -84,14 +88,25 @@ namespace AxibugEmuOnline.Client
public void LetControllerConnect(int conIndex, uint slotIndex)
{
var targetController = conIndex switch
Controller targetController;
switch (conIndex)
{
0 => Controller0,
1 => Controller1,
2 => Controller2,
3 => Controller3,
_ => throw new System.Exception($"Not Allowed conIndex Range: {conIndex}")
};
case 0: targetController = Controller0;break;
case 1: targetController = Controller1; break;
case 2: targetController = Controller2; break;
case 3: targetController = Controller3; break;
default:
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;
@ -176,7 +191,14 @@ namespace AxibugEmuOnline.Client
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))
{
return new KeyListener(PlayerPrefs.GetString(configKey));
@ -321,6 +343,38 @@ namespace AxibugEmuOnline.Client
break;
}
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,12 +212,10 @@ namespace AxibugEmuOnline.Client
EditorUtility.SetDirty(db);
AssetDatabase.SaveAssets();
}
#endif
public IControllerSetuper GetControllerSetuper()
{
return ControllerMapper;
}
#endif
}
}
}

View File

@ -18,9 +18,11 @@ public class SonyVitaCommonDialog : MonoBehaviour
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.
info.supportedLanguages = Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_JAPANESE |
info.supportedLanguages = Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_SIMPLIFIED_CHINESE |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_JAPANESE |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_ENGLISH_GB |
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_DANISH;
Sony.Vita.Dialog.Ime.FlagsSupportedLanguages.LANGUAGE_TRADITIONAL_CHINESE;
info.languagesForced = true;
info.type = Sony.Vita.Dialog.Ime.EnumImeDialogType.TYPE_DEFAULT;
@ -44,7 +46,7 @@ public class SonyVitaCommonDialog : MonoBehaviour
Debug.Log("IME text: " + result.text);
if (result.result == Sony.Vita.Dialog.Ime.EnumImeDialogResult.RESULT_OK)
{
resultAct.Invoke(result);
resultAct.Invoke(result.text);
resultAct = null;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,9 +51,25 @@ namespace VirtualNes.Core
public override int GetHashCode()
{
//return CombineHashCode(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)
{
return

View File

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

View File

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

View File

@ -1,4 +1,4 @@

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
namespace VirtualNes.Core
{
public struct ControllerState
public struct ControllerState : IEquatable<ControllerState>
{
public uint raw0;
public uint raw1;
@ -11,18 +11,56 @@ namespace VirtualNes.Core
public bool valid;
public ControllerState(
EnumButtonType player0_buttons,
EnumButtonType player1_buttons,
EnumButtonType player2_buttons,
EnumButtonType player3_buttons)
public ControllerState(EnumButtonType[] states)
{
raw0 = (uint)player0_buttons;
raw1 = (uint)player1_buttons;
raw2 = (uint)player2_buttons;
raw3 = (uint)player3_buttons;
raw0 = (uint)states[0];
raw1 = (uint)states[1];
raw2 = (uint)states[2];
raw3 = (uint)states[3];
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)
{
@ -37,24 +75,7 @@ namespace VirtualNes.Core
{
return !(left == right);
}
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;
}
#endregion
}
[Flags]

View File

@ -1,70 +1,16 @@
using System.IO;
using System.IO;
namespace VirtualNes.Core
{
public static class Supporter
{
private static ISupporterImpl s_support;
internal static ISupporterImpl S => s_support;
public static void Setup(ISupporterImpl 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
@ -75,7 +21,6 @@ namespace VirtualNes.Core
void SaveSRAMToFile(byte[] sramContent, string romName);
void SaveDISKToFile(byte[] diskFileContent, string romName);
EmulatorConfig Config { get; }
void PrepareDirectory(string directPath);
void SaveFile(byte[] fileData, string directPath, string fileName);
Stream OpenFile(string directPath, string fileName);
@ -83,4 +28,4 @@ namespace VirtualNes.Core
ControllerState GetControllerState();
void SampleInput(uint frameCount);
}
}
}