Compare commits

...

126 Commits

Author SHA1 Message Date
f275fa79c7 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-08-19 13:35:27 +08:00
1a526b10f6 projectsetting 2025-08-19 11:27:35 +08:00
a7807194ed 增加SwitchJoyCon手柄类型支持 2025-08-19 11:27:10 +08:00
cd4163d9fe 添加joycon手柄图标资源 2025-08-19 11:26:40 +08:00
c36adccbde using 2025-08-19 10:22:29 +08:00
e1d7ef2d13 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-08-19 10:21:27 +08:00
0f27fa328c switch 2025-08-19 10:21:17 +08:00
33283a9a34 Merge pull request '修复状态机bug' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-08-19 09:59:24 +08:00
0a45c4fbbd inputsystem 高低版本兼容 2025-08-18 22:51:04 +08:00
a1db47ab4b 完善AxiPoject工具 2025-08-18 22:20:56 +08:00
ebb4cb401c 一些不必要的usering 2025-08-18 22:20:18 +08:00
57c4947623 引入最新版本的AxiNSApi 2025-08-18 22:12:40 +08:00
629cd16016 修复状态机bug 2025-08-18 18:27:28 +08:00
8afcbce6b1 Merge pull request '增加登录时自动存档同步功能' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-08-18 17:48:41 +08:00
15c64ae655 增加登录时自动存档同步功能 2025-08-18 17:20:45 +08:00
3c04d26c50 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-07-15 14:56:44 +08:00
a1fe8dff21 增加RealisticCRT shader,来自godot 2025-06-25 18:57:26 +08:00
fbcaecf596 remove shader RLPro 因为效果不理想 2025-06-25 18:57:10 +08:00
c69340f7b9 Merge branch 'master' of http://git.axibug.com/alienjack/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsForFileSystem.cs.meta
2025-06-25 17:31:35 +08:00
f4af119cdb CRT_easymode format 2025-06-25 17:30:58 +08:00
45d075722b 帮皓月搽屁股 2025-06-25 17:30:31 +08:00
a596d199c2 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsForFileSystem.cs.meta
2025-06-21 15:41:12 +08:00
de7340ee39 增加一个左上角状态栏UI,用于显示当前已连接的输入设备,修复独占性设备(手柄)被错误的binding到多个模拟器虚拟输入设备的问题 2025-06-21 15:39:52 +08:00
d1c150e1be 补充shader引用 2025-06-21 15:35:26 +08:00
570419e2cc 补全代码 2025-06-20 18:58:29 +08:00
caaad7a6bf 实现PSVita背面触摸板子,模拟虚拟按键的功能 2025-06-20 18:58:10 +08:00
9995a784aa 初始化提示 2025-06-16 11:20:52 +08:00
92169c2f87 axio 2025-06-16 11:15:21 +08:00
59968bbd1f Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-06-16 10:59:28 +08:00
20b3d2e8ef 完善AxiIO为Switch可用且健壮的代码 2025-06-16 10:58:49 +08:00
7b40e190d0 引入AxiPlayerPrefs,替换现有PlayerPrefs,使用文件系统,替代不同平台的PlayerPrefs读写 2025-06-16 10:56:21 +08:00
fe53dc4021 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-06-16 10:53:21 +08:00
631d4bb0bc 移植retroarch中的crt-easymode shader效果 2025-06-16 10:52:33 +08:00
6193e57a99 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-06-09 13:48:55 +08:00
3cc79ca730 将EssgeeKeyCore中所有按键绑定类的控制器槽位固定为4个 2025-06-06 13:47:21 +08:00
bd45706c00 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-06-05 15:28:30 +08:00
7d2b80ab55 Merge branch 'master' of http://git.axibug.com/alienjack/AxibugEmuOnline 2025-06-05 15:28:16 +08:00
eaeb789513 什么鬼namespace 2025-06-05 15:28:09 +08:00
0e5421d6bd todo 2025-06-05 13:29:21 +08:00
7eed897474 todo 2025-06-05 13:25:51 +08:00
3783868bee Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-06-05 13:21:22 +08:00
7c3c025b7c todo 2025-06-05 13:20:42 +08:00
f192e748b4 Merge pull request '修复optionUI一系列表现bug' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-05-21 14:54:45 +08:00
235dc0ed39 修复optionUI一系列表现bug 2025-05-20 00:02:19 +08:00
c8f0d77b34 Client 存档功能 迭代 2025-05-14 22:54:35 +08:00
52e9f42184 Server 网络存档功能 修正保存逻辑 2025-05-14 22:53:33 +08:00
2bc6972ebe Server Savée 2025-05-14 19:32:46 +08:00
e6ef077f16 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-05-14 14:42:39 +08:00
f3d246ab43 Switch 定时Commit到存储池 2025-05-14 14:08:19 +08:00
0d3024521c 网络建立连接断开连接,回到主线程处理 2025-05-14 14:06:45 +08:00
ef419928ed 调整EmuCore基类中获取输入数据和推送的逻辑 2025-05-06 12:00:47 +08:00
6c23bdc1c2 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-05-06 10:43:33 +08:00
eb6b25256b 重构:AfterPushFrame修改为protected方法,原先跳帧逻辑从InGameUI移入EmuCore基类中实现,原先InGameUI.IsNetPlay移入EmuCore.IsNetPlay 2025-05-06 10:43:20 +08:00
6be11bdf42 IEmuCore rename to EmuCore 2025-05-06 10:41:25 +08:00
306199dba8 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-04-30 16:54:05 +08:00
97c278b4ec Merge branch 'master' into master 2025-04-30 16:53:13 +08:00
cc57a1e0df emucore基类替换 2025-04-30 15:41:20 +08:00
ace77987e4 fix NesEmulator重构后处理输入数据bug 2025-04-29 19:43:02 +08:00
1ffa708e71 NesEmulator重构 2025-04-29 19:18:02 +08:00
c7a4f1467a RLPRO_CRT滤镜完善 2025-04-29 19:17:40 +08:00
992adc115b NS fixed 2025-04-29 16:42:39 +08:00
902dc95d19 IEmuCore从接口修改为抽象类 2025-04-29 16:19:09 +08:00
e5f497a163 存档云同步状态UI提交 2025-04-28 11:58:22 +08:00
8fc65c2f70 调整几个工具脚本的目录 2025-04-28 11:20:45 +08:00
f0b139e692 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-04-27 15:09:27 +08:00
fcd64a54f6 完善RLPRO_CRT滤镜 2025-04-27 15:06:42 +08:00
e8fc45b006 RLPro_Bleed rename to RLPRO_CRT 2025-04-27 10:20:18 +08:00
9cfee768c3 ignore 2025-04-25 17:39:46 +08:00
e8bac390af Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-04-25 16:28:13 +08:00
412c9759df 滤镜添加 2025-04-25 16:27:57 +08:00
74bde1d94a 存档序号 追加到服务端 2025-04-25 14:42:12 +08:00
213ed7163c 补全Switch的Directory逻辑 2025-04-25 14:39:11 +08:00
24036739a7 整个项目和核心都不再强依赖System.IO进行文件读写,为Switch坐准备 2025-04-25 10:30:52 +08:00
1f33d35394 essgee fixed 2025-04-24 19:53:55 +08:00
e66740b8a9 mame essgee 不强依赖System的文件读写 2025-04-24 19:50:55 +08:00
36b614c4a7 主项目和VirtualNES.Core核心 NS下不再依赖system.io进行文件读写 2025-04-24 16:34:09 +08:00
d7fe849bb1 除了核心之外的,已经包装了区分Switch和普通的IO 2025-04-24 11:27:35 +08:00
ee9d54386b Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-04-22 19:02:09 +08:00
eb2f5d268c 存档支持云同步 2025-04-18 13:38:45 +08:00
13cddd8a3b 添加几个存档状态的图标资源 2025-04-18 13:38:21 +08:00
16a7acee61 存档文件改为每个独立用户各自拥有 2025-04-16 13:09:25 +08:00
959956706f 获取EmuCore的OutputTex时,还会根据DrawCanvas的localscale,来纠正存档图片Y轴翻转的处理 2025-04-15 15:41:50 +08:00
8e24f556af 存档图片UI元素的localscale改回1,1,1 不再在UI上去适应存档图片的Y轴翻转问题 2025-04-15 15:40:27 +08:00
424e139692 Nes DrawCanvas修改缩放系数 y=-1 而不是x轴翻转180,以实现Y轴偏转 2025-04-15 15:36:21 +08:00
49d0a9aa86 Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-04-14 09:47:20 +08:00
a079947bc4 gitignore添加对于AxibugEmuOnline.Client/ProjectSettings/PackageManagerSettings.asset的忽略 2025-04-13 19:06:29 +08:00
a21be185ce 移除PackageManagerSettings.asset文件的版本管理,因为国际版和国内版共用实在是太恶心了 2025-04-13 19:05:36 +08:00
3dc7e9acd1 实现存档以及读取存档功能 2025-04-13 19:03:43 +08:00
f325e63e26 存档界面的存档日期,日月数字使用0补全到2位 2025-04-13 18:16:36 +08:00
017026f706 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline 2025-04-10 17:00:47 +08:00
4116a05b6c 存档UI功能完成 2025-04-10 17:00:36 +08:00
209c82da80 侧边栏存档菜单UI实现中 2025-04-10 15:39:44 +08:00
8bd3b2247b 输出模块增加独占机制,避免一个设备绑定到多个手柄映射配置 2025-04-09 14:54:21 +08:00
5aabda7c37 Switch文件操作异步实现 2025-04-09 00:48:15 +08:00
6111319ad4 引入 AxiNSApi 以及 补完Switch自动打包 2025-04-08 10:36:07 +08:00
279483c14f Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-04-08 01:36:02 +08:00
c89b6b1ab5 存档模块提交(未完成) 2025-04-07 14:47:02 +08:00
8b2b66a940 存档相关proto,新增Sequence字段 2025-04-07 14:46:41 +08:00
902a8f1360 修复程序集定义错误语法 2025-04-07 14:45:24 +08:00
569e4e44fe cn 2025-04-07 11:07:07 +08:00
c77cac4812 fixed 2025-04-07 11:01:07 +08:00
5f9d67b36f AxiNSApi 2025-04-07 10:59:03 +08:00
5014c81539 引入 AxiNSApi 方便操作Switch的API 做一些安全封装 2025-04-07 10:56:09 +08:00
4b0a781957 更新忽略规则 2025-04-04 21:34:31 +08:00
10ac17c18b Merge pull request 'master' () from Alienjack/AxibugEmuOnline:master into master
Reviewed-on: 
2025-04-01 15:50:13 +08:00
591204e044 Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
# Conflicts:
#	AxibugEmuOnline.Client/Assets/Script/AppMain/AxiInputSP.Settings/NESMultiKeysSetting.cs
#	AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef
2025-04-01 15:37:43 +08:00
cfb3bc8b6a Input机制修改已完成 2025-04-01 15:35:17 +08:00
34cf5487e8 fix bug 2025-03-31 18:35:38 +08:00
6cc7b2fb4b 引入IDeviceBinder接口,以利用编译报错补充应该编写的代码,避免漏掉 2025-03-31 18:25:07 +08:00
fbe47bce1b 添加DS和Xbox手柄支持 2025-03-31 16:20:39 +08:00
3797bba442 完善GamePad支持 2025-03-27 20:13:00 +08:00
4e87cfe9ee Input代码迭代 2025-03-27 20:08:31 +08:00
e463c23c4c Input逻辑结构调整 2025-03-27 19:19:05 +08:00
50e3a30f31 将所有抽象层Input的类加上后缀,D代表设备,C代表控件,避免和InputSystem中的设备重名 2025-03-27 15:02:41 +08:00
8007af0bc5 InputControl的实现类挪入基本类型,不再每个设备单独实现 2025-03-27 11:54:10 +08:00
924727eb7c Input系统代码迭代 2025-03-26 19:07:46 +08:00
cf8127c553 修复GetBinding返回的InputControl对象并不完整的问题 2025-03-18 11:23:08 +08:00
49c893fdab GetBinding方法修改,在没有绑定设备时返回空迭代器而不是null 2025-03-18 10:56:24 +08:00
667089891a KeyMapper根据每种设备单独配置 2025-03-17 20:32:34 +08:00
811b0b2a48 InputManager迭代 2025-03-17 19:50:41 +08:00
a93f6449c8 键盘设备键值字段接口调整 2025-03-17 10:50:17 +08:00
3257e15dda 键盘映射配置加载机制修改,现在在初始化以及任何键盘设备断开和连接时,会检查可用键盘设备并且调用配置加载方法 2025-03-17 10:33:23 +08:00
1c20707751 输入系统迭代 2025-03-14 15:27:26 +08:00
4e1f8fd045 InputDevice中的keybase基类改为inputcontrol,突出基础类型作为一个输入控件的概念,以免和按钮类控件混淆 2025-03-14 11:02:38 +08:00
955a35659a 引入InputSystem,输入设备管理系统迭代中 2025-03-13 17:38:12 +08:00
3c10873180 输入设备管理器,以及按键映射设置基本框架搭建 2025-03-12 20:09:11 +08:00
436 changed files with 20256 additions and 4210 deletions
.gitignore
AxibugEmuOnline.Client/Assets
AxiProjectTools
Editors
Plugins

