Compare commits

...

113 Commits

Author SHA1 Message Date
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
399 changed files with 17441 additions and 4036 deletions
.gitignore
AxibugEmuOnline.Client/Assets
AxiProjectTools
Editors
Plugins
Resources

9
.gitignore vendored
View File

@ -14,8 +14,10 @@
/AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset /AxibugEmuOnline.Client/ProjectSettings/AutoStreamingSettings.asset
/AxibugEmuOnline.Client/Logs /AxibugEmuOnline.Client/Logs
/AxibugEmuOnline.Client/Assets/AxiProjectTools/AxiNSPack/switch_keys/*.keys **/switch_keys/*.keys
/AxibugEmuOnline.Client/Assets/AxiProjectTools/AxiNSPack/switch_keys/*.keys.meta **/switch_keys/*.keys.meta
**/NintendoSDKPlugin/
**/NintendoSDKPlugin.meta
/virtuanessrc097-master /virtuanessrc097-master
/AxibugEmuOnline.Server/config.cfg /AxibugEmuOnline.Server/config.cfg
@ -48,4 +50,5 @@
AxibugEmuOnline.GameScreenConvert/bin/ AxibugEmuOnline.GameScreenConvert/bin/
AxibugEmuOnline.GameScreenConvert/obj/ AxibugEmuOnline.GameScreenConvert/obj/
/.vs/ /.vs/
AxibugEmuOnline.Client/ProjectSettings/PackageManagerSettings.asset

View File

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

View File

@ -19,7 +19,17 @@ namespace AxibugEmuOnline.Editors
static Dictionary<string, string> tools = new Dictionary<string, string>(); static Dictionary<string, string> tools = new Dictionary<string, string>();
static string prodKeysPath; 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() static void RepackNSP()
{ {
if (!CheckEnvironmentVariable()) if (!CheckEnvironmentVariable())
@ -37,7 +47,29 @@ namespace AxibugEmuOnline.Editors
RepackNSP(path); 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() public static void BuildWithRepackNSP()
{ {
if (!CheckEnvironmentVariable()) if (!CheckEnvironmentVariable())
@ -82,7 +114,7 @@ namespace AxibugEmuOnline.Editors
{ {
BuildReport report = BuildPipeline.BuildPlayer(options); BuildReport report = BuildPipeline.BuildPlayer(options);
} }
catch(Exception ex) catch (Exception ex)
{ {
Debug.LogError($"[AxibugNSPTools] Unity Build NSP 错误:{ex.ToString()}"); Debug.LogError($"[AxibugNSPTools] Unity Build NSP 错误:{ex.ToString()}");
return; return;
@ -120,12 +152,7 @@ namespace AxibugEmuOnline.Editors
static void RepackNSP(string nspFile) static void RepackNSP(string nspFile)
{ {
#region InitToolPath();
// 삿혤뻔쓱긴좆(矜狼警속뻔쓱긴좆쇱꿴)
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
#region NSP文件路径 #region NSP文件路径
string nspFilePath = nspFile; string nspFilePath = nspFile;
@ -147,13 +174,13 @@ namespace AxibugEmuOnline.Editors
#region #region
CleanDirectory(Path.Combine(nspParentDir, "repacker_extract")); CleanDirectory(Path.Combine(nspParentDir, "repacker_extract"));
CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA")); CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA"));
CleanDirectory(Path.Combine(WorkRoot, "hacpack_backup")); CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup"));
#endregion #endregion
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"解包NSP文件", 0.2f); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"解包NSP文件", 0.2f);
#region NSP文件 #region NSP文件
string extractPath = Path.Combine(nspParentDir, "repacker_extract"); 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 controlPath = null;
string programPath = null; string programPath = null;
@ -167,34 +194,43 @@ namespace AxibugEmuOnline.Editors
#region NCA/NSP #region NCA/NSP
string tmpPath = Path.Combine(Path.GetTempPath(), "NCA"); string tmpPath = Path.Combine(Path.GetTempPath(), "NCA");
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.6f); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Program NCA", 0.3f);
string programNCA = BuildProgramNCA(tmpPath, titleID, programPath); string programNCA = BuildProgramNCA(tmpPath, titleID, programPath, nspParentDir);
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.7f); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Control NCA", 0.4f);
string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath); string controlNCA = BuildControlNCA(tmpPath, titleID, controlPath, nspParentDir);
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NCA", 0.8f); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建 Meta NCA", 0.5f);
BuildMetaNCA(tmpPath, titleID, programNCA, controlNCA); 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); EditorUtility.DisplayProgressBar("AxibugNSPTools", $"重建NSP", 0.9f);
string outputNSP = BuildFinalNSP(nspFilePath, nspParentDir, tmpPath, titleID);
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"路쉔NSP", 1f);
Debug.Log($"[AxibugNSPTools]Repacking completed: {outputNSP}"); Debug.Log($"[AxibugNSPTools]Repacking completed: {outputNSP}");
EditorUtility.ClearProgressBar();
#endregion #endregion
EditorUtility.DisplayProgressBar("AxibugNSPTools", $"清理临时目录", 1);
#region
CleanDirectory(Path.Combine(nspParentDir, "repacker_extract"));
CleanDirectory(Path.Combine(Path.GetTempPath(), "NCA"));
CleanDirectory(Path.Combine(nspParentDir, "hacpack_backup"));
#endregion
System.Diagnostics.Process.Start("explorer", "/select,\"" + outputNSP.Trim() + "\"");
EditorUtility.ClearProgressBar();
} }
#region #region
static string GetUserInput() static string GetUserInput()
{ {
Console.Write("Enter the NSP filepath: "); Console.Write("Enter the NSP filepath: ");
return Console.ReadLine(); return Console.ReadLine();
} }
static string ExtractTitleID(string path) static string ExtractTitleID(string path)
{ {
var match = Regex.Match(path, @"0100[\dA-Fa-f]{12}"); var match = Regex.Match(path, @"0100[\dA-Fa-f]{12}");
return match.Success ? match.Value : null; return match.Success ? match.Value : null;
} }
static void CleanDirectory(string path) static void CleanDirectory(string path)
{ {
if (Directory.Exists(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() var process = new System.Diagnostics.Process()
{ {
StartInfo = new System.Diagnostics.ProcessStartInfo StartInfo = new System.Diagnostics.ProcessStartInfo
@ -228,7 +265,8 @@ namespace AxibugEmuOnline.Editors
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true, CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8, // 明确指定编码 StandardOutputEncoding = Encoding.UTF8, // 明确指定编码
StandardErrorEncoding = Encoding.UTF8 StandardErrorEncoding = Encoding.UTF8,
WorkingDirectory = workdir
} }
}; };
@ -275,36 +313,36 @@ namespace AxibugEmuOnline.Editors
#endregion #endregion
#region NCA构建逻辑 #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} " + string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
$"--type nca --ncatype program --exefsdir \"{programDir}/fs0\" " + $"--type nca --ncatype program --exefsdir \"{programDir}/fs0\" " +
$"--romfsdir \"{programDir}/fs1\" --logodir \"{programDir}/fs2\""; $"--romfsdir \"{programDir}/fs1\" --logodir \"{programDir}/fs2\"";
string output = ExecuteCommand($"{tools["hacPack"]} {args}"); string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
return ParseNCAOutput(output, "Program"); 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} " + string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
$"--type nca --ncatype control --romfsdir \"{controlDir}/fs0\""; $"--type nca --ncatype control --romfsdir \"{controlDir}/fs0\"";
string output = ExecuteCommand($"{tools["hacPack"]} {args}"); string output = ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
return ParseNCAOutput(output, "Control"); 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} " + string args = $"-k \"{prodKeysPath}\" -o \"{tmpPath}\" --titleid {titleID} " +
$"--type nca --ncatype meta --titletype application " + $"--type nca --ncatype meta --titletype application " +
$"--programnca \"{programNCA}\" --controlnca \"{controlNCA}\""; $"--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"); string outputPath = origPath.Replace(".nsp", "_repacked.nsp");
if (File.Exists(outputPath)) File.Delete(outputPath); if (File.Exists(outputPath)) File.Delete(outputPath);
@ -312,7 +350,7 @@ namespace AxibugEmuOnline.Editors
string args = $"-k \"{prodKeysPath}\" -o \"{parentDir}\" --titleid {titleID} " + string args = $"-k \"{prodKeysPath}\" -o \"{parentDir}\" --titleid {titleID} " +
$"--type nsp --ncadir \"{tmpPath}\""; $"--type nsp --ncadir \"{tmpPath}\"";
ExecuteCommand($"{tools["hacPack"]} {args}"); ExecuteCommand($"{tools["hacPack"]} {args}", workdir);
File.Move(Path.Combine(parentDir, $"{titleID}.nsp"), outputPath); File.Move(Path.Combine(parentDir, $"{titleID}.nsp"), outputPath);
return outputPath; return outputPath;
} }
@ -321,7 +359,9 @@ namespace AxibugEmuOnline.Editors
{ {
var line = output.Split('\n') var line = output.Split('\n')
.FirstOrDefault(l => l.Contains($"Created {type} NCA:")); .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 #endregion
} }

View File

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

View File

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

View File

