Compare commits

..

No commits in common. "e8bac390af6e31abe436ee910e4f4ba74bf4c8ef" and "412c9759dfa108e59dba9b9c4fc46ea64a78f007" have entirely different histories.

114 changed files with 841 additions and 4028 deletions

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using UnityEditor; using UnityEditor;
@ -19,17 +20,7 @@ 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;
static void InitToolPath() [MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/RepackNSP(쏭路劤뭐쉔NPS")]
{
#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())
@ -47,29 +38,7 @@ 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())
@ -152,7 +121,12 @@ namespace AxibugEmuOnline.Editors
static void RepackNSP(string nspFile) static void RepackNSP(string nspFile)
{ {
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
#region ´¦ÀíNSPÎļþ·¾ #region ´¦ÀíNSPÎļþ·¾
string nspFilePath = nspFile; string nspFilePath = nspFile;

View File

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

View File

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

View File

@ -2,24 +2,20 @@
using nn.fs; using nn.fs;
#endif #endif
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
public class AxiNSIO public class AxiNSIO
{ {
string save_name => AxiNS.instance.mount.SaveMountName; string save_name => AxiNS.instance.mount.SaveMountName;
public string save_path => $"{save_name}:/"; public string save_path => $"{save_name}:/";
#if UNITY_SWITCH #if UNITY_SWITCH
private FileHandle fileHandle = new nn.fs.FileHandle(); private FileHandle fileHandle = new nn.fs.FileHandle();
#endif #endif
/// <summary> /// <summary>
/// 检查Path是否存在 /// 检查Path是否存在
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <returns></returns> /// <returns></returns>
public bool CheckPathExists(string filePath) public bool CheckPathExists(string filePath)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -29,14 +25,14 @@ public class AxiNSIO
//这个异常捕获。真的别扭 //这个异常捕获。真的别扭
return nn.fs.FileSystem.ResultPathAlreadyExists.Includes(result); return nn.fs.FileSystem.ResultPathAlreadyExists.Includes(result);
#endif #endif
} }
/// <summary> /// <summary>
/// 检查Path是否不存在 /// 检查Path是否不存在
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <returns></returns> /// <returns></returns>
public bool CheckPathNotFound(string filePath) public bool CheckPathNotFound(string filePath)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -45,14 +41,14 @@ public class AxiNSIO
//这个异常捕获。真的别扭 //这个异常捕获。真的别扭
return nn.fs.FileSystem.ResultPathNotFound.Includes(result); return nn.fs.FileSystem.ResultPathNotFound.Includes(result);
#endif #endif
} }
/// <summary> /// <summary>
/// 创建目录目录存在也会返回true /// 创建目录目录存在也会返回true
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <returns></returns> /// <returns></returns>
public bool CreateDir(string filePath) public bool CreateDir(string filePath)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -64,38 +60,38 @@ public class AxiNSIO
} }
return true; return true;
#endif #endif
} }
/// <summary> /// <summary>
/// 保存并创建文件(如果目录不存在回先自动创建目录) /// 保存并创建文件(如果目录不存在回先自动创建目录)
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <param name="bw"></param> /// <param name="bw"></param>
/// <returns></returns> /// <returns></returns>
public bool FileToSaveWithCreate(string filePath, System.IO.MemoryStream ms) public bool FileToSaveWithCreate(string filePath, System.IO.MemoryStream ms)
{ {
return FileToSaveWithCreate(filePath, ms.ToArray()); return FileToSaveWithCreate(filePath, ms.ToArray());
} }
/// <summary> /// <summary>
/// 保存并创建文件(如果目录不存在回先自动创建目录) /// 保存并创建文件(如果目录不存在回先自动创建目录)
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <param name="data"></param> /// <param name="data"></param>
/// <returns></returns> /// <returns></returns>
public AxiNSWait_FileToSaveByMSWithCreate FileToSaveWithCreateAsync(string filePath, System.IO.MemoryStream ms) public AxiNSWait_FileToSaveByMSWithCreate FileToSaveWithCreateAsync(string filePath, System.IO.MemoryStream ms)
{ {
var wait = new AxiNSWait_FileToSaveByMSWithCreate(filePath, ms); var wait = new AxiNSWait_FileToSaveByMSWithCreate(filePath, ms);
AxiNS.instance.wait.AddWait(wait); AxiNS.instance.wait.AddWait(wait);
return wait; return wait;
} }
/// <summary> /// <summary>
/// 保存并创建文件(如果目录不存在回先自动创建目录) /// 保存并创建文件(如果目录不存在回先自动创建目录)
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <param name="data"></param> /// <param name="data"></param>
/// <returns></returns> /// <returns></returns>
public bool FileToSaveWithCreate(string filePath, byte[] data) public bool FileToSaveWithCreate(string filePath, byte[] data)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -199,39 +195,33 @@ public class AxiNSIO
return true; return true;
#endif #endif
} }
/// <summary> /// <summary>
/// 保存并创建文件(如果目录不存在回先自动创建目录) /// 保存并创建文件(如果目录不存在回先自动创建目录)
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
/// <param name="data"></param> /// <param name="data"></param>
/// <returns></returns> /// <returns></returns>
public AxiNSWait_FileToSaveWithCreate FileToSaveWithCreateAsync(string filePath, byte[] data) public AxiNSWait_FileToSaveWithCreate FileToSaveWithCreateAsync(string filePath, byte[] data)
{ {
var wait = new AxiNSWait_FileToSaveWithCreate(filePath, data); var wait = new AxiNSWait_FileToSaveWithCreate(filePath, data);
AxiNS.instance.wait.AddWait(wait); AxiNS.instance.wait.AddWait(wait);
return wait; return wait;
} }
public byte[] LoadSwitchDataFile(string filename) public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms)
{ {
LoadSwitchDataFile(filename, out byte[] outputData); if (LoadSwitchDataFile(filename, out byte[] outputData))
return outputData; {
} using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(ms))
{
public bool LoadSwitchDataFile(string filename, ref System.IO.MemoryStream ms) writer.Write(outputData);
{ }
if (LoadSwitchDataFile(filename, out byte[] outputData)) return true;
{ }
using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(ms)) return false;
{ }
writer.Write(outputData); public bool LoadSwitchDataFile(string filename, out byte[] outputData)
} {
return true;
}
return false;
}
public bool LoadSwitchDataFile(string filename, out byte[] outputData)
{
#if !UNITY_SWITCH #if !UNITY_SWITCH
outputData = null; outputData = null;
return false; return false;
@ -282,94 +272,15 @@ public class AxiNSIO
outputData = loadedData; outputData = loadedData;
return true; return true;
#endif #endif
} }
public AxiNSWait_LoadSwitchDataFile LoadSwitchDataFileAsync(string filename) public AxiNSWait_LoadSwitchDataFile LoadSwitchDataFileAsync(string filename)
{ {
var wait = new AxiNSWait_LoadSwitchDataFile(filename); var wait = new AxiNSWait_LoadSwitchDataFile(filename);
AxiNS.instance.wait.AddWait(wait); AxiNS.instance.wait.AddWait(wait);
return wait; return wait;
} }
public bool DeletePathFile(string filename)
public bool GetDirectoryFiles(string path, out string[] entrys)
{
#if !UNITY_SWITCH
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
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)
{ {
entrys = null;
return false;
nn.fs.DirectoryHandle dirHandle = new nn.fs.DirectoryHandle();
nn.Result result = nn.fs.Directory.Open(ref dirHandle, 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, dirHandle);
nn.fs.DirectoryEntry[] dirEntries = new nn.fs.DirectoryEntry[entryCount];
long actualEntries = 0;
nn.fs.Directory.Read(ref actualEntries, dirEntries, dirHandle, entryCount);
entrys = new string[actualEntries];
for (int i = 0; i < actualEntries; i++)
{
entrys[i] = dirEntries[i].name;
}
nn.fs.Directory.Close(dirHandle);
return true;
}
#endif
public IEnumerable<string> EnumerateFiles(string path, string searchPattern)
{
#if !UNITY_SWITCH
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 #if !UNITY_SWITCH
return false; return false;
#else #else
@ -404,15 +315,15 @@ public class AxiNSIO
#endif #endif
#endif #endif
} }
public AxiNSWait_DeletePathFile DeletePathFileAsync(string filename) public AxiNSWait_DeletePathFile DeletePathFileAsync(string filename)
{ {
var wait = new AxiNSWait_DeletePathFile(filename); var wait = new AxiNSWait_DeletePathFile(filename);
AxiNS.instance.wait.AddWait(wait); AxiNS.instance.wait.AddWait(wait);
return wait; return wait;
} }
public bool DeletePathDir(string filename) public bool DeletePathDir(string filename)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -445,21 +356,21 @@ public class AxiNSIO
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection(); UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
#endif #endif
#endif #endif
} }
public AxiNSWait_DeletePathDir DeletePathDirAsync(string filename) public AxiNSWait_DeletePathDir DeletePathDirAsync(string filename)
{ {
var wait = new AxiNSWait_DeletePathDir(filename); var wait = new AxiNSWait_DeletePathDir(filename);
AxiNS.instance.wait.AddWait(wait); AxiNS.instance.wait.AddWait(wait);
return wait; return wait;
} }
/// <summary> /// <summary>
/// 递归删除目录 /// 递归删除目录
/// </summary> /// </summary>
/// <param name="filename"></param> /// <param name="filename"></param>
/// <returns></returns> /// <returns></returns>
public bool DeleteRecursivelyPathDir(string filename) public bool DeleteRecursivelyPathDir(string filename)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -492,15 +403,15 @@ public class AxiNSIO
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection(); UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
#endif #endif
#endif #endif
} }
/// <summary> /// <summary>
/// 递归删除情况 /// 递归删除情况
/// </summary> /// </summary>
/// <param name="filename"></param> /// <param name="filename"></param>
/// <returns></returns> /// <returns></returns>
public bool CleanRecursivelyPathDir(string filename) public bool CleanRecursivelyPathDir(string filename)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -533,10 +444,10 @@ public class AxiNSIO
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection(); UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
#endif #endif
#endif #endif
} }
public bool RenameDir(string oldpath, string newpath) public bool RenameDir(string oldpath, string newpath)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -570,9 +481,9 @@ public class AxiNSIO
UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection(); UnityEngine.Switch.Notification.LeaveExitRequestHandlingSection();
#endif #endif
#endif #endif
} }
bool EnsureParentDirectory(string filePath, bool bAutoCreateDir = true) bool EnsureParentDirectory(string filePath, bool bAutoCreateDir = true)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -648,14 +559,14 @@ public class AxiNSIO
return true; return true;
#endif #endif
} }
/// <summary> /// <summary>
/// 检查指定挂载点是否可访问 /// 检查指定挂载点是否可访问
/// </summary> /// </summary>
/// <param name="pathPrefix">路径前缀,例如 "save:/" 或 "sd:/"</param> /// <param name="pathPrefix">路径前缀,例如 "save:/" 或 "sd:/"</param>
/// <returns>挂载点是否可访问</returns> /// <returns>挂载点是否可访问</returns>
bool IsMountPointAccessible(string pathPrefix) bool IsMountPointAccessible(string pathPrefix)
{ {
#if !UNITY_SWITCH #if !UNITY_SWITCH
return false; return false;
#else #else
@ -693,5 +604,5 @@ public class AxiNSIO
return true; // 其他挂载点需根据实际需求实现 return true; // 其他挂载点需根据实际需求实现
} }
#endif #endif
} }
} }