7
.gitignore vendored
View File

@ -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
@ -49,3 +51,4 @@ AxibugEmuOnline.GameScreenConvert/bin/
AxibugEmuOnline.GameScreenConvert/obj/
/.vs/
AxibugEmuOnline.Client/ProjectSettings/PackageManagerSettings.asset

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 611bc182f939ea147a72b08613e2d2ba
guid: 164952f99969ca942b4761b200d7e381
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -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
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
}

View File

@ -0,0 +1,42 @@
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEngine;
public class AxiProjectTools_AssetsAutoSetting : EditorWindow
{
[MenuItem("Axibug移植工具/AssetsAutoSetting/自动设置TextureMaxSize为图片大小1倍")]
public static void AutoSettTextureSize_1x() { SetTextureSite(1f); }
[MenuItem("Axibug移植工具/AssetsAutoSetting/自动设置TextureMaxSize为图片大小2分之1倍")]
public static void AutoSettTextureSize_1_2x() { SetTextureSite(1f / 2f); }
[MenuItem("Axibug移植工具/AssetsAutoSetting/自动设置TextureMaxSize为图片大小4分之1倍")]
public static void AutoSettTextureSize_1_4x() { SetTextureSite(1f / 4f); }
public static void SetTextureSite(float Scale)
{
Texture2D[] textures = Selection.GetFiltered<Texture2D>(SelectionMode.DeepAssets);
if (textures.Length == 0)
{
Debug.LogWarning("请先选择目录或者Texture资源");
return;
}
AssetDatabase.StartAssetEditing(); // 开启批量编辑模式
foreach (var texture in textures)
{
string path = AssetDatabase.GetAssetPath(texture);
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
if (importer != null)
{
int size = Mathf.Max(texture.width, texture.height);
int maxsize = Mathf.ClosestPowerOfTwo((int)(size * Scale)); // Unity内置方法适配2的幂次方
importer.maxTextureSize = maxsize;
importer.SaveAndReimport();
}
}
AssetDatabase.StopAssetEditing(); // 结束批量编辑
Debug.Log($"Updated {textures.Length} textures.");
}
}
#endif

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dc0741a79e74f96449a260406f239066