@ -0,0 +1,41 @@
#if UNITY_SWITCH
using nn.account;
#endif
public class AxiNS
{
static AxiNS _instance;
public static AxiNS instance
{
get
{
if (_instance == null)
_instance = new AxiNS();
return _instance;
}
}
public AxiNSUser user;
public AxiNSMount mount;
public AxiNSIO io;
public AxiNSWaitHandle wait;
AxiNS()
{
user = new AxiNSUser();
mount = new AxiNSMount();
io = new AxiNSIO();
wait = new AxiNSWaitHandle();
}
/// <summary>
/// 初始化(最好在项目第一时间初始化,保证先初始化再使用某些东西,才不闪退)
/// </summary>
public void Init()
{
#if UNITY_SWITCH
if (!user.GetUserID(out Uid uid))
return;
mount.MountSave(uid);
#endif
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b8790f215d873d044aa8d00bacdee237 guid: 52541c757d45c4c488726bcc39f73ba6
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 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 fileFormatVersion: 2
guid: c29cb72b155d20a48a3a47a7a05160bd guid: 0e28b69692cb1bb4a9d8ddb91274fa50
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -0,0 +1,764 @@
#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)
{
LoadSwitchDataFile(filename, out byte[] outputData);
return outputData;
}
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
{
if (LoadSwitchDataFile(filename, out byte[] outputData))
{
using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(ms))
{
writer.Write(outputData);
}
return true;
}
return false;
}
public bool LoadSwitchDataFile(string filename, out byte[] outputData)
{
#if !UNITY_SWITCH || UNITY_EDITOR
outputData = null;
return false;
#else
outputData = null;
if (!AxiNS.instance.mount.SaveIsMount)
{
UnityEngine.Debug.LogError($"Save 尚未挂载,无法读取 {filename}");
return false;
}
if (CheckPathNotFound(filename))
return false;
nn.Result result;
result = nn.fs.File.Open(ref fileHandle, filename, nn.fs.OpenFileMode.Read);
if (result.IsSuccess() == false)
{
UnityEngine.Debug.LogError($"nn.fs.File.Open 失败 {filename} : result=>{result.GetErrorInfo()}");
return false; // Could not open file. This can be used to detect if this is the first time a user has launched your game.
// (However, be sure you are not getting this error due to your file being locked by another process, etc.)
}
UnityEngine.Debug.Log($"nn.fs.File.Open 成功 {filename}");
long iFileSize = 0;
result = nn.fs.File.GetSize(ref iFileSize, fileHandle);
if (result.IsSuccess() == false)
{
UnityEngine.Debug.LogError($"nn.fs.File.GetSize 失败 {filename} : result=>{result.GetErrorInfo()}");
return false;
}
UnityEngine.Debug.Log($"nn.fs.File.GetSize 成功 {filename},size=>{iFileSize}");
byte[] loadedData = new byte[iFileSize];
result = nn.fs.File.Read(fileHandle, 0, loadedData, iFileSize);
if (result.IsSuccess() == false)
{
UnityEngine.Debug.LogError($"nn.fs.File.Read 失败 {filename} : result=>{result.GetErrorInfo()}");
return false;
}
UnityEngine.Debug.Log($"nn.fs.File.Read 成功 {filename}");
nn.fs.File.Close(fileHandle);
//for (int i = 0; i < loadedData.Length; i++)
//{
// UnityEngine.Debug.Log($"data[{i}]:{loadedData[i]}");
//}
outputData = loadedData;
return true;
#endif
}
public AxiNSWait_LoadSwitchDataFile LoadSwitchDataFileAsync(string filename)
{
var wait = new AxiNSWait_LoadSwitchDataFile(filename);
AxiNS.instance.wait.AddWait(wait);
return wait;
}
public bool GetDirectoryFiles(string path, out string[] entrys)
{
#if !UNITY_SWITCH || UNITY_EDITOR
entrys = null;
return false;
#else
return GetDirectoryEntrys(path,nn.fs.OpenDirectoryMode.File,out entrys);
#endif
}
public bool GetDirectoryDirs(string path, out string[] entrys)
{
#if !UNITY_SWITCH || UNITY_EDITOR
entrys = null;
return false;
#else
return GetDirectoryEntrys(path, nn.fs.OpenDirectoryMode.Directory, out entrys);
#endif
}
#if UNITY_SWITCH
public bool GetDirectoryEntrys(string path, nn.fs.OpenDirectoryMode type, out string[] entrys)
{
nn.fs.DirectoryHandle eHandle = new nn.fs.DirectoryHandle();
nn.Result result = nn.fs.Directory.Open(ref eHandle, path, type);
if (nn.fs.FileSystem.ResultPathNotFound.Includes(result))
{
UnityEngine.Debug.Log($"目录 {path} 不存在");
entrys = null;
return false;
}
long entryCount = 0;
nn.fs.Directory.GetEntryCount(ref entryCount, eHandle);
nn.fs.DirectoryEntry[] entries = new nn.fs.DirectoryEntry[entryCount];
long actualEntries = 0;
nn.fs.Directory.Read(ref actualEntries, entries, eHandle, entryCount);
entrys = new string[actualEntries];
for (int i = 0; i < actualEntries; i++)
{
entrys[i] = System.IO.Path.Combine(path, entries[i].name);
}
nn.fs.Directory.Close(eHandle);
return true;
}
#endif
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 = default;
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
}
#if UNITY_SWITCH
public AxiNSWait_DeletePathDirRecursively DeletePathDirRecursivelyAsync(string filename)
{
var wait = new AxiNSWait_DeletePathDirRecursively(filename);
AxiNS.instance.wait.AddWait(wait);
return wait;
}
#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 fileFormatVersion: 2
guid: c8339ffab20bfea4cbc7d3aa440c3fdb guid: d910a015a6b6561418bdff7f2c48cffa
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

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 fileFormatVersion: 2
guid: 04e926e140ae5bc4fa46bd64067261cf guid: e28ed9d2fb16c7f42b28cafb6a2ce0ac
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -0,0 +1,119 @@
public abstract class AxiNSWaitBase : UnityEngine.CustomYieldInstruction
{
protected bool IsDone;
public abstract void Invoke();
public string errmsg = string.Empty;
public AxiNSWaitBase()
{
this.IsDone = false;
}
public void SetDone()
{
this.IsDone = true;
}
~AxiNSWaitBase()
{
}
public override bool keepWaiting
{
get { return !IsDone; }
}
}
public struct S_NSWAIT_PathWithBytes
{
public string filePath;
public byte[] data;
}
public class AxiNSWait_FileToSaveWithCreate : AxiNSWaitBase
{
S_NSWAIT_PathWithBytes req;
public bool result;
public AxiNSWait_FileToSaveWithCreate(string filePath, byte[] data)
{
req = new S_NSWAIT_PathWithBytes() { filePath = filePath, data = data };
}
public override void Invoke()
{
result = AxiNS.instance.io.FileToSaveWithCreate(req.filePath, req.data);
}
}
public struct S_NSWAIT_PathWithMS
{
public string filePath;
public System.IO.MemoryStream ms;
}
public class AxiNSWait_FileToSaveByMSWithCreate : AxiNSWaitBase
{
S_NSWAIT_PathWithMS req;
public bool result;
public AxiNSWait_FileToSaveByMSWithCreate(string filePath, System.IO.MemoryStream ms)
{
req = new S_NSWAIT_PathWithMS() { filePath = filePath, ms = ms };
}
public override void Invoke()
{
result = AxiNS.instance.io.FileToSaveWithCreate(req.filePath, req.ms);
}
}
public struct S_NSWAIT_Path
{
public string filePath;
}
public class AxiNSWait_LoadSwitchDataFile : AxiNSWaitBase
{
S_NSWAIT_Path req;
public bool result;
public byte[] outputData;
public AxiNSWait_LoadSwitchDataFile(string filePath)
{
req = new S_NSWAIT_Path() { filePath = filePath};
}
public override void Invoke()
{
result = AxiNS.instance.io.LoadSwitchDataFile(req.filePath, out outputData);
}
}
public class AxiNSWait_DeletePathFile : AxiNSWaitBase
{
S_NSWAIT_Path req;
public bool result;
public AxiNSWait_DeletePathFile(string filePath)
{
req = new S_NSWAIT_Path() { filePath = filePath };
}
public override void Invoke()
{
result = AxiNS.instance.io.DeletePathFile(req.filePath);
}
}
public class AxiNSWait_DeletePathDir : AxiNSWaitBase
{
S_NSWAIT_Path req;
public bool result;
public AxiNSWait_DeletePathDir(string filePath)
{
req = new S_NSWAIT_Path() { filePath = filePath };
}
public override void Invoke()
{
result = AxiNS.instance.io.DeletePathDir(req.filePath);
}
}

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,56 @@
using System;
using System.Collections.Generic;
using System.Threading;
public class AxiNSWaitHandle
{
static AutoResetEvent autoEvent = new AutoResetEvent(false);
static Thread waitThread = new Thread(Loop);
static bool bSingleInit = false;
static Queue<AxiNSWaitBase> m_QueueReady = new Queue<AxiNSWaitBase>();
static Queue<AxiNSWaitBase> m_QueueWork = new Queue<AxiNSWaitBase>();
public void AddWait(AxiNSWaitBase wait)
{
InitInternalThread();
lock (m_QueueReady)
{
m_QueueReady.Enqueue(wait);
}
autoEvent.Set();
}
static void InitInternalThread()
{
if (bSingleInit) return;
waitThread.Start();
bSingleInit = true;
}
static void Loop()
{
while (autoEvent.WaitOne())
{
lock (m_QueueReady)
{
while (m_QueueReady.Count > 0)
{
m_QueueWork.Enqueue(m_QueueReady.Dequeue());
}
}
while (m_QueueWork.Count > 0)
{
AxiNSWaitBase wait = m_QueueWork.Dequeue();
try
{
wait.Invoke();
}
catch (Exception ex)
{
wait.errmsg = ex.ToString();
UnityEngine.Debug.Log(ex.ToString());
}
wait.SetDone();
}
}
}
}

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); 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) if (!bNetInit)
{ {
@ -74,37 +74,27 @@ namespace AxiReplay
inputDiff = false; inputDiff = false;
return false; return false;
} }
TakeFrame(1, out data, out frameDiff, out inputDiff); return TakeFrameToTargetFrame(targetFrame, indirectGet, out data, out frameDiff, out inputDiff);
return frameDiff > 0;
} }
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); return targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx;
frameDiff = default(int); }
inputDiff = false; else
return false; {
} 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) bool TakeFrameToTargetFrame(int targetFrame, bool indirectGet, 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 result; bool result;
inputDiff = false; inputDiff = false;
if (checkCanGetFrame(targetFrame, indirectGet))
//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))
{ {
//当前帧追加 //当前帧追加
mCurrClientFrameIdx = targetFrame; mCurrClientFrameIdx = targetFrame;

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Essgee.Utilities namespace Essgee.Utilities
@ -84,21 +83,21 @@ namespace Essgee.Utilities
} }
#endregion #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); Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组 // 使用BinaryWriter写入临时数组
bw.Write(TempBuffer_src, 0, count); 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); Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组 // 使用BinaryWriter写入临时数组
fs.Write(TempBuffer_src, 0, count); 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写入临时数组 // 使用BinaryWriter写入临时数组
count = fs.Read(TempBuffer_src, offset, count); count = fs.Read(TempBuffer_src, offset, count);

View File