View File

@ -118,7 +118,7 @@ public class AxiNSMount
UnityEngine.Debug.LogError($"UnmountSDCardForDebug->ÒÑÐ¶ÔØ{m_SdCardDebugMountName}:/ "); UnityEngine.Debug.LogError($"UnmountSDCardForDebug->ÒÑÐ¶ÔØ{m_SdCardDebugMountName}:/ ");
bInSdCardDebugMount = false; bInSdCardDebugMount = false;
#endif #endif
} }
public void UnmountSDCard() public void UnmountSDCard()
{ {
#if UNITY_SWITCH #if UNITY_SWITCH

View File

@ -1,5 +1,6 @@
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
@ -83,21 +84,21 @@ namespace Essgee.Utilities
} }
#endregion #endregion
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count) public static void Write(this 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 System.IO.FileStream fs, byte* bufferPtr, int offset, int count) public static void Write(this 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 System.IO.FileStream fs, byte* bufferPtr, int offset, int count) public static int Read(this 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,6 +1,5 @@
using Essgee; using Essgee;
using Essgee.Metadata;
using System; using System;
public static class EmuStandInfo public static class EmuStandInfo
@ -9,6 +8,7 @@ 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,8 +131,7 @@ namespace Essgee.Emulation.CPU
{ {
if (AppEnvironment.EnableSuperSlowCPULogger && logEntries != null) if (AppEnvironment.EnableSuperSlowCPULogger && logEntries != null)
{ {
//TODO 暂时不要日志看后续是否需要加 System.IO.File.AppendAllText(logFile, string.Join("", logEntries.Take(numLogEntries)));
//System.IO.File.AppendAllText(logFile, string.Join("", logEntries.Take(numLogEntries)));
} }
// //
@ -176,8 +175,7 @@ namespace Essgee.Emulation.CPU
logEntries[numLogEntries++] = disasm; logEntries[numLogEntries++] = disasm;
if (numLogEntries >= logEntries.Length) if (numLogEntries >= logEntries.Length)
{ {
//TODO 暂时不要日志看后续是否需要加 System.IO.File.AppendAllText(logFile, string.Join("", logEntries));
//System.IO.File.AppendAllText(logFile, string.Join("", logEntries));
numLogEntries = 0; numLogEntries = 0;
} }
} }

View File

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

View File

@ -3,6 +3,7 @@ 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;
@ -31,19 +32,19 @@ namespace Essgee.Emulation
Type machineType = null; Type machineType = null;
byte[] romData = null; byte[] romData = null;
if (!EmulatorHandler.io.File_Exists(fileName)) if (!File.Exists(fileName))
throw new CartridgeLoaderException($"{fileType} file not found."); throw new CartridgeLoaderException($"{fileType} file not found.");
try try
{ {
var fileExtension = System.IO.Path.GetExtension(fileName); var fileExtension = 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 = System.IO.Path.GetExtension(entry.Name); var entryExtension = Path.GetExtension(entry.Name);
if (fileExtensionSystemDictionary.ContainsKey(entryExtension)) if (fileExtensionSystemDictionary.ContainsKey(entryExtension))
{ {
machineType = fileExtensionSystemDictionary[entryExtension]; machineType = fileExtensionSystemDictionary[entryExtension];
@ -60,7 +61,7 @@ namespace Essgee.Emulation
else if (fileExtensionSystemDictionary.ContainsKey(fileExtension)) else if (fileExtensionSystemDictionary.ContainsKey(fileExtension))
{ {
machineType = fileExtensionSystemDictionary[fileExtension]; machineType = fileExtensionSystemDictionary[fileExtension];
romData = System.IO.File.ReadAllBytes(fileName); romData = File.ReadAllBytes(fileName);
} }
} }
catch (Exception ex) when (!AppEnvironment.DebugMode) catch (Exception ex) when (!AppEnvironment.DebugMode)

View File

@ -5,6 +5,7 @@ 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
@ -13,7 +14,6 @@ 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 System.IO.Path.Combine(EmuStandInfo.SaveStatePath, $"{System.IO.Path.GetFileNameWithoutExtension(currentGameMetadata.FileName)} (State {number:D2}).est"); return Path.Combine(EmuStandInfo.SaveStatePath, $"{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 = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav")); var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
if (EmulatorHandler.io.File_Exists(savePath)) if (File.Exists(savePath))
ramData = EmulatorHandler.io.File_ReadAllBytes(savePath); ramData = 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 = System.IO.Path.Combine(EmuStandInfo.SaveDataPath, System.IO.Path.ChangeExtension(currentGameMetadata.FileName, "sav")); var savePath = Path.Combine(EmuStandInfo.SaveDataPath, Path.ChangeExtension(currentGameMetadata.FileName, "sav"));
EmulatorHandler.io.File_WriteAllBytes(savePath, ramData); 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,6 +1,7 @@
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
@ -63,7 +64,7 @@ namespace Essgee.Emulation.ExtDevices.Nintendo
ipcOffsetSelf = ipcBaseOffsetSerialData + 1; ipcOffsetSelf = ipcBaseOffsetSerialData + 1;
ipcOffsetRemote = ipcBaseOffsetSerialData + 0; ipcOffsetRemote = ipcBaseOffsetSerialData + 0;
} }
catch (Exception ex) catch (FileNotFoundException)
{ {
// 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,6 +10,7 @@ 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
@ -364,22 +365,9 @@ namespace Essgee.Emulation.Machines
irDatabaseCurrentIndex = irCycles = 0; irDatabaseCurrentIndex = irCycles = 0;
irExternalTransferActive = false; irExternalTransferActive = false;
//if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && EmulatorHandler.io.File_Exists(configuration.InfraredDatabasePikachu)) if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && 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 System.IO.BinaryReader(new System.IO.MemoryStream(EmulatorHandler.io.File_ReadAllBytes(configuration.InfraredDatabasePikachu)))) using (var reader = new BinaryReader(new FileStream(configuration.InfraredDatabasePikachu, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)))
{ {
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,4 +1,6 @@
namespace Essgee.Emulation using System.IO;
namespace Essgee.Emulation
{ {
public static class SaveStateHandler public static class SaveStateHandler
{ {
@ -40,12 +42,12 @@
// } // }
//} //}
public static AxiEssgssStatusData LoadAxiStatus(System.IO.Stream stream, string machineName) public static AxiEssgssStatusData LoadAxiStatus(Stream stream, string machineName)
{ {
using (var reader = new System.IO.BinaryReader(stream)) using (var reader = new BinaryReader(stream))
{ {
/* Check CRC32 */ /* Check CRC32 */
using (var stateStream = new System.IO.MemoryStream()) using (var stateStream = new MemoryStream())
{ {
reader.BaseStream.CopyTo(stateStream); reader.BaseStream.CopyTo(stateStream);
return stateStream.ToArray().ToAxiEssgssStatusData(); return stateStream.ToArray().ToAxiEssgssStatusData();
@ -100,11 +102,11 @@
// } // }
//} //}
//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,4 +1,5 @@
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -19,7 +20,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 System.IO.StreamReader(assembly.GetManifestResourceStream(resourceName))) using (var reader = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
return reader.ReadToEnd(); return reader.ReadToEnd();
} }

View File

@ -1,6 +1,8 @@
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,6 +2,7 @@
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;
@ -16,15 +17,6 @@ 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;
@ -32,8 +24,6 @@ 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;
@ -389,7 +379,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 (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) using (MemoryStream stream = new MemoryStream(loadedData))
{ {
datFile = (DatFile)serializer.Deserialize(stream); datFile = (DatFile)serializer.Deserialize(stream);
} }
@ -406,7 +396,7 @@ namespace Essgee.Metadata
/* Create game metadata */ /* Create game metadata */
var gameMetadata = new GameMetadata() var gameMetadata = new GameMetadata()
{ {
FileName = System.IO.Path.GetFileName(romFilename), FileName = Path.GetFileName(romFilename),
KnownName = gameInfo?.Name, KnownName = gameInfo?.Name,
RomCrc32 = romCrc32, RomCrc32 = romCrc32,
RomSize = romSize RomSize = romSize

View File

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
namespace Essgee.Utilities namespace Essgee.Utilities
{ {
@ -33,42 +34,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,5 +1,6 @@
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
@ -24,9 +25,8 @@ namespace MAME.Core
ISoundPlayer isp, ISoundPlayer isp,
IKeyboard ikb, IKeyboard ikb,
IMouse imou, IMouse imou,
ITimeSpan itime, ITimeSpan itime
IMAMEIOSupport io ) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime);
) => 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(System.IO.BinaryReader sr) public void LoadState(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(System.IO.BinaryWriter sw) public void SaveState(BinaryWriter sw)
{ {
Mame.paused = true; Mame.paused = true;
Thread.Sleep(20); Thread.Sleep(20);

View File

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

View File

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

View File

@ -1,6 +1,7 @@
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
@ -274,7 +275,7 @@ namespace cpu.m68000
// return a + b + c + d; // return a + b + c + d;
//} //}
public void SaveStateBinary(System.IO.BinaryWriter writer) public void SaveStateBinary(BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 0x08; i++) for (i = 0; i < 0x08; i++)
@ -303,7 +304,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(System.IO.BinaryReader reader) public void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 0x08; i++) for (i = 0; i < 0x08; i++)
@ -332,7 +333,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(System.IO.TextWriter writer, string id) public void SaveStateText(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);
@ -369,7 +370,7 @@ namespace cpu.m68000
writer.WriteLine("[/{0}]", id); writer.WriteLine("[/{0}]", id);
} }
public void LoadStateText(System.IO.TextReader reader, string id) public void LoadStateText(TextReader reader, string id)
{ {
while (true) while (true)
{ {

View File

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

View File

@ -1,5 +1,6 @@
using MAME.Core; using MAME.Core;
using System; using System;
using System.IO;
namespace cpu.m6809 namespace cpu.m6809
{ {
@ -860,7 +861,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(System.IO.BinaryWriter writer) public void SaveStateBinary(BinaryWriter writer)
{ {
writer.Write(PC.LowWord); writer.Write(PC.LowWord);
writer.Write(PPC.LowWord); writer.Write(PPC.LowWord);
@ -878,7 +879,7 @@ namespace cpu.m6809
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(System.IO.BinaryReader reader) public void LoadStateBinary(BinaryReader reader)
{ {
PC.LowWord = reader.ReadUInt16(); PC.LowWord = reader.ReadUInt16();
PPC.LowWord = reader.ReadUInt16(); PPC.LowWord = reader.ReadUInt16();

View File

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

View File

@ -1,6 +1,7 @@
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.
@ -132,7 +133,7 @@ namespace cpu.z80
// State Save/Load // State Save/Load
public void SaveStateBinary(System.IO.BinaryWriter writer) public void SaveStateBinary(BinaryWriter writer)
{ {
writer.Write(PPC); writer.Write(PPC);
writer.Write(RegisterAF); writer.Write(RegisterAF);
@ -161,7 +162,7 @@ namespace cpu.z80
writer.Write(TotalExecutedCycles); writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles); writer.Write(PendingCycles);
} }
public void LoadStateBinary(System.IO.BinaryReader reader) public void LoadStateBinary(BinaryReader reader)
{ {
PPC = reader.ReadUInt16(); PPC = reader.ReadUInt16();
RegisterAF = reader.ReadUInt16(); RegisterAF = reader.ReadUInt16();
@ -190,7 +191,7 @@ namespace cpu.z80
TotalExecutedCycles = reader.ReadUInt64(); TotalExecutedCycles = reader.ReadUInt64();
PendingCycles = reader.ReadInt32(); PendingCycles = reader.ReadInt32();
} }
public void SaveStateText(System.IO.TextWriter writer) public void SaveStateText(TextWriter writer)
{ {
writer.WriteLine("[Z80]"); writer.WriteLine("[Z80]");
writer.WriteLine("AF {0:X4}", RegAF.Word); writer.WriteLine("AF {0:X4}", RegAF.Word);
@ -220,7 +221,7 @@ namespace cpu.z80
writer.WriteLine(); writer.WriteLine();
} }
public void LoadStateText(System.IO.TextReader reader) public void LoadStateText(TextReader reader)
{ {
while (true) while (true)
{ {

View File

@ -6,6 +6,7 @@ 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
{ {
@ -2807,7 +2808,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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)
@ -2821,7 +2822,7 @@ namespace MAME.Core
writer.Write(Cpuexec.cpu[i].localtime.attoseconds); writer.Write(Cpuexec.cpu[i].localtime.attoseconds);
} }
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < ncpu; i++) for (i = 0; i < ncpu; i++)

View File

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

View File

@ -1,4 +1,6 @@
namespace MAME.Core using System.IO;
namespace MAME.Core
{ {
/*public enum eeprom_command /*public enum eeprom_command
{ {
@ -376,7 +378,7 @@
} }
clock_line = state; clock_line = state;
} }
public static void SaveStateBinary(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
writer.Write(eeprom_data); writer.Write(eeprom_data);
writer.Write(serial_buffer); writer.Write(serial_buffer);
@ -391,7 +393,7 @@
writer.Write(eeprom_data_bits); writer.Write(eeprom_data_bits);
writer.Write(eeprom_read_address); writer.Write(eeprom_read_address);
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(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,6 +1,7 @@
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
{ {
@ -641,7 +642,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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i, i1, n; int i, i1, n;
n = lt.Count; n = lt.Count;
@ -672,7 +673,7 @@ namespace MAME.Core
writer.Write((long)0); writer.Write((long)0);
} }
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, i1, n; int i, i1, n;
n = reader.ReadInt32(); n = reader.ReadInt32();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -263,12 +264,10 @@ 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];
@ -287,10 +286,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 (MameMainMotion.IoSupport.File_Exists(path)) if (File.Exists(path))
{ {
EmuLogger.Log($"Had File => {path}"); EmuLogger.Log($"Had File => {path}");
return MameMainMotion.IoSupport.File_ReadAllBytes(path); return File.ReadAllBytes(path);
} }
else else
{ {

View File

@ -1,4 +1,6 @@
 using MAME.Core;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class Mame public class Mame
@ -21,8 +23,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 System.IO.BinaryReader brRecord = null; public static BinaryReader brRecord = null;
public static System.IO.BinaryWriter bwRecord = null; public static 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
@ -40,6 +42,7 @@ 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,5 +1,6 @@
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
@ -487,26 +488,26 @@ namespace MAME.Core
} }
#endregion #endregion
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count) public static void Write(this 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,4 +1,6 @@
namespace MAME.Core using System.IO;
namespace MAME.Core
{ {
public class Pd4900a public class Pd4900a
{ {
@ -310,7 +312,7 @@
{ {
pd4990a_serial_control((byte)(data & 0x7)); pd4990a_serial_control((byte)(data & 0x7));
} }
public static void SaveStateBinary(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
writer.Write(pd4990a.seconds); writer.Write(pd4990a.seconds);
writer.Write(pd4990a.minutes); writer.Write(pd4990a.minutes);
@ -332,7 +334,7 @@
writer.Write(clock_line); writer.Write(clock_line);
writer.Write(command_line); writer.Write(command_line);
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
pd4990a.seconds = reader.ReadInt32(); pd4990a.seconds = reader.ReadInt32();
pd4990a.minutes = reader.ReadInt32(); pd4990a.minutes = reader.ReadInt32();

View File

@ -1,9 +1,11 @@
namespace MAME.Core using System.IO;
namespace MAME.Core
{ {
public class State public class State
{ {
public delegate void savestate_delegate(System.IO.BinaryWriter sw); public delegate void savestate_delegate(BinaryWriter sw);
public delegate void loadstate_delegate(System.IO.BinaryReader sr); public delegate void loadstate_delegate(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,4 +1,6 @@
using System; using MAME.Core;
using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -1100,7 +1102,7 @@ namespace MAME.Core
{ {
return flip_screen_x; return flip_screen_x;
} }
public static void SaveStateBinary(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
writer.Write(scanline_param); writer.Write(scanline_param);
writer.Write(screenstate.last_partial_scan); writer.Write(screenstate.last_partial_scan);
@ -1110,7 +1112,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(System.IO.BinaryReader reader) public static void LoadStateBinary(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,12 +1,13 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary_gng(BinaryWriter writer)
{ {
int i; int i;
writer.Write(bytedsw1); writer.Write(bytedsw1);
@ -52,7 +53,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(System.IO.BinaryReader reader) public static void LoadStateBinary_gng(BinaryReader reader)
{ {
int i; int i;
bytedsw1 = reader.ReadByte(); bytedsw1 = reader.ReadByte();
@ -98,7 +99,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_sf(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -147,7 +148,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(System.IO.BinaryReader reader) public static void LoadStateBinary_sf(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadUInt16(); dsw1 = reader.ReadUInt16();

View File

@ -1,11 +1,12 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinaryC(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dswa); writer.Write(dswa);
@ -75,7 +76,7 @@ namespace MAME.Core
break; break;
} }
} }
public static void SaveStateBinaryQ(System.IO.BinaryWriter writer) public static void SaveStateBinaryQ(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dswa); writer.Write(dswa);
@ -125,7 +126,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(System.IO.BinaryWriter writer) public static void SaveStateBinaryC2(BinaryWriter writer)
{ {
int i; int i;
writer.Write(basebanksnd); writer.Write(basebanksnd);
@ -190,7 +191,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(System.IO.BinaryReader reader) public static void LoadStateBinaryC(BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();
@ -260,7 +261,7 @@ namespace MAME.Core
break; break;
} }
} }
public static void LoadStateBinaryQ(System.IO.BinaryReader reader) public static void LoadStateBinaryQ(BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();
@ -308,7 +309,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(System.IO.BinaryReader reader) public static void LoadStateBinaryC2(BinaryReader reader)
{ {
int i; int i;
basebanksnd = reader.ReadInt32(); basebanksnd = reader.ReadInt32();

View File

@ -1,10 +1,11 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary_pcktgal(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw); writer.Write(dsw);
@ -47,7 +48,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(System.IO.BinaryReader reader) public static void LoadStateBinary_pcktgal(BinaryReader reader)
{ {
int i; int i;
dsw = reader.ReadByte(); dsw = reader.ReadByte();

View File

@ -1,10 +1,11 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)
@ -73,7 +74,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)

View File

@ -1,4 +1,6 @@
namespace MAME.Core using System.IO;
namespace MAME.Core
{ {
public unsafe partial class Konami68000 public unsafe partial class Konami68000
{ {
@ -407,7 +409,7 @@
{ {
return K052109_irq_enabled; return K052109_irq_enabled;
} }
public static void SaveStateBinary_K052109(System.IO.BinaryWriter writer) public static void SaveStateBinary_K052109(BinaryWriter writer)
{ {
int i; int i;
writer.Write(K052109_ram, 0, 0x6000); writer.Write(K052109_ram, 0, 0x6000);
@ -428,7 +430,7 @@
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(System.IO.BinaryReader reader) public static void LoadStateBinary_K052109(BinaryReader reader)
{ {
int i; int i;
K052109_ram = reader.ReadBytes(0x6000); K052109_ram = reader.ReadBytes(0x6000);
@ -449,7 +451,7 @@
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(System.IO.BinaryReader reader) public static void LoadStateBinary_K052109_2(BinaryReader reader)
{ {
int i; int i;
reader.ReadBytes(0x6000); reader.ReadBytes(0x6000);
@ -720,7 +722,7 @@
} }
} }
} }
public static void SaveStateBinary_K051960(System.IO.BinaryWriter writer) public static void SaveStateBinary_K051960(BinaryWriter writer)
{ {
writer.Write(K051960_romoffset); writer.Write(K051960_romoffset);
writer.Write(K051960_spriteflip); writer.Write(K051960_spriteflip);
@ -732,7 +734,7 @@
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(System.IO.BinaryReader reader) public static void LoadStateBinary_K051960(BinaryReader reader)
{ {
K051960_romoffset = reader.ReadInt32(); K051960_romoffset = reader.ReadInt32();
K051960_spriteflip = reader.ReadInt32(); K051960_spriteflip = reader.ReadInt32();
@ -744,7 +746,7 @@
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(System.IO.BinaryReader reader) public static void LoadStateBinary_K051960_2(BinaryReader reader)
{ {
reader.ReadInt32(); reader.ReadInt32();
reader.ReadInt32(); reader.ReadInt32();
@ -1078,7 +1080,7 @@
} }
} }
} }
public static void SaveStateBinary_K053245(System.IO.BinaryWriter writer) public static void SaveStateBinary_K053245(BinaryWriter writer)
{ {
int i; int i;
writer.Write(K05324x_z_rejection); writer.Write(K05324x_z_rejection);
@ -1102,7 +1104,7 @@
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(System.IO.BinaryReader reader) public static void LoadStateBinary_K053245(BinaryReader reader)
{ {
int i; int i;
K05324x_z_rejection = reader.ReadInt32(); K05324x_z_rejection = reader.ReadInt32();
@ -1226,7 +1228,7 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary_K053936(BinaryWriter writer)
{ {
int i, j; int i, j;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -1249,7 +1251,7 @@
writer.Write(K053936_wraparound[i]); writer.Write(K053936_wraparound[i]);
} }
} }
public static void LoadStateBinary_K053936(System.IO.BinaryReader reader) public static void LoadStateBinary_K053936(BinaryReader reader)
{ {
int i, j; int i, j;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -1371,7 +1373,7 @@
{ {
return K053251_palette_index[ci]; return K053251_palette_index[ci];
} }
public static void SaveStateBinary_K053251(System.IO.BinaryWriter writer) public static void SaveStateBinary_K053251(BinaryWriter writer)
{ {
int i; int i;
writer.Write(K053251_ram); writer.Write(K053251_ram);
@ -1381,7 +1383,7 @@
} }
writer.Write(K053251_tilemaps_set); writer.Write(K053251_tilemaps_set);
} }
public static void LoadStateBinary_K053251(System.IO.BinaryReader reader) public static void LoadStateBinary_K053251(BinaryReader reader)
{ {
int i; int i;
K053251_ram = reader.ReadBytes(0x10); K053251_ram = reader.ReadBytes(0x10);
@ -1391,7 +1393,7 @@
} }
K053251_tilemaps_set = reader.ReadInt32(); K053251_tilemaps_set = reader.ReadInt32();
} }
public static void LoadStateBinary_K053251_2(System.IO.BinaryReader reader) public static void LoadStateBinary_K053251_2(BinaryReader reader)
{ {
int i; int i;
reader.ReadBytes(0x10); reader.ReadBytes(0x10);

View File

@ -1,11 +1,12 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary_cuebrick(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -61,7 +62,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(System.IO.BinaryReader reader) public static void LoadStateBinary_cuebrick(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -117,7 +118,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_mia(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -179,7 +180,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(System.IO.BinaryReader reader) public static void LoadStateBinary_mia(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -241,7 +242,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_tmnt(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -313,7 +314,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(System.IO.BinaryReader reader) public static void LoadStateBinary_tmnt(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -385,7 +386,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_punkshot(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -438,7 +439,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(System.IO.BinaryReader reader) public static void LoadStateBinary_punkshot(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -491,7 +492,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_lgtnfght(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -544,7 +545,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(System.IO.BinaryReader reader) public static void LoadStateBinary_lgtnfght(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -597,7 +598,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_blswhstl(BinaryWriter writer)
{ {
int i; int i;
writer.Write(bytee); writer.Write(bytee);
@ -649,7 +650,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(System.IO.BinaryReader reader) public static void LoadStateBinary_blswhstl(BinaryReader reader)
{ {
int i; int i;
bytee = reader.ReadByte(); bytee = reader.ReadByte();
@ -701,7 +702,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_glfgreat(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -752,7 +753,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(System.IO.BinaryReader reader) public static void LoadStateBinary_glfgreat(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();
@ -803,7 +804,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_tmnt2(BinaryWriter writer)
{ {
int i; int i;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -859,7 +860,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(System.IO.BinaryReader reader) public static void LoadStateBinary_tmnt2(BinaryReader reader)
{ {
int i; int i;
for (i = 0; i < 0x10; i++) for (i = 0; i < 0x10; i++)
@ -915,7 +916,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_ssriders(BinaryWriter writer)
{ {
int i; int i;
writer.Write(init_eeprom_count); writer.Write(init_eeprom_count);
@ -967,7 +968,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(System.IO.BinaryReader reader) public static void LoadStateBinary_ssriders(BinaryReader reader)
{ {
int i; int i;
init_eeprom_count = reader.ReadInt32(); init_eeprom_count = reader.ReadInt32();
@ -1019,7 +1020,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_thndrx2(BinaryWriter writer)
{ {
int i; int i;
writer.Write(bytee); writer.Write(bytee);
@ -1071,7 +1072,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(System.IO.BinaryReader reader) public static void LoadStateBinary_thndrx2(BinaryReader reader)
{ {
int i; int i;
bytee = reader.ReadByte(); bytee = reader.ReadByte();
@ -1123,7 +1124,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_prmrsocr(BinaryWriter writer)
{ {
int i; int i;
writer.Write(basebanksnd); writer.Write(basebanksnd);
@ -1181,7 +1182,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(System.IO.BinaryReader reader) public static void LoadStateBinary_prmrsocr(BinaryReader reader)
{ {
int i; int i;
basebanksnd = reader.ReadInt32(); basebanksnd = reader.ReadInt32();

View File

@ -1,11 +1,12 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw); writer.Write(dsw);
@ -67,7 +68,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
dsw = reader.ReadUInt16(); dsw = reader.ReadUInt16();

View File

@ -1,10 +1,11 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dsw); writer.Write(dsw);
@ -81,7 +82,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, j; int i, j;
dsw = reader.ReadUInt16(); dsw = reader.ReadUInt16();

View File

@ -1,11 +1,12 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dipsw); writer.Write(dipsw);
@ -72,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, j; int i, j;
dipsw = reader.ReadByte(); dipsw = reader.ReadByte();

View File

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
@ -375,27 +376,19 @@ namespace MAME.Core
public static void nvram_handler_load_neogeo() public static void nvram_handler_load_neogeo()
{ {
if (MameMainMotion.IoSupport.File_Exists("nvram\\" + Machine.sName + ".nv")) if (File.Exists("nvram\\" + Machine.sName + ".nv"))
{ {
MameMainMotion.IoSupport.File_ReadAllBytes("nvram\\" + Machine.sName + ".nv"); FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
//FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open); int n = (int)fs1.Length;
//int n = (int)fs1.Length; fs1.Read(mainram2, 0, n);
//fs1.Read(mainram2, 0, n); fs1.Close();
//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,11 +1,12 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(dsw); writer.Write(dsw);
@ -76,7 +77,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, j; int i, j;
dsw = reader.ReadByte(); dsw = reader.ReadByte();

View File

@ -1,11 +1,12 @@
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(System.IO.BinaryWriter writer) public unsafe static void SaveStateBinary(BinaryWriter writer)
{ {
int i, j; int i, j;
writer.Write(pgm_tx_videoram, 0, 0x2000); writer.Write(pgm_tx_videoram, 0, 0x2000);
@ -57,7 +58,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(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i, j; int i, j;
pgm_tx_videoram = reader.ReadBytes(0x2000); pgm_tx_videoram = reader.ReadBytes(0x2000);

View File

@ -1,12 +1,14 @@
namespace MAME.Core using System.IO;
namespace MAME.Core
{ {
public partial class SunA8 public partial class SunA8
{ {
public static void SaveStateBinary_starfigh(System.IO.BinaryWriter writer) public static void SaveStateBinary_starfigh(BinaryWriter writer)
{ {
} }
public static void LoadStateBinary_starfigh(System.IO.BinaryReader reader) public static void LoadStateBinary_starfigh(BinaryReader reader)
{ {
} }

View File

@ -2,12 +2,13 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary_tokio(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -56,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_tokio(System.IO.BinaryReader reader) public static void LoadStateBinary_tokio(BinaryReader reader)
{ {
int i; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -105,7 +106,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_bublbobl(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -169,7 +170,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(System.IO.BinaryReader reader) public static void LoadStateBinary_bublbobl(BinaryReader reader)
{ {
int i; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -233,7 +234,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_boblbobl(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -287,7 +288,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(System.IO.BinaryReader reader) public static void LoadStateBinary_boblbobl(BinaryReader reader)
{ {
int i; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -340,7 +341,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_bub68705(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw0); writer.Write(dsw0);
@ -398,7 +399,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(System.IO.BinaryReader reader) public static void LoadStateBinary_bub68705(BinaryReader reader)
{ {
int i; int i;
dsw0 = reader.ReadByte(); dsw0 = reader.ReadByte();
@ -456,7 +457,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(System.IO.BinaryWriter writer) public static void SaveStateBinary_opwolf(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dswa); writer.Write(dswa);
@ -593,7 +594,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(System.IO.BinaryReader reader) public static void LoadStateBinary_opwolf(BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();

View File

@ -1,11 +1,13 @@
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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
//pixel_scroll //pixel_scroll
int i; int i;
@ -95,7 +97,7 @@ namespace MAME.Core
Eeprom.SaveStateBinary(writer); Eeprom.SaveStateBinary(writer);
Taitosnd.SaveStateBinary(writer); Taitosnd.SaveStateBinary(writer);
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
dswa = reader.ReadByte(); dswa = reader.ReadByte();

View File

@ -1,10 +1,11 @@
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(System.IO.BinaryWriter writer) public unsafe static void SaveStateBinary_pbaction(BinaryWriter writer)
{ {
int i; int i;
writer.Write(dsw1); writer.Write(dsw1);
@ -45,7 +46,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(System.IO.BinaryReader reader) public static void LoadStateBinary_pbaction(BinaryReader reader)
{ {
int i; int i;
dsw1 = reader.ReadByte(); dsw1 = reader.ReadByte();

View File

@ -1,11 +0,0 @@
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

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

View File

@ -1,4 +1,5 @@
 using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public unsafe class AY8910 public unsafe class AY8910
@ -557,7 +558,7 @@ namespace MAME.Core
} }
return ay8910info.regs[r]; return ay8910info.regs[r];
} }
public void SaveStateBinary(System.IO.BinaryWriter writer) public void SaveStateBinary(BinaryWriter writer)
{ {
int i; int i;
writer.Write(ay8910info.register_latch); writer.Write(ay8910info.register_latch);
@ -579,7 +580,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(System.IO.BinaryReader reader) public void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
ay8910info.register_latch = reader.ReadInt32(); ay8910info.register_latch = reader.ReadInt32();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
@ -271,7 +272,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(System.IO.BinaryWriter writer) public static void SaveStateBinary(BinaryWriter writer)
{ {
int i; int i;
writer.Write(OKI.command); writer.Write(OKI.command);
@ -287,7 +288,7 @@ namespace MAME.Core
writer.Write(adpcm[i].step); writer.Write(adpcm[i].step);
} }
} }
public static void LoadStateBinary(System.IO.BinaryReader reader) public static void LoadStateBinary(BinaryReader reader)
{ {
int i; int i;
OKI.command = reader.ReadInt32(); OKI.command = reader.ReadInt32();

View File

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

View File

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

View File

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

View File

@ -1,17 +1,16 @@
 using System.IO;
using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class WavWrite public class WavWrite
{ {
public static System.IO.FileStream mWaveFile = null; public static FileStream mWaveFile = null;
private static System.IO.BinaryWriter mWriter = null; private static 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 System.IO.BinaryWriter(mWaveFile); mWriter = new BinaryWriter(mWaveFile);
/************************************************************************** /**************************************************************************
Hereiswherethefilewillbecreated.A Hereiswherethefilewillbecreated.A
wavefileisaRIFFfile,whichhaschunks wavefileisaRIFFfile,whichhaschunks

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
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
@ -94,21 +95,21 @@ namespace StoicGooseUnity
} }
#endregion #endregion
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count) public static void Write(this 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 System.IO.FileStream fs, byte* bufferPtr, int offset, int count) public static void Write(this 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 System.IO.FileStream fs, byte* bufferPtr, int offset, int count) public static int Read(this 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(System.IO.Stream stream) public RgbaFile(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,4 +1,5 @@
using System; using System;
using System.IO;
namespace StoicGoose.Common.Utilities namespace StoicGoose.Common.Utilities
{ {
@ -31,37 +32,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,40 +1,41 @@
//using System.Reflection; using System.IO;
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 System.IO.Stream GetEmbeddedResourceStream(string name) private static 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;
// //} }
// } }
//} }

View File

@ -5,6 +5,7 @@ using AxibugProtobuf;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using static AxibugEmuOnline.Client.HttpAPI; using static AxibugEmuOnline.Client.HttpAPI;
@ -55,12 +56,9 @@ namespace AxibugEmuOnline.Client.ClientCore
static string s_persistentRoot = static string s_persistentRoot =
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机 #if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
"ux0:data/AxibugEmu"; "ux0:data/AxibugEmu";
#elif UNITY_SWITCH && !UNITY_EDITOR //Switch 真机
$"save:/AxibugEmu";
#else #else
Application.persistentDataPath; Application.persistentDataPath;
#endif #endif
public static string PersistentDataPath(RomPlatformType emuPlatform) public static string PersistentDataPath(RomPlatformType emuPlatform)
{ {
return s_persistentRoot + "/" + emuPlatform.ToString(); return s_persistentRoot + "/" + emuPlatform.ToString();
@ -132,10 +130,8 @@ namespace AxibugEmuOnline.Client.ClientCore
private static void PSP2Init() private static void PSP2Init()
{ {
//PSVita最好手动创建目录 //PSVita最好手动创建目录
if (!AxiIO.Directory.Exists("ux0:data/AxibugEmu")) if (!Directory.Exists("ux0:data/AxibugEmu"))
AxiIO.Directory.CreateDirectory("ux0:data/AxibugEmu"); Directory.CreateDirectory("ux0:data/AxibugEmu");
//if (!Directory.Exists("ux0:data/AxibugEmu"))
// Directory.CreateDirectory("ux0:data/AxibugEmu");
#if UNITY_PSP2 #if UNITY_PSP2
//创建PSV弹窗UI //创建PSV弹窗UI

View File

@ -1,7 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO.Compression; using System.IO;
using System.IO.Compression;
using System.Net; using System.Net;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
@ -161,7 +162,7 @@ public static class AxiHttp
public string fileName; public string fileName;
public float DownLoadPr => public float DownLoadPr =>
NeedloadedLenght <= 0 ? -1 : (float)loadedLenght / NeedloadedLenght; NeedloadedLenght <= 0 ? -1 : (float)loadedLenght / NeedloadedLenght;
public System.IO.BinaryWriter binaryWriter; public BinaryWriter binaryWriter;
} }
public static IPAddress GetDnsIP(string str) public static IPAddress GetDnsIP(string str)
@ -267,7 +268,7 @@ public static class AxiHttp
var ipEndPoint = new IPEndPoint(ip, port); var ipEndPoint = new IPEndPoint(ip, port);
using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) using (MemoryStream memoryStream = new MemoryStream())
{ {
client.Connect(ipEndPoint); client.Connect(ipEndPoint);
if (!client.Connected) if (!client.Connected)
@ -496,7 +497,7 @@ public static class AxiHttp
// 使用Uri类解析URL // 使用Uri类解析URL
Uri uri = new Uri(url); Uri uri = new Uri(url);
respinfo.fileName = System.IO.Path.GetFileName(uri.LocalPath); respinfo.fileName = Path.GetFileName(uri.LocalPath);
} }
else else
{ {
@ -566,7 +567,7 @@ public static class AxiHttp
//using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) //using (Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
//using (TcpClient tcpclient = new TcpClient()) //using (TcpClient tcpclient = new TcpClient())
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) using (MemoryStream memoryStream = new MemoryStream())
{ {
//client.Connect(ipEndPoint); //client.Connect(ipEndPoint);
@ -779,7 +780,7 @@ public static class AxiHttp
// 使用Uri类解析URL // 使用Uri类解析URL
Uri uri = new Uri(url); Uri uri = new Uri(url);
respinfo.fileName = System.IO.Path.GetFileName(uri.LocalPath); respinfo.fileName = Path.GetFileName(uri.LocalPath);
} }
else else
{ {
@ -864,9 +865,9 @@ public static class AxiHttp
{ {
string str = ""; string str = "";
System.IO.MemoryStream ms = new System.IO.MemoryStream(data, 0, len); MemoryStream ms = new MemoryStream(data, 0, len);
GZipStream gs = new GZipStream(ms, CompressionMode.Decompress); GZipStream gs = new GZipStream(ms, CompressionMode.Decompress);
System.IO.MemoryStream outbuf = new System.IO.MemoryStream(); MemoryStream outbuf = new MemoryStream();
byte[] block = new byte[1024]; byte[] block = new byte[1024];
try try
@ -903,9 +904,9 @@ public static class AxiHttp
public static byte[] unGzipBytes(byte[] data, int len) public static byte[] unGzipBytes(byte[] data, int len)
{ {
System.IO.MemoryStream ms = new System.IO.MemoryStream(data, 0, len); MemoryStream ms = new MemoryStream(data, 0, len);
GZipStream gs = new GZipStream(ms, CompressionMode.Decompress); GZipStream gs = new GZipStream(ms, CompressionMode.Decompress);
System.IO.MemoryStream outbuf = new System.IO.MemoryStream(); MemoryStream outbuf = new MemoryStream();
byte[] block = new byte[1024]; byte[] block = new byte[1024];
byte[] result; byte[] result;
try try

View File

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

View File

@ -1,89 +0,0 @@
using System.Collections.Generic;
namespace AxiIO
{
public static class AxiIO
{
static IAxiIO m_io;
public static IAxiIO io
{
get
{
if (m_io == null)
{
#if UNITY_SWITCH && !UNITY_EDITOR
m_io = new NSwitchIO();
#else
m_io = new CSharpIO();
#endif
}
return m_io;
}
}
}
public static class File
{
internal static void Delete(string filePath)
{
AxiIO.io.file_Delete(filePath);
}
internal static bool Exists(string filePath)
{
return AxiIO.io.file_Exists(filePath);
}
internal static byte[] ReadAllBytes(string filePath)
{
return AxiIO.io.file_ReadAllBytes(filePath);
}
internal static int ReadBytesToArr(string filePath, byte[] readToArr, int start, int len)
{
return AxiIO.io.file_ReadBytesToArr(filePath, readToArr, start, len);
}
internal static void WriteAllBytes(string path, byte[] data)
{
AxiIO.io.file_WriteAllBytes(path, data);
}
internal static void WriteAllBytesFromStream(string path, System.IO.MemoryStream ms)
{
AxiIO.io.file_WriteAllBytes(path, ms);
}
}
public static class Directory
{
public static bool Exists(string dirpath)
{
return AxiIO.io.dir_Exists(dirpath);
}
public static void CreateDirectory(string dirpath)
{
AxiIO.io.dir_CreateDirectory(dirpath);
}
public static IEnumerable<string> EnumerateFiles(string path, string searchPattern)
{
return AxiIO.io.dir_EnumerateFiles(path, searchPattern);
}
public static string[] GetDirectories(string path)
{
return AxiIO.io.dir_GetDirectories(path);
}
public static string[] GetFiles(string path)
{
return AxiIO.io.dir_GetFiles(path);
}
internal static void Delete(string cacheDirPath, bool v)
{
AxiIO.io.dir_Delete(cacheDirPath, v);
}
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 32f63f62398d8184590292135b011084

View File

@ -1,70 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace AxiIO
{
public class CSharpIO : IAxiIO
{
public void dir_CreateDirectory(string dirpath)
{
System.IO.Directory.CreateDirectory(dirpath);
}
public void dir_Delete(string path, bool recursive)
{
System.IO.Directory.Delete(path, recursive);
}
public IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern)
{
return System.IO.Directory.EnumerateFiles(path, searchPattern);
}
public bool dir_Exists(string dirpath)
{
return System.IO.Directory.Exists(dirpath);
}
public void file_WriteAllBytes(string filePath, byte[] data)
{
System.IO.File.WriteAllBytes(filePath, data);
}
public void file_WriteAllBytes(string filePath, MemoryStream ms)
{
System.IO.File.WriteAllBytes(filePath, ms.ToArray());
}
public void file_Delete(string filePath)
{
System.IO.File.Delete(filePath);
}
public bool file_Exists(string filePath)
{
return System.IO.File.Exists(filePath);
}
public byte[] file_ReadAllBytes(string filePath)
{
return System.IO.File.ReadAllBytes(filePath);
}
public int file_ReadBytesToArr(string filePath, byte[] readToArr, int start, int len)
{
FileStream streaming = System.IO.File.OpenRead(filePath);
return streaming.Read(readToArr, 0, 4);
}
public string[] dir_GetDirectories(string path)
{
return System.IO.Directory.GetDirectories(path);
}
public string[] dir_GetFiles(string path)
{
return System.IO.Directory.GetFiles(path);
}
}
}

View File

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

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
namespace AxiIO
{
public interface IAxiIO
{
bool dir_Exists(string dirpath);
void dir_CreateDirectory(string dirpath);
IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern);
void dir_Delete(string path, bool recursive);
byte[] file_ReadAllBytes(string filePath);
bool file_Exists(string filePath);
void file_Delete(string filePath);
void file_WriteAllBytes(string filePath, byte[] data);
void file_WriteAllBytes(string filePath, System.IO.MemoryStream ms);
int file_ReadBytesToArr(string filePath, byte[] readToArr, int start, int len);
string[] dir_GetDirectories(string path);
string[] dir_GetFiles(string path);
};
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 588eae2a7e121cc40907d8ac6f4250d4

View File

@ -1,83 +0,0 @@
using System;
using System.Collections.Generic;
namespace AxiIO
{
public class NSwitchIO : IAxiIO
{
public NSwitchIO()
{
AxiNS.instance.Init();
}
public void dir_CreateDirectory(string dirpath)
{
AxiNS.instance.io.CreateDir(dirpath);
}
public void dir_Delete(string path, bool recursive)
{
AxiNS.instance.io.DeletePathFile(path);
}
public IEnumerable<string> dir_EnumerateFiles(string path, string searchPattern)
{
return AxiNS.instance.io.EnumerateFiles(path, searchPattern);
}
public bool dir_Exists(string dirpath)
{
return AxiNS.instance.io.CheckPathExists(dirpath);
}
public string[] dir_GetDirectories(string path)
{
if (!AxiNS.instance.io.GetDirectoryDirs(path, out string[] result))
{
return new string[0];
}
return result;
}
public string[] dir_GetFiles(string path)
{
if (!AxiNS.instance.io.GetDirectoryFiles(path, out string[] result))
{
return new string[0];
}
return result;
}
public void file_Delete(string filePath)
{
AxiNS.instance.io.DeletePathFile(filePath);
}
public bool file_Exists(string filePath)
{
return AxiNS.instance.io.CheckPathExists(filePath);
}
public byte[] file_ReadAllBytes(string filePath)
{
return AxiNS.instance.io.LoadSwitchDataFile(filePath);
}
public int file_ReadBytesToArr(string filePath, byte[] readToArr, int start, int len)
{
byte[] bytes = file_ReadAllBytes(filePath);
int templen = Math.Min(len, bytes.Length);
Array.Copy(readToArr, readToArr, len);
return templen;
}
public void file_WriteAllBytes(string filePath, byte[] data)
{
AxiNS.instance.io.FileToSaveWithCreate(filePath, data);
}
public void file_WriteAllBytes(string filePath, System.IO.MemoryStream ms)
{
AxiNS.instance.io.FileToSaveWithCreate(filePath, ms);
}
}
}

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 3da9b14bf7568f34989774dc5f5fbcf4

View File

@ -1,4 +1,4 @@
{ {
"name": "AxibugEmuOnline.Client", "name": "AxibugEmuOnline.Client",
"rootNamespace": "", "rootNamespace": "",
"references": [ "references": [
@ -7,9 +7,8 @@
"UIEffect2018", "UIEffect2018",
"Mame.Core", "Mame.Core",
"Essgee.Unity", "Essgee.Unity",
"StoicGooseUnity", "StoicGooseUnity",
"Unity.InputSystem", "Unity.InputSystem"
"AxiNSApi"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -1,5 +1,6 @@
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.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@ -25,7 +26,7 @@ namespace AxibugEmuOnline.Client.Common
public static byte[] CompressByteArray(byte[] bytesToCompress) public static byte[] CompressByteArray(byte[] bytesToCompress)
{ {
using (var compressedMemoryStream = new System.IO.MemoryStream()) using (var compressedMemoryStream = new MemoryStream())
using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Compress)) using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Compress))
{ {
gzipStream.Write(bytesToCompress, 0, bytesToCompress.Length); gzipStream.Write(bytesToCompress, 0, bytesToCompress.Length);
@ -36,35 +37,35 @@ namespace AxibugEmuOnline.Client.Common
public static byte[] DecompressByteArray(byte[] compressedBytes) public static byte[] DecompressByteArray(byte[] compressedBytes)
{ {
using (var compressedMemoryStream = new System.IO.MemoryStream(compressedBytes)) using (var compressedMemoryStream = new MemoryStream(compressedBytes))
using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Decompress)) using (var gzipStream = new GZipStream(compressedMemoryStream, CompressionMode.Decompress))
using (var resultMemoryStream = new System.IO.MemoryStream()) using (var resultMemoryStream = new MemoryStream())
{ {
gzipStream.CopyTo(resultMemoryStream); gzipStream.CopyTo(resultMemoryStream);
return resultMemoryStream.ToArray(); return resultMemoryStream.ToArray();
} }
} }
//public static string FileMD5Hash(string filePath) public static string FileMD5Hash(string filePath)
//{ {
// using (var md5 = MD5.Create()) using (var md5 = MD5.Create())
// { {
// using (var stream = File.OpenRead(filePath)) using (var stream = File.OpenRead(filePath))
// { {
// var hash = md5.ComputeHash(stream); var hash = md5.ComputeHash(stream);
// var sb = new StringBuilder(hash.Length * 2); var sb = new StringBuilder(hash.Length * 2);
// foreach (var b in hash) foreach (var b in hash)
// sb.AppendFormat("{0:x2}", b); sb.AppendFormat("{0:x2}", b);
// return sb.ToString(); return sb.ToString();
// } }
// } }
//} }
static byte[] FileMD5HashByte(byte[] data) static byte[] FileMD5HashByte(byte[] data)
{ {
using (var md5 = MD5.Create()) using (var md5 = MD5.Create())
{ {
using (var stream = new System.IO.MemoryStream(data)) using (var stream = new MemoryStream(data))
{ {
return md5.ComputeHash(stream); return md5.ComputeHash(stream);
} }

View File

@ -11,7 +11,7 @@ using Essgee.Metadata;
using Essgee.Utilities; using Essgee.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
@ -40,7 +40,6 @@ public class UEssgee : MonoBehaviour, IEmuCore
GameMetadata lastGameMetadata; GameMetadata lastGameMetadata;
Essgee.Emulation.EmulatorHandler emulatorHandler; Essgee.Emulation.EmulatorHandler emulatorHandler;
UEGResources uegResources; UEGResources uegResources;
UEGIO uegIO;
UEGLog uegLog; UEGLog uegLog;
UEGSaveByteConvert uegSaveByteConvert; UEGSaveByteConvert uegSaveByteConvert;
private Canvas mCanvas; private Canvas mCanvas;
@ -56,7 +55,6 @@ public class UEssgee : MonoBehaviour, IEmuCore
App.tick.SetFrameRate(60); App.tick.SetFrameRate(60);
instance = this; instance = this;
uegResources = new UEGResources(); uegResources = new UEGResources();
uegIO = new UEGIO();
uegLog = new UEGLog(); uegLog = new UEGLog();
uegSaveByteConvert = new UEGSaveByteConvert(); uegSaveByteConvert = new UEGSaveByteConvert();
mCanvas = GameObject.Find("Canvas").GetComponent<Canvas>(); mCanvas = GameObject.Find("Canvas").GetComponent<Canvas>();
@ -106,7 +104,7 @@ public class UEssgee : MonoBehaviour, IEmuCore
{ {
mPlatform = romFile.Platform; mPlatform = romFile.Platform;
InitAll(uegResources, uegIO, App.PersistentDataPath(mPlatform)); InitAll(uegResources, App.PersistentDataPath(mPlatform));
bLogicUpdatePause = true; bLogicUpdatePause = true;
@ -167,18 +165,17 @@ public class UEssgee : MonoBehaviour, IEmuCore
} }
#endregion #endregion
void InitAll(IGameMetaReources metaresources, IEssgeeIOSupport uegIO, string CustonDataDir) void InitAll(IGameMetaReources metaresources, string CustonDataDir)
{ {
//³õʼ»¯ÅäÖà //³õʼ»¯ÅäÖÃ
InitAppEnvironment(CustonDataDir, uegIO); InitAppEnvironment(CustonDataDir);
InitEmu(); InitEmu();
//ϸ½Ú³õʼ»¯ //ϸ½Ú³õʼ»¯
InitializeHandlers(metaresources); InitializeHandlers(metaresources);
} }
private void InitAppEnvironment(string CustonDataDir, IEssgeeIOSupport uegIO) private void InitAppEnvironment(string CustonDataDir)
{ {
Essgee.Emulation.EmulatorHandler.io = uegIO;
EssgeeLogger.Init(uegLog); EssgeeLogger.Init(uegLog);
//EmuStandInfo.datDirectoryPath = Path.Combine(BaseDataDir, "EssgeeAssets", "No-Intro"); //EmuStandInfo.datDirectoryPath = Path.Combine(BaseDataDir, "EssgeeAssets", "No-Intro");
@ -192,29 +189,29 @@ public class UEssgee : MonoBehaviour, IEmuCore
EmuStandInfo.ProductName = "AxibugEmu"; EmuStandInfo.ProductName = "AxibugEmu";
EmuStandInfo.ProductVersion = ""; EmuStandInfo.ProductVersion = "";
EmuStandInfo.programDataDirectory = System.IO.Path.Combine(CustonDataDir, EmuStandInfo.ProductName); EmuStandInfo.programDataDirectory = Path.Combine(CustonDataDir, EmuStandInfo.ProductName);
EmuStandInfo.programConfigPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.jsonConfigFileName); EmuStandInfo.programConfigPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.jsonConfigFileName);
EmuStandInfo.ShaderPath = System.IO.Path.Combine(CustonDataDir, "Assets", "Shaders"); EmuStandInfo.ShaderPath = Path.Combine(CustonDataDir, "Assets", "Shaders");
EmuStandInfo.SaveDataPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveDataDirectoryName); EmuStandInfo.SaveDataPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveDataDirectoryName);
EmuStandInfo.ScreenshotPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.screenshotDirectoryName); EmuStandInfo.ScreenshotPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.screenshotDirectoryName);
EmuStandInfo.SaveStatePath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveStateDirectoryName); EmuStandInfo.SaveStatePath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.saveStateDirectoryName);
EmuStandInfo.ExtraDataPath = System.IO.Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.extraDataDirectoryName); EmuStandInfo.ExtraDataPath = Path.Combine(EmuStandInfo.programDataDirectory, EmuStandInfo.extraDataDirectoryName);
LoadConfiguration(); LoadConfiguration();
if (!AxiIO.Directory.Exists(EmuStandInfo.SaveDataPath)) if (!Directory.Exists(EmuStandInfo.SaveDataPath))
AxiIO.Directory.CreateDirectory(EmuStandInfo.SaveDataPath); Directory.CreateDirectory(EmuStandInfo.SaveDataPath);
if (!AxiIO.Directory.Exists(EmuStandInfo.ScreenshotPath)) if (!Directory.Exists(EmuStandInfo.ScreenshotPath))
AxiIO.Directory.CreateDirectory(EmuStandInfo.ScreenshotPath); Directory.CreateDirectory(EmuStandInfo.ScreenshotPath);
if (!AxiIO.Directory.Exists(EmuStandInfo.SaveStatePath)) if (!Directory.Exists(EmuStandInfo.SaveStatePath))
AxiIO.Directory.CreateDirectory(EmuStandInfo.SaveStatePath); Directory.CreateDirectory(EmuStandInfo.SaveStatePath);
if (!AxiIO.Directory.Exists(EmuStandInfo.ExtraDataPath)) if (!Directory.Exists(EmuStandInfo.ExtraDataPath))
AxiIO.Directory.CreateDirectory(EmuStandInfo.ExtraDataPath); Directory.CreateDirectory(EmuStandInfo.ExtraDataPath);
if (AppEnvironment.EnableLogger) if (AppEnvironment.EnableLogger)
{ {
@ -759,13 +756,13 @@ public class UEssgee : MonoBehaviour, IEmuCore
} }
/* Generate filename/path */ /* Generate filename/path */
var filePrefix = $"{System.IO.Path.GetFileNameWithoutExtension(lastGameMetadata.FileName)} ({e.Description}{(includeDateTime ? $" {DateTime.Now:yyyy-MM-dd HH-mm-ss})" : ")")}"; var filePrefix = $"{Path.GetFileNameWithoutExtension(lastGameMetadata.FileName)} ({e.Description}{(includeDateTime ? $" {DateTime.Now:yyyy-MM-dd HH-mm-ss})" : ")")}";
var filePath = System.IO.Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix}.{extension}"); var filePath = Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix}.{extension}");
if (!allowOverwrite) if (!allowOverwrite)
{ {
var existingFiles = AxiIO.Directory.EnumerateFiles(EmuStandInfo.ExtraDataPath, $"{filePrefix}*{extension}"); var existingFiles = Directory.EnumerateFiles(EmuStandInfo.ExtraDataPath, $"{filePrefix}*{extension}");
if (existingFiles.Contains(filePath)) if (existingFiles.Contains(filePath))
for (int i = 2; existingFiles.Contains(filePath = System.IO.Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix} ({i}).{extension}")); i++) { } for (int i = 2; existingFiles.Contains(filePath = Path.Combine(EmuStandInfo.ExtraDataPath, $"{filePrefix} ({i}).{extension}")); i++) { }
} }
/* Handle data */ /* Handle data */
@ -780,12 +777,10 @@ public class UEssgee : MonoBehaviour, IEmuCore
else if (e.Data is byte[] raw) else if (e.Data is byte[] raw)
{ {
/* Raw bytes */ /* Raw bytes */
//using (var file = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) using (var file = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
//{ {
// file.Write(raw, 0, raw.Length); file.Write(raw, 0, raw.Length);
//} }
AxiIO.File.WriteAllBytes(filePath, raw);
} }
} }

View File

@ -1,25 +0,0 @@
using Essgee.Metadata;
using System.IO;
public class UEGIO : IEssgeeIOSupport
{
public bool File_Exists(string path)
{
return AxiIO.File.Exists(path);
}
public byte[] File_ReadAllBytes(string path)
{
return AxiIO.File.ReadAllBytes(path);
}
public void File_WriteAllBytes(string savePath, byte[] data)
{
AxiIO.File.WriteAllBytes(savePath, data);
}
public void File_WriteAllBytesFromStre(string path, MemoryStream ms)
{
AxiIO.File.WriteAllBytesFromStream(path, ms);
}
}

View File

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

View File

@ -1,6 +1,9 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEngine; using UnityEngine;
public class UEGSoundPlayer : MonoBehaviour public class UEGSoundPlayer : MonoBehaviour

View File

@ -5,6 +5,7 @@ using AxiReplay;
using MAME.Core; using MAME.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -20,7 +21,6 @@ public class UMAME : MonoBehaviour, IEmuCore
UniSoundPlayer mUniSoundPlayer; UniSoundPlayer mUniSoundPlayer;
UniKeyboard mUniKeyboard; UniKeyboard mUniKeyboard;
UniResources mUniResources; UniResources mUniResources;
UniIO mUniIO;
public Text mFPS; public Text mFPS;
private Canvas mCanvas; private Canvas mCanvas;
@ -54,10 +54,9 @@ public class UMAME : MonoBehaviour, IEmuCore
mUniSoundPlayer = GameObject.Find("Audio").transform.GetComponent<UniSoundPlayer>(); mUniSoundPlayer = GameObject.Find("Audio").transform.GetComponent<UniSoundPlayer>();
mUniKeyboard = this.gameObject.AddComponent<UniKeyboard>(); mUniKeyboard = this.gameObject.AddComponent<UniKeyboard>();
mUniResources = new UniResources(); mUniResources = new UniResources();
mUniIO = new UniIO();
mChangeRomName = string.Empty; mChangeRomName = string.Empty;
mTimeSpan = new UniTimeSpan(); mTimeSpan = new UniTimeSpan();
emu.Init(RomPath, mUniLog, mUniResources, mUniVideoPlayer, mUniSoundPlayer, mUniKeyboard, mUniMouse, mTimeSpan, mUniIO); emu.Init(RomPath, mUniLog, mUniResources, mUniVideoPlayer, mUniSoundPlayer, mUniKeyboard, mUniMouse, mTimeSpan);
} }
void OnEnable() void OnEnable()
{ {
@ -198,11 +197,11 @@ public class UMAME : MonoBehaviour, IEmuCore
} }
byte[] SaveState() byte[] SaveState()
{ {
if (!AxiIO.Directory.Exists(SavePath)) if (!Directory.Exists(SavePath))
AxiIO.Directory.CreateDirectory(SavePath); Directory.CreateDirectory(SavePath);
System.IO.MemoryStream ms = new System.IO.MemoryStream(); MemoryStream ms = new MemoryStream();
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); BinaryWriter bw = new BinaryWriter(ms);
emu.SaveState(bw); emu.SaveState(bw);
byte[] data = ms.ToArray(); byte[] data = ms.ToArray();
bw.Close(); bw.Close();
@ -219,8 +218,8 @@ public class UMAME : MonoBehaviour, IEmuCore
} }
void LoadState(byte[] data) void LoadState(byte[] data)
{ {
System.IO.MemoryStream fs = new System.IO.MemoryStream(data); MemoryStream fs = new MemoryStream(data);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs); BinaryReader br = new BinaryReader(fs);
emu.LoadState(br); emu.LoadState(br);
br.Close(); br.Close();
fs.Close(); fs.Close();

View File

@ -1,19 +0,0 @@
using MAME.Core;
public class UniIO : IMAMEIOSupport
{
public bool File_Exists(string path)
{
return AxiIO.File.Exists(path);
}
public byte[] File_ReadAllBytes(string path)
{
return AxiIO.File.ReadAllBytes(path);
}
public void File_WriteAllBytesFromStre(string path, System.IO.MemoryStream ms)
{
AxiIO.File.WriteAllBytesFromStream(path, ms);
}
}

View File

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

View File

@ -2,6 +2,7 @@
using AxibugProtobuf; using AxibugProtobuf;
using AxiReplay; using AxiReplay;
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using UnityEngine; using UnityEngine;
using VirtualNes.Core; using VirtualNes.Core;
@ -16,14 +17,14 @@ namespace AxibugEmuOnline.Client
m_controllerMapper = conMapper; m_controllerMapper = conMapper;
} }
public System.IO.Stream OpenRom(string fname) public Stream OpenRom(string fname)
{ {
try try
{ {
var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname); var romFile = App.GetRomLib(RomPlatformType.Nes).GetRomFile(fname);
var bytes = romFile.GetRomFileData(); var bytes = romFile.GetRomFileData();
Debug.Log($"Open {romFile.Alias}"); Debug.Log($"Open {romFile.Alias}");
return new System.IO.MemoryStream(bytes); return new MemoryStream(bytes);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -38,34 +39,34 @@ namespace AxibugEmuOnline.Client
UnityEngine.Debug.Assert(romFile != null); UnityEngine.Debug.Assert(romFile != null);
fullPath = romFile.LocalFilePath; fullPath = romFile.LocalFilePath;
directPath = System.IO.Path.GetDirectoryName(fullPath); directPath = Path.GetDirectoryName(fullPath);
} }
public System.IO.Stream OpenFile_DISKSYS() public Stream OpenFile_DISKSYS()
{ {
return new System.IO.MemoryStream(Resources.Load<TextAsset>("NES/Disksys.rom").bytes); return new MemoryStream(Resources.Load<TextAsset>("NES/Disksys.rom").bytes);
} }
public void SaveSRAMToFile(byte[] sramContent, string romName) public void SaveSRAMToFile(byte[] sramContent, string romName)
{ {
string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}"; string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}";
AxiIO.Directory.CreateDirectory(sramDirectoryPath); Directory.CreateDirectory(sramDirectoryPath);
romName = System.IO.Path.GetFileNameWithoutExtension(romName); romName = Path.GetFileNameWithoutExtension(romName);
AxiIO.File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent); File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
} }
public void SaveDISKToFile(byte[] diskFileContent, string romName) public void SaveDISKToFile(byte[] diskFileContent, string romName)
{ {
string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/dsv"; string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/dsv";
AxiIO.Directory.CreateDirectory(diskFileDirectoryPath); Directory.CreateDirectory(diskFileDirectoryPath);
romName = System.IO.Path.GetFileNameWithoutExtension(romName); romName = Path.GetFileNameWithoutExtension(romName);
AxiIO.File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent); File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
} }
public EmulatorConfig Config { get; private set; } = new EmulatorConfig(); public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
public void PrepareDirectory(string directPath) public void PrepareDirectory(string directPath)
{ {
AxiIO.Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}"); Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}");
} }
public void SaveFile(byte[] fileData, string directPath, string fileName) public void SaveFile(byte[] fileData, string directPath, string fileName)
@ -73,17 +74,17 @@ namespace AxibugEmuOnline.Client
PrepareDirectory(directPath); PrepareDirectory(directPath);
var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}"; var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
AxiIO.File.WriteAllBytes(fileFullpath, fileData); File.WriteAllBytes(fileFullpath, fileData);
} }
public System.IO.Stream OpenFile(string directPath, string fileName) public Stream OpenFile(string directPath, string fileName)
{ {
try try
{ {
var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}"; var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
var data = AxiIO.File.ReadAllBytes(path); var data = File.ReadAllBytes(path);
if (data == null) return null; if (data == null) return null;
return new System.IO.MemoryStream(data); return new MemoryStream(data);
} }
catch catch
{ {

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