View File

@ -0,0 +1,840 @@
#if UNITY_EDITOR && UNITY_2020_1_OR_NEWER
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
public class AxiProjectToolsStatistics : EditorWindow
{
static string cachecfgPath = "Assets/AxiStatisticsDatas.asset";
static Dictionary<string, AxiStatisticsDatas> dictTempData = new Dictionary<string, AxiStatisticsDatas>();
static void ClearTempData()
{
dictTempData.Clear();
}
static string GetRootTempKey(int type, string rootName)
{
return type + "_" + rootName;
}
// 添加Hierarchy右键菜单项
[MenuItem("GameObject/AxiStatistics/GetAxiNodeHash", false, 10)]
public static void GetAxiNodeHash()
{
// 获取当前右键选中的Transform
Transform selectedTransform = Selection.activeTransform;
if (selectedTransform != null)
{
Debug.Log("选中的对象"+selectedTransform.name+",Hash=>"+ GetNodeDataHash(selectedTransform,true));
}
}
static int GetNodeDataHash(Transform trans,bool bLog = false)
{
long hashplus = 0;
hashplus += trans.position.GetHashCode();
hashplus += trans.localPosition.GetHashCode();
#if UNITY_2017_1_OR_NEWER
int count = trans.childCount;
#else
int count = trans.GetChildCount();
#endif
hashplus += count;
for (int i = 0; i < count; i++)
{
hashplus += trans.GetChild(i).name.GetHashCode();
}
if (bLog)
{
//Debug.Log("trans.position.GetHashCode()=>" + trans.position.GetHashCode());
//Debug.Log("trans.localPosition.GetHashCode()=>" + trans.localPosition.GetHashCode());
//Debug.Log("childCount =>" + count);
//Debug.Log("hashplus =>" + hashplus);
//Debug.Log("hashplus.GetHashCode() =>" + hashplus.GetHashCode());
}
return hashplus.GetHashCode();
}
static int GetNodeLinkListHash(List<AxiStatistics_Node_Link> nodes)
{
string hashplus = string.Empty;
foreach (var node in nodes)
{
hashplus += node.Name;
hashplus += node.Idx.ToString();
}
return hashplus.GetHashCode();
}
static string GetNodeLinkListStr(List<AxiStatistics_Node_Link> nodes)
{
string linkstr = string.Empty;
foreach (var node in nodes)
{
linkstr += "/";
linkstr += node.Name;
linkstr += "[" + node.Idx + "]";
}
return linkstr;
}
static void AddComponentData(int _type, string _rootPath, AxiStatistics_Node_Component _comdata, string _nodepath, Component lastcom)
{
string rootKey = GetRootTempKey(_type, _rootPath);
if (!dictTempData.ContainsKey(rootKey))
{
dictTempData[rootKey] = new AxiStatisticsDatas() { type = _type, FullPath = _rootPath, nodes = new List<AxiStatistics_Node>() };
}
AxiStatisticsDatas rootData = dictTempData[rootKey];
List<AxiStatistics_Node_Link> link = new List<AxiStatistics_Node_Link>();
if (lastcom.transform.parent != null)
{
Transform currNode = lastcom.transform;
while (currNode != null)
{
//最顶层了
if (currNode.parent == null)
{
link.Insert(0, new AxiStatistics_Node_Link()
{
NodeHash = GetNodeDataHash(currNode),
Idx = 0,
OnlyOne = true,
Name = currNode.gameObject.name
});
break;
}
int thisNameAllCount = 0;
int thisNodeIdx = -1;
#if UNITY_2017_1_OR_NEWER
int count = currNode.parent.childCount;
#else
int count = currNode.parent.GetChildCount();
#endif
bool bFind = false;
for (int i = 0; i < count; i++)
{
GameObject checkGobj = currNode.parent.GetChild(i).gameObject;
if (checkGobj.name == currNode.name)
{
thisNameAllCount++;
if (checkGobj == currNode.gameObject)
{
thisNodeIdx = thisNameAllCount - 1;
bFind = true;
}
}
}
if (bFind)
{
link.Insert(0, new AxiStatistics_Node_Link()
{
NodeHash = GetNodeDataHash(currNode),
Idx = thisNodeIdx,
OnlyOne = thisNameAllCount == 1,
Name = currNode.gameObject.name
});
currNode = currNode.parent;
}
else
break;
}
}
else
{
link.Insert(0, new AxiStatistics_Node_Link()
{
NodeHash = GetNodeDataHash(lastcom.transform),
Idx = 0,
OnlyOne = true,
Name = lastcom.gameObject.name
});
}
int linkhash = GetNodeLinkListHash(link);
AxiStatistics_Node nodeData = rootData.nodes.Where(w => w.LinkHash == linkhash).FirstOrDefault();
if (nodeData == null)
{
nodeData = new AxiStatistics_Node();
nodeData.Name = Path.GetFileName(_nodepath);
//nodeData.NodeFullPath = _nodepath;
nodeData.components = new List<AxiStatistics_Node_Component>();
//nodeData.NodeIdx = thisNodeIdx;
//nodeData.NodeIdxOnlyOne = bNodeIdxOnlyOne;
nodeData.link = link;
nodeData.LinkHash = linkhash;
nodeData.LinkFullStr = GetNodeLinkListStr(link);
rootData.nodes.Add(nodeData);
}
nodeData.components.Add(_comdata);
}
static bool CheckCom(Component[] allcoms, int comRealIdx, int _type, string _rootPath, Component com, string nodepath)
{
if (com is BoxCollider2D)
{
BoxCollider2D bc = com as BoxCollider2D;
#if UNITY_2017_1_OR_NEWER
Debug.Log(nodepath + "BoxCollider2D->center=>(" + bc.offset.x + "," + bc.offset.y + ") size=>(" + bc.size.x + "," + bc.size.y + "");
#else
Debug.Log(nodepath +"BoxCollider2D->center=>("+ bc.center.x+","+bc.center.y+") size=>("+ bc.size.x+","+bc.size.y+"");
#endif
AxiStatistics_Node_Component _com = new AxiStatistics_Node_Component();
_com.type = typeof(BoxCollider2D).ToString();
#if UNITY_2017_1_OR_NEWER
_com.center = bc.offset;
#else
_com.center = bc.center;
#endif
_com.size = bc.size;
SetCompnentIdxNum<BoxCollider2D>(_com, allcoms, comRealIdx, bc);
AddComponentData(_type, _rootPath, _com, nodepath, com);
}
if (com is Rigidbody2D)
{
Rigidbody2D rig2d = com as Rigidbody2D;
Debug.Log(_rootPath + "Rigidbody2D->simulated=>(" + rig2d.simulated + ")");
Debug.Log(_rootPath + "Rigidbody2D->IsSleeping=>(" + rig2d.isKinematic.ToString() + ")");
AxiStatistics_Node_Component _com = new AxiStatistics_Node_Component();
_com.type = typeof(Rigidbody2D).ToString();
_com.isKinematic = rig2d.isKinematic;
_com.simulated = rig2d.simulated;
_com.gravityScale = rig2d.gravityScale;
SetCompnentIdxNum<Rigidbody2D>(_com, allcoms, comRealIdx, rig2d);
AddComponentData(_type, _rootPath, _com, nodepath, com);
}
return true;
}
/// <summary>
/// 找出同类Idx
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="allcoms"></param>
/// <param name="comRealIdx"></param>
/// <param name="com"></param>
/// <returns></returns>
static void SetCompnentIdxNum<T>(AxiStatistics_Node_Component _comData, Component[] allcoms, int comRealIdx, T com) where T : Component
{
int ComIdxNum;
bool ComTypeIsOnlyOne = false;
int TCount = com.transform.GetComponents<T>().Length;
if (TCount == 1)
{
ComIdxNum = 0;
ComTypeIsOnlyOne = true;
}
else if (TCount < 1)
{
Debug.LogError("找不到,不应该");
ComIdxNum = -1;
}
ComIdxNum = -1;
for (int i = 0; i < allcoms.Length; i++)
{
//他自己自然是了
if (i == comRealIdx)
{
ComIdxNum++;
break;
}
if (allcoms[i] is T)
ComIdxNum++;
}
_comData.ComIdxNum = ComIdxNum;
_comData.ComTypeOnlyOne = ComTypeIsOnlyOne;
}
[MenuItem("Axibug移植工具/Statistics/[1]Collider和RigBody")]
public static void StatisticsCollider()
{
ClearTempData();
StatisticsCollider<BoxCollider2D>();
StatisticsCollider<Rigidbody2D>();
AxiStatisticsCache cache = ScriptableObject.CreateInstance<AxiStatisticsCache>();
foreach (var data in dictTempData)
cache.caches.Add(data.Value);
AssetDatabase.CreateAsset(cache, cachecfgPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
public static void StatisticsCollider<T>() where T : Component
{
AxiProjectTools.GoTAxiProjectToolsSence();
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(AxiProjectTools.toolSenceName))
continue;
#if UNITY_4_6
EditorApplication.OpenScene(path);
#else
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
#endif
// 创建一个列表来存储根节点
List<GameObject> rootNodes = new List<GameObject>();
// 遍历场景中的所有对象
GameObject[] allObjects = FindObjectsOfType<GameObject>();
foreach (GameObject obj in allObjects)
{
// 检查对象是否有父对象
if (obj.transform.parent == null)
{
// 如果没有父对象,则它是一个根节点
rootNodes.Add(obj);
}
}
foreach (var node in rootNodes)
LoopPrefabNode<T>(0, path, path, node, 0);
}
string[] prefabGuids = AssetDatabase.FindAssets("t:Prefab");
foreach (string guid in prefabGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
GetPrefab<T>(path);
}
AxiProjectTools.GoTAxiProjectToolsSence();
Debug.Log("<Color=#FFF333>处理完毕 统计所有预制体和场景下的" + typeof(T).FullName + "</color>");
}
static void GetPrefab<T>(string path) where T : Component
{
#if UNITY_4_6
GameObject prefab = AssetDatabase.LoadAssetAtPath(path,typeof(GameObject)) as GameObject;
#else
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
#endif
LoopPrefabNode<T>(1, path, path, prefab.gameObject, 0);
}
static void LoopPrefabNode<T>(int _type, string _rootPath, string noderootPath, GameObject trans, int depth) where T : Component
{
// #if UNITY_2018_4_OR_NEWER
string nodename = noderootPath + "/" + trans.name;
GameObject prefabRoot = trans.gameObject;
Component[] components = prefabRoot.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
var com = components[i];
if (com == null)
continue;
T comobj = com as T;
if (comobj == null)
continue;
if (CheckCom(components, i, _type, _rootPath, comobj, nodename))
continue;
}
//遍历
foreach (Transform child in trans.transform)
LoopPrefabNode<T>(_type, _rootPath, nodename, child.gameObject, depth + 1);
//#else
// Debug.Log("低版本不要执行本函数");
//#endif
}
#if UNITY_2017_1_OR_NEWER
[MenuItem("Axibug移植工具/Statistics/[2]")]
public static void RepairRigBodyByStatistics()
{
List<string> errLog = new List<string>();
List<string> doneLog = new List<string>();
List<ValueTuple<string, string>> NeedRepair = new List<ValueTuple<string, string>>();
List<ValueTuple<string, string>> FinishRepair = new List<ValueTuple<string, string>>();
string CurrScenePath = string.Empty;
AxiProjectTools.GoTAxiProjectToolsSence();
#if UNITY_4_6
AxiStatisticsCache data = AssetDatabase.LoadAssetAtPath(cachecfgPath,typeof(AxiStatisticsCache)) as AxiStatisticsCache;
#else
AxiStatisticsCache data = AssetDatabase.LoadAssetAtPath<AxiStatisticsCache>(cachecfgPath);
#endif
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
List<string> ScenePath = new List<string>();
List<string> SceneName = new List<string>();
foreach (string guid in sceneGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(AxiProjectTools.toolSenceName))
continue;
ScenePath.Add(path);
SceneName.Add(Path.GetFileName(path));
}
string[] prefabGuids = AssetDatabase.FindAssets("t:prefab");
List<string> prefabPath = new List<string>();
List<string> prefabName = new List<string>();
foreach (string guid in prefabGuids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
prefabPath.Add(path);
prefabName.Add(Path.GetFileName(path));
}
foreach (var cache in data.caches.OrderBy(w => w.type))
{
//场景
if (cache.type == 0)
{
#region
string targetName = Path.GetFileName(cache.FullPath);
int Idx = SceneName.IndexOf(targetName);
if (Idx < 0)
{
Debug.LogError(targetName + "[Repair]找不到对应资源");
continue;
}
string targetpath = ScenePath[Idx];
//保证场景切换
if (!string.Equals(CurrScenePath, targetpath))
{
#if UNITY_4_6
EditorApplication.OpenScene(targetpath);
#else
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(targetpath);
#endif
}
CurrScenePath = targetpath;
#endregion
int DirtyCount = 0;
foreach (var node in cache.nodes)
{
GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out string errStr);
if (targetNodePathObj == null)
{
errLog.Add(errStr);
continue;
}
/*
string targetNodePath = node.NodeFullPath.Substring(cache.FullPath.Length, node.NodeFullPath.Length - cache.FullPath.Length);
//GameObject targetNodePathObj = GameObject.Find(targetNodePath);
GameObject targetNodePathObj = GetNodeByIdx(node, targetNodePath);
if (targetNodePathObj == null)
{
string err = "[Repair]" + node.NodeFullPath + "找不到对应节点";
errLog.Add(err);
Debug.LogError(err);
continue;
}
*/
foreach (var com in node.components)
{
if (RepairComponent(node.LinkFullStr, targetNodePathObj, com, out var errlog))
{
NeedRepair.Add(new ValueTuple<string, string>($"{cache.FullPath}:{node.LinkFullStr}", $"{com.type}[{com.ComIdxNum}]"));
DirtyCount++;
}
errLog.AddRange(errlog);
}
}
if (DirtyCount > 0)
{
Debug.Log($"[Repair][场景处理]{cache.FullPath}共{DirtyCount}个需要处理");
// 获取当前打开的场景
var activeScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene();
// 保存场景
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(activeScene);
Debug.Log("场景已保存: " + activeScene.path);
string donestr = $"[Repair][场景处理成功]{targetpath},共{DirtyCount}个";
doneLog.Add(donestr);
}
}
else if (cache.type == 1)
{
string targetpath = cache.FullPath;
//来到空场景
if (!string.IsNullOrEmpty(CurrScenePath))
{
AxiProjectTools.GoTAxiProjectToolsSence();
CurrScenePath = string.Empty;
}
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(targetpath);
if (prefabInstance == null)
{
Debug.LogError($"[Repair]Failed to load prefab at path: {prefabPath}");
return;
}
var obj = GameObject.Instantiate(prefabInstance, null);
int DirtyCount = 0;
foreach (var node in cache.nodes)
{
GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out string errStr, obj);
if (targetNodePathObj == null)
{
errLog.Add(errStr);
continue;
}
//if (node.NodeFullPath == targetpath + "/" + Path.GetFileNameWithoutExtension(targetpath))
//{
// //预制体自己就是目标
// targetNodePathObj = obj;
//}
//else
//{
// string targetNodePath = node.NodeFullPath.Substring(cache.FullPath.Length + prefabInstance.name.Length + 2, node.NodeFullPath.Length - cache.FullPath.Length - prefabInstance.name.Length - 2);
// //targetNodePathObj = obj.transform.Find(targetNodePath)?.gameObject;
// targetNodePathObj = GetNodeByIdx(node, targetNodePath, obj);
// if (targetNodePathObj == null)
// {
// Debug.LogError("[Repair]" + targetNodePath + "找不到对应节点");
// continue;
// }
//}
foreach (var com in node.components)
{
if (RepairComponent(node.LinkFullStr, targetNodePathObj, com, out var errlog))
{
NeedRepair.Add(new ValueTuple<string, string>($"{cache.FullPath}:{node.LinkFullStr}", $"{com.type}[{com.ComIdxNum}]"));
DirtyCount++;
}
errLog.AddRange(errlog);
}
}
if (DirtyCount > 0)
{
Debug.Log($"[Repair][预制体处理]{targetpath}共{DirtyCount}个需要处理");
PrefabUtility.SaveAsPrefabAsset(obj, targetpath);
string donestr = $"[Repair][预制体处理成功]{targetpath},共{DirtyCount}个";
doneLog.Add(donestr);
}
GameObject.DestroyImmediate(obj);
}
}
AxiProjectTools.GoTAxiProjectToolsSence();
StringBuilder sb = new StringBuilder();
sb.AppendLine("[Repair][统计]:");
sb.AppendLine("----处理成功----");
foreach (var val in doneLog.OrderBy(w => w))
{
sb.AppendLine(val);
}
sb.AppendLine("----异常统计----");
foreach (var val in errLog.OrderBy(w => w))
{
sb.AppendLine(val);
}
sb.AppendLine("----需要处理----");
foreach (var val in NeedRepair.OrderBy(w => w.Item1))
{
sb.AppendLine($"{val.Item1}=>{val.Item2}");
}
Debug.Log($"{sb}");
File.WriteAllText("Assets/AxiNeedRepair.txt", sb.ToString());
}
// static GameObject GetNodeByIdx(AxiStatistics_Node nodedata, string targetNodePath, GameObject root = null)
// {
// GameObject targetNodePathObj;
// if (root == null)
// targetNodePathObj = GameObject.Find(targetNodePath);
// else
// targetNodePathObj = root.transform.Find(targetNodePath)?.gameObject;
// if (targetNodePathObj == null)
// return null;
// string targetName = targetNodePathObj.name;
// int currIdx = -1;
// if (!nodedata.NodeIdxOnlyOne)
// {
// if (targetNodePathObj.transform.parent != null)
// {
//#if UNITY_2017_1_OR_NEWER
// int count = targetNodePathObj.transform.parent.childCount;
//#else
// int count = targetNodePathObj.transform.parent.GetChildCount();
//#endif
// for (int i = 0; i < count; i++)
// {
// GameObject checkGobj = targetNodePathObj.transform.parent.GetChild(i).gameObject;
// if (checkGobj.name == targetName)
// {
// currIdx++;
// if (nodedata.NodeIdx == currIdx)
// {
// targetNodePathObj = checkGobj;
// break;
// }
// }
// }
// }
// }
// return targetNodePathObj;
// }
static GameObject GetNodeByLink(string rootPath, List<AxiStatistics_Node_Link> linklist, out string errStr, GameObject PrefabRoot = null)
{
List<AxiStatistics_Node_Link> temp_useddlink = new List<AxiStatistics_Node_Link>();
if (linklist.Count < 1)
{
errStr = $"[Repair] Link 为空";
Debug.LogError(errStr);
return null;
}
temp_useddlink.Add(linklist[0]);
GameObject currRoot;
if (PrefabRoot == null)
currRoot = GameObject.Find(linklist[0].Name);
else
{
currRoot = PrefabRoot;
//currRoot = PrefabRoot.transform.Find(linklist[0].Name)?.gameObject;
}
if (currRoot == null)
{
errStr = $"[Repair] 根节点找不到{rootPath}:{GetNodeLinkListStr(linklist)} => null";
Debug.LogError(errStr);
return null;
}
for (int link_i = 1; link_i < linklist.Count; link_i++)
{
AxiStatistics_Node_Link targetLink = linklist[link_i];
temp_useddlink.Add(targetLink);
GameObject findNode = null;
#if UNITY_2017_1_OR_NEWER
int count = currRoot.transform.childCount;
#else
int count = currNode.transform.GetChildCount();
#endif
if (targetLink.OnlyOne)
{
for (int i = 0; i < count; i++)
{
GameObject checkGobj = currRoot.transform.GetChild(i).gameObject;
if (checkGobj.name == targetLink.Name)
{
findNode = checkGobj;
break;
}
}
}
else
{
Dictionary<int, GameObject> tempHash2Node = new Dictionary<int, GameObject>();
List<GameObject> tempGobjList = new List<GameObject>();
bool HashDrity = false;
for (int i = 0; i < count; i++)
{
GameObject checkGobj = currRoot.transform.GetChild(i).gameObject;
if (checkGobj.name == targetLink.Name)
{
int temphash = GetNodeDataHash(checkGobj.transform);
if (!tempHash2Node.ContainsKey(temphash))
{
tempHash2Node.Add(GetNodeDataHash(checkGobj.transform), checkGobj);
}
else
{
HashDrity = true;
}
tempGobjList.Add(checkGobj);
}
}
//Hash严格模式
if (!HashDrity && tempHash2Node.TryGetValue(targetLink.NodeHash, out var val))
{
findNode = val;
}
//下标模式
else
{
if (targetLink.Idx < 0 || tempGobjList.Count == 0 || (tempGobjList.Count != 0 && targetLink.Idx >= tempGobjList.Count))
{
errStr = $"[Repair]link 下标模式 找不到=>{rootPath}:{GetNodeLinkListStr(temp_useddlink)}[{targetLink.Idx}] => 完整链路{rootPath}:{GetNodeLinkListStr(linklist)}";
Debug.LogError(errStr);
return null;
}
else
{
findNode = tempGobjList[targetLink.Idx];
}
}
}
currRoot = findNode;
if (currRoot == null)
break;
}
if (currRoot == null)
{
errStr = $"[Repair]link 找不到[{rootPath}:{GetNodeLinkListStr(temp_useddlink)}] => 完整链路{rootPath}:{GetNodeLinkListStr(linklist)}";
Debug.LogError(errStr);
return null;
}
else
{
errStr = string.Empty;
return currRoot;
}
}
static bool RepairComponent(string NodePath, GameObject targetNodePathObj, AxiStatistics_Node_Component comdata, out List<string> Errlog)
{
Errlog = new List<string>();
string err;
bool Dirty = false;
if (comdata.type == typeof(Rigidbody2D).ToString())
{
Rigidbody2D rg2d = GetCompnentById<Rigidbody2D>(targetNodePathObj, comdata);
if (rg2d == null)
{
err = $"[Repair]{NodePath}=> Rigidbody2D[{comdata.ComIdxNum}] == null";
Debug.LogError(err);
Errlog.Add(err);
Dirty = false;
}
/*
Unity的差异
BodyType选项Unity 4.6.7Rigidbody2D默认等效于新版的Dynamic类型Static或Kinematic
Simulated选项Rigidbody2D组件且Gravity Scale > 0
gravityScale > 0,simulated = true;bodyType = RigidbodyType2D.Dynamic;
*/
if (rg2d.gravityScale != comdata.gravityScale)
{
Debug.Log($"[Repair]{NodePath}=> Rigidbody2D[{comdata.ComIdxNum}] simulated:{rg2d.gravityScale} != :{comdata.gravityScale} rg2d.bodyType => {rg2d.bodyType} ");
rg2d.gravityScale = comdata.gravityScale;
Dirty = true;
}
//if (rg2d.gravityScale > 0 && (!rg2d.simulated || rg2d.bodyType != RigidbodyType2D.Dynamic))
if (!rg2d.simulated || rg2d.bodyType != RigidbodyType2D.Dynamic)
{
Debug.Log($"[Repair]{NodePath}=> Rigidbody2D[{comdata.ComIdxNum}] simulated:{rg2d.simulated} != :{comdata.simulated} rg2d.bodyType => {rg2d.bodyType} ");
rg2d.simulated = true;
rg2d.bodyType = RigidbodyType2D.Dynamic;
Dirty = true;
}
}
else if (comdata.type == typeof(BoxCollider2D).ToString())
{
BoxCollider2D bc = GetCompnentById<BoxCollider2D>(targetNodePathObj, comdata);
if (bc == null)
{
err = $"[Repair]{NodePath}=> BoxCollider2D[{comdata.ComIdxNum}] == null";
Debug.LogError(err);
Errlog.Add(err);
Dirty = false;
}
else
{
if (bc.size != comdata.size)
{
Debug.Log($"[Repair]{NodePath} BoxCollider2D[{comdata.ComIdxNum}] => size:{bc.size} != {comdata.size} ");
bc.size = comdata.size;
Dirty = true;
}
if (bc.offset != comdata.center)
{
Debug.Log($"[Repair]{NodePath} BoxCollider2D[{comdata.ComIdxNum}] => offset:{bc.offset} != center{comdata.center} ");
bc.offset = comdata.center;
Dirty = true;
}
if (Dirty)
{
bc.size = comdata.size;
bc.offset = comdata.center;
}
}
}
return Dirty;
}
static T GetCompnentById<T>(GameObject gobj, AxiStatistics_Node_Component node) where T : Component
{
if (node.ComIdxNum == 0)
return gobj.GetComponent<T>();
else if (node.ComIdxNum > 0)
{
T[] coms = gobj.GetComponents<T>();
if (node.ComIdxNum < coms.Length)
return coms[node.ComIdxNum];
}
return null;
}
#endif
}
#endif

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 32aabdd304d2c4d47b8ef660f672ead1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -3,19 +3,18 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
public class AxiProjectTools : EditorWindow
{
static string cachecfgPath = "Assets/AxiComToolCache.asset";
static string toolSenceName = "AxiProjectTools";
static string outCsDir = Application.dataPath + "/AxiCom/";
static Dictionary<string, AxiPrefabCache_Com2GUID> ComType2GUID = new Dictionary<string, AxiPrefabCache_Com2GUID>();
public static string toolSenceName = "AxiProjectTools";
public static string outCsDir = Application.dataPath + "/AxiCom/";
public static Dictionary<string, AxiPrefabCache_Com2GUID> ComType2GUID = new Dictionary<string, AxiPrefabCache_Com2GUID>();
static void GoTAxiProjectToolsSence()
public static void GoTAxiProjectToolsSence()
{
string[] sceneGuids = AssetDatabase.FindAssets("t:scene");
foreach (string guid in sceneGuids)
@ -23,7 +22,11 @@ public class AxiProjectTools : EditorWindow
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.Contains(toolSenceName))
{
EditorSceneManager.OpenScene(path);
#if UNITY_4_6
EditorApplication.OpenScene(path);
#else
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
#endif
return;
}
}
@ -41,7 +44,11 @@ public class AxiProjectTools : EditorWindow
if (path.Contains(toolSenceName))
continue;
EditorSceneManager.OpenScene(path);
#if UNITY_4_6
EditorApplication.OpenScene(path);
#else
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
#endif
// 创建一个列表来存储根节点
List<GameObject> rootNodes = new List<GameObject>();
@ -82,18 +89,25 @@ public class AxiProjectTools : EditorWindow
static void GetPrefab(string path)
{
#if UNITY_4_6
GameObject prefab = AssetDatabase.LoadAssetAtPath(path,typeof(GameObject)) as GameObject;
#else
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
#endif
LoopPrefabNode(path, prefab.gameObject, 0);
}
static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
{
string nodename = $"{rootPath}>{trans.name}";
#if UNITY_2018_4_OR_NEWER
// #if UNITY_2018_4_OR_NEWER
string nodename = rootPath + trans.name;
GameObject prefabRoot = trans.gameObject;
int comCount = prefabRoot.GetComponentCount();
for (int i = 0; i < comCount; i++)
Component[] components = prefabRoot.GetComponents<Component>();
for (int i = 0; i < components.Length; i++)
{
var com = prefabRoot.GetComponentAtIndex(i);
var com = components[i];
if (com == null)
continue;
@ -109,7 +123,7 @@ public class AxiProjectTools : EditorWindow
{
// 获取MonoScript资源的GUID
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(monoScript));
Debug.Log($"{nodename} | <color=#FFF333>[{monoType.Name}]</color> <color=#FF0000>{guid}</color><color=#00FF00>({monoType.FullName})</color>");
Debug.Log(nodename+" | <color=#FFF333>["+monoType.Name+"]</color> <color=#FF0000>"+guid+"</color><color=#00FF00>("+monoType.FullName+")</color>");
ComType2GUID[monoType.FullName] =
new AxiPrefabCache_Com2GUID()
{
@ -127,18 +141,33 @@ public class AxiProjectTools : EditorWindow
//遍历
foreach (Transform child in trans.transform)
LoopPrefabNode(nodename, child.gameObject, depth + 1);
#else
Debug.Log("低版本不要执行本函数");
#endif
//#else
// Debug.Log("低版本不要执行本函数");
//#endif
}
[MenuItem("Axibug移植工具/ToLowVersionUnity/[2]")]
public static void Part2()
{
#if UNITY_4_6
if(System.IO.Directory.Exists(outCsDir))
System.IO.Directory.Delete(outCsDir);
#else
if (UnityEngine.Windows.Directory.Exists(outCsDir))
UnityEngine.Windows.Directory.Delete(outCsDir);
#endif
Directory.CreateDirectory(outCsDir);
#if UNITY_4_6
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath(cachecfgPath,typeof(AxiPrefabCache)) as AxiPrefabCache;
#else
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
#endif
foreach (var data in cache.caches)
{
string toName = "Axi" + data.SrcName;
@ -164,8 +193,14 @@ public class AxiProjectTools : EditorWindow
[MenuItem("Axibug移植工具/ToLowVersionUnity/[3]")]
public static void Part3()
{
#if UNITY_4_6
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath(cachecfgPath,typeof(AxiPrefabCache)) as AxiPrefabCache;
MonoScript[] allMonoScripts = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript));
#else
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
List<MonoScript> allMonoScripts = FindAllAssetsOfType<MonoScript>();
#endif
foreach (var data in cache.caches)
{
MonoScript monoScript = allMonoScripts.FirstOrDefault(w => w.name == data.ToName);
@ -194,7 +229,12 @@ public class AxiProjectTools : EditorWindow
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.EndsWith(".cs") || path.EndsWith(".js") || path.EndsWith(".boo")) // Unity支持多种脚本语言但现代Unity主要使用C#
{
#if UNITY_4_6
T asset = AssetDatabase.LoadAssetAtPath(cachecfgPath,typeof(T)) as T;
#else
T asset = AssetDatabase.LoadAssetAtPath<T>(path);
#endif
if (asset != null)
{
assets.Add(asset);
@ -208,7 +248,13 @@ public class AxiProjectTools : EditorWindow
[MenuItem("Axibug移植工具/ToLowVersionUnity/[4]")]
public static void Part4()
{
#if UNITY_4_6
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath(cachecfgPath,typeof(AxiPrefabCache)) as AxiPrefabCache;
#else
AxiPrefabCache cache = AssetDatabase.LoadAssetAtPath<AxiPrefabCache>(cachecfgPath);
#endif
Dictionary<string, string> tempReplaceDict = new Dictionary<string, string>();
foreach (var data in cache.caches)
{
@ -263,7 +309,7 @@ public class AxiProjectTools : EditorWindow
public static void UnpackPrefabs()
{
#if UNITY_2018_4_OR_NEWER
#if UNITY_2018_4_OR_NEWER
GoTAxiProjectToolsSence();
string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
int prefabCount = 0;
@ -286,8 +332,8 @@ public class AxiProjectTools : EditorWindow
if (path.Contains(toolSenceName))
continue;
EditorSceneManager.OpenScene(path);
Scene currentScene = SceneManager.GetActiveScene();
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(path);
UnityEngine.SceneManagement.Scene currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
GameObject[] rootObjects = currentScene.GetRootGameObjects();
foreach (GameObject rootObj in rootObjects)
{
@ -295,23 +341,23 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(rootObj);
}
// Save the scene // 获取当前打开的场景
currentScene = EditorSceneManager.GetActiveScene();
currentScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene();
// 保存场景到文件(默认路径和名称)
bool success = EditorSceneManager.SaveScene(currentScene, currentScene.path);
bool success = UnityEditor.SceneManagement.EditorSceneManager.SaveScene(currentScene, currentScene.path);
Debug.Log($"{currentScene.name}场景中 所有物体Unpack");
}
GoTAxiProjectToolsSence();
Debug.Log("<Color=#FFF333>处理完毕 [5]UnPack所有预制体</color>");
#else
#else
Debug.Log("低版本不要执行本函数");
#endif
#endif
}
static void UnpackPrefab(string prefabPath)
{
#if UNITY_2018_4_OR_NEWER
#if UNITY_2018_4_OR_NEWER
GameObject prefabInstance = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
if (prefabInstance == null)
{
@ -323,14 +369,14 @@ public class AxiProjectTools : EditorWindow
TraverseHierarchy(obj);
PrefabUtility.SaveAsPrefabAsset(obj, prefabPath);
GameObject.DestroyImmediate(obj);
#else
#else
Debug.Log("低版本不要执行本函数");
#endif
#endif
}
static void TraverseHierarchy(GameObject obj)
{
#if UNITY_2018_4_OR_NEWER
#if UNITY_2018_4_OR_NEWER
// 检查该对象是否是预制体的实例
if (PrefabUtility.IsPartOfPrefabInstance(obj))
{
@ -344,9 +390,9 @@ public class AxiProjectTools : EditorWindow
{
TraverseHierarchy(obj.transform.GetChild(i).gameObject);
}
#else
#else
Debug.Log("低版本不要执行本函数");
#endif
#endif
}
@ -413,5 +459,48 @@ public class AxiProjectTools : EditorWindow
textureImporter.SaveAndReimport();
}
}
[MenuItem("Axibug移植工具/ToLowVersionUnity/[7]")]
static void FixPrefabRefs()
{
// 1. 扫描所有预制体
string[] prefabPaths = Directory.GetFiles("Assets", "*.prefab", SearchOption.AllDirectories);
foreach (var path in prefabPaths) FixRefTypeInFile(path);
// 2. 处理场景文件
string[] scenePaths = Directory.GetFiles("Assets", "*.unity", SearchOption.AllDirectories);
foreach (var path in scenePaths) FixRefTypeInFile(path);
AssetDatabase.Refresh();
Debug.Log("<Color=#FFF333>处理完毕 [5]导入低版本后:修复预制体依赖丢失</color>");
Debug.Log("修复完成!已处理" + prefabPaths.Length + "个预制体");
}
public static void FixRefTypeInFile(string filePath)
{
string content = File.ReadAllText(filePath);
// 匹配所有 {fileID: X, guid: Y, type: Z} 结构
string pattern = @"(\{[^}]*guid:\s*(\w+)[^}]*type:\s*)3(\s*[^}]*\})";
string newContent = Regex.Replace(content, pattern, match => {
string guid = match.Groups[2].Value;
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
// 仅当资源类型为 GameObject 时修改 type
if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(GameObject))
// if (assetPath.ToLower().EndsWith(".prefab")
////&& assetPath.Contains("/sound/")
//&& assetPath.Contains("/level")
// )
{
Debug.Log("已处理被引用项=>"+assetPath+" ,引用到=>"+ filePath);
Debug.Log("原值=>" + match.Value + " ,处理值=>"+ match.Groups[1].Value + "2" + match.Groups[3].Value);
//return match.Value;
return match.Groups[1].Value + "2" + match.Groups[3].Value; // type:3→2
}
return match.Value;
});
File.WriteAllText(filePath, newContent);
}
}
#endif

View File

@ -0,0 +1,73 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class AxiStatisticsCache : ScriptableObject
{
public List<AxiStatisticsDatas> caches = new List<AxiStatisticsDatas>();
}
[Serializable]
public class AxiStatisticsDatas
{
/// <summary>
/// [0]Sence [1]Prefab
/// </summary>
public int type;
public string FullPath;
public List<AxiStatistics_Node> nodes = new List<AxiStatistics_Node>();
}
[Serializable]
public class AxiStatistics_Node
{
public string Name;
public List<AxiStatistics_Node_Link> link = new List<AxiStatistics_Node_Link>();
public int LinkHash;
public string LinkFullStr;
//public string NodeFullPath;
// /// <summary>
// /// 表示相同路径只有一个
// /// </summary>
// public bool NodeIdxOnlyOne;
/// <summary>
/// 表示相同路径是第几个下标
/// </summary>
//public int NodeIdx;
public List<AxiStatistics_Node_Component> components = new List<AxiStatistics_Node_Component>();
}
[Serializable]
public class AxiStatistics_Node_Link
{
public string Name;
public bool OnlyOne;
public int Idx;
public int NodeHash;
}
[Serializable]
public class AxiStatistics_Node_Component
{
public string type;
/// <summary>
/// 表示相同组件只有一个
/// </summary>
public bool ComTypeOnlyOne;
/// <summary>
/// 表示相同组件是第几个下标
/// </summary>
public int ComIdxNum;
//Rigboody
public bool simulated;
public float gravityScale;
public bool isKinematic;
//BoxCollider2D
public Vector2 center;
public Vector2 size;
}
#endif

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e4cee4feffb506b4c833262e779424f6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Editors
}
EditorGUILayout.EndVertical();
EditorGUILayout.LabelField(dispacather.Current.Name);
EditorGUILayout.LabelField(dispacather.Mode.ToString());
Repaint();
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 91746af636f351140a4796dc4e98be6d
guid: 4094856a5db24f142a14fda03f1215a2
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,46 @@
#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;
}
}
/// <summary>
/// 延迟提交是否使用多线程
/// </summary>
public static bool usedmultithreading = false;
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
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b8790f215d873d044aa8d00bacdee237
guid: 52541c757d45c4c488726bcc39f73ba6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,3 @@
{
"name": "AxiNSApi"
}

View File

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

View 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}";
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c29cb72b155d20a48a3a47a7a05160bd
guid: 0e28b69692cb1bb4a9d8ddb91274fa50
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,837 @@
#if UNITY_SWITCH
using nn.fs;
#endif
using System.Collections.Generic;
using System.Text.RegularExpressions;
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();
//这个异常捕获。真的别扭
//日FileSystem.ResultPathAlreadyExists 貌似不太行
//return nn.fs.FileSystem.ResultPathAlreadyExists.Includes(result);
return !nn.fs.FileSystem.ResultPathNotFound.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;
}
//读取文件Handle
result = File.Open(ref fileHandle, filePath, OpenFileMode.Write);
}
else
{
//读取文件Handle
result = File.Open(ref fileHandle, filePath, OpenFileMode.Write);
long currsize = 0;
File.GetSize(ref currsize, fileHandle);
if (currsize == data.Length)
{
UnityEngine.Debug.Log($"文件({filePath})存在,长度一致,不用重新创建");
}
else
{
UnityEngine.Debug.Log($"文件({filePath})存在,长度不一致,先删除再重建");
nn.fs.File.Close(fileHandle);
//删除
File.Delete(filePath);
//重新创建
result = nn.fs.File.Create(filePath, data.Length);
if (!result.IsSuccess())
{
UnityEngine.Debug.LogError($"创建文件失败 {filePath} : " + result.GetErrorInfo());
return false;
}
//重新读取文件Handle
result = File.Open(ref fileHandle, filePath, OpenFileMode.Write);
}
}
// //OpenFileMode.AllowAppend 好像不可用
// //result = File.Open(ref fileHandle, filePath, OpenFileMode.AllowAppend);
// 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)
{
byte[] outputData;
LoadSwitchDataFile(filename, out outputData);
return outputData;
}
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
{
byte[] outputData;
if (LoadSwitchDataFile(filename, out 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
public bool GetDirectoryEntrysFullRecursion(string path, out string[] entrys)
{
#if UNITY_SWITCH
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;
#else
entrys = null;
return false;
#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;
}
public bool DeletePathDirRecursively(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.Recursively 失败 {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_DeletePathDirRecursively DeletePathDirRecursivelyAsync(string filename)
{
var wait = new AxiNSWait_DeletePathDirRecursively(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
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c8339ffab20bfea4cbc7d3aa440c3fdb
guid: d910a015a6b6561418bdff7f2c48cffa
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,41 @@
using System;
using UnityEngine;
public class AxiNSMono : MonoBehaviour
{
Action act;
float waittime;
float lastinvokeTime;
public static void SetInvoke(Action _act, int _waitsec)
{
GameObject gobj = GameObject.Find($"[{nameof(AxiNSMono)}]");
if (gobj == null)
{
gobj = new GameObject();
gobj.name = $"[{nameof(AxiNSMono)}]";
GameObject.DontDestroyOnLoad(gobj);
}
AxiNSMono com = gobj.GetComponent<AxiNSMono>();
if (com == null)
{
com = gobj.AddComponent<AxiNSMono>();
}
com.act = _act;
com.waittime = _waitsec;
}
public void OnEnable()
{
Debug.Log("AxiNSMono Enable");
}
public void Update()
{
if (Time.time - lastinvokeTime < waittime)
return;
lastinvokeTime = Time.time;
if (act != null)
act.Invoke();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 23d5745b8989af04d8a871b5c7b65d50
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48826c5dc8959ff4db8c6a51b6568bb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21fa04ba4da10d74aafd65dd138478b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95c2e164c69c6cc4887a194d6eba0cc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 04e926e140ae5bc4fa46bd64067261cf
guid: e28ed9d2fb16c7f42b28cafb6a2ce0ac
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,134 @@
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);
}
}
public class AxiNSWait_DeletePathDirRecursively : AxiNSWaitBase
{
S_NSWAIT_Path req;
public bool result;
public AxiNSWait_DeletePathDirRecursively(string filePath)
{
req = new S_NSWAIT_Path() { filePath = filePath };
}
public override void Invoke()
{
result = AxiNS.instance.io.DeletePathDirRecursively(req.filePath);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46a1a776d2f9dba49b9641d8e0976861
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Threading;
public class AxiNSWaitHandle
{
static Queue<AxiNSWaitBase> m_QueueReady = new Queue<AxiNSWaitBase>();
static Queue<AxiNSWaitBase> m_QueueWork = new Queue<AxiNSWaitBase>();
public void AddWait(AxiNSWaitBase wait)
{
lock (m_QueueReady)
{
m_QueueReady.Enqueue(wait);
}
if (AxiNS.usedmultithreading)
{
InitInternalThread();
autoEvent.Set();
}
else
{
InitMonoInit();
}
}
#region 线
static AutoResetEvent autoEvent = new AutoResetEvent(false);
static Thread waitThread = new Thread(Loop);
static bool bSingleInit = false;
static void InitInternalThread()
{
if (bSingleInit) return;
waitThread.Start();
bSingleInit = true;
}
static void Loop()
{
while (autoEvent.WaitOne())
{
Do();
}
}
#endregion
#region 线
static bool bMonoInit = false;
static void InitMonoInit()
{
if (bMonoInit) return;
AxiNSMono.SetInvoke(Do,15);
bMonoInit = true;
}
#endregion
static void Do()
{
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();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5e36180ba1c4a8f4db3ceed533a43999
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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)
bool checkCanGetFrame(int targetFrame, bool indirectGet)
{
if (!bNetInit)
if (indirectGet)
{
data = default(ReplayStep);
frameDiff = default(int);
inputDiff = false;
return false;
return targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx;
}
else
{
return targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count >= frameProfiler.TempFrameCount(mRemoteForwardCount);
}
return TakeFrameToTargetFrame(targetFrame, out data, out frameDiff, out inputDiff);
}
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;

View File

@ -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);

View File

@ -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";

View File

@ -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;
}
}

View File

@ -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 */

View File

@ -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)

View File

@ -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()
{

View File

@ -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);

View File

@ -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++)

View File

@ -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);

View File

@ -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();
}

View File

@ -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

View File

@ -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

View File

@ -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)
{

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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)
{

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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)
{

View File

@ -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++)

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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
{

View File

@ -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()
{

View File

@ -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

View File

@ -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();

View File

@ -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()

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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++)

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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()
{

View File

@ -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();

View File

@ -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);

View File

@ -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)
{
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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);
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: da0b580f2a446f948a80085bb9b7b3ee

View File

@ -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();

View File

@ -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();
}

View File

@ -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++)

View File

@ -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++)

View File

@ -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++)

View File

@ -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();

View File

@ -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++)

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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++)

View File

@ -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++)

View File

@ -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);

View File

@ -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();

View File

@ -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

View File

@ -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++)

Some files were not shown because too many files have changed in this diff Show More