@ -1,5 +1,6 @@
using Essgee; using Essgee;
using Essgee.Metadata;
using System; using System;
public static class EmuStandInfo public static class EmuStandInfo
@ -8,7 +9,6 @@ public static class EmuStandInfo
//public static string datDirectoryPath; //public static string datDirectoryPath;
//public static string metadataDatabaseFilePath; //public static string metadataDatabaseFilePath;
public static string jsonConfigFileName;//= "Config.json"; public static string jsonConfigFileName;//= "Config.json";
public static string saveDataDirectoryName;//= "Saves"; public static string saveDataDirectoryName;//= "Saves";
public static string screenshotDirectoryName;//= "Screenshots"; public static string screenshotDirectoryName;//= "Screenshots";

View File

@ -131,7 +131,8 @@ namespace Essgee.Emulation.CPU
{ {
if (AppEnvironment.EnableSuperSlowCPULogger && logEntries != null) 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; logEntries[numLogEntries++] = disasm;
if (numLogEntries >= logEntries.Length) if (numLogEntries >= logEntries.Length)
{ {
System.IO.File.AppendAllText(logFile, string.Join("", logEntries)); //TODO 暂时不要日志看后续是否需要加
//System.IO.File.AppendAllText(logFile, string.Join("", logEntries));
numLogEntries = 0; numLogEntries = 0;
} }
} }

View File

