Compare commits
82 Commits
beforinput
...
master
Author | SHA1 | Date | |
---|---|---|---|
c8f0d77b34 | |||
52e9f42184 | |||
2bc6972ebe | |||
e6ef077f16 | |||
f3d246ab43 | |||
0d3024521c | |||
ef419928ed | |||
6c23bdc1c2 | |||
eb6b25256b | |||
6be11bdf42 | |||
306199dba8 | |||
97c278b4ec | |||
cc57a1e0df | |||
ace77987e4 | |||
1ffa708e71 | |||
c7a4f1467a | |||
992adc115b | |||
902dc95d19 | |||
e5f497a163 | |||
8fc65c2f70 | |||
f0b139e692 | |||
fcd64a54f6 | |||
e8fc45b006 | |||
9cfee768c3 | |||
e8bac390af | |||
412c9759df | |||
74bde1d94a | |||
213ed7163c | |||
24036739a7 | |||
1f33d35394 | |||
e66740b8a9 | |||
36b614c4a7 | |||
d7fe849bb1 | |||
ee9d54386b | |||
eb2f5d268c | |||
13cddd8a3b | |||
16a7acee61 | |||
959956706f | |||
8e24f556af | |||
424e139692 | |||
49d0a9aa86 | |||
a079947bc4 | |||
a21be185ce | |||
3dc7e9acd1 | |||
f325e63e26 | |||
017026f706 | |||
4116a05b6c | |||
209c82da80 | |||
8bd3b2247b | |||
5aabda7c37 | |||
6111319ad4 | |||
279483c14f | |||
c89b6b1ab5 | |||
8b2b66a940 | |||
902a8f1360 | |||
569e4e44fe | |||
c77cac4812 | |||
5f9d67b36f | |||
5014c81539 | |||
4b0a781957 | |||
10ac17c18b | |||
591204e044 | |||
cfb3bc8b6a | |||
34cf5487e8 | |||
6cc7b2fb4b | |||
fbe47bce1b | |||
3797bba442 | |||
4e87cfe9ee | |||
e463c23c4c | |||
50e3a30f31 | |||
8007af0bc5 | |||
924727eb7c | |||
cf8127c553 | |||
49c893fdab | |||
667089891a | |||
811b0b2a48 | |||
a93f6449c8 | |||
3257e15dda | |||
1c20707751 | |||
4e1f8fd045 | |||
955a35659a | |||
3c10873180 |
.gitignore
AxibugEmuOnline.Client/Assets
AxiProjectTools
Editors
Plugins
AxiNSApi.meta
AxiNSApi
AxiNS.csAxiNS.cs.metaAxiNSApi.asmdefAxiNSApi.asmdef.metaAxiNSErrCode.csAxiNSErrCode.cs.metaAxiNSIO.csAxiNSIO.cs.metaAxiNSMount.csAxiNSMount.cs.metaAxiNSSDCard.csAxiNSSDCard.cs.metaAxiNSUser.csAxiNSUser.cs.metaAxiNSWaitHandle.meta
AxiNSWaitHandle
AxiReplay
Essgee.Unity
AxiMemory.csEmuStandInfo.cs
Emulation
Extensions
IAxiEssgssStatus.csMetadata
Utilities
Mame.Core
MAMEEmu.cs
Motion
cpu
emu
mame
capcom
cps
dataeast
igs011
konami68000
m72
m92
namcos1
neogeo
pgm
suna8
taito
taitob
tehkan
run_interface
sound
StoicGooseUnity
Resources
9
.gitignore
vendored
9
.gitignore
vendored
@ -14,8 +14,10 @@
|
||||
/AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset
|
||||
/AxibugEmuOnline.Client/Logs
|
||||
|
||||
/AxibugEmuOnline.Client/Assets/AxiProjectTools/AxiNSPack/switch_keys/*.keys
|
||||
/AxibugEmuOnline.Client/Assets/AxiProjectTools/AxiNSPack/switch_keys/*.keys.meta
|
||||
**/switch_keys/*.keys
|
||||
**/switch_keys/*.keys.meta
|
||||
**/NintendoSDKPlugin/
|
||||
**/NintendoSDKPlugin.meta
|
||||
|
||||
/virtuanessrc097-master
|
||||
/AxibugEmuOnline.Server/config.cfg
|
||||
@ -48,4 +50,5 @@
|
||||
AxibugEmuOnline.GameScreenConvert/bin/
|
||||
AxibugEmuOnline.GameScreenConvert/obj/
|
||||
|
||||
/.vs/
|
||||
/.vs/
|
||||
AxibugEmuOnline.Client/ProjectSettings/PackageManagerSettings.asset
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 611bc182f939ea147a72b08613e2d2ba
|
||||
guid: 164952f99969ca942b4761b200d7e381
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
@ -19,7 +19,17 @@ namespace AxibugEmuOnline.Editors
|
||||
static Dictionary<string, string> tools = new Dictionary<string, string>();
|
||||
static string prodKeysPath;
|
||||
|
||||
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/RepackNSP(쏭路劤뭐쉔NPS)")]
|
||||
static void InitToolPath()
|
||||
{
|
||||
#region 初始化工具路径
|
||||
// 获取环境变量(需要添加环境变量检查)
|
||||
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
|
||||
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
|
||||
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
|
||||
#endregion
|
||||
}
|
||||
|
||||
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/RepackNSP(仅重新构建NSP)")]
|
||||
static void RepackNSP()
|
||||
{
|
||||
if (!CheckEnvironmentVariable())
|
||||
@ -37,7 +47,29 @@ namespace AxibugEmuOnline.Editors
|
||||
RepackNSP(path);
|
||||
}
|
||||
|
||||
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/Build With RepackNSP(댔관NSP깻路劤뭐쉔NPS)")]
|
||||
|
||||
//[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/UnpackNSP(解包工具)")]
|
||||
//static void UnpackNSP()
|
||||
//{
|
||||
// InitToolPath();
|
||||
// if (!CheckEnvironmentVariable())
|
||||
// return;
|
||||
|
||||
// string nspFilePath = EditorUtility.OpenFilePanel(
|
||||
// title: "选择 .nsp 文件",
|
||||
// directory: Path.Combine(Application.dataPath, ".."), // 默认路径为项目 Assets 目录
|
||||
// extension: "nsp" // 限制文件类型为 .nsp
|
||||
// );
|
||||
|
||||
// if (string.IsNullOrEmpty(nspFilePath))
|
||||
// return;
|
||||
|
||||
// string nspParentDir = Path.GetDirectoryName(nspFilePath);
|
||||
// string extractPath = Path.Combine(nspParentDir, "repacker_extract");
|
||||
// ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"", nspParentDir);
|
||||
//}
|
||||
|
||||
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/Build With RepackNSP(打包NSP并重新构建NSP)")]
|
||||
public static void BuildWithRepackNSP()
|
||||
{
|
||||
if (!CheckEnvironmentVariable())
|
||||
@ -82,7 +114,7 @@ namespace AxibugEmuOnline.Editors
|
||||
{
|
||||
BuildReport report = BuildPipeline.BuildPlayer(options);
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"[AxibugNSPTools] Unity Build NSP 错误:{ex.ToString()}");
|
||||
return;
|
||||
@ -120,12 +152,7 @@ namespace AxibugEmuOnline.Editors
|
||||
|
||||
static void RepackNSP(string nspFile)
|
||||
{
|
||||
#region 놓迦뺏묏야쨌쓺
|
||||
// 삿혤뻔쓱긴좆(矜狼警속뻔쓱긴좆쇱꿴)
|
||||
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
|
||||
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
|
||||
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
|
||||
#endregion
|
||||
InitToolPath();
|
||||
|
||||
#region 处理NSP文件路径
|
||||
string nspFilePath = nspFile;
|
||||
@ -147,13 +174,13 @@ namespace AxibugEmuOnline.Editors
|
||||
#region 清理临时目录
|
||||
CleanDirectory(Path.Combine(nspParentDir, "repacker_extract"));
|
||||
CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA"));
|
||||
CleanDirectory(Path.Combine(WorkRoot, "hacpack_backup"));
|
||||
CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup"));
|
||||
#endregion
|
||||
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"解包NSP文件", 0.2f);
|
||||
#region 解包NSP文件
|
||||
string extractPath = Path.Combine(nspParentDir, "repacker_extract");
|
||||
ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"");
|
||||
ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"", nspParentDir);
|
||||
|
||||
string controlPath = null;
|
||||
string programPath = null;
|
||||
@ -167,34 +194,43 @@ namespace AxibugEmuOnline.Editors
|
||||
|
||||
#region 重建NCA/NSP
|
||||
string tmpPath = Path.Combine(Path.GetTempPath(), "NCA");
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.6f);
|
||||
string programNCA = BuildProgramNCA(tmpPath, titleID, programPath);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.7f);
|
||||
string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.8f);
|
||||
BuildMetaNCA(tmpPath, titleID, programNCA, controlNCA);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Program NCA", 0.3f);
|
||||
string programNCA = BuildProgramNCA(tmpPath, titleID, programPath, nspParentDir);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Control NCA", 0.4f);
|
||||
string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath, nspParentDir);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Meta NCA", 0.5f);
|
||||
BuildMetaNCA(tmpPath, titleID, programNCA, controlNCA, nspParentDir);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建NSP", 0.6f);
|
||||
string outputNSP = BuildFinalNSP(nspFilePath, nspParentDir, tmpPath, titleID, nspParentDir);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建NSP", 0.9f);
|
||||
string outputNSP = BuildFinalNSP(nspFilePath, nspParentDir, tmpPath, titleID);
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NSP", 1f);
|
||||
Debug.Log($"[AxibugNSPTools]Repacking completed: {outputNSP}");
|
||||
EditorUtility.ClearProgressBar();
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"清理临时目录", 1);
|
||||
#region 清理临时目录
|
||||
CleanDirectory(Path.Combine(nspParentDir, "repacker_extract"));
|
||||
CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA"));
|
||||
CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup"));
|
||||
#endregion
|
||||
System.Diagnostics.Process.Start("explorer", "/select,\"" + outputNSP.Trim() + "\"");
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 辅助方法
|
||||
static string GetUserInput()
|
||||
{
|
||||
Console.Write("Enter the NSP filepath: ");
|
||||
return Console.ReadLine();
|
||||
}
|
||||
|
||||
static string ExtractTitleID(string path)
|
||||
{
|
||||
var match = Regex.Match(path, @"0100[\dA-Fa-f]{12}");
|
||||
return match.Success ? match.Value : null;
|
||||
}
|
||||
|
||||
|
||||
static void CleanDirectory(string path)
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
@ -215,8 +251,9 @@ namespace AxibugEmuOnline.Editors
|
||||
}
|
||||
}
|
||||
|
||||
static string ExecuteCommand(string command)
|
||||
static string ExecuteCommand(string command, string workdir)
|
||||
{
|
||||
Debug.Log($"调用cmd=>{command}");
|
||||
var process = new System.Diagnostics.Process()
|
||||
{
|
||||
StartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
@ -228,7 +265,8 @@ namespace AxibugEmuOnline.Editors
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
StandardOutputEncoding = Encoding.UTF8, // 明确指定编码
|
||||
StandardErrorEncoding = Encoding.UTF8
|
||||
StandardErrorEncoding = Encoding.UTF8,
|
||||
WorkingDirectory = workdir
|
||||
}
|
||||
};
|
||||
|
||||
@ -275,36 +313,36 @@ namespace AxibugEmuOnline.Editors
|
||||
#endregion
|
||||
|
||||
#region NCA构建逻辑
|
||||
static string BuildProgramNCA(string tmpPath, string titleID, string programDir)
|
||||
static string BuildProgramNCA(string tmpPath, string titleID, string programDir, string workdir)
|
||||
{
|
||||
string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
|
||||
$"--type nca --ncatype program --exefsdir \"{programDir}/fs0\" " +
|
||||
$"--romfsdir \"{programDir}/fs1\" --logodir \"{programDir}/fs2\"";
|
||||
|
||||
string output = ExecuteCommand($"{tools["hacPack"]} {args}");
|
||||
string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
|
||||
return ParseNCAOutput(output, "Program");
|
||||
}
|
||||
|
||||
static string BuildControlNCA(string tmpPath, string titleID, string controlDir)
|
||||
static string BuildControlNCA(string tmpPath, string titleID, string controlDir, string workdir)
|
||||
{
|
||||
string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
|
||||
$"--type nca --ncatype control --romfsdir \"{controlDir}/fs0\"";
|
||||
|
||||
string output = ExecuteCommand($"{tools["hacPack"]} {args}");
|
||||
string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
|
||||
|
||||
return ParseNCAOutput(output, "Control");
|
||||
}
|
||||
|
||||
static void BuildMetaNCA(string tmpPath, string titleID, string programNCA, string controlNCA)
|
||||
static void BuildMetaNCA(string tmpPath, string titleID, string programNCA, string controlNCA, string workdir)
|
||||
{
|
||||
string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
|
||||
$"--type nca --ncatype meta --titletype application " +
|
||||
$"--programnca \"{programNCA}\" --controlnca \"{controlNCA}\"";
|
||||
|
||||
ExecuteCommand($"{tools["hacPack"]} {args}");
|
||||
ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
|
||||
}
|
||||
|
||||
static string BuildFinalNSP(string origPath, string parentDir, string tmpPath, string titleID)
|
||||
static string BuildFinalNSP(string origPath, string parentDir, string tmpPath, string titleID, string workdir)
|
||||
{
|
||||
string outputPath = origPath.Replace(".nsp", "_repacked.nsp");
|
||||
if (File.Exists(outputPath)) File.Delete(outputPath);
|
||||
@ -312,7 +350,7 @@ namespace AxibugEmuOnline.Editors
|
||||
string args = $"-k \"{prodKeysPath}\" -o \"{parentDir}\" --titleid {titleID} " +
|
||||
$"--type nsp --ncadir \"{tmpPath}\"";
|
||||
|
||||
ExecuteCommand($"{tools["hacPack"]} {args}");
|
||||
ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
|
||||
File.Move(Path.Combine(parentDir, $"{titleID}.nsp"), outputPath);
|
||||
return outputPath;
|
||||
}
|
||||
@ -321,7 +359,9 @@ namespace AxibugEmuOnline.Editors
|
||||
{
|
||||
var line = output.Split('\n')
|
||||
.FirstOrDefault(l => l.Contains($"Created {type} NCA:"));
|
||||
return line?.Split(':').Last().Trim();
|
||||
//return line?.Split(':').Last().Trim();
|
||||
return line?.Substring(line.IndexOf("NCA:") + "NCA:".Length).Trim();
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Editors
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.LabelField(dispacather.Current.Name);
|
||||
EditorGUILayout.LabelField(dispacather.Mode.ToString());
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91746af636f351140a4796dc4e98be6d
|
||||
guid: 4094856a5db24f142a14fda03f1215a2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
41
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNS.cs
Normal file
41
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNS.cs
Normal file
@ -0,0 +1,41 @@
|
||||
#if UNITY_SWITCH
|
||||
using nn.account;
|
||||
#endif
|
||||
|
||||
public class AxiNS
|
||||
{
|
||||
static AxiNS _instance;
|
||||
public static AxiNS instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new AxiNS();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public AxiNSUser user;
|
||||
public AxiNSMount mount;
|
||||
public AxiNSIO io;
|
||||
public AxiNSWaitHandle wait;
|
||||
AxiNS()
|
||||
{
|
||||
user = new AxiNSUser();
|
||||
mount = new AxiNSMount();
|
||||
io = new AxiNSIO();
|
||||
wait = new AxiNSWaitHandle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化(最好在项目第一时间初始化,保证先初始化再使用某些东西,才不闪退)
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (!user.GetUserID(out Uid uid))
|
||||
return;
|
||||
mount.MountSave(uid);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8790f215d873d044aa8d00bacdee237
|
||||
guid: 52541c757d45c4c488726bcc39f73ba6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "AxiNSApi"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8ad600c72d635843bd8aeb9d8aebfb8
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
367
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSErrCode.cs
Normal file
367
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSErrCode.cs
Normal file
@ -0,0 +1,367 @@
|
||||
public static class AxiNSErrCode
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
public static string GetErrorInfo(this nn.Result result)
|
||||
{
|
||||
if (result.IsSuccess())
|
||||
return "NoErr";
|
||||
return GetErrorDetails(result.GetModule(), result.GetDescription());
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// 根据模块 ID 和描述 ID 返回任天堂 Switch 错误码的含义、可能原因及解决办法。
|
||||
/// </summary>
|
||||
/// <param name="moduleId">模块 ID</param>
|
||||
/// <param name="descriptionId">描述 ID</param>
|
||||
/// <returns>包含错误码、含义、可能原因及解决办法的字符串</returns>
|
||||
public static string GetErrorDetails(int moduleId, int descriptionId)
|
||||
{
|
||||
string errorCode = $"2{moduleId:D3}-{descriptionId:D4}"; // 格式化为 2XXX-YYYY
|
||||
string meaning = "未知错误";
|
||||
string causeAndSolution = "未知错误,请检查日志或联系任天堂支持。";
|
||||
|
||||
switch (moduleId)
|
||||
{
|
||||
case 2: // nn::fs (文件系统)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1:
|
||||
meaning = "ResultPathNotFound";
|
||||
causeAndSolution = "路径未找到。检查路径是否正确,确保父目录存在。使用 nn.fs.Directory.Create 创建父目录。";
|
||||
break;
|
||||
case 2:
|
||||
meaning = "ResultPermissionDenied";
|
||||
causeAndSolution = "权限被拒绝。可能是 Atmosphere 限制了 save:/ 的写权限。尝试调整 Atmosphere 配置或使用 sd:/ 挂载点。";
|
||||
break;
|
||||
case 3:
|
||||
meaning = "ResultPathAlreadyExists";
|
||||
causeAndSolution = "路径已存在。检查路径是否被占用,删除或重命名现有文件/目录。";
|
||||
break;
|
||||
case 5:
|
||||
meaning = "ResultTargetLocked";
|
||||
causeAndSolution = "目标被锁定。可能是文件正在使用中,关闭相关程序后重试。";
|
||||
break;
|
||||
case 7:
|
||||
meaning = "ResultTargetNotFound";
|
||||
causeAndSolution = "目标未找到。确认目标文件/目录是否存在,检查路径拼写。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: // nn::err (错误处理)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 3:
|
||||
meaning = "microSD 卡相关错误";
|
||||
causeAndSolution = "无法下载软件,可能是 microSD 卡损坏。移除 microSD 卡,重新插入,或更换卡。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: // nn::oe (操作系统错误)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 247:
|
||||
meaning = "microSD 卡存储问题";
|
||||
causeAndSolution = "microSD 卡损坏或不兼容。更换 microSD 卡,或将默认存储位置设置为系统内存。";
|
||||
break;
|
||||
case 390:
|
||||
meaning = "不支持的 microSD 卡";
|
||||
causeAndSolution = "microSD 卡格式不受支持。格式化为 exFAT 或 FAT32 后重试。";
|
||||
break;
|
||||
case 601:
|
||||
meaning = "microSD 卡数据损坏";
|
||||
causeAndSolution = "microSD 卡数据损坏。备份数据后格式化卡,或更换新卡。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 21: // nn::settings (设置)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 3:
|
||||
meaning = "系统软件未更新或损坏";
|
||||
causeAndSolution = "系统固件版本过旧或损坏。更新系统固件,或重新安装系统。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 101: // nn::fssrv (文件系统服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1:
|
||||
meaning = "系统错误";
|
||||
causeAndSolution = "通用系统错误。重启 Switch,若问题持续,联系任天堂支持。";
|
||||
break;
|
||||
case 2:
|
||||
meaning = "固件损坏";
|
||||
causeAndSolution = "系统固件损坏。尝试更新系统,或恢复出厂设置(注意备份数据)。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 107: // nn::nim (网络安装管理)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 427:
|
||||
meaning = "固件损坏";
|
||||
causeAndSolution = "系统固件损坏。更新系统固件,或重新安装系统。";
|
||||
break;
|
||||
case 445:
|
||||
meaning = "硬件损坏或盗版内容";
|
||||
causeAndSolution = "可能是硬件损坏或存在盗版内容。删除盗版内容,重启 Switch,若无效联系任天堂支持。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 110: // nn::socket (网络套接字)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1000:
|
||||
meaning = "网络连接失败";
|
||||
causeAndSolution = "无法连接到网络。检查网络连接,重启路由器,尝试切换到其他网络频段(2.4GHz/5GHz)。";
|
||||
break;
|
||||
case 2003:
|
||||
meaning = "无线网络连接失败";
|
||||
causeAndSolution = "无线信号弱或不稳定。靠近路由器,移除干扰物,或重启路由器。";
|
||||
break;
|
||||
case 2004:
|
||||
meaning = "网络设置不支持";
|
||||
causeAndSolution = "网络安全类型不受支持。Switch 支持 WEP/WPA/WPA2,调整路由器设置后重试。";
|
||||
break;
|
||||
case 2091:
|
||||
meaning = "有线网络连接失败";
|
||||
causeAndSolution = "有线连接问题。检查网线是否插好,重启 Switch 和路由器。";
|
||||
break;
|
||||
case 3127:
|
||||
meaning = "网络连接失败";
|
||||
causeAndSolution = "网络不稳定。测试网络连接,重启路由器,或联系网络提供商。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 115: // nn::mii (Mii 相关)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 96:
|
||||
meaning = "Mii 数据错误";
|
||||
causeAndSolution = "Mii 数据损坏。删除并重新创建 Mii,或更新系统。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 139: // nn::nfp (NFC/Amiibo)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 6:
|
||||
meaning = "Amiibo 读取错误";
|
||||
causeAndSolution = "Amiibo 读取失败。检查 Amiibo 是否损坏,更新系统,或尝试其他 Amiibo。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 153: // nn::ir (红外摄像头)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 321:
|
||||
meaning = "红外摄像头读取错误";
|
||||
causeAndSolution = "红外摄像头无法读取。检查摄像头是否被遮挡,清洁镜头,或联系任天堂支持。";
|
||||
break;
|
||||
case 1540:
|
||||
meaning = "红外摄像头硬件错误";
|
||||
causeAndSolution = "红外摄像头硬件故障。联系任天堂支持进行维修。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 155: // nn::account (账户服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 8006:
|
||||
meaning = "无法链接任天堂账户";
|
||||
causeAndSolution = "网络问题或服务中断。检查网络连接,稍后重试,或查看任天堂网络状态页面。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 160: // nn::online (在线服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 103:
|
||||
meaning = "无法加入在线匹配";
|
||||
causeAndSolution = "网络不稳定。重启 Switch,检查网络连接,或稍后重试。";
|
||||
break;
|
||||
case 202:
|
||||
meaning = "无法连接到在线服务";
|
||||
causeAndSolution = "服务可能正在维护。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
case 8006:
|
||||
meaning = "连接测试失败";
|
||||
causeAndSolution = "网络问题。重启路由器,检查网络设置,或尝试其他网络。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 162: // nn::application (应用程序)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 2:
|
||||
meaning = "软件崩溃";
|
||||
causeAndSolution = "软件崩溃,可能是盗版内容或固件问题。删除盗版内容,更新系统,或重新安装软件。";
|
||||
break;
|
||||
case 101:
|
||||
meaning = "软件需要更新";
|
||||
causeAndSolution = "游戏或软件需要更新。检查软件更新并安装。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 168: // nn::sys (系统)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 0:
|
||||
meaning = "需要软件更新";
|
||||
causeAndSolution = "软件需要更新。更新游戏或系统固件。";
|
||||
break;
|
||||
case 2:
|
||||
meaning = "系统崩溃";
|
||||
causeAndSolution = "系统崩溃,可能是硬件问题。重启 Switch,若无效联系任天堂支持。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 205: // nn::camera (摄像头)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 123:
|
||||
meaning = "摄像头读取错误";
|
||||
causeAndSolution = "摄像头无法读取。检查摄像头是否被遮挡,清洁镜头,或联系任天堂支持。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 306: // nn::ngc (网络游戏连接)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 501:
|
||||
meaning = "无法加入在线匹配";
|
||||
causeAndSolution = "网络连接中断。重启 Switch,检查网络连接,或稍后重试。";
|
||||
break;
|
||||
case 502:
|
||||
meaning = "匹配过程失败";
|
||||
causeAndSolution = "网络不稳定。测试网络连接,重启路由器,或联系网络提供商。";
|
||||
break;
|
||||
case 820:
|
||||
meaning = "在线服务不可用";
|
||||
causeAndSolution = "服务可能正在维护。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 613: // nn::eShop (eShop)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1400:
|
||||
meaning = "无法使用信用卡购买";
|
||||
causeAndSolution = "信用卡信息错误或 eShop 服务问题。检查信用卡信息,稍后重试,或联系任天堂支持。";
|
||||
break;
|
||||
case 6838:
|
||||
meaning = "eShop 连接失败";
|
||||
causeAndSolution = "网络问题或 eShop 维护。检查网络连接,查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 618: // nn::ngc (网络游戏连接)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 6:
|
||||
meaning = "无法加入在线匹配";
|
||||
causeAndSolution = "网络不稳定。重启 Switch,检查网络连接,或稍后重试。";
|
||||
break;
|
||||
case 201:
|
||||
meaning = "匹配已满";
|
||||
causeAndSolution = "尝试加入的匹配已满。稍后重试,或加入其他匹配。";
|
||||
break;
|
||||
case 501:
|
||||
meaning = "匹配过程失败";
|
||||
causeAndSolution = "网络连接中断。重启 Switch,检查网络连接,或稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 801: // nn::sns (社交网络服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 7002:
|
||||
meaning = "无法上传截图到 Twitter";
|
||||
causeAndSolution = "服务可能正在维护。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
case 7199:
|
||||
meaning = "无法上传照片到 Facebook";
|
||||
causeAndSolution = "服务可能正在维护。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 810: // nn::account (账户服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1224:
|
||||
meaning = "无法登录任天堂账户";
|
||||
causeAndSolution = "网络问题或服务中断。检查网络连接,稍后重试,或查看任天堂网络状态页面。";
|
||||
break;
|
||||
case 1500:
|
||||
meaning = "无法登录 Facebook 账户";
|
||||
causeAndSolution = "服务可能正在维护。重启 Switch,稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 811: // nn::account (账户服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 1006:
|
||||
meaning = "无法链接任天堂账户";
|
||||
causeAndSolution = "网络问题或 DNS 错误。检查网络连接,尝试更换 DNS(如 8.8.8.8),或稍后重试。";
|
||||
break;
|
||||
case 5001:
|
||||
meaning = "无法访问 eShop";
|
||||
causeAndSolution = "eShop 服务中断。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 813: // nn::eShop (eShop)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 0:
|
||||
meaning = "eShop 访问失败";
|
||||
causeAndSolution = "eShop 服务中断。查看任天堂网络状态页面,稍后重试。";
|
||||
break;
|
||||
case 2470:
|
||||
meaning = "交易处理失败";
|
||||
causeAndSolution = "信用卡信息错误或 eShop 服务问题。检查信用卡信息,稍后重试,或联系任天堂支持。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 819: // nn::online (在线服务)
|
||||
switch (descriptionId)
|
||||
{
|
||||
case 3:
|
||||
meaning = "软件被暂停";
|
||||
causeAndSolution = "同一账户在另一台设备上使用。关闭其他设备上的软件,或使用不同账户。";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
meaning = "未知模块";
|
||||
causeAndSolution = "未识别的模块 ID,请检查日志或联系任天堂支持。";
|
||||
break;
|
||||
}
|
||||
|
||||
return $"错误码: {errorCode}\n含义: {meaning}\n可能原因及解决办法: {causeAndSolution}";
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c29cb72b155d20a48a3a47a7a05160bd
|
||||
guid: 0e28b69692cb1bb4a9d8ddb91274fa50
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
762
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSIO.cs
Normal file
762
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSIO.cs
Normal file
@ -0,0 +1,762 @@
|
||||
#if UNITY_SWITCH
|
||||
using nn.fs;
|
||||
#endif
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AxiNSIO
|
||||
{
|
||||
string save_name => AxiNS.instance.mount.SaveMountName;
|
||||
public string save_path => $"{save_name}:/";
|
||||
#if UNITY_SWITCH
|
||||
private FileHandle fileHandle = new nn.fs.FileHandle();
|
||||
#endif
|
||||
|
||||
static object commitLock = new object();
|
||||
|
||||
static bool bDirty = false;
|
||||
|
||||
bool CommitSave()
|
||||
{
|
||||
lock (commitLock)
|
||||
{
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
|
||||
// 阻止用户在保存时,退出游戏 Switch 条例 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
nn.Result ret = FileSystem.Commit(save_name);
|
||||
|
||||
if (!ret.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"FileSystem.Commit({save_name}) 失败: " + ret.GetErrorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 停止阻止用户退出游戏
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
|
||||
bDirty = false;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SetCommitDirty()
|
||||
{
|
||||
lock (commitLock)
|
||||
{
|
||||
bDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyAutoCommit()
|
||||
{
|
||||
bool temp;
|
||||
lock (commitLock)
|
||||
{
|
||||
temp = bDirty;
|
||||
}
|
||||
|
||||
if (temp)
|
||||
{
|
||||
CommitSave();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查Path是否存在
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public bool CheckPathExists(string filePath)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
nn.fs.EntryType entryType = 0;
|
||||
nn.Result result = nn.fs.FileSystem.GetEntryType(ref entryType, filePath);
|
||||
//result.abortUnlessSuccess();
|
||||
//这个异常捕获。真的别扭
|
||||
return nn.fs.FileSystem.ResultPathAlreadyExists.Includes(result);
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// 检查Path是否不存在
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public bool CheckPathNotFound(string filePath)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
nn.fs.EntryType entryType = 0;
|
||||
nn.Result result = nn.fs.FileSystem.GetEntryType(ref entryType, filePath);
|
||||
//这个异常捕获。真的别扭
|
||||
return nn.fs.FileSystem.ResultPathNotFound.Includes(result);
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建目录,目录存在也会返回true
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public bool CreateDir(string filePath)
|
||||
{
|
||||
lock (commitLock)
|
||||
{
|
||||
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
// 使用封装函数检查和创建父目录
|
||||
if (!EnsureParentDirectory(filePath, true))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"无法确保父目录,文件写入取消: {filePath}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存并创建文件(如果目录不存在回先自动创建目录)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="bw"></param>
|
||||
/// <returns></returns>
|
||||
public bool FileToSaveWithCreate(string filePath, System.IO.MemoryStream ms)
|
||||
{
|
||||
return FileToSaveWithCreate(filePath, ms.ToArray());
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存并创建文件(如果目录不存在回先自动创建目录)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public AxiNSWait_FileToSaveByMSWithCreate FileToSaveWithCreateAsync(string filePath, System.IO.MemoryStream ms)
|
||||
{
|
||||
var wait = new AxiNSWait_FileToSaveByMSWithCreate(filePath, ms);
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存并创建文件(如果目录不存在回先自动创建目录)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="immediatelyCommit">是否立即Commit到物理存储</param>
|
||||
/// <returns></returns>
|
||||
public bool FileToSaveWithCreate(string filePath, byte[] data, bool immediatelyCommit = true)
|
||||
{
|
||||
lock (commitLock)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
if (!AxiNS.instance.mount.SaveIsMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Save 尚未挂载,无法存储 {filePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
nn.Result result;
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// 阻止用户在保存时,退出游戏
|
||||
// Switch 条例 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
// 使用封装函数检查和创建父目录
|
||||
if (!EnsureParentDirectory(filePath, true))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"无法确保父目录,文件写入取消: {filePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
//string directoryPath = System.IO.Path.GetDirectoryName(filePath.Replace(save_path, ""));
|
||||
//string fullDirectoryPath = $"{save_path}{directoryPath}";
|
||||
//UnityEngine.Debug.Log($"检查父目录: {fullDirectoryPath}");
|
||||
|
||||
//nn.fs.EntryType entryType = 0;
|
||||
//result = nn.fs.FileSystem.GetEntryType(ref entryType, fullDirectoryPath);
|
||||
//if (!result.IsSuccess() && nn.fs.FileSystem.ResultPathNotFound.Includes(result))
|
||||
//{
|
||||
// UnityEngine.Debug.Log($"父目录 {fullDirectoryPath} 不存在,尝试创建 (判断依据 result=>{result.ToString()})");
|
||||
// result = nn.fs.Directory.Create(fullDirectoryPath);
|
||||
// if (!result.IsSuccess())
|
||||
// {
|
||||
// UnityEngine.Debug.LogError($"创建父目录失败: {result.GetErrorInfo()}");
|
||||
// return false;
|
||||
// }
|
||||
// UnityEngine.Debug.Log($"父目录 {fullDirectoryPath} 创建成功");
|
||||
//}
|
||||
//else if (result.IsSuccess() && entryType != nn.fs.EntryType.Directory)
|
||||
//{
|
||||
// UnityEngine.Debug.LogError($"路径 {fullDirectoryPath} 已存在,但不是目录");
|
||||
// return false;
|
||||
//}
|
||||
//else if (!result.IsSuccess())
|
||||
//{
|
||||
// UnityEngine.Debug.LogError($"检查父目录失败: {result.GetErrorInfo()}");
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (CheckPathNotFound(filePath))
|
||||
{
|
||||
UnityEngine.Debug.Log($"文件({filePath})不存在需要创建");
|
||||
result = nn.fs.File.Create(filePath, data.Length); //this makes a file the size of your save journal. You may want to make a file smaller than this.
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"创建文件失败 {filePath} : " + result.GetErrorInfo());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
UnityEngine.Debug.Log($"文件({filePath})存在,不必创建");
|
||||
|
||||
result = File.Open(ref fileHandle, filePath, OpenFileMode.Write);
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"失败 File.Open(ref filehandle, {filePath}, OpenFileMode.Write): " + result.GetErrorInfo());
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"成功 File.Open(ref filehandle, {filePath}, OpenFileMode.Write)");
|
||||
|
||||
//nn.fs.WriteOption.Flush 应该就是覆盖写入
|
||||
result = nn.fs.File.Write(fileHandle, 0, data, data.Length, nn.fs.WriteOption.Flush); // Writes and flushes the write at the same time
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError("写入文件失败: " + result.GetErrorInfo());
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log("写入文件成功: " + filePath);
|
||||
|
||||
nn.fs.File.Close(fileHandle);
|
||||
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// 停止阻止用户退出游戏
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if(immediatelyCommit)
|
||||
{
|
||||
//必须得提交,否则没有真实写入
|
||||
return CommitSave();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCommitDirty();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存并创建文件(如果目录不存在回先自动创建目录)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public AxiNSWait_FileToSaveWithCreate FileToSaveWithCreateAsync(string filePath, byte[] data)
|
||||
{
|
||||
var wait = new AxiNSWait_FileToSaveWithCreate(filePath, data);
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
public byte[] LoadSwitchDataFile(string filename)
|
||||
{
|
||||
LoadSwitchDataFile(filename, out byte[] outputData);
|
||||
return outputData;
|
||||
}
|
||||
|
||||
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
|
||||
{
|
||||
if (LoadSwitchDataFile(filename, out byte[] outputData))
|
||||
{
|
||||
using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(ms))
|
||||
{
|
||||
writer.Write(outputData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool LoadSwitchDataFile(string filename, out byte[] outputData)
|
||||
{
|
||||
#if !UNITY_SWITCH || UNITY_EDITOR
|
||||
outputData = null;
|
||||
return false;
|
||||
#else
|
||||
outputData = null;
|
||||
if (!AxiNS.instance.mount.SaveIsMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Save 尚未挂载,无法读取 {filename}");
|
||||
return false;
|
||||
}
|
||||
if (CheckPathNotFound(filename))
|
||||
return false;
|
||||
|
||||
nn.Result result;
|
||||
result = nn.fs.File.Open(ref fileHandle, filename, nn.fs.OpenFileMode.Read);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.Open 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false; // Could not open file. This can be used to detect if this is the first time a user has launched your game.
|
||||
// (However, be sure you are not getting this error due to your file being locked by another process, etc.)
|
||||
}
|
||||
UnityEngine.Debug.Log($"nn.fs.File.Open 成功 {filename}");
|
||||
long iFileSize = 0;
|
||||
result = nn.fs.File.GetSize(ref iFileSize, fileHandle);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.GetSize 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"nn.fs.File.GetSize 成功 {filename},size=>{iFileSize}");
|
||||
|
||||
byte[] loadedData = new byte[iFileSize];
|
||||
result = nn.fs.File.Read(fileHandle, 0, loadedData, iFileSize);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.Read 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"nn.fs.File.Read 成功 {filename}");
|
||||
|
||||
nn.fs.File.Close(fileHandle);
|
||||
|
||||
//for (int i = 0; i < loadedData.Length; i++)
|
||||
//{
|
||||
// UnityEngine.Debug.Log($"data[{i}]:{loadedData[i]}");
|
||||
//}
|
||||
|
||||
outputData = loadedData;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
public AxiNSWait_LoadSwitchDataFile LoadSwitchDataFileAsync(string filename)
|
||||
{
|
||||
var wait = new AxiNSWait_LoadSwitchDataFile(filename);
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
|
||||
public bool GetDirectoryFiles(string path, out string[] entrys)
|
||||
{
|
||||
#if !UNITY_SWITCH || UNITY_EDITOR
|
||||
|
||||
entrys = null;
|
||||
return false;
|
||||
#else
|
||||
return GetDirectoryEntrys(path,nn.fs.OpenDirectoryMode.File,out entrys);
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool GetDirectoryDirs(string path, out string[] entrys)
|
||||
{
|
||||
#if !UNITY_SWITCH || UNITY_EDITOR
|
||||
entrys = null;
|
||||
return false;
|
||||
#else
|
||||
return GetDirectoryEntrys(path, nn.fs.OpenDirectoryMode.Directory, out entrys);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH
|
||||
public bool GetDirectoryEntrys(string path, nn.fs.OpenDirectoryMode type, out string[] entrys)
|
||||
{
|
||||
nn.fs.DirectoryHandle eHandle = new nn.fs.DirectoryHandle();
|
||||
nn.Result result = nn.fs.Directory.Open(ref eHandle, path, type);
|
||||
if (nn.fs.FileSystem.ResultPathNotFound.Includes(result))
|
||||
{
|
||||
UnityEngine.Debug.Log($"目录 {path} 不存在");
|
||||
entrys = null;
|
||||
return false;
|
||||
}
|
||||
long entryCount = 0;
|
||||
nn.fs.Directory.GetEntryCount(ref entryCount, eHandle);
|
||||
nn.fs.DirectoryEntry[] entries = new nn.fs.DirectoryEntry[entryCount];
|
||||
long actualEntries = 0;
|
||||
nn.fs.Directory.Read(ref actualEntries, entries, eHandle, entryCount);
|
||||
|
||||
entrys = new string[actualEntries];
|
||||
for (int i = 0; i < actualEntries; i++)
|
||||
{
|
||||
entrys[i] = System.IO.Path.Combine(path, entries[i].name);
|
||||
}
|
||||
nn.fs.Directory.Close(eHandle);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if UNITY_SWITCH
|
||||
public bool GetDirectoryEntrysFullRecursion(string path, out string[] entrys)
|
||||
{
|
||||
nn.fs.DirectoryHandle eHandle = new nn.fs.DirectoryHandle();
|
||||
nn.Result result = nn.fs.Directory.Open(ref eHandle, path, OpenDirectoryMode.All);
|
||||
if (nn.fs.FileSystem.ResultPathNotFound.Includes(result))
|
||||
{
|
||||
UnityEngine.Debug.Log($"目录 {path} 不存在");
|
||||
entrys = null;
|
||||
return false;
|
||||
}
|
||||
long entryCount = 0;
|
||||
nn.fs.Directory.GetEntryCount(ref entryCount, eHandle);
|
||||
nn.fs.DirectoryEntry[] entries = new nn.fs.DirectoryEntry[entryCount];
|
||||
long actualEntries = 0;
|
||||
nn.fs.Directory.Read(ref actualEntries, entries, eHandle, entryCount);
|
||||
|
||||
List<string> temp = new List<string>();
|
||||
for (int i = 0; i < actualEntries; i++)
|
||||
{
|
||||
string singlePath = System.IO.Path.Combine(path, entries[i].name);
|
||||
temp.Add(singlePath);
|
||||
if (entries[i].entryType == EntryType.Directory && GetDirectoryEntrysFullRecursion(singlePath, out string[] singleEntryList))
|
||||
{
|
||||
temp.AddRange(singleEntryList);
|
||||
}
|
||||
}
|
||||
nn.fs.Directory.Close(eHandle);
|
||||
entrys = temp.ToArray();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
public IEnumerable<string> EnumerateFiles(string path, string searchPattern)
|
||||
{
|
||||
#if !UNITY_SWITCH || UNITY_EDITOR
|
||||
yield break;
|
||||
#else
|
||||
// 将通配符转换为正则表达式(支持*和?)
|
||||
var regexPattern = "^" +
|
||||
Regex.Escape(searchPattern)
|
||||
.Replace("\\*", ".*")
|
||||
.Replace("\\?", ".")
|
||||
+ "$";
|
||||
|
||||
var regex = new Regex(regexPattern, RegexOptions.IgnoreCase);
|
||||
|
||||
if (!GetDirectoryEntrys(path, nn.fs.OpenDirectoryMode.File, out string[] entrys))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entrys.Length; i++)
|
||||
{
|
||||
if (regex.IsMatch(System.IO.Path.GetFileName(entrys[i])))
|
||||
{
|
||||
yield return entrys[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool DeletePathFile(string filename)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// This next line prevents the user from quitting the game while saving.
|
||||
// This is required for Nintendo Switch Guideline 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if (CheckPathNotFound(filename))
|
||||
return false;
|
||||
nn.Result result;
|
||||
result = nn.fs.File.Delete(filename);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.Delete 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// End preventing the user from quitting the game while saving.
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
return CommitSave();
|
||||
|
||||
#endif
|
||||
}
|
||||
public AxiNSWait_DeletePathFile DeletePathFileAsync(string filename)
|
||||
{
|
||||
var wait = new AxiNSWait_DeletePathFile(filename);
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
public bool DeletePathDir(string filename)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// This next line prevents the user from quitting the game while saving.
|
||||
// This is required for Nintendo Switch Guideline 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if (CheckPathNotFound(filename))
|
||||
return false;
|
||||
nn.Result result;
|
||||
result = nn.fs.Directory.Delete(filename);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.Delete 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// End preventing the user from quitting the game while saving.
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
return CommitSave();
|
||||
#endif
|
||||
}
|
||||
public AxiNSWait_DeletePathDir DeletePathDirAsync(string filename)
|
||||
{
|
||||
var wait = new AxiNSWait_DeletePathDir(filename);
|
||||
AxiNS.instance.wait.AddWait(wait);
|
||||
return wait;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归删除目录
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteRecursivelyPathDir(string filename)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// This next line prevents the user from quitting the game while saving.
|
||||
// This is required for Nintendo Switch Guideline 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if (CheckPathNotFound(filename))
|
||||
return false;
|
||||
nn.Result result;
|
||||
result = nn.fs.Directory.DeleteRecursively(filename);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.DeleteRecursively 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// End preventing the user from quitting the game while saving.
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
return CommitSave();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归删除情况
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public bool CleanRecursivelyPathDir(string filename)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// This next line prevents the user from quitting the game while saving.
|
||||
// This is required for Nintendo Switch Guideline 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if (CheckPathNotFound(filename))
|
||||
return false;
|
||||
nn.Result result;
|
||||
result = nn.fs.Directory.CleanRecursively(filename);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.DeleteRecursively 失败 {filename} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// End preventing the user from quitting the game while saving.
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
return CommitSave();
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool RenameDir(string oldpath, string newpath)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// This next line prevents the user from quitting the game while saving.
|
||||
// This is required for Nintendo Switch Guideline 0080
|
||||
UnityEngine.Switch.Notification.EnterExitRequestHandlingSection();
|
||||
#endif
|
||||
|
||||
if (CheckPathNotFound(oldpath))
|
||||
return false;
|
||||
|
||||
nn.Result result;
|
||||
result = nn.fs.Directory.Rename(oldpath, newpath);
|
||||
if (result.IsSuccess() == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn.fs.File.Rename 失败 {oldpath} to {newpath} : result=>{result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH && !UNITY_EDITOR
|
||||
// End preventing the user from quitting the game while saving.
|
||||
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
|
||||
#endif
|
||||
return CommitSave();
|
||||
|
||||
#endif
|
||||
}
|
||||
bool EnsureParentDirectory(string filePath, bool bAutoCreateDir = true)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
// 参数校验
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"无效参数:filePath={filePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 提取路径前缀(如 save:/、sd:/)
|
||||
int prefixEndIndex = filePath.IndexOf(":/");
|
||||
if (prefixEndIndex == -1)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"文件路径 {filePath} 格式无效,未找到 ':/' 前缀");
|
||||
return false;
|
||||
}
|
||||
string pathPrefix = filePath.Substring(0, prefixEndIndex + 2); // 提取前缀,例如 "save:/"
|
||||
string relativePath = filePath.Substring(prefixEndIndex + 2); // 移除前缀,得到相对路径
|
||||
|
||||
// 检查挂载状态
|
||||
if (!IsMountPointAccessible(pathPrefix))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"挂载点 {pathPrefix} 未挂载,无法操作路径 {filePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 提取父目录路径
|
||||
string directoryPath = System.IO.Path.GetDirectoryName(relativePath); // 获取父目录相对路径
|
||||
if (string.IsNullOrEmpty(directoryPath))
|
||||
{
|
||||
UnityEngine.Debug.Log($"文件路径 {filePath} 无需创建父目录(位于根目录)");
|
||||
return true; // 根目录无需创建
|
||||
}
|
||||
|
||||
string fullDirectoryPath = $"{pathPrefix}{directoryPath}"; // 拼接完整父目录路径
|
||||
UnityEngine.Debug.Log($"检查父目录: {fullDirectoryPath}");
|
||||
|
||||
// 检查路径是否存在及其类型
|
||||
nn.fs.EntryType entryType = 0;
|
||||
nn.Result result = nn.fs.FileSystem.GetEntryType(ref entryType, fullDirectoryPath);
|
||||
if (!result.IsSuccess() && nn.fs.FileSystem.ResultPathNotFound.Includes(result))
|
||||
{
|
||||
if (bAutoCreateDir)
|
||||
{
|
||||
// 路径不存在,尝试创建
|
||||
UnityEngine.Debug.Log($"父目录 {fullDirectoryPath} 不存在,尝试创建 (判断依据 result=>{result.ToString()})");
|
||||
result = nn.fs.Directory.Create(fullDirectoryPath);
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"创建父目录失败: {result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"父目录 {fullDirectoryPath} 创建成功");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (result.IsSuccess() && entryType != nn.fs.EntryType.Directory)
|
||||
{
|
||||
// 路径存在,但不是目录
|
||||
UnityEngine.Debug.LogError($"路径 {fullDirectoryPath} 已存在,但不是目录");
|
||||
return false;
|
||||
}
|
||||
else if (!result.IsSuccess())
|
||||
{
|
||||
// 其他错误
|
||||
UnityEngine.Debug.LogError($"检查父目录失败: {result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
// 路径存在且是目录
|
||||
UnityEngine.Debug.Log($"父目录 {fullDirectoryPath} 已存在且有效");
|
||||
return true;
|
||||
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// 检查指定挂载点是否可访问
|
||||
/// </summary>
|
||||
/// <param name="pathPrefix">路径前缀,例如 "save:/" 或 "sd:/"</param>
|
||||
/// <returns>挂载点是否可访问</returns>
|
||||
bool IsMountPointAccessible(string pathPrefix)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
if (string.IsNullOrEmpty(pathPrefix))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"无效挂载点: {pathPrefix}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据前缀判断挂载点类型并检查挂载状态
|
||||
if (pathPrefix == $"{save_name}:/")
|
||||
{
|
||||
if (!AxiNS.instance.mount.SaveIsMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{save_name}:/ 未挂载");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (pathPrefix == "sd:/")
|
||||
{
|
||||
long freeSpace = 0;
|
||||
// 检查 SD 卡挂载状态(示例,需根据实际实现调整)
|
||||
nn.Result result = nn.fs.FileSystem.GetFreeSpaceSize(ref freeSpace, "sd:/");
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"sd:/ 未挂载或无法访问: {result.GetErrorInfo()}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"未知挂载点 {pathPrefix},假定已挂载");
|
||||
return true; // 其他挂载点需根据实际需求实现
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8339ffab20bfea4cbc7d3aa440c3fdb
|
||||
guid: d910a015a6b6561418bdff7f2c48cffa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
134
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSMount.cs
Normal file
134
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSMount.cs
Normal file
@ -0,0 +1,134 @@
|
||||
#if UNITY_SWITCH
|
||||
using nn.account;
|
||||
#endif
|
||||
public class AxiNSMount
|
||||
{
|
||||
static bool bInMount = false;
|
||||
internal static string m_SaveMountName;
|
||||
static bool bInSdCardMount = false;
|
||||
internal static string m_SdCardMountName;
|
||||
static bool bInSdCardDebugMount = false;
|
||||
internal static string m_SdCardDebugMountName;
|
||||
|
||||
public bool SaveIsMount => bInMount;
|
||||
public string SaveMountName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!bInMount)
|
||||
return string.Empty;
|
||||
else
|
||||
return m_SaveMountName;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_SWITCH
|
||||
public bool MountSave(Uid userId, string mountName = "save")
|
||||
{
|
||||
if (bInMount)
|
||||
return true;
|
||||
|
||||
if (!nn.fs.SaveData.IsExisting(userId))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{userId.ToString()}存档不存在!");
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"{userId.ToString()}存档确保存在!");
|
||||
|
||||
nn.Result result;
|
||||
result = nn.fs.SaveData.Mount(mountName, userId);
|
||||
//result.abortUnlessSuccess();
|
||||
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"MountSave->挂载{mountName}:/ 失败: " + result.ToString());
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"MountSave->挂载{mountName}:/ 成功 ");
|
||||
m_SaveMountName = mountName;
|
||||
bInMount = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool MountSDForDebug(string mountName = "dbgsd")
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
if (bInSdCardDebugMount)
|
||||
return true;
|
||||
nn.Result result;
|
||||
result = nn.fs.SdCard.MountForDebug(mountName);
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn_fs_MountSdCardForDebug->挂载{mountName}:/ 失败: " + result.ToString());
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"nn_fs_MountSdCardForDebug->挂载{mountName}:/ 成功 ");
|
||||
m_SdCardDebugMountName = mountName;
|
||||
bInSdCardDebugMount = true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
public bool MountSD(string mountName = "sd")
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
return false;
|
||||
#else
|
||||
if (bInSdCardMount)
|
||||
return true;
|
||||
nn.Result result;
|
||||
result = AxiNSSDCard.Mount(mountName);
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"nn_fs_MountSdCard->挂载{mountName}:/ 失败: " + result.ToString());
|
||||
return false;
|
||||
}
|
||||
UnityEngine.Debug.Log($"nn_fs_MountSdCard->挂载{mountName}:/ 成功 ");
|
||||
m_SdCardMountName = mountName;
|
||||
bInSdCardMount = true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
public void UnmountSave()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (!bInMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{m_SaveMountName}:/ 没有被挂载,无需卸载");
|
||||
return;
|
||||
}
|
||||
nn.fs.FileSystem.Unmount(m_SaveMountName);
|
||||
UnityEngine.Debug.LogError($"UnmountSaveForDebufa->已卸载{m_SaveMountName}:/ ");
|
||||
bInMount = false;
|
||||
#endif
|
||||
}
|
||||
public void UnmountSDCardForDebug()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (!bInSdCardDebugMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{m_SdCardDebugMountName}:/ 没有被挂载,无需卸载");
|
||||
return;
|
||||
}
|
||||
nn.fs.FileSystem.Unmount(m_SdCardDebugMountName);
|
||||
UnityEngine.Debug.LogError($"UnmountSDCardForDebug->已卸载{m_SdCardDebugMountName}:/ ");
|
||||
bInSdCardDebugMount = false;
|
||||
#endif
|
||||
}
|
||||
public void UnmountSDCard()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (!bInSdCardMount)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{m_SdCardMountName}:/ 没有被挂载,无需卸载");
|
||||
return;
|
||||
}
|
||||
nn.fs.FileSystem.Unmount(m_SdCardMountName);
|
||||
UnityEngine.Debug.LogError($"UnmountSDCard->已卸载{m_SdCardMountName}:/ ");
|
||||
bInSdCardMount = false;
|
||||
#endif
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48826c5dc8959ff4db8c6a51b6568bb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,23 @@
|
||||
#if UNITY_SWITCH
|
||||
using nn.account;
|
||||
#endif
|
||||
public class AxiNSSDCard
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
|
||||
#if DEVELOPMENT_BUILD || NN_FS_SD_CARD_FOR_DEBUG_ENABLE
|
||||
[DllImport(Nn.DllName,
|
||||
CallingConvention = CallingConvention.Cdecl,
|
||||
EntryPoint = "nn_fs_MountSdCard")]
|
||||
public static extern nn.Result Mount(string name);
|
||||
#else
|
||||
|
||||
public static nn.Result Mount(string name)
|
||||
{
|
||||
return new nn.Result();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21fa04ba4da10d74aafd65dd138478b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
106
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSUser.cs
Normal file
106
AxibugEmuOnline.Client/Assets/Plugins/AxiNSApi/AxiNSUser.cs
Normal file
@ -0,0 +1,106 @@
|
||||
#if UNITY_SWITCH
|
||||
using nn.account;
|
||||
#endif
|
||||
|
||||
public class AxiNSUser
|
||||
{
|
||||
bool m_bInit = false;
|
||||
bool m_bGotOpenPreselectedUser = false;
|
||||
|
||||
#if UNITY_SWITCH
|
||||
Uid m_UserId;
|
||||
nn.account.UserHandle mUserHandle;
|
||||
nn.account.Nickname m_NickName;
|
||||
#endif
|
||||
|
||||
#region 对外公开接口,确保内部安全处理,避免崩溃
|
||||
|
||||
#if UNITY_SWITCH
|
||||
public bool GetUserID(out Uid uid)
|
||||
{
|
||||
InitPreselectedUserInfo();
|
||||
if (!m_bGotOpenPreselectedUser)
|
||||
{
|
||||
uid = Uid.Invalid;
|
||||
return false;
|
||||
}
|
||||
uid = m_UserId;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
public bool GetNickName(out string NickName)
|
||||
{
|
||||
#if !UNITY_SWITCH
|
||||
NickName = "";
|
||||
return true;
|
||||
#else
|
||||
InitPreselectedUserInfo();
|
||||
if (!m_bGotOpenPreselectedUser)
|
||||
{
|
||||
NickName = string.Empty;
|
||||
return false;
|
||||
}
|
||||
NickName = m_NickName.ToString();
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 初始化Account模块儿
|
||||
/// </summary>
|
||||
void InitNSAccount()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (m_bInit)
|
||||
return;
|
||||
//必须先初始化NS的Account 不然调用即崩
|
||||
nn.account.Account.Initialize();
|
||||
m_bInit = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取预选用户
|
||||
/// </summary>
|
||||
void InitPreselectedUserInfo()
|
||||
{
|
||||
#if UNITY_SWITCH
|
||||
if (m_bGotOpenPreselectedUser)
|
||||
return;
|
||||
|
||||
InitNSAccount();
|
||||
nn.Result result;
|
||||
mUserHandle = new nn.account.UserHandle();
|
||||
if (!nn.account.Account.TryOpenPreselectedUser(ref mUserHandle))
|
||||
{
|
||||
UnityEngine.Debug.LogError("打开预选的用户失败.");
|
||||
return;
|
||||
}
|
||||
UnityEngine.Debug.Log("打开预选用户成功.");
|
||||
result = nn.account.Account.GetUserId(ref m_UserId, mUserHandle);
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"GetUserId失败: {result.ToString()}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_UserId == Uid.Invalid)
|
||||
{
|
||||
UnityEngine.Debug.LogError("无法获取用户 ID");
|
||||
return;
|
||||
}
|
||||
UnityEngine.Debug.Log($"获取用户 ID:{m_UserId.ToString()}");
|
||||
|
||||
result = nn.account.Account.GetNickname(ref m_NickName, m_UserId);
|
||||
//result.abortUnlessSuccess();
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
UnityEngine.Debug.LogError($"GetNickname失败: {result.ToString()}");
|
||||
return;
|
||||
}
|
||||
UnityEngine.Debug.Log($"获取用户 NickName ID:{m_NickName.ToString()}");
|
||||
m_bGotOpenPreselectedUser = true;
|
||||
#endif
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95c2e164c69c6cc4887a194d6eba0cc2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04e926e140ae5bc4fa46bd64067261cf
|
||||
guid: e28ed9d2fb16c7f42b28cafb6a2ce0ac
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,119 @@
|
||||
public abstract class AxiNSWaitBase : UnityEngine.CustomYieldInstruction
|
||||
{
|
||||
protected bool IsDone;
|
||||
public abstract void Invoke();
|
||||
public string errmsg = string.Empty;
|
||||
public AxiNSWaitBase()
|
||||
{
|
||||
this.IsDone = false;
|
||||
}
|
||||
|
||||
public void SetDone()
|
||||
{
|
||||
this.IsDone = true;
|
||||
}
|
||||
|
||||
~AxiNSWaitBase()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool keepWaiting
|
||||
{
|
||||
get { return !IsDone; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public struct S_NSWAIT_PathWithBytes
|
||||
{
|
||||
public string filePath;
|
||||
public byte[] data;
|
||||
}
|
||||
|
||||
public class AxiNSWait_FileToSaveWithCreate : AxiNSWaitBase
|
||||
{
|
||||
S_NSWAIT_PathWithBytes req;
|
||||
public bool result;
|
||||
public AxiNSWait_FileToSaveWithCreate(string filePath, byte[] data)
|
||||
{
|
||||
req = new S_NSWAIT_PathWithBytes() { filePath = filePath, data = data };
|
||||
}
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
result = AxiNS.instance.io.FileToSaveWithCreate(req.filePath, req.data);
|
||||
}
|
||||
}
|
||||
|
||||
public struct S_NSWAIT_PathWithMS
|
||||
{
|
||||
public string filePath;
|
||||
public System.IO.MemoryStream ms;
|
||||
}
|
||||
|
||||
public class AxiNSWait_FileToSaveByMSWithCreate : AxiNSWaitBase
|
||||
{
|
||||
S_NSWAIT_PathWithMS req;
|
||||
public bool result;
|
||||
public AxiNSWait_FileToSaveByMSWithCreate(string filePath, System.IO.MemoryStream ms)
|
||||
{
|
||||
req = new S_NSWAIT_PathWithMS() { filePath = filePath, ms = ms };
|
||||
}
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
result = AxiNS.instance.io.FileToSaveWithCreate(req.filePath, req.ms);
|
||||
}
|
||||
}
|
||||
|
||||
public struct S_NSWAIT_Path
|
||||
{
|
||||
public string filePath;
|
||||
}
|
||||
|
||||
public class AxiNSWait_LoadSwitchDataFile : AxiNSWaitBase
|
||||
{
|
||||
S_NSWAIT_Path req;
|
||||
public bool result;
|
||||
public byte[] outputData;
|
||||
public AxiNSWait_LoadSwitchDataFile(string filePath)
|
||||
{
|
||||
req = new S_NSWAIT_Path() { filePath = filePath};
|
||||
}
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
result = AxiNS.instance.io.LoadSwitchDataFile(req.filePath, out outputData);
|
||||
}
|
||||
}
|
||||
|
||||
public class AxiNSWait_DeletePathFile : AxiNSWaitBase
|
||||
{
|
||||
S_NSWAIT_Path req;
|
||||
public bool result;
|
||||
public AxiNSWait_DeletePathFile(string filePath)
|
||||
{
|
||||
req = new S_NSWAIT_Path() { filePath = filePath };
|
||||
}
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
result = AxiNS.instance.io.DeletePathFile(req.filePath);
|
||||
}
|
||||
}
|
||||
|
||||
public class AxiNSWait_DeletePathDir : AxiNSWaitBase
|
||||
{
|
||||
S_NSWAIT_Path req;
|
||||
public bool result;
|
||||
public AxiNSWait_DeletePathDir(string filePath)
|
||||
{
|
||||
req = new S_NSWAIT_Path() { filePath = filePath };
|
||||
}
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
result = AxiNS.instance.io.DeletePathDir(req.filePath);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46a1a776d2f9dba49b9641d8e0976861
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class AxiNSWaitHandle
|
||||
{
|
||||
static AutoResetEvent autoEvent = new AutoResetEvent(false);
|
||||
static Thread waitThread = new Thread(Loop);
|
||||
static bool bSingleInit = false;
|
||||
static Queue<AxiNSWaitBase> m_QueueReady = new Queue<AxiNSWaitBase>();
|
||||
static Queue<AxiNSWaitBase> m_QueueWork = new Queue<AxiNSWaitBase>();
|
||||
public void AddWait(AxiNSWaitBase wait)
|
||||
{
|
||||
InitInternalThread();
|
||||
lock (m_QueueReady)
|
||||
{
|
||||
m_QueueReady.Enqueue(wait);
|
||||
}
|
||||
autoEvent.Set();
|
||||
}
|
||||
|
||||
static void InitInternalThread()
|
||||
{
|
||||
if (bSingleInit) return;
|
||||
waitThread.Start();
|
||||
bSingleInit = true;
|
||||
}
|
||||
|
||||
static void Loop()
|
||||
{
|
||||
while (autoEvent.WaitOne())
|
||||
{
|
||||
lock (m_QueueReady)
|
||||
{
|
||||
while (m_QueueReady.Count > 0)
|
||||
{
|
||||
m_QueueWork.Enqueue(m_QueueReady.Dequeue());
|
||||
}
|
||||
}
|
||||
while (m_QueueWork.Count > 0)
|
||||
{
|
||||
AxiNSWaitBase wait = m_QueueWork.Dequeue();
|
||||
try
|
||||
{
|
||||
wait.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
wait.errmsg = ex.ToString();
|
||||
UnityEngine.Debug.Log(ex.ToString());
|
||||
}
|
||||
wait.SetDone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e36180ba1c4a8f4db3ceed533a43999
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -65,7 +65,7 @@ namespace AxiReplay
|
||||
frameProfiler.InputHead(inputData.FrameStartID);
|
||||
}
|
||||
|
||||
public bool TryGetNextFrame(out ReplayStep data, out int frameDiff, out bool inputDiff)
|
||||
public bool TryGetNextFrame(int targetFrame, bool indirectGet, out ReplayStep data, out int frameDiff, out bool inputDiff)
|
||||
{
|
||||
if (!bNetInit)
|
||||
{
|
||||
@ -74,37 +74,27 @@ namespace AxiReplay
|
||||
inputDiff = false;
|
||||
return false;
|
||||
}
|
||||
TakeFrame(1, out data, out frameDiff, out inputDiff);
|
||||
return frameDiff > 0;
|
||||
return TakeFrameToTargetFrame(targetFrame, indirectGet, out data, out frameDiff, out inputDiff);
|
||||
}
|
||||
|
||||
public bool TryGetNextFrame(int targetFrame, out ReplayStep data, out int frameDiff, out bool inputDiff)
|
||||
{
|
||||
if (!bNetInit)
|
||||
{
|
||||
data = default(ReplayStep);
|
||||
frameDiff = default(int);
|
||||
inputDiff = false;
|
||||
return false;
|
||||
}
|
||||
return TakeFrameToTargetFrame(targetFrame, out data, out frameDiff, out inputDiff);
|
||||
bool checkCanGetFrame(int targetFrame, bool indirectGet)
|
||||
{
|
||||
if (indirectGet)
|
||||
{
|
||||
return targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
return targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count >= frameProfiler.TempFrameCount(mRemoteForwardCount);
|
||||
}
|
||||
}
|
||||
|
||||
void TakeFrame(int addFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
|
||||
{
|
||||
int targetFrame = mCurrClientFrameIdx + addFrame;
|
||||
TakeFrameToTargetFrame(targetFrame, out data, out bFrameDiff, out inputDiff);
|
||||
}
|
||||
|
||||
bool TakeFrameToTargetFrame(int targetFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
|
||||
bool TakeFrameToTargetFrame(int targetFrame, bool indirectGet, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
|
||||
{
|
||||
bool result;
|
||||
inputDiff = false;
|
||||
|
||||
|
||||
//if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
|
||||
//if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count >= mRemoteForwardCount)
|
||||
if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count >= frameProfiler.TempFrameCount(mRemoteForwardCount))
|
||||
if (checkCanGetFrame(targetFrame, indirectGet))
|
||||
{
|
||||
//当前帧追加
|
||||
mCurrClientFrameIdx = targetFrame;
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Essgee.Utilities
|
||||
@ -84,21 +83,21 @@ namespace Essgee.Utilities
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void Write(this BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用指针复制数据到临时数组
|
||||
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
|
||||
// 使用BinaryWriter写入临时数组
|
||||
bw.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用指针复制数据到临时数组
|
||||
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
|
||||
// 使用BinaryWriter写入临时数组
|
||||
fs.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用BinaryWriter写入临时数组
|
||||
count = fs.Read(TempBuffer_src, offset, count);
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
using Essgee;
|
||||
using Essgee.Metadata;
|
||||
using System;
|
||||
|
||||
public static class EmuStandInfo
|
||||
@ -8,7 +9,6 @@ public static class EmuStandInfo
|
||||
//public static string datDirectoryPath;
|
||||
//public static string metadataDatabaseFilePath;
|
||||
|
||||
|
||||
public static string jsonConfigFileName;//= "Config.json";
|
||||
public static string saveDataDirectoryName;//= "Saves";
|
||||
public static string screenshotDirectoryName;//= "Screenshots";
|
||||
|
@ -131,7 +131,8 @@ namespace Essgee.Emulation.CPU
|
||||
{
|
||||
if (AppEnvironment.EnableSuperSlowCPULogger && logEntries != null)
|
||||
{
|
||||
System.IO.File.AppendAllText(logFile, string.Join("", logEntries.Take(numLogEntries)));
|
||||
//TODO 暂时不要日志看后续是否需要加
|
||||
//System.IO.File.AppendAllText(logFile, string.Join("", logEntries.Take(numLogEntries)));
|
||||
}
|
||||
|
||||
//
|
||||
@ -175,7 +176,8 @@ namespace Essgee.Emulation.CPU
|
||||
logEntries[numLogEntries++] = disasm;
|
||||
if (numLogEntries >= logEntries.Length)
|
||||
{
|
||||
System.IO.File.AppendAllText(logFile, string.Join("", logEntries));
|
||||
//TODO 暂时不要日志看后续是否需要加
|
||||
//System.IO.File.AppendAllText(logFile, string.Join("", logEntries));
|
||||
numLogEntries = 0;
|
||||
}
|
||||
}
|
||||
|
@ -207,8 +207,9 @@ namespace Essgee.Emulation.CPU
|
||||
|
||||
if (AppEnvironment.EnableSuperSlowCPULogger)
|
||||
{
|
||||
string disasm = string.Format("{0} | {1} | {2} | {3}\n", DisassembleOpcode(this, pc).PadRight(48), PrintRegisters(this), PrintFlags(this), PrintInterrupt(this));
|
||||
System.IO.File.AppendAllText(@"D:\Temp\Essgee\log.txt", disasm);
|
||||
//TODO 暂时不要日志看后续是否需要加
|
||||
//string disasm = string.Format("{0} | {1} | {2} | {3}\n", DisassembleOpcode(this, pc).PadRight(48), PrintRegisters(this), PrintFlags(this), PrintInterrupt(this));
|
||||
//System.IO.File.AppendAllText(@"D:\Temp\Essgee\log.txt", disasm);
|
||||
}
|
||||
|
||||
/* Fetch and execute opcode */
|
||||
|
@ -3,7 +3,6 @@ using Essgee.Exceptions;
|
||||
using Essgee.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@ -32,19 +31,19 @@ namespace Essgee.Emulation
|
||||
Type machineType = null;
|
||||
byte[] romData = null;
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
if (!EmulatorHandler.io.File_Exists(fileName))
|
||||
throw new CartridgeLoaderException($"{fileType} file not found.");
|
||||
|
||||
try
|
||||
{
|
||||
var fileExtension = Path.GetExtension(fileName);
|
||||
var fileExtension = System.IO.Path.GetExtension(fileName);
|
||||
if (fileExtension == ".zip")
|
||||
{
|
||||
using (var zip = ZipFile.Open(fileName, ZipArchiveMode.Read))
|
||||
{
|
||||
foreach (var entry in zip.Entries)
|
||||
{
|
||||
var entryExtension = Path.GetExtension(entry.Name);
|
||||
var entryExtension = System.IO.Path.GetExtension(entry.Name);
|
||||
if (fileExtensionSystemDictionary.ContainsKey(entryExtension))
|
||||
{
|
||||
machineType = fileExtensionSystemDictionary[entryExtension];
|
||||
@ -61,7 +60,7 @@ namespace Essgee.Emulation
|
||||
else if (fileExtensionSystemDictionary.ContainsKey(fileExtension))
|
||||
{
|
||||
machineType = fileExtensionSystemDictionary[fileExtension];
|
||||
romData = File.ReadAllBytes(fileName);
|
||||
romData = System.IO.File.ReadAllBytes(fileName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (!AppEnvironment.DebugMode)
|
||||
|
@ -5,7 +5,6 @@ using Essgee.Metadata;
|
||||
using Essgee.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace Essgee.Emulation
|
||||
@ -14,6 +13,7 @@ namespace Essgee.Emulation
|
||||
{
|
||||
readonly Action<Exception> exceptionHandler;
|
||||
|
||||
public static IEssgeeIOSupport io;
|
||||
public IMachine emulator { get; private set; }
|
||||
|
||||
Thread emulationThread;
|
||||
@ -158,7 +158,7 @@ namespace Essgee.Emulation
|
||||
|
||||
public string GetSaveStateFilename(int number)
|
||||
{
|
||||
return Path.Combine(EmuStandInfo.SaveStatePath, $"{Path.GetFileNameWithoutExtension(currentGameMetadata.FileName)} (State {number:D2}).est");
|
||||
return System.IO.Path.Combine(EmuStandInfo.SaveStatePath, $"{System.IO.Path.GetFileNameWithoutExtension(currentGameMetadata.FileName)} (State {number:D2}).est");
|
||||
}
|
||||
|
||||
public void LoadState(int number)
|
||||
@ -182,9 +182,9 @@ namespace Essgee.Emulation
|
||||
|
||||
byte[] ramData = new byte[currentGameMetadata.RamSize];
|
||||
|
||||
var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
|
||||
if (File.Exists(savePath))
|
||||
ramData = File.ReadAllBytes(savePath);
|
||||
var savePath = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
|
||||
if (EmulatorHandler.io.File_Exists(savePath))
|
||||
ramData = EmulatorHandler.io.File_ReadAllBytes(savePath);
|
||||
|
||||
emulator.Load(romData, ramData, currentGameMetadata.MapperType);
|
||||
|
||||
@ -202,8 +202,8 @@ namespace Essgee.Emulation
|
||||
cartRamSaveNeeded)
|
||||
{
|
||||
var ramData = emulator.GetCartridgeRam();
|
||||
var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
|
||||
File.WriteAllBytes(savePath, ramData);
|
||||
var savePath = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
|
||||
EmulatorHandler.io.File_WriteAllBytes(savePath, ramData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,28 +370,28 @@ namespace Essgee.Emulation
|
||||
// }
|
||||
//}
|
||||
|
||||
public void SaveSnapShotToFile(int stateNumber)
|
||||
{
|
||||
var statePath = GetSaveStateFilename(stateNumber);
|
||||
using (var stream = new FileStream(statePath, FileMode.OpenOrCreate))
|
||||
{
|
||||
//SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.GetState());
|
||||
SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.SaveAxiStatus());
|
||||
}
|
||||
}
|
||||
//public void SaveSnapShotToFile(int stateNumber)
|
||||
//{
|
||||
// var statePath = GetSaveStateFilename(stateNumber);
|
||||
// using (var stream = new FileStream(statePath, FileMode.OpenOrCreate))
|
||||
// {
|
||||
// //SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.GetState());
|
||||
// SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.SaveAxiStatus());
|
||||
// }
|
||||
//}
|
||||
|
||||
public void LoadSnapShotFromFile(int stateNumber)
|
||||
{
|
||||
var statePath = GetSaveStateFilename(stateNumber);
|
||||
if (File.Exists(statePath))
|
||||
{
|
||||
using (var stream = new FileStream(statePath, FileMode.Open))
|
||||
{
|
||||
//emulator.SetState(SaveStateHandler.Load(stream, emulator.GetType().Name));
|
||||
emulator.LoadAxiStatus(SaveStateHandler.LoadAxiStatus(stream, emulator.GetType().Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
//public void LoadSnapShotFromFile(int stateNumber)
|
||||
//{
|
||||
// var statePath = GetSaveStateFilename(stateNumber);
|
||||
// if (File.Exists(statePath))
|
||||
// {
|
||||
// using (var stream = new FileStream(statePath, FileMode.Open))
|
||||
// {
|
||||
// //emulator.SetState(SaveStateHandler.Load(stream, emulator.GetType().Name));
|
||||
// emulator.LoadAxiStatus(SaveStateHandler.LoadAxiStatus(stream, emulator.GetType().Name));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public byte[] GetStateData()
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Essgee.EventArguments;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
|
||||
namespace Essgee.Emulation.ExtDevices.Nintendo
|
||||
@ -64,7 +63,7 @@ namespace Essgee.Emulation.ExtDevices.Nintendo
|
||||
ipcOffsetSelf = ipcBaseOffsetSerialData + 1;
|
||||
ipcOffsetRemote = ipcBaseOffsetSerialData + 0;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Mapped file does not yet exist, create file and assume this instance is first machine
|
||||
mmf = MemoryMappedFile.CreateOrOpen(ipcName, ipcLength);
|
||||
|
@ -10,7 +10,6 @@ using Essgee.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Essgee.Emulation.Machines
|
||||
@ -365,9 +364,22 @@ namespace Essgee.Emulation.Machines
|
||||
irDatabaseCurrentIndex = irCycles = 0;
|
||||
irExternalTransferActive = false;
|
||||
|
||||
if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && File.Exists(configuration.InfraredDatabasePikachu))
|
||||
//if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && EmulatorHandler.io.File_Exists(configuration.InfraredDatabasePikachu))
|
||||
//{
|
||||
// using (var reader = new System.IO.BinaryReader(new FileStream(configuration.InfraredDatabasePikachu, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)))
|
||||
// {
|
||||
// irDatabase = new ushort[reader.BaseStream.Length / 2];
|
||||
// for (var i = 0; i < irDatabase.Length; i++)
|
||||
// irDatabase[i] = reader.ReadUInt16();
|
||||
|
||||
// irDatabaseStep = 2007;
|
||||
// if ((irDatabaseBaseIndex < 0) || (irDatabaseBaseIndex * irDatabaseStep >= irDatabase.Length))
|
||||
// irDatabaseBaseIndex = 0;
|
||||
// }
|
||||
//}
|
||||
if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && EmulatorHandler.io.File_Exists(configuration.InfraredDatabasePikachu))
|
||||
{
|
||||
using (var reader = new BinaryReader(new FileStream(configuration.InfraredDatabasePikachu, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)))
|
||||
using (var reader = new System.IO.BinaryReader(new System.IO.MemoryStream(EmulatorHandler.io.File_ReadAllBytes(configuration.InfraredDatabasePikachu))))
|
||||
{
|
||||
irDatabase = new ushort[reader.BaseStream.Length / 2];
|
||||
for (var i = 0; i < irDatabase.Length; i++)
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Essgee.Emulation
|
||||
namespace Essgee.Emulation
|
||||
{
|
||||
public static class SaveStateHandler
|
||||
{
|
||||
@ -42,12 +40,12 @@ namespace Essgee.Emulation
|
||||
// }
|
||||
//}
|
||||
|
||||
public static AxiEssgssStatusData LoadAxiStatus(Stream stream, string machineName)
|
||||
public static AxiEssgssStatusData LoadAxiStatus(System.IO.Stream stream, string machineName)
|
||||
{
|
||||
using (var reader = new BinaryReader(stream))
|
||||
using (var reader = new System.IO.BinaryReader(stream))
|
||||
{
|
||||
/* Check CRC32 */
|
||||
using (var stateStream = new MemoryStream())
|
||||
using (var stateStream = new System.IO.MemoryStream())
|
||||
{
|
||||
reader.BaseStream.CopyTo(stateStream);
|
||||
return stateStream.ToArray().ToAxiEssgssStatusData();
|
||||
@ -102,11 +100,11 @@ namespace Essgee.Emulation
|
||||
// }
|
||||
//}
|
||||
|
||||
public static void Save(Stream stream, string machineName, AxiEssgssStatusData state)
|
||||
{
|
||||
byte[] data = state.ToByteArray();
|
||||
stream.Write(data, 0, data.Length);
|
||||
}
|
||||
//public static void Save(Stream stream, string machineName, AxiEssgssStatusData state)
|
||||
//{
|
||||
// byte[] data = state.ToByteArray();
|
||||
// stream.Write(data, 0, data.Length);
|
||||
//}
|
||||
//private static string GenerateMachineIdString(string machineId)
|
||||
//{
|
||||
// return machineId.Substring(0, Math.Min(machineId.Length, 16)).PadRight(16);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
@ -20,7 +19,7 @@ namespace Essgee.Extensions
|
||||
|
||||
public static string ReadEmbeddedTextFile(this Assembly assembly, string resourceName)
|
||||
{
|
||||
using (var reader = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
|
||||
using (var reader = new System.IO.StreamReader(assembly.GetManifestResourceStream(resourceName)))
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
[Serializable]
|
||||
public class AxiEssgssStatusData
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Essgee.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
@ -17,6 +16,15 @@ namespace Essgee.Metadata
|
||||
public bool GetDatBytes(string DatName, out byte[] loadedData);
|
||||
}
|
||||
|
||||
|
||||
public interface IEssgeeIOSupport
|
||||
{
|
||||
bool File_Exists(string path);
|
||||
byte[] File_ReadAllBytes(string path);
|
||||
void File_WriteAllBytes(string savePath, byte[] data);
|
||||
void File_WriteAllBytesFromStre(string path, System.IO.MemoryStream ms);
|
||||
}
|
||||
|
||||
public class GameMetadataHandler
|
||||
{
|
||||
public static GameMetadataHandler instance;
|
||||
@ -24,6 +32,8 @@ namespace Essgee.Metadata
|
||||
//static string metadataDatabaseFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "MetadataDatabase.json");
|
||||
|
||||
public IGameMetaReources gameMetaReources;
|
||||
public IEssgeeIOSupport uegIO;
|
||||
|
||||
//readonly Dictionary<string, DatFile> datFiles;
|
||||
readonly List<CartridgeJSON> cartMetadataDatabase;
|
||||
|
||||
@ -379,7 +389,7 @@ namespace Essgee.Metadata
|
||||
XmlSerializer serializer;
|
||||
root = new XmlRootAttribute("datafile") { IsNullable = true };
|
||||
serializer = new XmlSerializer(typeof(DatFile), root);
|
||||
using (MemoryStream stream = new MemoryStream(loadedData))
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
|
||||
{
|
||||
datFile = (DatFile)serializer.Deserialize(stream);
|
||||
}
|
||||
@ -396,7 +406,7 @@ namespace Essgee.Metadata
|
||||
/* Create game metadata */
|
||||
var gameMetadata = new GameMetadata()
|
||||
{
|
||||
FileName = Path.GetFileName(romFilename),
|
||||
FileName = System.IO.Path.GetFileName(romFilename),
|
||||
KnownName = gameInfo?.Name,
|
||||
RomCrc32 = romCrc32,
|
||||
RomSize = romSize
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Essgee.Utilities
|
||||
{
|
||||
@ -34,42 +33,42 @@ namespace Essgee.Utilities
|
||||
if ((segmentStart + segmentLength) > dataLength) throw new Crc32Exception("Segment end offset is greater than total length");
|
||||
}
|
||||
|
||||
public static uint Calculate(FileInfo fileInfo)
|
||||
{
|
||||
return Calculate(fileInfo, 0, (int)fileInfo.Length);
|
||||
}
|
||||
//public static uint Calculate(FileInfo fileInfo)
|
||||
//{
|
||||
// return Calculate(fileInfo, 0, (int)fileInfo.Length);
|
||||
//}
|
||||
|
||||
public static uint Calculate(FileInfo fileInfo, int start, int length)
|
||||
{
|
||||
VerifyStartAndLength((int)fileInfo.Length, start, length);
|
||||
//public static uint Calculate(FileInfo fileInfo, int start, int length)
|
||||
//{
|
||||
// VerifyStartAndLength((int)fileInfo.Length, start, length);
|
||||
|
||||
using (FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
return Calculate(file, start, length);
|
||||
}
|
||||
}
|
||||
// using (FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
// {
|
||||
// return Calculate(file, start, length);
|
||||
// }
|
||||
//}
|
||||
|
||||
public static uint Calculate(Stream stream)
|
||||
{
|
||||
return Calculate(stream, 0, (int)stream.Length);
|
||||
}
|
||||
//public static uint Calculate(Stream stream)
|
||||
//{
|
||||
// return Calculate(stream, 0, (int)stream.Length);
|
||||
//}
|
||||
|
||||
public static uint Calculate(Stream stream, int start, int length)
|
||||
{
|
||||
VerifyStartAndLength((int)stream.Length, start, length);
|
||||
//public static uint Calculate(Stream stream, int start, int length)
|
||||
//{
|
||||
// VerifyStartAndLength((int)stream.Length, start, length);
|
||||
|
||||
uint crc = 0;
|
||||
// uint crc = 0;
|
||||
|
||||
var lastStreamPosition = stream.Position;
|
||||
// var lastStreamPosition = stream.Position;
|
||||
|
||||
byte[] data = new byte[length];
|
||||
stream.Position = start;
|
||||
stream.Read(data, 0, length);
|
||||
crc = Calculate(data, 0, data.Length);
|
||||
stream.Position = lastStreamPosition;
|
||||
// byte[] data = new byte[length];
|
||||
// stream.Position = start;
|
||||
// stream.Read(data, 0, length);
|
||||
// crc = Calculate(data, 0, data.Length);
|
||||
// stream.Position = lastStreamPosition;
|
||||
|
||||
return crc;
|
||||
}
|
||||
// return crc;
|
||||
//}
|
||||
|
||||
public static uint Calculate(byte[] data)
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -25,8 +24,9 @@ namespace MAME.Core
|
||||
ISoundPlayer isp,
|
||||
IKeyboard ikb,
|
||||
IMouse imou,
|
||||
ITimeSpan itime
|
||||
) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime);
|
||||
ITimeSpan itime,
|
||||
IMAMEIOSupport io
|
||||
) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime,io);
|
||||
|
||||
public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir);
|
||||
|
||||
@ -40,7 +40,7 @@ namespace MAME.Core
|
||||
public void StopGame() => mameMainMotion.StopGame();
|
||||
public long currEmuFrame => Video.screenstate.frame_number;
|
||||
public bool IsPaused => Mame.paused;
|
||||
public void LoadState(BinaryReader sr)
|
||||
public void LoadState(System.IO.BinaryReader sr)
|
||||
{
|
||||
Mame.paused = true;
|
||||
Thread.Sleep(20);
|
||||
@ -51,7 +51,7 @@ namespace MAME.Core
|
||||
Mame.paused = false;
|
||||
}
|
||||
|
||||
public void SaveState(BinaryWriter sw)
|
||||
public void SaveState(System.IO.BinaryWriter sw)
|
||||
{
|
||||
Mame.paused = true;
|
||||
Thread.Sleep(20);
|
||||
|
@ -21,6 +21,7 @@ namespace MAME.Core
|
||||
public AutoResetEvent emuAutoLoopEvent;
|
||||
|
||||
public static IResources resource;
|
||||
public static IMAMEIOSupport IoSupport;
|
||||
public bool bRom => Machine.bRom;
|
||||
|
||||
public MameMainMotion()
|
||||
@ -42,7 +43,8 @@ namespace MAME.Core
|
||||
ISoundPlayer isp,
|
||||
IKeyboard ikb,
|
||||
IMouse imou,
|
||||
ITimeSpan itime
|
||||
ITimeSpan itime,
|
||||
IMAMEIOSupport io
|
||||
)
|
||||
{
|
||||
AxiMemoryEx.Init();
|
||||
@ -54,6 +56,7 @@ namespace MAME.Core
|
||||
Video.BindFunc(ivp);
|
||||
Sound.BindFunc(isp);
|
||||
resource = iRes;
|
||||
IoSupport = io;
|
||||
|
||||
sSelect = string.Empty;
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
|
||||
namespace cpu.m6502
|
||||
{
|
||||
@ -232,7 +230,7 @@ namespace cpu.m6502
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(subtype);
|
||||
writer.Write(ppc.LowWord);
|
||||
@ -250,7 +248,7 @@ namespace cpu.m6502
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
subtype = reader.ReadByte();
|
||||
ppc.LowWord = reader.ReadUInt16();
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace cpu.m6800
|
||||
{
|
||||
@ -1216,7 +1215,7 @@ namespace cpu.m6800
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(PPC.LowWord);
|
||||
writer.Write(PC.LowWord);
|
||||
@ -1260,7 +1259,7 @@ namespace cpu.m6800
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
PPC.LowWord = reader.ReadUInt16();
|
||||
PC.LowWord = reader.ReadUInt16();
|
||||
|
@ -1,7 +1,6 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace cpu.m68000
|
||||
@ -275,7 +274,7 @@ namespace cpu.m68000
|
||||
// return a + b + c + d;
|
||||
//}
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 0x08; i++)
|
||||
@ -304,7 +303,7 @@ namespace cpu.m68000
|
||||
writer.Write(MC68000.m1.TotalExecutedCycles);
|
||||
writer.Write(MC68000.m1.PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 0x08; i++)
|
||||
@ -333,7 +332,7 @@ namespace cpu.m68000
|
||||
MC68000.m1.TotalExecutedCycles = reader.ReadUInt64();
|
||||
MC68000.m1.PendingCycles = reader.ReadInt32();
|
||||
}
|
||||
public void SaveStateText(TextWriter writer, string id)
|
||||
public void SaveStateText(System.IO.TextWriter writer, string id)
|
||||
{
|
||||
writer.WriteLine("[{0}]", id);
|
||||
writer.WriteLine("D0 {0:X8}", D[0].s32);
|
||||
@ -370,7 +369,7 @@ namespace cpu.m68000
|
||||
writer.WriteLine("[/{0}]", id);
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader, string id)
|
||||
public void LoadStateText(System.IO.TextReader reader, string id)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace cpu.m6805
|
||||
{
|
||||
@ -831,7 +830,7 @@ namespace cpu.m6805
|
||||
while (pendingCycles > 0);
|
||||
return cycles - pendingCycles;
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(ea.LowWord);
|
||||
@ -850,7 +849,7 @@ namespace cpu.m6805
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
ea.LowWord = reader.ReadUInt16();
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace cpu.m6809
|
||||
{
|
||||
@ -861,7 +860,7 @@ namespace cpu.m6809
|
||||
case 0xff: EA = IMMWORD(); EA.d = RM16(EA.LowWord); pendingCycles -= 8; break;
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(PC.LowWord);
|
||||
writer.Write(PPC.LowWord);
|
||||
@ -879,7 +878,7 @@ namespace cpu.m6809
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
PC.LowWord = reader.ReadUInt16();
|
||||
PPC.LowWord = reader.ReadUInt16();
|
||||
|
@ -1,6 +1,5 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace cpu.nec
|
||||
{
|
||||
@ -1190,7 +1189,7 @@ namespace cpu.nec
|
||||
nec_interrupt(-1, false);
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(I.regs.b, 0, 16);
|
||||
@ -1220,7 +1219,7 @@ namespace cpu.nec
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
I.regs.b = reader.ReadBytes(16);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
// This Z80 emulator is a modified version of Ben Ryves 'Brazil' emulator.
|
||||
// It is MIT licensed.
|
||||
@ -133,7 +132,7 @@ namespace cpu.z80
|
||||
|
||||
// State Save/Load
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(PPC);
|
||||
writer.Write(RegisterAF);
|
||||
@ -162,7 +161,7 @@ namespace cpu.z80
|
||||
writer.Write(TotalExecutedCycles);
|
||||
writer.Write(PendingCycles);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
PPC = reader.ReadUInt16();
|
||||
RegisterAF = reader.ReadUInt16();
|
||||
@ -191,7 +190,7 @@ namespace cpu.z80
|
||||
TotalExecutedCycles = reader.ReadUInt64();
|
||||
PendingCycles = reader.ReadInt32();
|
||||
}
|
||||
public void SaveStateText(TextWriter writer)
|
||||
public void SaveStateText(System.IO.TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[Z80]");
|
||||
writer.WriteLine("AF {0:X4}", RegAF.Word);
|
||||
@ -221,7 +220,7 @@ namespace cpu.z80
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
public void LoadStateText(System.IO.TextReader reader)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -6,7 +6,6 @@ using cpu.m6809;
|
||||
using cpu.nec;
|
||||
using cpu.z80;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -2808,7 +2807,7 @@ namespace MAME.Core
|
||||
if (perfect_interleave.attoseconds == Attotime.ATTOSECONDS_PER_SECOND - 1)
|
||||
perfect_interleave.attoseconds = cpu[0].attoseconds_per_cycle;
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ncpu; i++)
|
||||
@ -2822,7 +2821,7 @@ namespace MAME.Core
|
||||
writer.Write(Cpuexec.cpu[i].localtime.attoseconds);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ncpu; i++)
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -262,7 +260,7 @@ namespace MAME.Core
|
||||
{
|
||||
return cpu_irq_callback(3, line);
|
||||
}
|
||||
public static void SaveStateBinary_v(BinaryWriter writer)
|
||||
public static void SaveStateBinary_v(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, n;
|
||||
n = lvec.Count;
|
||||
@ -280,7 +278,7 @@ namespace MAME.Core
|
||||
writer.Write((long)0);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary_v(BinaryReader reader)
|
||||
public static void LoadStateBinary_v(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, n;
|
||||
n = reader.ReadInt32();
|
||||
@ -299,7 +297,7 @@ namespace MAME.Core
|
||||
reader.ReadInt64();
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j, n;
|
||||
n = lirq.Count;
|
||||
@ -351,7 +349,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j, n;
|
||||
n = reader.ReadInt32();
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core
|
||||
{
|
||||
/*public enum eeprom_command
|
||||
{
|
||||
@ -378,7 +376,7 @@ namespace MAME.Core
|
||||
}
|
||||
clock_line = state;
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(eeprom_data);
|
||||
writer.Write(serial_buffer);
|
||||
@ -393,7 +391,7 @@ namespace MAME.Core
|
||||
writer.Write(eeprom_data_bits);
|
||||
writer.Write(eeprom_read_address);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
eeprom_data = reader.ReadBytes(0x80);
|
||||
serial_buffer = reader.ReadBytes(40);
|
||||
|
@ -1,7 +1,6 @@
|
||||
using cpu.m6800;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -642,7 +641,7 @@ namespace MAME.Core
|
||||
{
|
||||
return Attotime.attotime_sub(which.expire, get_current_time());
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, i1, n;
|
||||
n = lt.Count;
|
||||
@ -673,7 +672,7 @@ namespace MAME.Core
|
||||
writer.Write((long)0);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, i1, n;
|
||||
n = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -264,10 +263,12 @@ namespace MAME.Core
|
||||
{
|
||||
byte[] bb1;
|
||||
string path = System.IO.Path.Combine(Mame.RomRoot + "/neogeo/", sFile);
|
||||
if (File.Exists(path))
|
||||
//if (File.Exists(path))
|
||||
if (MameMainMotion.IoSupport.File_Exists(path))
|
||||
{
|
||||
EmuLogger.Log($"Had File => {path}");
|
||||
return File.ReadAllBytes(path);
|
||||
//return File.ReadAllBytes(path);
|
||||
return MameMainMotion.IoSupport.File_ReadAllBytes(path);
|
||||
//FileStream fs1 = new FileStream(path, FileMode.Open);
|
||||
//int n1 = (int)fs1.Length;
|
||||
//bb1 = new byte[n1];
|
||||
@ -286,10 +287,10 @@ namespace MAME.Core
|
||||
foreach (string s1 in lsParents)
|
||||
{
|
||||
string path = System.IO.Path.Combine(Mame.RomRoot + "/" + s1 + "/", sFile);
|
||||
if (File.Exists(path))
|
||||
if (MameMainMotion.IoSupport.File_Exists(path))
|
||||
{
|
||||
EmuLogger.Log($"Had File => {path}");
|
||||
return File.ReadAllBytes(path);
|
||||
return MameMainMotion.IoSupport.File_ReadAllBytes(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
using MAME.Core;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class Mame
|
||||
@ -23,8 +21,8 @@ namespace MAME.Core
|
||||
public static bool paused;
|
||||
public static bool exit_pending;
|
||||
public static EmuTimer.emu_timer soft_reset_timer;
|
||||
public static BinaryReader brRecord = null;
|
||||
public static BinaryWriter bwRecord = null;
|
||||
public static System.IO.BinaryReader brRecord = null;
|
||||
public static System.IO.BinaryWriter bwRecord = null;
|
||||
public static bool bPP = true;
|
||||
public static string RomRoot = string.Empty;
|
||||
public class AA
|
||||
@ -42,7 +40,6 @@ namespace MAME.Core
|
||||
new AA(6547,"2"),
|
||||
new AA(13955,"3")
|
||||
};
|
||||
private static FileStream fsRecord = null;
|
||||
|
||||
public static void mame_execute()
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -488,26 +487,26 @@ namespace MAME.Core
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void Write(this BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
int singlesize = sizeof(byte);
|
||||
long totalBytesToCopy = count * singlesize;
|
||||
Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy);
|
||||
bw.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
int singlesize = sizeof(byte);
|
||||
long totalBytesToCopy = count * singlesize;
|
||||
Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy);
|
||||
fs.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
count = fs.Read(TempBuffer_src, offset, count);
|
||||
Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count);
|
||||
return count;
|
||||
}
|
||||
//public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
//{
|
||||
// int singlesize = sizeof(byte);
|
||||
// long totalBytesToCopy = count * singlesize;
|
||||
// Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy);
|
||||
// fs.Write(TempBuffer_src, 0, count);
|
||||
//}
|
||||
//public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
//{
|
||||
// count = fs.Read(TempBuffer_src, offset, count);
|
||||
// Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count);
|
||||
// return count;
|
||||
//}
|
||||
}
|
||||
|
||||
public unsafe static class AxiArray
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class Pd4900a
|
||||
{
|
||||
@ -312,7 +310,7 @@ namespace MAME.Core
|
||||
{
|
||||
pd4990a_serial_control((byte)(data & 0x7));
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(pd4990a.seconds);
|
||||
writer.Write(pd4990a.minutes);
|
||||
@ -334,7 +332,7 @@ namespace MAME.Core
|
||||
writer.Write(clock_line);
|
||||
writer.Write(command_line);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
pd4990a.seconds = reader.ReadInt32();
|
||||
pd4990a.minutes = reader.ReadInt32();
|
||||
|
@ -1,11 +1,9 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class State
|
||||
{
|
||||
public delegate void savestate_delegate(BinaryWriter sw);
|
||||
public delegate void loadstate_delegate(BinaryReader sr);
|
||||
public delegate void savestate_delegate(System.IO.BinaryWriter sw);
|
||||
public delegate void loadstate_delegate(System.IO.BinaryReader sr);
|
||||
public static savestate_delegate savestate_callback;
|
||||
public static loadstate_delegate loadstate_callback;
|
||||
public static void state_init()
|
||||
|
@ -1,6 +1,4 @@
|
||||
using MAME.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -1102,7 +1100,7 @@ namespace MAME.Core
|
||||
{
|
||||
return flip_screen_x;
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(scanline_param);
|
||||
writer.Write(screenstate.last_partial_scan);
|
||||
@ -1112,7 +1110,7 @@ namespace MAME.Core
|
||||
writer.Write(screenstate.vblank_end_time.attoseconds);
|
||||
writer.Write(screenstate.frame_number);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
scanline_param = reader.ReadInt32();
|
||||
screenstate.last_partial_scan = reader.ReadInt32();
|
||||
|
@ -1,13 +1,12 @@
|
||||
using cpu.m68000;
|
||||
using cpu.m6809;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Capcom
|
||||
{
|
||||
public static void SaveStateBinary_gng(BinaryWriter writer)
|
||||
public static void SaveStateBinary_gng(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(bytedsw1);
|
||||
@ -53,7 +52,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_gng(BinaryReader reader)
|
||||
public static void LoadStateBinary_gng(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
bytedsw1 = reader.ReadByte();
|
||||
@ -99,7 +98,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_sf(BinaryWriter writer)
|
||||
public static void SaveStateBinary_sf(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -148,7 +147,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_sf(BinaryReader reader)
|
||||
public static void LoadStateBinary_sf(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadUInt16();
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.m68000;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class CPS
|
||||
{
|
||||
public static void SaveStateBinaryC(BinaryWriter writer)
|
||||
public static void SaveStateBinaryC(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dswa);
|
||||
@ -76,7 +75,7 @@ namespace MAME.Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinaryQ(BinaryWriter writer)
|
||||
public static void SaveStateBinaryQ(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dswa);
|
||||
@ -126,7 +125,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void SaveStateBinaryC2(BinaryWriter writer)
|
||||
public static void SaveStateBinaryC2(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(basebanksnd);
|
||||
@ -191,7 +190,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinaryC(BinaryReader reader)
|
||||
public static void LoadStateBinaryC(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dswa = reader.ReadByte();
|
||||
@ -261,7 +260,7 @@ namespace MAME.Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinaryQ(BinaryReader reader)
|
||||
public static void LoadStateBinaryQ(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dswa = reader.ReadByte();
|
||||
@ -309,7 +308,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
Eeprom.LoadStateBinary(reader);
|
||||
}
|
||||
public static void LoadStateBinaryC2(BinaryReader reader)
|
||||
public static void LoadStateBinaryC2(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
basebanksnd = reader.ReadInt32();
|
||||
|
@ -1,11 +1,10 @@
|
||||
using cpu.m6502;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Dataeast
|
||||
{
|
||||
public static void SaveStateBinary_pcktgal(BinaryWriter writer)
|
||||
public static void SaveStateBinary_pcktgal(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw);
|
||||
@ -48,7 +47,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_pcktgal(BinaryReader reader)
|
||||
public static void LoadStateBinary_pcktgal(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw = reader.ReadByte();
|
||||
|
@ -1,11 +1,10 @@
|
||||
using cpu.m68000;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class IGS011
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 0x800; i++)
|
||||
@ -74,7 +73,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 0x800; i++)
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Konami68000
|
||||
{
|
||||
@ -409,7 +407,7 @@ namespace MAME.Core
|
||||
{
|
||||
return K052109_irq_enabled;
|
||||
}
|
||||
public static void SaveStateBinary_K052109(BinaryWriter writer)
|
||||
public static void SaveStateBinary_K052109(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(K052109_ram, 0, 0x6000);
|
||||
@ -430,7 +428,7 @@ namespace MAME.Core
|
||||
writer.Write(has_extra_video_ram);
|
||||
writer.Write(K052109_tileflip_enable);
|
||||
}
|
||||
public static void LoadStateBinary_K052109(BinaryReader reader)
|
||||
public static void LoadStateBinary_K052109(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
K052109_ram = reader.ReadBytes(0x6000);
|
||||
@ -451,7 +449,7 @@ namespace MAME.Core
|
||||
has_extra_video_ram = reader.ReadByte();
|
||||
K052109_tileflip_enable = reader.ReadInt32();
|
||||
}
|
||||
public static void LoadStateBinary_K052109_2(BinaryReader reader)
|
||||
public static void LoadStateBinary_K052109_2(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
reader.ReadBytes(0x6000);
|
||||
@ -722,7 +720,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary_K051960(BinaryWriter writer)
|
||||
public static void SaveStateBinary_K051960(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(K051960_romoffset);
|
||||
writer.Write(K051960_spriteflip);
|
||||
@ -734,7 +732,7 @@ namespace MAME.Core
|
||||
writer.Write(K051960_irq_enabled);
|
||||
writer.Write(K051960_nmi_enabled);
|
||||
}
|
||||
public static void LoadStateBinary_K051960(BinaryReader reader)
|
||||
public static void LoadStateBinary_K051960(System.IO.BinaryReader reader)
|
||||
{
|
||||
K051960_romoffset = reader.ReadInt32();
|
||||
K051960_spriteflip = reader.ReadInt32();
|
||||
@ -746,7 +744,7 @@ namespace MAME.Core
|
||||
K051960_irq_enabled = reader.ReadInt32();
|
||||
K051960_nmi_enabled = reader.ReadInt32();
|
||||
}
|
||||
public static void LoadStateBinary_K051960_2(BinaryReader reader)
|
||||
public static void LoadStateBinary_K051960_2(System.IO.BinaryReader reader)
|
||||
{
|
||||
reader.ReadInt32();
|
||||
reader.ReadInt32();
|
||||
@ -1080,7 +1078,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary_K053245(BinaryWriter writer)
|
||||
public static void SaveStateBinary_K053245(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(K05324x_z_rejection);
|
||||
@ -1104,7 +1102,7 @@ namespace MAME.Core
|
||||
writer.Write(K053244_regs[0], 0, 0x10);
|
||||
writer.Write(K054000_ram, 0, 0x20);
|
||||
}
|
||||
public static void LoadStateBinary_K053245(BinaryReader reader)
|
||||
public static void LoadStateBinary_K053245(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
K05324x_z_rejection = reader.ReadInt32();
|
||||
@ -1228,7 +1226,7 @@ namespace MAME.Core
|
||||
K053936_offset[chip][0] = xoffs;
|
||||
K053936_offset[chip][1] = yoffs;
|
||||
}
|
||||
public static void SaveStateBinary_K053936(BinaryWriter writer)
|
||||
public static void SaveStateBinary_K053936(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 0x10; i++)
|
||||
@ -1251,7 +1249,7 @@ namespace MAME.Core
|
||||
writer.Write(K053936_wraparound[i]);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary_K053936(BinaryReader reader)
|
||||
public static void LoadStateBinary_K053936(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 0x10; i++)
|
||||
@ -1373,7 +1371,7 @@ namespace MAME.Core
|
||||
{
|
||||
return K053251_palette_index[ci];
|
||||
}
|
||||
public static void SaveStateBinary_K053251(BinaryWriter writer)
|
||||
public static void SaveStateBinary_K053251(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(K053251_ram);
|
||||
@ -1383,7 +1381,7 @@ namespace MAME.Core
|
||||
}
|
||||
writer.Write(K053251_tilemaps_set);
|
||||
}
|
||||
public static void LoadStateBinary_K053251(BinaryReader reader)
|
||||
public static void LoadStateBinary_K053251(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
K053251_ram = reader.ReadBytes(0x10);
|
||||
@ -1393,7 +1391,7 @@ namespace MAME.Core
|
||||
}
|
||||
K053251_tilemaps_set = reader.ReadInt32();
|
||||
}
|
||||
public static void LoadStateBinary_K053251_2(BinaryReader reader)
|
||||
public static void LoadStateBinary_K053251_2(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
reader.ReadBytes(0x10);
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.m68000;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Konami68000
|
||||
{
|
||||
public static void SaveStateBinary_cuebrick(BinaryWriter writer)
|
||||
public static void SaveStateBinary_cuebrick(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -62,7 +61,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_cuebrick(BinaryReader reader)
|
||||
public static void LoadStateBinary_cuebrick(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -118,7 +117,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_mia(BinaryWriter writer)
|
||||
public static void SaveStateBinary_mia(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -180,7 +179,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_mia(BinaryReader reader)
|
||||
public static void LoadStateBinary_mia(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -242,7 +241,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_tmnt(BinaryWriter writer)
|
||||
public static void SaveStateBinary_tmnt(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -314,7 +313,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_tmnt(BinaryReader reader)
|
||||
public static void LoadStateBinary_tmnt(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -386,7 +385,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_punkshot(BinaryWriter writer)
|
||||
public static void SaveStateBinary_punkshot(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -439,7 +438,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_punkshot(BinaryReader reader)
|
||||
public static void LoadStateBinary_punkshot(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -492,7 +491,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_lgtnfght(BinaryWriter writer)
|
||||
public static void SaveStateBinary_lgtnfght(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -545,7 +544,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_lgtnfght(BinaryReader reader)
|
||||
public static void LoadStateBinary_lgtnfght(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -598,7 +597,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_blswhstl(BinaryWriter writer)
|
||||
public static void SaveStateBinary_blswhstl(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(bytee);
|
||||
@ -650,7 +649,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary_blswhstl(BinaryReader reader)
|
||||
public static void LoadStateBinary_blswhstl(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
bytee = reader.ReadByte();
|
||||
@ -702,7 +701,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
Eeprom.LoadStateBinary(reader);
|
||||
}
|
||||
public static void SaveStateBinary_glfgreat(BinaryWriter writer)
|
||||
public static void SaveStateBinary_glfgreat(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -753,7 +752,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_glfgreat(BinaryReader reader)
|
||||
public static void LoadStateBinary_glfgreat(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
@ -804,7 +803,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_tmnt2(BinaryWriter writer)
|
||||
public static void SaveStateBinary_tmnt2(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 0x10; i++)
|
||||
@ -860,7 +859,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary_tmnt2(BinaryReader reader)
|
||||
public static void LoadStateBinary_tmnt2(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 0x10; i++)
|
||||
@ -916,7 +915,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
Eeprom.LoadStateBinary(reader);
|
||||
}
|
||||
public static void SaveStateBinary_ssriders(BinaryWriter writer)
|
||||
public static void SaveStateBinary_ssriders(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(init_eeprom_count);
|
||||
@ -968,7 +967,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary_ssriders(BinaryReader reader)
|
||||
public static void LoadStateBinary_ssriders(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
init_eeprom_count = reader.ReadInt32();
|
||||
@ -1020,7 +1019,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
Eeprom.LoadStateBinary(reader);
|
||||
}
|
||||
public static void SaveStateBinary_thndrx2(BinaryWriter writer)
|
||||
public static void SaveStateBinary_thndrx2(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(bytee);
|
||||
@ -1072,7 +1071,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary_thndrx2(BinaryReader reader)
|
||||
public static void LoadStateBinary_thndrx2(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
bytee = reader.ReadByte();
|
||||
@ -1124,7 +1123,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
Eeprom.LoadStateBinary(reader);
|
||||
}
|
||||
public static void SaveStateBinary_prmrsocr(BinaryWriter writer)
|
||||
public static void SaveStateBinary_prmrsocr(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(basebanksnd);
|
||||
@ -1182,7 +1181,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary_prmrsocr(BinaryReader reader)
|
||||
public static void LoadStateBinary_prmrsocr(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
basebanksnd = reader.ReadInt32();
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.nec;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class M72
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw);
|
||||
@ -68,7 +67,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw = reader.ReadUInt16();
|
||||
|
@ -1,11 +1,10 @@
|
||||
using cpu.nec;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class M92
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(dsw);
|
||||
@ -82,7 +81,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
dsw = reader.ReadUInt16();
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.m6800;
|
||||
using cpu.m6809;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Namcos1
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(dipsw);
|
||||
@ -73,7 +72,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
dipsw = reader.ReadByte();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -376,19 +375,27 @@ namespace MAME.Core
|
||||
|
||||
public static void nvram_handler_load_neogeo()
|
||||
{
|
||||
if (File.Exists("nvram\\" + Machine.sName + ".nv"))
|
||||
if (MameMainMotion.IoSupport.File_Exists("nvram\\" + Machine.sName + ".nv"))
|
||||
{
|
||||
FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
|
||||
int n = (int)fs1.Length;
|
||||
fs1.Read(mainram2, 0, n);
|
||||
fs1.Close();
|
||||
MameMainMotion.IoSupport.File_ReadAllBytes("nvram\\" + Machine.sName + ".nv");
|
||||
//FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
|
||||
//int n = (int)fs1.Length;
|
||||
//fs1.Read(mainram2, 0, n);
|
||||
//fs1.Close();
|
||||
}
|
||||
}
|
||||
public static void nvram_handler_save_neogeo()
|
||||
{
|
||||
FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create);
|
||||
fs1.Write(mainram2, 0, 0x2000);
|
||||
fs1.Close();
|
||||
//FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create);
|
||||
//fs1.Write(mainram2, 0, 0x2000);
|
||||
//fs1.Close();
|
||||
|
||||
byte[] temp = new byte[0x2000];
|
||||
Buffer.BlockCopy(mainram2_src, 0, temp, 0, temp.Length);
|
||||
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(temp))
|
||||
{
|
||||
MameMainMotion.IoSupport.File_WriteAllBytesFromStre("nvram\\" + Machine.sName + ".nv",ms);
|
||||
}
|
||||
}
|
||||
public static void machine_reset_neogeo()
|
||||
{
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.m68000;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Neogeo
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(dsw);
|
||||
@ -77,7 +76,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
Pd4900a.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
dsw = reader.ReadByte();
|
||||
|
@ -1,12 +1,11 @@
|
||||
using cpu.m68000;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class PGM
|
||||
{
|
||||
public unsafe static void SaveStateBinary(BinaryWriter writer)
|
||||
public unsafe static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(pgm_tx_videoram, 0, 0x2000);
|
||||
@ -58,7 +57,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
pgm_tx_videoram = reader.ReadBytes(0x2000);
|
||||
|
@ -1,14 +1,12 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
namespace MAME.Core
|
||||
{
|
||||
public partial class SunA8
|
||||
{
|
||||
public static void SaveStateBinary_starfigh(BinaryWriter writer)
|
||||
public static void SaveStateBinary_starfigh(System.IO.BinaryWriter writer)
|
||||
{
|
||||
|
||||
}
|
||||
public static void LoadStateBinary_starfigh(BinaryReader reader)
|
||||
public static void LoadStateBinary_starfigh(System.IO.BinaryReader reader)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,12 @@
|
||||
using cpu.m68000;
|
||||
using cpu.m6805;
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Taito
|
||||
{
|
||||
public static void SaveStateBinary_tokio(BinaryWriter writer)
|
||||
public static void SaveStateBinary_tokio(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw0);
|
||||
@ -57,7 +56,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_tokio(BinaryReader reader)
|
||||
public static void LoadStateBinary_tokio(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw0 = reader.ReadByte();
|
||||
@ -106,7 +105,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_bublbobl(BinaryWriter writer)
|
||||
public static void SaveStateBinary_bublbobl(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw0);
|
||||
@ -170,7 +169,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_bublbobl(BinaryReader reader)
|
||||
public static void LoadStateBinary_bublbobl(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw0 = reader.ReadByte();
|
||||
@ -234,7 +233,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_boblbobl(BinaryWriter writer)
|
||||
public static void SaveStateBinary_boblbobl(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw0);
|
||||
@ -288,7 +287,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_boblbobl(BinaryReader reader)
|
||||
public static void LoadStateBinary_boblbobl(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw0 = reader.ReadByte();
|
||||
@ -341,7 +340,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_bub68705(BinaryWriter writer)
|
||||
public static void SaveStateBinary_bub68705(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw0);
|
||||
@ -399,7 +398,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_bub68705(BinaryReader reader)
|
||||
public static void LoadStateBinary_bub68705(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw0 = reader.ReadByte();
|
||||
@ -457,7 +456,7 @@ namespace MAME.Core
|
||||
Sound.mixerstream.output_sampindex = reader.ReadInt32();
|
||||
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
|
||||
}
|
||||
public static void SaveStateBinary_opwolf(BinaryWriter writer)
|
||||
public static void SaveStateBinary_opwolf(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dswa);
|
||||
@ -594,7 +593,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_opwolf(BinaryReader reader)
|
||||
public static void LoadStateBinary_opwolf(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dswa = reader.ReadByte();
|
||||
|
@ -1,13 +1,11 @@
|
||||
using cpu.m68000;
|
||||
using cpu.z80;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe partial class Taitob
|
||||
{
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
//pixel_scroll
|
||||
int i;
|
||||
@ -97,7 +95,7 @@ namespace MAME.Core
|
||||
Eeprom.SaveStateBinary(writer);
|
||||
Taitosnd.SaveStateBinary(writer);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dswa = reader.ReadByte();
|
||||
|
@ -1,11 +1,10 @@
|
||||
using cpu.z80;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public partial class Tehkan
|
||||
{
|
||||
public unsafe static void SaveStateBinary_pbaction(BinaryWriter writer)
|
||||
public unsafe static void SaveStateBinary_pbaction(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(dsw1);
|
||||
@ -46,7 +45,7 @@ namespace MAME.Core
|
||||
writer.Write(Sound.mixerstream.output_sampindex);
|
||||
writer.Write(Sound.mixerstream.output_base_sampindex);
|
||||
}
|
||||
public static void LoadStateBinary_pbaction(BinaryReader reader)
|
||||
public static void LoadStateBinary_pbaction(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
dsw1 = reader.ReadByte();
|
||||
|
@ -0,0 +1,11 @@
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public interface IMAMEIOSupport
|
||||
{
|
||||
bool File_Exists(string path);
|
||||
byte[] File_ReadAllBytes(string path);
|
||||
void File_WriteAllBytesFromStre(string path, MemoryStream ms);
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da0b580f2a446f948a80085bb9b7b3ee
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class AY8910
|
||||
@ -558,7 +557,7 @@ namespace MAME.Core
|
||||
}
|
||||
return ay8910info.regs[r];
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(ay8910info.register_latch);
|
||||
@ -580,7 +579,7 @@ namespace MAME.Core
|
||||
writer.Write(ay8910info.rng);
|
||||
writer.Write(ay8910info.vol_enabled, 0, 3);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
ay8910info.register_latch = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class DAC
|
||||
@ -57,11 +56,11 @@ namespace MAME.Core
|
||||
DAC_build_voltable();
|
||||
dac1.output = 0;
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(DAC.dac1.output);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
dac1.output = reader.ReadInt16();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class ICS2115
|
||||
@ -415,7 +414,7 @@ namespace MAME.Core
|
||||
}
|
||||
recalc_irq();
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
@ -449,7 +448,7 @@ namespace MAME.Core
|
||||
writer.Write(irq_pending);
|
||||
writer.Write(irq_on);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class Iremga20
|
||||
@ -162,7 +161,7 @@ namespace MAME.Core
|
||||
chip.regs[i] = 0;
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
@ -179,7 +178,7 @@ namespace MAME.Core
|
||||
writer.Write(chip.channel[i].play);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class K007232
|
||||
@ -232,7 +231,7 @@ namespace MAME.Core
|
||||
info.bank[0] = (uint)(chABank << 17);
|
||||
info.bank[1] = (uint)(chBBank << 17);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 2; i++)
|
||||
@ -271,7 +270,7 @@ namespace MAME.Core
|
||||
writer.Write(info.pcmbuf_offset[i]);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 2; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class K053260
|
||||
@ -379,7 +378,7 @@ namespace MAME.Core
|
||||
{
|
||||
k053260_0_w(offset, data);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(ic1.mode);
|
||||
@ -402,7 +401,7 @@ namespace MAME.Core
|
||||
writer.Write(ic1.channels[i].ppcm_data);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
ic1.mode = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -567,7 +566,7 @@ namespace MAME.Core
|
||||
{
|
||||
return k054539_r(0, offset);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 8; i++)
|
||||
@ -596,7 +595,7 @@ namespace MAME.Core
|
||||
writer.Write(zoneflag);
|
||||
writer.Write(zonedata);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 8; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -254,7 +253,7 @@ namespace MAME.Core
|
||||
mm1[num].voice.bitwidth = bitwidth;
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(voice.select);
|
||||
writer.Write(voice.index);
|
||||
@ -267,7 +266,7 @@ namespace MAME.Core
|
||||
writer.Write(voice.signal);
|
||||
writer.Write(voice.step);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
voice.select = reader.ReadInt32();
|
||||
voice.index = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class Namco
|
||||
@ -255,7 +254,7 @@ namespace MAME.Core
|
||||
{
|
||||
return namco_wavedata[offset];
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(nam1.num_voices);
|
||||
@ -282,7 +281,7 @@ namespace MAME.Core
|
||||
}
|
||||
writer.Write(namco_wavedata, 0, 0x400);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
nam1.num_voices = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -272,7 +271,7 @@ namespace MAME.Core
|
||||
//if (ACCESSING_BITS_0_7)
|
||||
okim6295_data_w(0, data & 0xff);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
writer.Write(OKI.command);
|
||||
@ -288,7 +287,7 @@ namespace MAME.Core
|
||||
writer.Write(adpcm[i].step);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
OKI.command = reader.ReadInt32();
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -195,7 +194,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
@ -215,7 +214,7 @@ namespace MAME.Core
|
||||
}
|
||||
writer.Write(QChip.data);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MAME.Core
|
||||
@ -186,7 +185,7 @@ namespace MAME.Core
|
||||
info.starthandler();
|
||||
}
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info.numchannels; i++)
|
||||
@ -201,7 +200,7 @@ namespace MAME.Core
|
||||
writer.Write(info.channel[i].paused);
|
||||
}
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info.numchannels; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class Taitosnd
|
||||
@ -201,7 +200,7 @@ namespace MAME.Core
|
||||
{
|
||||
return (ushort)(taitosound_comm_r(0) << 8);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(tc0140syt.slavedata, 0, 4);
|
||||
writer.Write(tc0140syt.masterdata, 0, 4);
|
||||
@ -211,7 +210,7 @@ namespace MAME.Core
|
||||
writer.Write(tc0140syt.nmi_enabled);
|
||||
writer.Write(tc0140syt.nmi_req);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
tc0140syt.slavedata = reader.ReadBytes(4);
|
||||
tc0140syt.masterdata = reader.ReadBytes(4);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class Upd7759
|
||||
@ -362,7 +361,7 @@ namespace MAME.Core
|
||||
{
|
||||
return (byte)upd7759_busy_r(0);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(chip.pos);
|
||||
writer.Write(chip.step);
|
||||
@ -389,7 +388,7 @@ namespace MAME.Core
|
||||
writer.Write(chip.romoffset);
|
||||
writer.Write(chip.rombase);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
chip.pos = reader.ReadUInt32();
|
||||
chip.step = reader.ReadUInt32();
|
||||
|
@ -1,16 +1,17 @@
|
||||
using System.IO;
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class WavWrite
|
||||
{
|
||||
public static FileStream mWaveFile = null;
|
||||
private static BinaryWriter mWriter = null;
|
||||
public static System.IO.FileStream mWaveFile = null;
|
||||
private static System.IO.BinaryWriter mWriter = null;
|
||||
private static int mSampleCount = 0;
|
||||
public static void CreateSoundFile(string filename)
|
||||
{
|
||||
mWaveFile = new FileStream(filename, FileMode.Create);
|
||||
mWriter = new BinaryWriter(mWaveFile);
|
||||
mWriter = new System.IO.BinaryWriter(mWaveFile);
|
||||
/**************************************************************************
|
||||
Hereiswherethefilewillbecreated.A
|
||||
wavefileisaRIFFfile,whichhaschunks
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -2038,7 +2037,7 @@ namespace MAME.Core
|
||||
// chanout[imem[op1]] = PSG.oper[op1].mem_value;
|
||||
// }
|
||||
//}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
@ -2115,7 +2114,7 @@ namespace MAME.Core
|
||||
writer.Write(PSG.irqlinestate);
|
||||
writer.Write(PSG.connect);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class YM2203
|
||||
@ -339,7 +338,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(REGS, 0, 256);
|
||||
@ -435,7 +434,7 @@ namespace MAME.Core
|
||||
writer.Write(YMDeltat.DELTAT.adpcmd);
|
||||
writer.Write(YMDeltat.DELTAT.adpcml);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
REGS = reader.ReadBytes(256);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public unsafe class YM2610
|
||||
@ -654,7 +653,7 @@ namespace MAME.Core
|
||||
{
|
||||
adpcm_arrivedEndAddress &= (byte)(~changebits);
|
||||
}
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
writer.Write(REGS, 0, 512);
|
||||
@ -771,7 +770,7 @@ namespace MAME.Core
|
||||
writer.Write(YMDeltat.DELTAT.adpcmd);
|
||||
writer.Write(YMDeltat.DELTAT.adpcml);
|
||||
}
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
REGS = reader.ReadBytes(512);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
public class YM3812
|
||||
@ -85,7 +84,7 @@ namespace MAME.Core
|
||||
{
|
||||
FMOpl.ym3812_write(1, data);
|
||||
}
|
||||
public static void SaveStateBinary(BinaryWriter writer)
|
||||
public static void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 9; i++)
|
||||
@ -140,7 +139,7 @@ namespace MAME.Core
|
||||
writer.Write(FMOpl.YM3812.statusmask);
|
||||
writer.Write(FMOpl.YM3812.mode);
|
||||
}
|
||||
public static void LoadStateBinary(BinaryReader reader)
|
||||
public static void LoadStateBinary(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 9; i++)
|
||||
@ -268,7 +267,7 @@ namespace MAME.Core
|
||||
{
|
||||
return FMOpl.ym3526_read(1);
|
||||
}
|
||||
public static void SaveStateBinary_YM3526(BinaryWriter writer)
|
||||
public static void SaveStateBinary_YM3526(System.IO.BinaryWriter writer)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 9; i++)
|
||||
@ -323,7 +322,7 @@ namespace MAME.Core
|
||||
writer.Write(FMOpl.YM3526.statusmask);
|
||||
writer.Write(FMOpl.YM3526.mode);
|
||||
}
|
||||
public static void LoadStateBinary_YM3526(BinaryReader reader)
|
||||
public static void LoadStateBinary_YM3526(System.IO.BinaryReader reader)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < 9; i++)
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StoicGooseUnity
|
||||
@ -95,21 +94,21 @@ namespace StoicGooseUnity
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void Write(this BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用指针复制数据到临时数组
|
||||
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
|
||||
// 使用BinaryWriter写入临时数组
|
||||
bw.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用指针复制数据到临时数组
|
||||
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
|
||||
// 使用BinaryWriter写入临时数组
|
||||
fs.Write(TempBuffer_src, 0, count);
|
||||
}
|
||||
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
|
||||
{
|
||||
// 使用BinaryWriter写入临时数组
|
||||
count = fs.Read(TempBuffer_src, offset, count);
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace StoicGoose.Common.Drawing
|
||||
@ -10,46 +10,46 @@ namespace StoicGoose.Common.Drawing
|
||||
|
||||
public class RgbaFile
|
||||
{
|
||||
const string expectedMagic = "RGBA";
|
||||
//const string expectedMagic = "RGBA";
|
||||
|
||||
public string MagicNumber { get; protected set; }
|
||||
public uint Width { get; protected set; }
|
||||
public uint Height { get; protected set; }
|
||||
public byte[] PixelData { get; protected set; }
|
||||
//public string MagicNumber { get; protected set; }
|
||||
//public uint Width { get; protected set; }
|
||||
//public uint Height { get; protected set; }
|
||||
//public byte[] PixelData { get; protected set; }
|
||||
|
||||
public RgbaFile(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
|
||||
//public RgbaFile(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
|
||||
|
||||
public RgbaFile(Stream stream)
|
||||
{
|
||||
MagicNumber = ReadString(stream, 4);
|
||||
Width = ReadUInt32(stream);
|
||||
Height = ReadUInt32(stream);
|
||||
PixelData = new byte[Width * Height * 4];
|
||||
stream.Read(PixelData);
|
||||
}
|
||||
//public RgbaFile(System.IO.Stream stream)
|
||||
//{
|
||||
// MagicNumber = ReadString(stream, 4);
|
||||
// Width = ReadUInt32(stream);
|
||||
// Height = ReadUInt32(stream);
|
||||
// PixelData = new byte[Width * Height * 4];
|
||||
// stream.Read(PixelData);
|
||||
//}
|
||||
|
||||
public RgbaFile(uint width, uint height, byte[] pixelData)
|
||||
{
|
||||
MagicNumber = expectedMagic;
|
||||
Width = width;
|
||||
Height = height;
|
||||
PixelData = pixelData;
|
||||
}
|
||||
//public RgbaFile(uint width, uint height, byte[] pixelData)
|
||||
//{
|
||||
// MagicNumber = expectedMagic;
|
||||
// Width = width;
|
||||
// Height = height;
|
||||
// PixelData = pixelData;
|
||||
//}
|
||||
|
||||
public void Save(string filename) => Save(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite));
|
||||
//public void Save(string filename) => Save(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite));
|
||||
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
WriteString(stream, MagicNumber);
|
||||
WriteUInt32(stream, Width);
|
||||
WriteUInt32(stream, Height);
|
||||
stream.Write(PixelData);
|
||||
}
|
||||
//public void Save(Stream stream)
|
||||
//{
|
||||
// WriteString(stream, MagicNumber);
|
||||
// WriteUInt32(stream, Width);
|
||||
// WriteUInt32(stream, Height);
|
||||
// stream.Write(PixelData);
|
||||
//}
|
||||
|
||||
private static string ReadString(Stream stream, int length) => new(Enumerable.Range(0, length).Select(_ => (char)stream.ReadByte()).ToArray());
|
||||
private static uint ReadUInt32(Stream stream) => (uint)(((stream.ReadByte() & 0xFF) << 24) | ((stream.ReadByte() & 0xFF) << 16) | ((stream.ReadByte() & 0xFF) << 8) | ((stream.ReadByte() & 0xFF) << 0));
|
||||
//private static string ReadString(Stream stream, int length) => new(Enumerable.Range(0, length).Select(_ => (char)stream.ReadByte()).ToArray());
|
||||
//private static uint ReadUInt32(Stream stream) => (uint)(((stream.ReadByte() & 0xFF) << 24) | ((stream.ReadByte() & 0xFF) << 16) | ((stream.ReadByte() & 0xFF) << 8) | ((stream.ReadByte() & 0xFF) << 0));
|
||||
|
||||
private static void WriteString(Stream stream, string str) => Array.ForEach(str.ToCharArray(), (x) => stream.WriteByte((byte)x));
|
||||
private static void WriteUInt32(Stream stream, uint val) { stream.WriteByte((byte)((val >> 24) & 0xFF)); stream.WriteByte((byte)((val >> 16) & 0xFF)); stream.WriteByte((byte)((val >> 8) & 0xFF)); stream.WriteByte((byte)((val >> 0) & 0xFF)); }
|
||||
//private static void WriteString(Stream stream, string str) => Array.ForEach(str.ToCharArray(), (x) => stream.WriteByte((byte)x));
|
||||
//private static void WriteUInt32(Stream stream, uint val) { stream.WriteByte((byte)((val >> 24) & 0xFF)); stream.WriteByte((byte)((val >> 16) & 0xFF)); stream.WriteByte((byte)((val >> 8) & 0xFF)); stream.WriteByte((byte)((val >> 0) & 0xFF)); }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace StoicGoose.Common.Utilities
|
||||
{
|
||||
@ -32,37 +31,37 @@ namespace StoicGoose.Common.Utilities
|
||||
if ((segmentStart + segmentLength) > dataLength) throw new Exception("Segment end offset is greater than total length");
|
||||
}
|
||||
|
||||
public static uint Calculate(FileInfo fileInfo)
|
||||
{
|
||||
return Calculate(fileInfo, 0, (int)fileInfo.Length);
|
||||
}
|
||||
//public static uint Calculate(FileInfo fileInfo)
|
||||
//{
|
||||
// return Calculate(fileInfo, 0, (int)fileInfo.Length);
|
||||
//}
|
||||
|
||||
public static uint Calculate(FileInfo fileInfo, int start, int length)
|
||||
{
|
||||
VerifyStartAndLength((int)fileInfo.Length, start, length);
|
||||
//public static uint Calculate(FileInfo fileInfo, int start, int length)
|
||||
//{
|
||||
// VerifyStartAndLength((int)fileInfo.Length, start, length);
|
||||
|
||||
using FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
return Calculate(file, start, length);
|
||||
}
|
||||
// using FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
// return Calculate(file, start, length);
|
||||
//}
|
||||
|
||||
public static uint Calculate(Stream stream)
|
||||
{
|
||||
return Calculate(stream, 0, (int)stream.Length);
|
||||
}
|
||||
//public static uint Calculate(Stream stream)
|
||||
//{
|
||||
// return Calculate(stream, 0, (int)stream.Length);
|
||||
//}
|
||||
|
||||
public static uint Calculate(Stream stream, int start, int length)
|
||||
{
|
||||
VerifyStartAndLength((int)stream.Length, start, length);
|
||||
//public static uint Calculate(Stream stream, int start, int length)
|
||||
//{
|
||||
// VerifyStartAndLength((int)stream.Length, start, length);
|
||||
|
||||
var lastStreamPosition = stream.Position;
|
||||
var data = new byte[length];
|
||||
stream.Position = start;
|
||||
stream.Read(data, 0, length);
|
||||
var crc = Calculate(data, 0, data.Length);
|
||||
stream.Position = lastStreamPosition;
|
||||
// var lastStreamPosition = stream.Position;
|
||||
// var data = new byte[length];
|
||||
// stream.Position = start;
|
||||
// stream.Read(data, 0, length);
|
||||
// var crc = Calculate(data, 0, data.Length);
|
||||
// stream.Position = lastStreamPosition;
|
||||
|
||||
return crc;
|
||||
}
|
||||
// return crc;
|
||||
//}
|
||||
|
||||
public static uint Calculate(byte[] data)
|
||||
{
|
||||
|
@ -1,41 +1,40 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
//using System.Reflection;
|
||||
|
||||
using StoicGoose.Common.Drawing;
|
||||
//using StoicGoose.Common.Drawing;
|
||||
|
||||
namespace StoicGoose.Common.Utilities
|
||||
{
|
||||
public static class Resources
|
||||
{
|
||||
private static Stream GetEmbeddedResourceStream(string name)
|
||||
{
|
||||
var assembly = Assembly.GetEntryAssembly();
|
||||
name = $"{assembly.GetName().Name}.{name}";
|
||||
return assembly.GetManifestResourceStream(name);
|
||||
}
|
||||
//namespace StoicGoose.Common.Utilities
|
||||
//{
|
||||
// public static class Resources
|
||||
// {
|
||||
// //private static System.IO.Stream GetEmbeddedResourceStream(string name)
|
||||
// //{
|
||||
// // var assembly = Assembly.GetEntryAssembly();
|
||||
// // name = $"{assembly.GetName().Name}.{name}";
|
||||
// // return assembly.GetManifestResourceStream(name);
|
||||
// //}
|
||||
|
||||
public static RgbaFile GetEmbeddedRgbaFile(string name)
|
||||
{
|
||||
using var stream = GetEmbeddedResourceStream(name);
|
||||
if (stream == null) return null;
|
||||
return new RgbaFile(stream);
|
||||
}
|
||||
// //public static RgbaFile GetEmbeddedRgbaFile(string name)
|
||||
// //{
|
||||
// // using var stream = GetEmbeddedResourceStream(name);
|
||||
// // if (stream == null) return null;
|
||||
// // return new RgbaFile(stream);
|
||||
// //}
|
||||
|
||||
public static string GetEmbeddedText(string name)
|
||||
{
|
||||
using var stream = GetEmbeddedResourceStream(name);
|
||||
if (stream == null) return string.Empty;
|
||||
using var reader = new StreamReader(stream);
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
// //public static string GetEmbeddedText(string name)
|
||||
// //{
|
||||
// // using var stream = GetEmbeddedResourceStream(name);
|
||||
// // if (stream == null) return string.Empty;
|
||||
// // using var reader = new StreamReader(stream);
|
||||
// // return reader.ReadToEnd();
|
||||
// //}
|
||||
|
||||
public static byte[] GetEmbeddedRawData(string name)
|
||||
{
|
||||
using var stream = GetEmbeddedResourceStream(name);
|
||||
if (stream == null) return null;
|
||||
var buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, buffer.Length);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
// //public static byte[] GetEmbeddedRawData(string name)
|
||||
// //{
|
||||
// // using var stream = GetEmbeddedResourceStream(name);
|
||||
// // if (stream == null) return null;
|
||||
// // var buffer = new byte[stream.Length];
|
||||
// // stream.Read(buffer, 0, buffer.Length);
|
||||
// // return buffer;
|
||||
// //}
|
||||
// }
|
||||
//}
|
||||
|
@ -10,7 +10,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 3186794564434009199}
|
||||
- component: {fileID: 1464475178787633862}
|
||||
- component: {fileID: 2053226018124086955}
|
||||
- component: {fileID: 3126747713153700628}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
@ -48,7 +48,7 @@ MonoBehaviour:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 0
|
||||
m_DragThreshold: 10
|
||||
--- !u!114 &2053226018124086955
|
||||
--- !u!114 &3126747713153700628
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -57,17 +57,28 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 173080370084988713}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1 &261166211120060501
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1204,6 +1215,14 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
|
BIN
AxibugEmuOnline.Client/Assets/Resources/Icons/conflict.png
Normal file
BIN
AxibugEmuOnline.Client/Assets/Resources/Icons/conflict.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.1 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user