@ -207,8 +207,9 @@ namespace Essgee.Emulation.CPU
if (AppEnvironment.EnableSuperSlowCPULogger) if (AppEnvironment.EnableSuperSlowCPULogger)
{ {
string disasm = string.Format("{0} | {1} | {2} | {3}\n", DisassembleOpcode(this, pc).PadRight(48), PrintRegisters(this), PrintFlags(this), PrintInterrupt(this)); //TODO 暂时不要日志看后续是否需要加
System.IO.File.AppendAllText(@"D:\Temp\Essgee\log.txt", disasm); //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 */ /* Fetch and execute opcode */

View File

@ -3,7 +3,6 @@ using Essgee.Exceptions;
using Essgee.Utilities; using Essgee.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -32,19 +31,19 @@ namespace Essgee.Emulation
Type machineType = null; Type machineType = null;
byte[] romData = null; byte[] romData = null;
if (!File.Exists(fileName)) if (!EmulatorHandler.io.File_Exists(fileName))
throw new CartridgeLoaderException($"{fileType} file not found."); throw new CartridgeLoaderException($"{fileType} file not found.");
try try
{ {
var fileExtension = Path.GetExtension(fileName); var fileExtension = System.IO.Path.GetExtension(fileName);
if (fileExtension == ".zip") if (fileExtension == ".zip")
{ {
using (var zip = ZipFile.Open(fileName, ZipArchiveMode.Read)) using (var zip = ZipFile.Open(fileName, ZipArchiveMode.Read))
{ {
foreach (var entry in zip.Entries) foreach (var entry in zip.Entries)
{ {
var entryExtension = Path.GetExtension(entry.Name); var entryExtension = System.IO.Path.GetExtension(entry.Name);
if (fileExtensionSystemDictionary.ContainsKey(entryExtension)) if (fileExtensionSystemDictionary.ContainsKey(entryExtension))
{ {
machineType = fileExtensionSystemDictionary[entryExtension]; machineType = fileExtensionSystemDictionary[entryExtension];
@ -61,7 +60,7 @@ namespace Essgee.Emulation
else if (fileExtensionSystemDictionary.ContainsKey(fileExtension)) else if (fileExtensionSystemDictionary.ContainsKey(fileExtension))
{ {
machineType = fileExtensionSystemDictionary[fileExtension]; machineType = fileExtensionSystemDictionary[fileExtension];
romData = File.ReadAllBytes(fileName); romData = System.IO.File.ReadAllBytes(fileName);
} }
} }
catch (Exception ex) when (!AppEnvironment.DebugMode) catch (Exception ex) when (!AppEnvironment.DebugMode)

View File

@ -5,7 +5,6 @@ using Essgee.Metadata;
using Essgee.Utilities; using Essgee.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading; using System.Threading;
namespace Essgee.Emulation namespace Essgee.Emulation
@ -14,6 +13,7 @@ namespace Essgee.Emulation
{ {
readonly Action<Exception> exceptionHandler; readonly Action<Exception> exceptionHandler;
public static IEssgeeIOSupport io;
public IMachine emulator { get; private set; } public IMachine emulator { get; private set; }
Thread emulationThread; Thread emulationThread;
@ -158,7 +158,7 @@ namespace Essgee.Emulation
public string GetSaveStateFilename(int number) 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) public void LoadState(int number)
@ -182,9 +182,9 @@ namespace Essgee.Emulation
byte[] ramData = new byte[currentGameMetadata.RamSize]; byte[] ramData = new byte[currentGameMetadata.RamSize];
var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav")); var savePath = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
if (File.Exists(savePath)) if (EmulatorHandler.io.File_Exists(savePath))
ramData = File.ReadAllBytes(savePath); ramData = EmulatorHandler.io.File_ReadAllBytes(savePath);
emulator.Load(romData, ramData, currentGameMetadata.MapperType); emulator.Load(romData, ramData, currentGameMetadata.MapperType);
@ -202,8 +202,8 @@ namespace Essgee.Emulation
cartRamSaveNeeded) cartRamSaveNeeded)
{ {
var ramData = emulator.GetCartridgeRam(); var ramData = emulator.GetCartridgeRam();
var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav")); var savePath = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
File.WriteAllBytes(savePath, ramData); EmulatorHandler.io.File_WriteAllBytes(savePath, ramData);
} }
} }
@ -370,28 +370,28 @@ namespace Essgee.Emulation
// } // }
//} //}
public void SaveSnapShotToFile(int stateNumber) //public void SaveSnapShotToFile(int stateNumber)
{ //{
var statePath = GetSaveStateFilename(stateNumber); // var statePath = GetSaveStateFilename(stateNumber);
using (var stream = new FileStream(statePath, FileMode.OpenOrCreate)) // using (var stream = new FileStream(statePath, FileMode.OpenOrCreate))
{ // {
//SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.GetState()); // //SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.GetState());
SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.SaveAxiStatus()); // SaveStateHandler.Save(stream, emulator.GetType().Name, emulator.SaveAxiStatus());
} // }
} //}
public void LoadSnapShotFromFile(int stateNumber) //public void LoadSnapShotFromFile(int stateNumber)
{ //{
var statePath = GetSaveStateFilename(stateNumber); // var statePath = GetSaveStateFilename(stateNumber);
if (File.Exists(statePath)) // if (File.Exists(statePath))
{ // {
using (var stream = new FileStream(statePath, FileMode.Open)) // using (var stream = new FileStream(statePath, FileMode.Open))
{ // {
//emulator.SetState(SaveStateHandler.Load(stream, emulator.GetType().Name)); // //emulator.SetState(SaveStateHandler.Load(stream, emulator.GetType().Name));
emulator.LoadAxiStatus(SaveStateHandler.LoadAxiStatus(stream, emulator.GetType().Name)); // emulator.LoadAxiStatus(SaveStateHandler.LoadAxiStatus(stream, emulator.GetType().Name));
} // }
} // }
} //}
public byte[] GetStateData() public byte[] GetStateData()
{ {

View File

@ -1,7 +1,6 @@
using Essgee.EventArguments; using Essgee.EventArguments;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.IO.MemoryMappedFiles; using System.IO.MemoryMappedFiles;
namespace Essgee.Emulation.ExtDevices.Nintendo namespace Essgee.Emulation.ExtDevices.Nintendo
@ -64,7 +63,7 @@ namespace Essgee.Emulation.ExtDevices.Nintendo
ipcOffsetSelf = ipcBaseOffsetSerialData + 1; ipcOffsetSelf = ipcBaseOffsetSerialData + 1;
ipcOffsetRemote = ipcBaseOffsetSerialData + 0; ipcOffsetRemote = ipcBaseOffsetSerialData + 0;
} }
catch (FileNotFoundException) catch (Exception ex)
{ {
// Mapped file does not yet exist, create file and assume this instance is first machine // Mapped file does not yet exist, create file and assume this instance is first machine
mmf = MemoryMappedFile.CreateOrOpen(ipcName, ipcLength); mmf = MemoryMappedFile.CreateOrOpen(ipcName, ipcLength);

View File

@ -10,7 +10,6 @@ using Essgee.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
namespace Essgee.Emulation.Machines namespace Essgee.Emulation.Machines
@ -365,9 +364,22 @@ namespace Essgee.Emulation.Machines
irDatabaseCurrentIndex = irCycles = 0; irDatabaseCurrentIndex = irCycles = 0;
irExternalTransferActive = false; 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]; irDatabase = new ushort[reader.BaseStream.Length / 2];
for (var i = 0; i < irDatabase.Length; i++) 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 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 */ /* Check CRC32 */
using (var stateStream = new MemoryStream()) using (var stateStream = new System.IO.MemoryStream())
{ {
reader.BaseStream.CopyTo(stateStream); reader.BaseStream.CopyTo(stateStream);
return stateStream.ToArray().ToAxiEssgssStatusData(); return stateStream.ToArray().ToAxiEssgssStatusData();
@ -102,11 +100,11 @@ namespace Essgee.Emulation
// } // }
//} //}
public static void Save(Stream stream, string machineName, AxiEssgssStatusData state) //public static void Save(Stream stream, string machineName, AxiEssgssStatusData state)
{ //{
byte[] data = state.ToByteArray(); // byte[] data = state.ToByteArray();
stream.Write(data, 0, data.Length); // stream.Write(data, 0, data.Length);
} //}
//private static string GenerateMachineIdString(string machineId) //private static string GenerateMachineIdString(string machineId)
//{ //{
// return machineId.Substring(0, Math.Min(machineId.Length, 16)).PadRight(16); // return machineId.Substring(0, Math.Min(machineId.Length, 16)).PadRight(16);

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -20,7 +19,7 @@ namespace Essgee.Extensions
public static string ReadEmbeddedTextFile(this Assembly assembly, string resourceName) 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(); return reader.ReadToEnd();
} }

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable] [Serializable]
public class AxiEssgssStatusData public class AxiEssgssStatusData

View File

@ -2,7 +2,6 @@
using Essgee.Exceptions; using Essgee.Exceptions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Serialization; using System.Xml.Serialization;
@ -17,6 +16,15 @@ namespace Essgee.Metadata
public bool GetDatBytes(string DatName, out byte[] loadedData); 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 class GameMetadataHandler
{ {
public static GameMetadataHandler instance; public static GameMetadataHandler instance;
@ -24,6 +32,8 @@ namespace Essgee.Metadata
//static string metadataDatabaseFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "MetadataDatabase.json"); //static string metadataDatabaseFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "MetadataDatabase.json");
public IGameMetaReources gameMetaReources; public IGameMetaReources gameMetaReources;
public IEssgeeIOSupport uegIO;
//readonly Dictionary<string, DatFile> datFiles; //readonly Dictionary<string, DatFile> datFiles;
readonly List<CartridgeJSON> cartMetadataDatabase; readonly List<CartridgeJSON> cartMetadataDatabase;
@ -379,7 +389,7 @@ namespace Essgee.Metadata
XmlSerializer serializer; XmlSerializer serializer;
root = new XmlRootAttribute("datafile") { IsNullable = true }; root = new XmlRootAttribute("datafile") { IsNullable = true };
serializer = new XmlSerializer(typeof(DatFile), root); 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); datFile = (DatFile)serializer.Deserialize(stream);
} }
@ -396,7 +406,7 @@ namespace Essgee.Metadata
/* Create game metadata */ /* Create game metadata */
var gameMetadata = new GameMetadata() var gameMetadata = new GameMetadata()
{ {
FileName = Path.GetFileName(romFilename), FileName = System.IO.Path.GetFileName(romFilename),
KnownName = gameInfo?.Name, KnownName = gameInfo?.Name,
RomCrc32 = romCrc32, RomCrc32 = romCrc32,
RomSize = romSize RomSize = romSize

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace Essgee.Utilities 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"); if ((segmentStart + segmentLength) > dataLength) throw new Crc32Exception("Segment end offset is greater than total length");
} }
public static uint Calculate(FileInfo fileInfo) //public static uint Calculate(FileInfo fileInfo)
{ //{
return Calculate(fileInfo, 0, (int)fileInfo.Length); // return Calculate(fileInfo, 0, (int)fileInfo.Length);
} //}
public static uint Calculate(FileInfo fileInfo, int start, int length) //public static uint Calculate(FileInfo fileInfo, int start, int length)
{ //{
VerifyStartAndLength((int)fileInfo.Length, start, length); // VerifyStartAndLength((int)fileInfo.Length, start, length);
using (FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) // using (FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{ // {
return Calculate(file, start, length); // return Calculate(file, start, length);
} // }
} //}
public static uint Calculate(Stream stream) //public static uint Calculate(Stream stream)
{ //{
return Calculate(stream, 0, (int)stream.Length); // return Calculate(stream, 0, (int)stream.Length);
} //}
public static uint Calculate(Stream stream, int start, int length) //public static uint Calculate(Stream stream, int start, int length)
{ //{
VerifyStartAndLength((int)stream.Length, start, 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]; // byte[] data = new byte[length];
stream.Position = start; // stream.Position = start;
stream.Read(data, 0, length); // stream.Read(data, 0, length);
crc = Calculate(data, 0, data.Length); // crc = Calculate(data, 0, data.Length);
stream.Position = lastStreamPosition; // stream.Position = lastStreamPosition;
return crc; // return crc;
} //}
public static uint Calculate(byte[] data) public static uint Calculate(byte[] data)
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading; using System.Threading;
namespace MAME.Core namespace MAME.Core
@ -25,8 +24,9 @@ namespace MAME.Core
ISoundPlayer isp, ISoundPlayer isp,
IKeyboard ikb, IKeyboard ikb,
IMouse imou, IMouse imou,
ITimeSpan itime ITimeSpan itime,
) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime); IMAMEIOSupport io
) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime,io);
public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir); public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir);
@ -40,7 +40,7 @@ namespace MAME.Core
public void StopGame() => mameMainMotion.StopGame(); public void StopGame() => mameMainMotion.StopGame();
public long currEmuFrame => Video.screenstate.frame_number; public long currEmuFrame => Video.screenstate.frame_number;
public bool IsPaused => Mame.paused; public bool IsPaused => Mame.paused;
public void LoadState(BinaryReader sr) public void LoadState(System.IO.BinaryReader sr)
{ {
Mame.paused = true; Mame.paused = true;
Thread.Sleep(20); Thread.Sleep(20);
@ -51,7 +51,7 @@ namespace MAME.Core
Mame.paused = false; Mame.paused = false;
} }
public void SaveState(BinaryWriter sw) public void SaveState(System.IO.BinaryWriter sw)
{ {
Mame.paused = true; Mame.paused = true;
Thread.Sleep(20); Thread.Sleep(20);

View File

@ -21,6 +21,7 @@ namespace MAME.Core
public AutoResetEvent emuAutoLoopEvent; public AutoResetEvent emuAutoLoopEvent;
public static IResources resource; public static IResources resource;
public static IMAMEIOSupport IoSupport;
public bool bRom => Machine.bRom; public bool bRom => Machine.bRom;
public MameMainMotion() public MameMainMotion()
@ -42,7 +43,8 @@ namespace MAME.Core
ISoundPlayer isp, ISoundPlayer isp,
IKeyboard ikb, IKeyboard ikb,
IMouse imou, IMouse imou,
ITimeSpan itime ITimeSpan itime,
IMAMEIOSupport io
) )
{ {
AxiMemoryEx.Init(); AxiMemoryEx.Init();
@ -54,6 +56,7 @@ namespace MAME.Core
Video.BindFunc(ivp); Video.BindFunc(ivp);
Sound.BindFunc(isp); Sound.BindFunc(isp);
resource = iRes; resource = iRes;
IoSupport = io;
sSelect = string.Empty; sSelect = string.Empty;

View File

@ -1,7 +1,5 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
//using System.IO;
namespace cpu.m6502 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(subtype);
writer.Write(ppc.LowWord); writer.Write(ppc.LowWord);
@ -250,7 +248,7 @@ namespace cpu.m6502
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
subtype = reader.ReadByte(); subtype = reader.ReadByte();
ppc.LowWord = reader.ReadUInt16(); ppc.LowWord = reader.ReadUInt16();

View File

@ -1,6 +1,5 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
namespace cpu.m6800 namespace cpu.m6800
{ {
@ -1216,7 +1215,7 @@ namespace cpu.m6800
break; break;
} }
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(PPC.LowWord); writer.Write(PPC.LowWord);
writer.Write(PC.LowWord); writer.Write(PC.LowWord);
@ -1260,7 +1259,7 @@ namespace cpu.m6800
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
PPC.LowWord = reader.ReadUInt16(); PPC.LowWord = reader.ReadUInt16();
PC.LowWord = reader.ReadUInt16(); PC.LowWord = reader.ReadUInt16();

View File

@ -1,7 +1,6 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace cpu.m68000 namespace cpu.m68000
@ -275,7 +274,7 @@ namespace cpu.m68000
// return a + b + c + d; // return a + b + c + d;
//} //}
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 0x08; i++) for (i = 0; i < 0x08; i++)
@ -304,7 +303,7 @@ namespace cpu.m68000
writer.Write(MC68000.m1.TotalExecutedCycles); writer.Write(MC68000.m1.TotalExecutedCycles);
writer.Write(MC68000.m1.PendingCycles); writer.Write(MC68000.m1.PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 0x08; i++) for (i = 0; i < 0x08; i++)
@ -333,7 +332,7 @@ namespace cpu.m68000
MC68000.m1.TotalExecutedCycles = reader.ReadUInt64(); MC68000.m1.TotalExecutedCycles = reader.ReadUInt64();
MC68000.m1.PendingCycles = reader.ReadInt32(); 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("[{0}]", id);
writer.WriteLine("D0 {0:X8}", D[0].s32); writer.WriteLine("D0 {0:X8}", D[0].s32);
@ -370,7 +369,7 @@ namespace cpu.m68000
writer.WriteLine("[/{0}]", id); writer.WriteLine("[/{0}]", id);
} }
public void LoadStateText(TextReader reader, string id) public void LoadStateText(System.IO.TextReader reader, string id)
{ {
while (true) while (true)
{ {

View File

@ -1,6 +1,5 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
namespace cpu.m6805 namespace cpu.m6805
{ {
@ -831,7 +830,7 @@ namespace cpu.m6805
while (pendingCycles > 0); while (pendingCycles > 0);
return cycles - pendingCycles; return cycles - pendingCycles;
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(ea.LowWord); writer.Write(ea.LowWord);
@ -850,7 +849,7 @@ namespace cpu.m6805
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
ea.LowWord = reader.ReadUInt16(); ea.LowWord = reader.ReadUInt16();

View File

@ -1,6 +1,5 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
namespace cpu.m6809 namespace cpu.m6809
{ {
@ -861,7 +860,7 @@ namespace cpu.m6809
case 0xff: EA = IMMWORD(); EA.d = RM16(EA.LowWord); pendingCycles -= 8; break; 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(PC.LowWord);
writer.Write(PPC.LowWord); writer.Write(PPC.LowWord);
@ -879,7 +878,7 @@ namespace cpu.m6809
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
PC.LowWord = reader.ReadUInt16(); PC.LowWord = reader.ReadUInt16();
PPC.LowWord = reader.ReadUInt16(); PPC.LowWord = reader.ReadUInt16();

View File

@ -1,6 +1,5 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
namespace cpu.nec namespace cpu.nec
{ {
@ -1190,7 +1189,7 @@ namespace cpu.nec
nec_interrupt(-1, false); nec_interrupt(-1, false);
} }
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(I.regs.b, 0, 16); writer.Write(I.regs.b, 0, 16);
@ -1220,7 +1219,7 @@ namespace cpu.nec
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
I.regs.b = reader.ReadBytes(16); I.regs.b = reader.ReadBytes(16);

View File

@ -1,7 +1,6 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO;
// This Z80 emulator is a modified version of Ben Ryves 'Brazil' emulator. // This Z80 emulator is a modified version of Ben Ryves 'Brazil' emulator.
// It is MIT licensed. // It is MIT licensed.
@ -133,7 +132,7 @@ namespace cpu.z80
// State Save/Load // State Save/Load
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(PPC); writer.Write(PPC);
writer.Write(RegisterAF); writer.Write(RegisterAF);
@ -162,7 +161,7 @@ namespace cpu.z80
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
PPC = reader.ReadUInt16(); PPC = reader.ReadUInt16();
RegisterAF = reader.ReadUInt16(); RegisterAF = reader.ReadUInt16();
@ -191,7 +190,7 @@ namespace cpu.z80
TotalExecutedCycles = reader.ReadUInt64(); TotalExecutedCycles = reader.ReadUInt64();
PendingCycles = reader.ReadInt32(); PendingCycles = reader.ReadInt32();
} }
public void SaveStateText(TextWriter writer) public void SaveStateText(System.IO.TextWriter writer)
{ {
writer.WriteLine("[Z80]"); writer.WriteLine("[Z80]");
writer.WriteLine("AF {0:X4}", RegAF.Word); writer.WriteLine("AF {0:X4}", RegAF.Word);
@ -221,7 +220,7 @@ namespace cpu.z80
writer.WriteLine(); writer.WriteLine();
} }
public void LoadStateText(TextReader reader) public void LoadStateText(System.IO.TextReader reader)
{ {
while (true) while (true)
{ {

View File

@ -6,7 +6,6 @@ using cpu.m6809;
using cpu.nec; using cpu.nec;
using cpu.z80; using cpu.z80;
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -2808,7 +2807,7 @@ namespace MAME.Core
if (perfect_interleave.attoseconds == Attotime.ATTOSECONDS_PER_SECOND - 1) if (perfect_interleave.attoseconds == Attotime.ATTOSECONDS_PER_SECOND - 1)
perfect_interleave.attoseconds = cpu[0].attoseconds_per_cycle; perfect_interleave.attoseconds = cpu[0].attoseconds_per_cycle;
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)
@ -2822,7 +2821,7 @@ namespace MAME.Core
writer.Write(Cpuexec.cpu[i].localtime.attoseconds); writer.Write(Cpuexec.cpu[i].localtime.attoseconds);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -262,7 +260,7 @@ namespace MAME.Core
{ {
return cpu_irq_callback(3, line); 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; int i, n;
n = lvec.Count; n = lvec.Count;
@ -280,7 +278,7 @@ namespace MAME.Core
writer.Write((long)0); writer.Write((long)0);
} }
} }
public static void LoadStateBinary_v(BinaryReader reader) public static void LoadStateBinary_v(System.IO.BinaryReader reader)
{ {
int i, n; int i, n;
n = reader.ReadInt32(); n = reader.ReadInt32();
@ -299,7 +297,7 @@ namespace MAME.Core
reader.ReadInt64(); reader.ReadInt64();
} }
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j, n; int i, j, n;
n = lirq.Count; 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; int i, j, n;
n = reader.ReadInt32(); n = reader.ReadInt32();

View File

@ -1,6 +1,4 @@
using System.IO; namespace MAME.Core
namespace MAME.Core
{ {
/*public enum eeprom_command /*public enum eeprom_command
{ {
@ -378,7 +376,7 @@ namespace MAME.Core
} }
clock_line = state; clock_line = state;
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(eeprom_data); writer.Write(eeprom_data);
writer.Write(serial_buffer); writer.Write(serial_buffer);
@ -393,7 +391,7 @@ namespace MAME.Core
writer.Write(eeprom_data_bits); writer.Write(eeprom_data_bits);
writer.Write(eeprom_read_address); writer.Write(eeprom_read_address);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
eeprom_data = reader.ReadBytes(0x80); eeprom_data = reader.ReadBytes(0x80);
serial_buffer = reader.ReadBytes(40); serial_buffer = reader.ReadBytes(40);

View File

@ -1,7 +1,6 @@
using cpu.m6800; using cpu.m6800;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -642,7 +641,7 @@ namespace MAME.Core
{ {
return Attotime.attotime_sub(which.expire, get_current_time()); 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; int i, i1, n;
n = lt.Count; n = lt.Count;
@ -673,7 +672,7 @@ namespace MAME.Core
writer.Write((long)0); writer.Write((long)0);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, i1, n; int i, i1, n;
n = reader.ReadInt32(); n = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -264,10 +263,12 @@ namespace MAME.Core
{ {
byte[] bb1; byte[] bb1;
string path = System.IO.Path.Combine(Mame.RomRoot + "/neogeo/", sFile); 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}"); 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); //FileStream fs1 = new FileStream(path, FileMode.Open);
//int n1 = (int)fs1.Length; //int n1 = (int)fs1.Length;
//bb1 = new byte[n1]; //bb1 = new byte[n1];
@ -286,10 +287,10 @@ namespace MAME.Core
foreach (string s1 in lsParents) foreach (string s1 in lsParents)
{ {
string path = System.IO.Path.Combine(Mame.RomRoot + "/" + s1 + "/", sFile); 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}"); EmuLogger.Log($"Had File => {path}");
return File.ReadAllBytes(path); return MameMainMotion.IoSupport.File_ReadAllBytes(path);
} }
else else
{ {

View File

@ -1,6 +1,4 @@
using MAME.Core; 
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class Mame public class Mame
@ -23,8 +21,8 @@ namespace MAME.Core
public static bool paused; public static bool paused;
public static bool exit_pending; public static bool exit_pending;
public static EmuTimer.emu_timer soft_reset_timer; public static EmuTimer.emu_timer soft_reset_timer;
public static BinaryReader brRecord = null; public static System.IO.BinaryReader brRecord = null;
public static BinaryWriter bwRecord = null; public static System.IO.BinaryWriter bwRecord = null;
public static bool bPP = true; public static bool bPP = true;
public static string RomRoot = string.Empty; public static string RomRoot = string.Empty;
public class AA public class AA
@ -42,7 +40,6 @@ namespace MAME.Core
new AA(6547,"2"), new AA(6547,"2"),
new AA(13955,"3") new AA(13955,"3")
}; };
private static FileStream fsRecord = null;
public static void mame_execute() public static void mame_execute()
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -488,26 +487,26 @@ namespace MAME.Core
} }
#endregion #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); int singlesize = sizeof(byte);
long totalBytesToCopy = count * singlesize; long totalBytesToCopy = count * singlesize;
Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy); Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy);
bw.Write(TempBuffer_src, 0, count); bw.Write(TempBuffer_src, 0, count);
} }
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count) //public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
{ //{
int singlesize = sizeof(byte); // int singlesize = sizeof(byte);
long totalBytesToCopy = count * singlesize; // long totalBytesToCopy = count * singlesize;
Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy); // Buffer.MemoryCopy(&bufferPtr[offset], TempBuffer, totalBytesToCopy, totalBytesToCopy);
fs.Write(TempBuffer_src, 0, count); // fs.Write(TempBuffer_src, 0, count);
} //}
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count) //public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
{ //{
count = fs.Read(TempBuffer_src, offset, count); // count = fs.Read(TempBuffer_src, offset, count);
Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count); // Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count);
return count; // return count;
} //}
} }
public unsafe static class AxiArray public unsafe static class AxiArray

View File

@ -1,6 +1,4 @@
using System.IO; namespace MAME.Core
namespace MAME.Core
{ {
public class Pd4900a public class Pd4900a
{ {
@ -312,7 +310,7 @@ namespace MAME.Core
{ {
pd4990a_serial_control((byte)(data & 0x7)); 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.seconds);
writer.Write(pd4990a.minutes); writer.Write(pd4990a.minutes);
@ -334,7 +332,7 @@ namespace MAME.Core
writer.Write(clock_line); writer.Write(clock_line);
writer.Write(command_line); writer.Write(command_line);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
pd4990a.seconds = reader.ReadInt32(); pd4990a.seconds = reader.ReadInt32();
pd4990a.minutes = 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 class State
{ {
public delegate void savestate_delegate(BinaryWriter sw); public delegate void savestate_delegate(System.IO.BinaryWriter sw);
public delegate void loadstate_delegate(BinaryReader sr); public delegate void loadstate_delegate(System.IO.BinaryReader sr);
public static savestate_delegate savestate_callback; public static savestate_delegate savestate_callback;
public static loadstate_delegate loadstate_callback; public static loadstate_delegate loadstate_callback;
public static void state_init() public static void state_init()

View File

@ -1,6 +1,4 @@
using MAME.Core; using System;
using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -1102,7 +1100,7 @@ namespace MAME.Core
{ {
return flip_screen_x; return flip_screen_x;
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(scanline_param); writer.Write(scanline_param);
writer.Write(screenstate.last_partial_scan); writer.Write(screenstate.last_partial_scan);
@ -1112,7 +1110,7 @@ namespace MAME.Core
writer.Write(screenstate.vblank_end_time.attoseconds); writer.Write(screenstate.vblank_end_time.attoseconds);
writer.Write(screenstate.frame_number); writer.Write(screenstate.frame_number);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
scanline_param = reader.ReadInt32(); scanline_param = reader.ReadInt32();
screenstate.last_partial_scan = reader.ReadInt32(); screenstate.last_partial_scan = reader.ReadInt32();

View File

@ -1,13 +1,12 @@
using cpu.m68000; using cpu.m68000;
using cpu.m6809; using cpu.m6809;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Capcom public unsafe partial class Capcom
{ {
public static void SaveStateBinary_gng(BinaryWriter writer) public static void SaveStateBinary_gng(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(bytedsw1); writer.Write(bytedsw1);
@ -53,7 +52,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
bytedsw1 = reader.ReadByte(); bytedsw1 = reader.ReadByte();
@ -99,7 +98,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -148,7 +147,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadUInt16(); dsw1 = reader.ReadUInt16();

View File

@ -1,12 +1,11 @@
using cpu.m68000; using cpu.m68000;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class CPS public unsafe partial class CPS
{ {
public static void SaveStateBinaryC(BinaryWriter writer) public static void SaveStateBinaryC(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dswa); writer.Write(dswa);
@ -76,7 +75,7 @@ namespace MAME.Core
break; break;
} }
} }
public static void SaveStateBinaryQ(BinaryWriter writer) public static void SaveStateBinaryQ(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dswa); writer.Write(dswa);
@ -126,7 +125,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void SaveStateBinaryC2(BinaryWriter writer) public static void SaveStateBinaryC2(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(basebanksnd); writer.Write(basebanksnd);
@ -191,7 +190,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinaryC(BinaryReader reader) public static void LoadStateBinaryC(System.IO.BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();
@ -261,7 +260,7 @@ namespace MAME.Core
break; break;
} }
} }
public static void LoadStateBinaryQ(BinaryReader reader) public static void LoadStateBinaryQ(System.IO.BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();
@ -309,7 +308,7 @@ namespace MAME.Core
Sound.mixerstream.output_base_sampindex = reader.ReadInt32(); Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
Eeprom.LoadStateBinary(reader); Eeprom.LoadStateBinary(reader);
} }
public static void LoadStateBinaryC2(BinaryReader reader) public static void LoadStateBinaryC2(System.IO.BinaryReader reader)
{ {
int i; int i;
basebanksnd = reader.ReadInt32(); basebanksnd = reader.ReadInt32();

View File

@ -1,11 +1,10 @@
using cpu.m6502; using cpu.m6502;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Dataeast public unsafe partial class Dataeast
{ {
public static void SaveStateBinary_pcktgal(BinaryWriter writer) public static void SaveStateBinary_pcktgal(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw); writer.Write(dsw);
@ -48,7 +47,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw = reader.ReadByte(); dsw = reader.ReadByte();

View File

@ -1,11 +1,10 @@
using cpu.m68000; using cpu.m68000;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class IGS011 public unsafe partial class IGS011
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)
@ -74,7 +73,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i, j;
for (i = 0; i < 0x800; i++) 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 public unsafe partial class Konami68000
{ {
@ -409,7 +407,7 @@ namespace MAME.Core
{ {
return K052109_irq_enabled; return K052109_irq_enabled;
} }
public static void SaveStateBinary_K052109(BinaryWriter writer) public static void SaveStateBinary_K052109(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(K052109_ram, 0, 0x6000); writer.Write(K052109_ram, 0, 0x6000);
@ -430,7 +428,7 @@ namespace MAME.Core
writer.Write(has_extra_video_ram); writer.Write(has_extra_video_ram);
writer.Write(K052109_tileflip_enable); writer.Write(K052109_tileflip_enable);
} }
public static void LoadStateBinary_K052109(BinaryReader reader) public static void LoadStateBinary_K052109(System.IO.BinaryReader reader)
{ {
int i; int i;
K052109_ram = reader.ReadBytes(0x6000); K052109_ram = reader.ReadBytes(0x6000);
@ -451,7 +449,7 @@ namespace MAME.Core
has_extra_video_ram = reader.ReadByte(); has_extra_video_ram = reader.ReadByte();
K052109_tileflip_enable = reader.ReadInt32(); 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; int i;
reader.ReadBytes(0x6000); 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_romoffset);
writer.Write(K051960_spriteflip); writer.Write(K051960_spriteflip);
@ -734,7 +732,7 @@ namespace MAME.Core
writer.Write(K051960_irq_enabled); writer.Write(K051960_irq_enabled);
writer.Write(K051960_nmi_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_romoffset = reader.ReadInt32();
K051960_spriteflip = reader.ReadInt32(); K051960_spriteflip = reader.ReadInt32();
@ -746,7 +744,7 @@ namespace MAME.Core
K051960_irq_enabled = reader.ReadInt32(); K051960_irq_enabled = reader.ReadInt32();
K051960_nmi_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();
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; int i;
writer.Write(K05324x_z_rejection); writer.Write(K05324x_z_rejection);
@ -1104,7 +1102,7 @@ namespace MAME.Core
writer.Write(K053244_regs[0], 0, 0x10); writer.Write(K053244_regs[0], 0, 0x10);
writer.Write(K054000_ram, 0, 0x20); writer.Write(K054000_ram, 0, 0x20);
} }
public static void LoadStateBinary_K053245(BinaryReader reader) public static void LoadStateBinary_K053245(System.IO.BinaryReader reader)
{ {
int i; int i;
K05324x_z_rejection = reader.ReadInt32(); K05324x_z_rejection = reader.ReadInt32();
@ -1228,7 +1226,7 @@ namespace MAME.Core
K053936_offset[chip][0] = xoffs; K053936_offset[chip][0] = xoffs;
K053936_offset[chip][1] = yoffs; K053936_offset[chip][1] = yoffs;
} }
public static void SaveStateBinary_K053936(BinaryWriter writer) public static void SaveStateBinary_K053936(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -1251,7 +1249,7 @@ namespace MAME.Core
writer.Write(K053936_wraparound[i]); writer.Write(K053936_wraparound[i]);
} }
} }
public static void LoadStateBinary_K053936(BinaryReader reader) public static void LoadStateBinary_K053936(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -1373,7 +1371,7 @@ namespace MAME.Core
{ {
return K053251_palette_index[ci]; return K053251_palette_index[ci];
} }
public static void SaveStateBinary_K053251(BinaryWriter writer) public static void SaveStateBinary_K053251(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(K053251_ram); writer.Write(K053251_ram);
@ -1383,7 +1381,7 @@ namespace MAME.Core
} }
writer.Write(K053251_tilemaps_set); writer.Write(K053251_tilemaps_set);
} }
public static void LoadStateBinary_K053251(BinaryReader reader) public static void LoadStateBinary_K053251(System.IO.BinaryReader reader)
{ {
int i; int i;
K053251_ram = reader.ReadBytes(0x10); K053251_ram = reader.ReadBytes(0x10);
@ -1393,7 +1391,7 @@ namespace MAME.Core
} }
K053251_tilemaps_set = reader.ReadInt32(); 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; int i;
reader.ReadBytes(0x10); reader.ReadBytes(0x10);

View File

@ -1,12 +1,11 @@
using cpu.m68000; using cpu.m68000;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Konami68000 public unsafe partial class Konami68000
{ {
public static void SaveStateBinary_cuebrick(BinaryWriter writer) public static void SaveStateBinary_cuebrick(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -62,7 +61,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -118,7 +117,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -180,7 +179,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -242,7 +241,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -314,7 +313,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -386,7 +385,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -439,7 +438,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -492,7 +491,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -545,7 +544,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -598,7 +597,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(bytee); writer.Write(bytee);
@ -650,7 +649,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinary_blswhstl(BinaryReader reader) public static void LoadStateBinary_blswhstl(System.IO.BinaryReader reader)
{ {
int i; int i;
bytee = reader.ReadByte(); bytee = reader.ReadByte();
@ -702,7 +701,7 @@ namespace MAME.Core
Sound.mixerstream.output_base_sampindex = reader.ReadInt32(); Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
Eeprom.LoadStateBinary(reader); Eeprom.LoadStateBinary(reader);
} }
public static void SaveStateBinary_glfgreat(BinaryWriter writer) public static void SaveStateBinary_glfgreat(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -753,7 +752,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -804,7 +803,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -860,7 +859,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinary_tmnt2(BinaryReader reader) public static void LoadStateBinary_tmnt2(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -916,7 +915,7 @@ namespace MAME.Core
Sound.mixerstream.output_base_sampindex = reader.ReadInt32(); Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
Eeprom.LoadStateBinary(reader); Eeprom.LoadStateBinary(reader);
} }
public static void SaveStateBinary_ssriders(BinaryWriter writer) public static void SaveStateBinary_ssriders(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(init_eeprom_count); writer.Write(init_eeprom_count);
@ -968,7 +967,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinary_ssriders(BinaryReader reader) public static void LoadStateBinary_ssriders(System.IO.BinaryReader reader)
{ {
int i; int i;
init_eeprom_count = reader.ReadInt32(); init_eeprom_count = reader.ReadInt32();
@ -1020,7 +1019,7 @@ namespace MAME.Core
Sound.mixerstream.output_base_sampindex = reader.ReadInt32(); Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
Eeprom.LoadStateBinary(reader); Eeprom.LoadStateBinary(reader);
} }
public static void SaveStateBinary_thndrx2(BinaryWriter writer) public static void SaveStateBinary_thndrx2(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(bytee); writer.Write(bytee);
@ -1072,7 +1071,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinary_thndrx2(BinaryReader reader) public static void LoadStateBinary_thndrx2(System.IO.BinaryReader reader)
{ {
int i; int i;
bytee = reader.ReadByte(); bytee = reader.ReadByte();
@ -1124,7 +1123,7 @@ namespace MAME.Core
Sound.mixerstream.output_base_sampindex = reader.ReadInt32(); Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
Eeprom.LoadStateBinary(reader); Eeprom.LoadStateBinary(reader);
} }
public static void SaveStateBinary_prmrsocr(BinaryWriter writer) public static void SaveStateBinary_prmrsocr(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(basebanksnd); writer.Write(basebanksnd);
@ -1182,7 +1181,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
} }
public static void LoadStateBinary_prmrsocr(BinaryReader reader) public static void LoadStateBinary_prmrsocr(System.IO.BinaryReader reader)
{ {
int i; int i;
basebanksnd = reader.ReadInt32(); basebanksnd = reader.ReadInt32();

View File

@ -1,12 +1,11 @@
using cpu.nec; using cpu.nec;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class M72 public unsafe partial class M72
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw); writer.Write(dsw);
@ -68,7 +67,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
dsw = reader.ReadUInt16(); dsw = reader.ReadUInt16();

View File

@ -1,11 +1,10 @@
using cpu.nec; using cpu.nec;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class M92 public unsafe partial class M92
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dsw); writer.Write(dsw);
@ -82,7 +81,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i, j;
dsw = reader.ReadUInt16(); dsw = reader.ReadUInt16();

View File

@ -1,12 +1,11 @@
using cpu.m6800; using cpu.m6800;
using cpu.m6809; using cpu.m6809;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Namcos1 public unsafe partial class Namcos1
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dipsw); writer.Write(dipsw);
@ -73,7 +72,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i, j;
dipsw = reader.ReadByte(); dipsw = reader.ReadByte();

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -376,19 +375,27 @@ namespace MAME.Core
public static void nvram_handler_load_neogeo() 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); MameMainMotion.IoSupport.File_ReadAllBytes("nvram\\" + Machine.sName + ".nv");
int n = (int)fs1.Length; //FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
fs1.Read(mainram2, 0, n); //int n = (int)fs1.Length;
fs1.Close(); //fs1.Read(mainram2, 0, n);
//fs1.Close();
} }
} }
public static void nvram_handler_save_neogeo() public static void nvram_handler_save_neogeo()
{ {
FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create); //FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create);
fs1.Write(mainram2, 0, 0x2000); //fs1.Write(mainram2, 0, 0x2000);
fs1.Close(); //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() public static void machine_reset_neogeo()
{ {

View File

@ -1,12 +1,11 @@
using cpu.m68000; using cpu.m68000;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Neogeo public unsafe partial class Neogeo
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dsw); writer.Write(dsw);
@ -77,7 +76,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_base_sampindex); writer.Write(Sound.mixerstream.output_base_sampindex);
Pd4900a.SaveStateBinary(writer); Pd4900a.SaveStateBinary(writer);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
dsw = reader.ReadByte(); dsw = reader.ReadByte();

View File

@ -1,12 +1,11 @@
using cpu.m68000; using cpu.m68000;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class PGM public unsafe partial class PGM
{ {
public unsafe static void SaveStateBinary(BinaryWriter writer) public unsafe static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(pgm_tx_videoram, 0, 0x2000); 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_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i, j;
pgm_tx_videoram = reader.ReadBytes(0x2000); 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 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.m68000;
using cpu.m6805; using cpu.m6805;
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Taito public unsafe partial class Taito
{ {
public static void SaveStateBinary_tokio(BinaryWriter writer) public static void SaveStateBinary_tokio(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -57,7 +56,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -106,7 +105,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -170,7 +169,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -234,7 +233,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -288,7 +287,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -341,7 +340,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -399,7 +398,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -457,7 +456,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32(); Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_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; int i;
writer.Write(dswa); writer.Write(dswa);
@ -594,7 +593,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();

View File

@ -1,13 +1,11 @@
using cpu.m68000; using cpu.m68000;
using cpu.z80; using cpu.z80;
using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe partial class Taitob public unsafe partial class Taitob
{ {
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
//pixel_scroll //pixel_scroll
int i; int i;
@ -97,7 +95,7 @@ namespace MAME.Core
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
Taitosnd.SaveStateBinary(writer); Taitosnd.SaveStateBinary(writer);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();

View File

@ -1,11 +1,10 @@
using cpu.z80; using cpu.z80;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public partial class Tehkan public partial class Tehkan
{ {
public unsafe static void SaveStateBinary_pbaction(BinaryWriter writer) public unsafe static void SaveStateBinary_pbaction(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -46,7 +45,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex); writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_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; int i;
dsw1 = reader.ReadByte(); 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 namespace MAME.Core
{ {
public unsafe class AY8910 public unsafe class AY8910
@ -558,7 +557,7 @@ namespace MAME.Core
} }
return ay8910info.regs[r]; return ay8910info.regs[r];
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(ay8910info.register_latch); writer.Write(ay8910info.register_latch);
@ -580,7 +579,7 @@ namespace MAME.Core
writer.Write(ay8910info.rng); writer.Write(ay8910info.rng);
writer.Write(ay8910info.vol_enabled, 0, 3); writer.Write(ay8910info.vol_enabled, 0, 3);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
ay8910info.register_latch = reader.ReadInt32(); ay8910info.register_latch = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public class DAC public class DAC
@ -57,11 +56,11 @@ namespace MAME.Core
DAC_build_voltable(); DAC_build_voltable();
dac1.output = 0; dac1.output = 0;
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(DAC.dac1.output); writer.Write(DAC.dac1.output);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
dac1.output = reader.ReadInt16(); dac1.output = reader.ReadInt16();
} }

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class ICS2115 public unsafe class ICS2115
@ -415,7 +414,7 @@ namespace MAME.Core
} }
recalc_irq(); recalc_irq();
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
@ -449,7 +448,7 @@ namespace MAME.Core
writer.Write(irq_pending); writer.Write(irq_pending);
writer.Write(irq_on); writer.Write(irq_on);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class Iremga20 public unsafe class Iremga20
@ -162,7 +161,7 @@ namespace MAME.Core
chip.regs[i] = 0; chip.regs[i] = 0;
} }
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -179,7 +178,7 @@ namespace MAME.Core
writer.Write(chip.channel[i].play); writer.Write(chip.channel[i].play);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class K007232 public unsafe class K007232
@ -232,7 +231,7 @@ namespace MAME.Core
info.bank[0] = (uint)(chABank << 17); info.bank[0] = (uint)(chABank << 17);
info.bank[1] = (uint)(chBBank << 17); info.bank[1] = (uint)(chBBank << 17);
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -271,7 +270,7 @@ namespace MAME.Core
writer.Write(info.pcmbuf_offset[i]); writer.Write(info.pcmbuf_offset[i]);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class K053260 public unsafe class K053260
@ -379,7 +378,7 @@ namespace MAME.Core
{ {
k053260_0_w(offset, data); k053260_0_w(offset, data);
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(ic1.mode); writer.Write(ic1.mode);
@ -402,7 +401,7 @@ namespace MAME.Core
writer.Write(ic1.channels[i].ppcm_data); writer.Write(ic1.channels[i].ppcm_data);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
ic1.mode = reader.ReadInt32(); ic1.mode = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -567,7 +566,7 @@ namespace MAME.Core
{ {
return k054539_r(0, offset); return k054539_r(0, offset);
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
@ -596,7 +595,7 @@ namespace MAME.Core
writer.Write(zoneflag); writer.Write(zoneflag);
writer.Write(zonedata); writer.Write(zonedata);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -254,7 +253,7 @@ namespace MAME.Core
mm1[num].voice.bitwidth = bitwidth; mm1[num].voice.bitwidth = bitwidth;
} }
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
writer.Write(voice.select); writer.Write(voice.select);
writer.Write(voice.index); writer.Write(voice.index);
@ -267,7 +266,7 @@ namespace MAME.Core
writer.Write(voice.signal); writer.Write(voice.signal);
writer.Write(voice.step); writer.Write(voice.step);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
voice.select = reader.ReadInt32(); voice.select = reader.ReadInt32();
voice.index = reader.ReadInt32(); voice.index = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class Namco public unsafe class Namco
@ -255,7 +254,7 @@ namespace MAME.Core
{ {
return namco_wavedata[offset]; return namco_wavedata[offset];
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(nam1.num_voices); writer.Write(nam1.num_voices);
@ -282,7 +281,7 @@ namespace MAME.Core
} }
writer.Write(namco_wavedata, 0, 0x400); writer.Write(namco_wavedata, 0, 0x400);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
nam1.num_voices = reader.ReadInt32(); nam1.num_voices = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -272,7 +271,7 @@ namespace MAME.Core
//if (ACCESSING_BITS_0_7) //if (ACCESSING_BITS_0_7)
okim6295_data_w(0, data & 0xff); okim6295_data_w(0, data & 0xff);
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
writer.Write(OKI.command); writer.Write(OKI.command);
@ -288,7 +287,7 @@ namespace MAME.Core
writer.Write(adpcm[i].step); writer.Write(adpcm[i].step);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
OKI.command = reader.ReadInt32(); OKI.command = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace MAME.Core 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; int i;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
@ -215,7 +214,7 @@ namespace MAME.Core
} }
writer.Write(QChip.data); writer.Write(QChip.data);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -186,7 +185,7 @@ namespace MAME.Core
info.starthandler(); info.starthandler();
} }
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < info.numchannels; i++) for (i = 0; i < info.numchannels; i++)
@ -201,7 +200,7 @@ namespace MAME.Core
writer.Write(info.channel[i].paused); writer.Write(info.channel[i].paused);
} }
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < info.numchannels; i++) for (i = 0; i < info.numchannels; i++)

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public class Taitosnd public class Taitosnd
@ -201,7 +200,7 @@ namespace MAME.Core
{ {
return (ushort)(taitosound_comm_r(0) << 8); 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.slavedata, 0, 4);
writer.Write(tc0140syt.masterdata, 0, 4); writer.Write(tc0140syt.masterdata, 0, 4);
@ -211,7 +210,7 @@ namespace MAME.Core
writer.Write(tc0140syt.nmi_enabled); writer.Write(tc0140syt.nmi_enabled);
writer.Write(tc0140syt.nmi_req); 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.slavedata = reader.ReadBytes(4);
tc0140syt.masterdata = reader.ReadBytes(4); tc0140syt.masterdata = reader.ReadBytes(4);

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class Upd7759 public unsafe class Upd7759
@ -362,7 +361,7 @@ namespace MAME.Core
{ {
return (byte)upd7759_busy_r(0); 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.pos);
writer.Write(chip.step); writer.Write(chip.step);
@ -389,7 +388,7 @@ namespace MAME.Core
writer.Write(chip.romoffset); writer.Write(chip.romoffset);
writer.Write(chip.rombase); writer.Write(chip.rombase);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
chip.pos = reader.ReadUInt32(); chip.pos = reader.ReadUInt32();
chip.step = reader.ReadUInt32(); chip.step = reader.ReadUInt32();

View File

@ -1,16 +1,17 @@
using System.IO; 
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class WavWrite public class WavWrite
{ {
public static FileStream mWaveFile = null; public static System.IO.FileStream mWaveFile = null;
private static BinaryWriter mWriter = null; private static System.IO.BinaryWriter mWriter = null;
private static int mSampleCount = 0; private static int mSampleCount = 0;
public static void CreateSoundFile(string filename) public static void CreateSoundFile(string filename)
{ {
mWaveFile = new FileStream(filename, FileMode.Create); mWaveFile = new FileStream(filename, FileMode.Create);
mWriter = new BinaryWriter(mWaveFile); mWriter = new System.IO.BinaryWriter(mWaveFile);
/************************************************************************** /**************************************************************************
Hereiswherethefilewillbecreated.A Hereiswherethefilewillbecreated.A
wavefileisaRIFFfile,whichhaschunks wavefileisaRIFFfile,whichhaschunks

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -2038,7 +2037,7 @@ namespace MAME.Core
// chanout[imem[op1]] = PSG.oper[op1].mem_value; // chanout[imem[op1]] = PSG.oper[op1].mem_value;
// } // }
//} //}
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
@ -2115,7 +2114,7 @@ namespace MAME.Core
writer.Write(PSG.irqlinestate); writer.Write(PSG.irqlinestate);
writer.Write(PSG.connect); writer.Write(PSG.connect);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class YM2203 public unsafe class YM2203
@ -339,7 +338,7 @@ namespace MAME.Core
} }
} }
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(REGS, 0, 256); writer.Write(REGS, 0, 256);
@ -435,7 +434,7 @@ namespace MAME.Core
writer.Write(YMDeltat.DELTAT.adpcmd); writer.Write(YMDeltat.DELTAT.adpcmd);
writer.Write(YMDeltat.DELTAT.adpcml); writer.Write(YMDeltat.DELTAT.adpcml);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
REGS = reader.ReadBytes(256); REGS = reader.ReadBytes(256);

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class YM2610 public unsafe class YM2610
@ -654,7 +653,7 @@ namespace MAME.Core
{ {
adpcm_arrivedEndAddress &= (byte)(~changebits); adpcm_arrivedEndAddress &= (byte)(~changebits);
} }
public void SaveStateBinary(BinaryWriter writer) public void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(REGS, 0, 512); writer.Write(REGS, 0, 512);
@ -771,7 +770,7 @@ namespace MAME.Core
writer.Write(YMDeltat.DELTAT.adpcmd); writer.Write(YMDeltat.DELTAT.adpcmd);
writer.Write(YMDeltat.DELTAT.adpcml); writer.Write(YMDeltat.DELTAT.adpcml);
} }
public void LoadStateBinary(BinaryReader reader) public void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
REGS = reader.ReadBytes(512); REGS = reader.ReadBytes(512);

View File

@ -1,5 +1,4 @@
using System.IO; 
namespace MAME.Core namespace MAME.Core
{ {
public class YM3812 public class YM3812
@ -85,7 +84,7 @@ namespace MAME.Core
{ {
FMOpl.ym3812_write(1, data); FMOpl.ym3812_write(1, data);
} }
public static void SaveStateBinary(BinaryWriter writer) public static void SaveStateBinary(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
@ -140,7 +139,7 @@ namespace MAME.Core
writer.Write(FMOpl.YM3812.statusmask); writer.Write(FMOpl.YM3812.statusmask);
writer.Write(FMOpl.YM3812.mode); writer.Write(FMOpl.YM3812.mode);
} }
public static void LoadStateBinary(BinaryReader reader) public static void LoadStateBinary(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
@ -268,7 +267,7 @@ namespace MAME.Core
{ {
return FMOpl.ym3526_read(1); return FMOpl.ym3526_read(1);
} }
public static void SaveStateBinary_YM3526(BinaryWriter writer) public static void SaveStateBinary_YM3526(System.IO.BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
@ -323,7 +322,7 @@ namespace MAME.Core
writer.Write(FMOpl.YM3526.statusmask); writer.Write(FMOpl.YM3526.statusmask);
writer.Write(FMOpl.YM3526.mode); writer.Write(FMOpl.YM3526.mode);
} }
public static void LoadStateBinary_YM3526(BinaryReader reader) public static void LoadStateBinary_YM3526(System.IO.BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace StoicGooseUnity namespace StoicGooseUnity
@ -95,21 +94,21 @@ namespace StoicGooseUnity
} }
#endregion #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); Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组 // 使用BinaryWriter写入临时数组
bw.Write(TempBuffer_src, 0, count); 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); Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组 // 使用BinaryWriter写入临时数组
fs.Write(TempBuffer_src, 0, count); 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写入临时数组 // 使用BinaryWriter写入临时数组
count = fs.Read(TempBuffer_src, offset, count); count = fs.Read(TempBuffer_src, offset, count);

View File

@ -1,5 +1,5 @@
using System; using System;
using System.IO; //using System.IO;
using System.Linq; using System.Linq;
namespace StoicGoose.Common.Drawing namespace StoicGoose.Common.Drawing
@ -10,46 +10,46 @@ namespace StoicGoose.Common.Drawing
public class RgbaFile public class RgbaFile
{ {
const string expectedMagic = "RGBA"; //const string expectedMagic = "RGBA";
public string MagicNumber { get; protected set; } //public string MagicNumber { get; protected set; }
public uint Width { get; protected set; } //public uint Width { get; protected set; }
public uint Height { get; protected set; } //public uint Height { get; protected set; }
public byte[] PixelData { get; protected set; } //public byte[] PixelData { get; protected set; }
public RgbaFile(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { } //public RgbaFile(string filename) : this(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
public RgbaFile(Stream stream) //public RgbaFile(System.IO.Stream stream)
{ //{
MagicNumber = ReadString(stream, 4); // MagicNumber = ReadString(stream, 4);
Width = ReadUInt32(stream); // Width = ReadUInt32(stream);
Height = ReadUInt32(stream); // Height = ReadUInt32(stream);
PixelData = new byte[Width * Height * 4]; // PixelData = new byte[Width * Height * 4];
stream.Read(PixelData); // stream.Read(PixelData);
} //}
public RgbaFile(uint width, uint height, byte[] pixelData) //public RgbaFile(uint width, uint height, byte[] pixelData)
{ //{
MagicNumber = expectedMagic; // MagicNumber = expectedMagic;
Width = width; // Width = width;
Height = height; // Height = height;
PixelData = pixelData; // PixelData = pixelData;
} //}
public void Save(string filename) => Save(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)); //public void Save(string filename) => Save(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite));
public void Save(Stream stream) //public void Save(Stream stream)
{ //{
WriteString(stream, MagicNumber); // WriteString(stream, MagicNumber);
WriteUInt32(stream, Width); // WriteUInt32(stream, Width);
WriteUInt32(stream, Height); // WriteUInt32(stream, Height);
stream.Write(PixelData); // stream.Write(PixelData);
} //}
private static string ReadString(Stream stream, int length) => new(Enumerable.Range(0, length).Select(_ => (char)stream.ReadByte()).ToArray()); //private static string ReadString(Stream stream, int length) => new(Enumerable.Range(0, length).Select(_ => (char)stream.ReadByte()).ToArray());
private static uint ReadUInt32(Stream stream) => (uint)(((stream.ReadByte() & 0xFF) << 24) | ((stream.ReadByte() & 0xFF) << 16) | ((stream.ReadByte() & 0xFF) << 8) | ((stream.ReadByte() & 0xFF) << 0)); //private static uint ReadUInt32(Stream stream) => (uint)(((stream.ReadByte() & 0xFF) << 24) | ((stream.ReadByte() & 0xFF) << 16) | ((stream.ReadByte() & 0xFF) << 8) | ((stream.ReadByte() & 0xFF) << 0));
private static void WriteString(Stream stream, string str) => Array.ForEach(str.ToCharArray(), (x) => stream.WriteByte((byte)x)); //private static void WriteString(Stream stream, string str) => Array.ForEach(str.ToCharArray(), (x) => stream.WriteByte((byte)x));
private static void WriteUInt32(Stream stream, uint val) { stream.WriteByte((byte)((val >> 24) & 0xFF)); stream.WriteByte((byte)((val >> 16) & 0xFF)); stream.WriteByte((byte)((val >> 8) & 0xFF)); stream.WriteByte((byte)((val >> 0) & 0xFF)); } //private static void WriteUInt32(Stream stream, uint val) { stream.WriteByte((byte)((val >> 24) & 0xFF)); stream.WriteByte((byte)((val >> 16) & 0xFF)); stream.WriteByte((byte)((val >> 8) & 0xFF)); stream.WriteByte((byte)((val >> 0) & 0xFF)); }
} }
} }

View File

@ -1,5 +1,4 @@
using System; using System;
using System.IO;
namespace StoicGoose.Common.Utilities namespace StoicGoose.Common.Utilities
{ {
@ -32,37 +31,37 @@ namespace StoicGoose.Common.Utilities
if ((segmentStart + segmentLength) > dataLength) throw new Exception("Segment end offset is greater than total length"); if ((segmentStart + segmentLength) > dataLength) throw new Exception("Segment end offset is greater than total length");
} }
public static uint Calculate(FileInfo fileInfo) //public static uint Calculate(FileInfo fileInfo)
{ //{
return Calculate(fileInfo, 0, (int)fileInfo.Length); // return Calculate(fileInfo, 0, (int)fileInfo.Length);
} //}
public static uint Calculate(FileInfo fileInfo, int start, int length) //public static uint Calculate(FileInfo fileInfo, int start, int length)
{ //{
VerifyStartAndLength((int)fileInfo.Length, start, length); // VerifyStartAndLength((int)fileInfo.Length, start, length);
using FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); // using FileStream file = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return Calculate(file, start, length); // return Calculate(file, start, length);
} //}
public static uint Calculate(Stream stream) //public static uint Calculate(Stream stream)
{ //{
return Calculate(stream, 0, (int)stream.Length); // return Calculate(stream, 0, (int)stream.Length);
} //}
public static uint Calculate(Stream stream, int start, int length) //public static uint Calculate(Stream stream, int start, int length)
{ //{
VerifyStartAndLength((int)stream.Length, start, length); // VerifyStartAndLength((int)stream.Length, start, length);
var lastStreamPosition = stream.Position; // var lastStreamPosition = stream.Position;
var data = new byte[length]; // var data = new byte[length];
stream.Position = start; // stream.Position = start;
stream.Read(data, 0, length); // stream.Read(data, 0, length);
var crc = Calculate(data, 0, data.Length); // var crc = Calculate(data, 0, data.Length);
stream.Position = lastStreamPosition; // stream.Position = lastStreamPosition;
return crc; // return crc;
} //}
public static uint Calculate(byte[] data) public static uint Calculate(byte[] data)
{ {

View File

@ -1,41 +1,40 @@
using System.IO; //using System.Reflection;
using System.Reflection;
using StoicGoose.Common.Drawing; //using StoicGoose.Common.Drawing;
namespace StoicGoose.Common.Utilities //namespace StoicGoose.Common.Utilities
{ //{
public static class Resources // public static class Resources
{ // {
private static Stream GetEmbeddedResourceStream(string name) // //private static System.IO.Stream GetEmbeddedResourceStream(string name)
{ // //{
var assembly = Assembly.GetEntryAssembly(); // // var assembly = Assembly.GetEntryAssembly();
name = $"{assembly.GetName().Name}.{name}"; // // name = $"{assembly.GetName().Name}.{name}";
return assembly.GetManifestResourceStream(name); // // return assembly.GetManifestResourceStream(name);
} // //}
public static RgbaFile GetEmbeddedRgbaFile(string name) // //public static RgbaFile GetEmbeddedRgbaFile(string name)
{ // //{
using var stream = GetEmbeddedResourceStream(name); // // using var stream = GetEmbeddedResourceStream(name);
if (stream == null) return null; // // if (stream == null) return null;
return new RgbaFile(stream); // // return new RgbaFile(stream);
} // //}
public static string GetEmbeddedText(string name) // //public static string GetEmbeddedText(string name)
{ // //{
using var stream = GetEmbeddedResourceStream(name); // // using var stream = GetEmbeddedResourceStream(name);
if (stream == null) return string.Empty; // // if (stream == null) return string.Empty;
using var reader = new StreamReader(stream); // // using var reader = new StreamReader(stream);
return reader.ReadToEnd(); // // return reader.ReadToEnd();
} // //}
public static byte[] GetEmbeddedRawData(string name) // //public static byte[] GetEmbeddedRawData(string name)
{ // //{
using var stream = GetEmbeddedResourceStream(name); // // using var stream = GetEmbeddedResourceStream(name);
if (stream == null) return null; // // if (stream == null) return null;
var buffer = new byte[stream.Length]; // // var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length); // // stream.Read(buffer, 0, buffer.Length);
return buffer; // // return buffer;
} // //}
} // }
} //}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5fe26f58ab822c44888b86305c5326e0 guid: 2d28d800dbf30c84da9e5d605a4f9896
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

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