1
0
This commit is contained in:
ALIENJACK\alien 2025-04-25 16:28:13 +08:00
commit e8bac390af
114 changed files with 4028 additions and 841 deletions
AxibugEmuOnline.Client/Assets
AxiProjectTools/AxiNSPack/Editors
Plugins
Resources/UIPrefabs
Script/AppMain

View File

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
@ -20,7 +19,17 @@ namespace AxibugEmuOnline.Editors
static Dictionary<string, string> tools = new Dictionary<string, string>();
static string prodKeysPath;
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/RepackNSP(쏭路劤뭐쉔NPS")]
static void InitToolPath()
{
#region
// 获取环境变量(需要添加环境变量检查)
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
#endregion
}
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/RepackNSP(仅重新构建NSP")]
static void RepackNSP()
{
if (!CheckEnvironmentVariable())
@ -38,7 +47,29 @@ namespace AxibugEmuOnline.Editors
RepackNSP(path);
}
[MenuItem("Axibug盧濂묏야/Switch/AxibugNSPTools/Build With RepackNSP(댔관NSP깻路劤뭐쉔NPS")]
//[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/UnpackNSP(解包工具)")]
//static void UnpackNSP()
//{
// InitToolPath();
// if (!CheckEnvironmentVariable())
// return;
// string nspFilePath = EditorUtility.OpenFilePanel(
// title: "选择 .nsp 文件",
// directory: Path.Combine(Application.dataPath, ".."), // 默认路径为项目 Assets 目录
// extension: "nsp" // 限制文件类型为 .nsp
// );
// if (string.IsNullOrEmpty(nspFilePath))
// return;
// string nspParentDir = Path.GetDirectoryName(nspFilePath);
// string extractPath = Path.Combine(nspParentDir, "repacker_extract");
// ExecuteCommand($"{tools["authoringTool"]} extract -o \"{extractPath}\" \"{nspFilePath}\"", nspParentDir);
//}
[MenuItem("Axibug移植工具/Switch/AxibugNSPTools/Build With RepackNSP(打包NSP并重新构建NSP")]
public static void BuildWithRepackNSP()
{
if (!CheckEnvironmentVariable())
@ -121,12 +152,7 @@ namespace AxibugEmuOnline.Editors
static void RepackNSP(string nspFile)
{
#region
// 삿혤뻔쓱긴좆(矜狼警속뻔쓱긴좆쇱꿴)
string sdkRoot = Environment.GetEnvironmentVariable("NINTENDO_SDK_ROOT");
tools["authoringTool"] = Path.Combine(sdkRoot, "Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe");
tools["hacPack"] = Path.Combine(hacpack_root, "hacpack");
#endregion
InitToolPath();
#region ´¦ÀíNSPÎļþ·¾
string nspFilePath = nspFile;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Essgee.Utilities
@ -84,21 +83,21 @@ namespace Essgee.Utilities
}
#endregion
public static void Write(this BinaryWriter bw, byte* bufferPtr, int offset, int count)
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count)
{
// 使用指针复制数据到临时数组
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组
bw.Write(TempBuffer_src, 0, count);
}
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
{
// 使用指针复制数据到临时数组
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组
fs.Write(TempBuffer_src, 0, count);
}
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
{
// 使用BinaryWriter写入临时数组
count = fs.Read(TempBuffer_src, offset, count);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,6 @@ using Essgee.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
namespace Essgee.Emulation.Machines
@ -365,9 +364,22 @@ namespace Essgee.Emulation.Machines
irDatabaseCurrentIndex = irCycles = 0;
irExternalTransferActive = false;
if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && File.Exists(configuration.InfraredDatabasePikachu))
//if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && EmulatorHandler.io.File_Exists(configuration.InfraredDatabasePikachu))
//{
// using (var reader = new System.IO.BinaryReader(new FileStream(configuration.InfraredDatabasePikachu, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)))
// {
// irDatabase = new ushort[reader.BaseStream.Length / 2];
// for (var i = 0; i < irDatabase.Length; i++)
// irDatabase[i] = reader.ReadUInt16();
// irDatabaseStep = 2007;
// if ((irDatabaseBaseIndex < 0) || (irDatabaseBaseIndex * irDatabaseStep >= irDatabase.Length))
// irDatabaseBaseIndex = 0;
// }
//}
if (configuration.InfraredSource == InfraredSources.PocketPikachuColor && EmulatorHandler.io.File_Exists(configuration.InfraredDatabasePikachu))
{
using (var reader = new BinaryReader(new FileStream(configuration.InfraredDatabasePikachu, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)))
using (var reader = new System.IO.BinaryReader(new System.IO.MemoryStream(EmulatorHandler.io.File_ReadAllBytes(configuration.InfraredDatabasePikachu))))
{
irDatabase = new ushort[reader.BaseStream.Length / 2];
for (var i = 0; i < irDatabase.Length; i++)

View File

@ -1,6 +1,4 @@
using System.IO;
namespace Essgee.Emulation
namespace Essgee.Emulation
{
public static class SaveStateHandler
{
@ -42,12 +40,12 @@ namespace Essgee.Emulation
// }
//}
public static AxiEssgssStatusData LoadAxiStatus(Stream stream, string machineName)
public static AxiEssgssStatusData LoadAxiStatus(System.IO.Stream stream, string machineName)
{
using (var reader = new BinaryReader(stream))
using (var reader = new System.IO.BinaryReader(stream))
{
/* Check CRC32 */
using (var stateStream = new MemoryStream())
using (var stateStream = new System.IO.MemoryStream())
{
reader.BaseStream.CopyTo(stateStream);
return stateStream.ToArray().ToAxiEssgssStatusData();
@ -102,11 +100,11 @@ namespace Essgee.Emulation
// }
//}
public static void Save(Stream stream, string machineName, AxiEssgssStatusData state)
{
byte[] data = state.ToByteArray();
stream.Write(data, 0, data.Length);
}
//public static void Save(Stream stream, string machineName, AxiEssgssStatusData state)
//{
// byte[] data = state.ToByteArray();
// stream.Write(data, 0, data.Length);
//}
//private static string GenerateMachineIdString(string machineId)
//{
// return machineId.Substring(0, Math.Min(machineId.Length, 16)).PadRight(16);

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
@ -20,7 +19,7 @@ namespace Essgee.Extensions
public static string ReadEmbeddedTextFile(this Assembly assembly, string resourceName)
{
using (var reader = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
using (var reader = new System.IO.StreamReader(assembly.GetManifestResourceStream(resourceName)))
return reader.ReadToEnd();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
using MAME.Core;
using System;
using System.IO;
//using System.IO;
namespace cpu.m6502
{
@ -232,7 +230,7 @@ namespace cpu.m6502
}
}
}
public void SaveStateBinary(BinaryWriter writer)
public void SaveStateBinary(System.IO.BinaryWriter writer)
{
writer.Write(subtype);
writer.Write(ppc.LowWord);
@ -250,7 +248,7 @@ namespace cpu.m6502
writer.Write(TotalExecutedCycles);
writer.Write(PendingCycles);
}
public void LoadStateBinary(BinaryReader reader)
public void LoadStateBinary(System.IO.BinaryReader reader)
{
subtype = reader.ReadByte();
ppc.LowWord = reader.ReadUInt16();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,4 @@
using MAME.Core;
using System.IO;

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

View File

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

View File

@ -1,6 +1,4 @@
using System.IO;
namespace MAME.Core
namespace MAME.Core
{
public class Pd4900a
{
@ -312,7 +310,7 @@ namespace MAME.Core
{
pd4990a_serial_control((byte)(data & 0x7));
}
public static void SaveStateBinary(BinaryWriter writer)
public static void SaveStateBinary(System.IO.BinaryWriter writer)
{
writer.Write(pd4990a.seconds);
writer.Write(pd4990a.minutes);
@ -334,7 +332,7 @@ namespace MAME.Core
writer.Write(clock_line);
writer.Write(command_line);
}
public static void LoadStateBinary(BinaryReader reader)
public static void LoadStateBinary(System.IO.BinaryReader reader)
{
pd4990a.seconds = reader.ReadInt32();
pd4990a.minutes = reader.ReadInt32();

View File

@ -1,11 +1,9 @@
using System.IO;
namespace MAME.Core
namespace MAME.Core
{
public class State
{
public delegate void savestate_delegate(BinaryWriter sw);
public delegate void loadstate_delegate(BinaryReader sr);
public delegate void savestate_delegate(System.IO.BinaryWriter sw);
public delegate void loadstate_delegate(System.IO.BinaryReader sr);
public static savestate_delegate savestate_callback;
public static loadstate_delegate loadstate_callback;
public static void state_init()

View File

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

View File

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

View File

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

View File

@ -1,11 +1,10 @@
using cpu.m6502;
using System.IO;
namespace MAME.Core
{
public unsafe partial class Dataeast
{
public static void SaveStateBinary_pcktgal(BinaryWriter writer)
public static void SaveStateBinary_pcktgal(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw);
@ -48,7 +47,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_pcktgal(BinaryReader reader)
public static void LoadStateBinary_pcktgal(System.IO.BinaryReader reader)
{
int i;
dsw = reader.ReadByte();

View File

@ -1,11 +1,10 @@
using cpu.m68000;
using System.IO;
namespace MAME.Core
{
public unsafe partial class IGS011
{
public static void SaveStateBinary(BinaryWriter writer)
public static void SaveStateBinary(System.IO.BinaryWriter writer)
{
int i, j;
for (i = 0; i < 0x800; i++)
@ -74,7 +73,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary(BinaryReader reader)
public static void LoadStateBinary(System.IO.BinaryReader reader)
{
int i, j;
for (i = 0; i < 0x800; i++)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace MAME.Core
@ -376,19 +375,27 @@ namespace MAME.Core
public static void nvram_handler_load_neogeo()
{
if (File.Exists("nvram\\" + Machine.sName + ".nv"))
if (MameMainMotion.IoSupport.File_Exists("nvram\\" + Machine.sName + ".nv"))
{
FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
int n = (int)fs1.Length;
fs1.Read(mainram2, 0, n);
fs1.Close();
MameMainMotion.IoSupport.File_ReadAllBytes("nvram\\" + Machine.sName + ".nv");
//FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Open);
//int n = (int)fs1.Length;
//fs1.Read(mainram2, 0, n);
//fs1.Close();
}
}
public static void nvram_handler_save_neogeo()
{
FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create);
fs1.Write(mainram2, 0, 0x2000);
fs1.Close();
//FileStream fs1 = new FileStream("nvram\\" + Machine.sName + ".nv", FileMode.Create);
//fs1.Write(mainram2, 0, 0x2000);
//fs1.Close();
byte[] temp = new byte[0x2000];
Buffer.BlockCopy(mainram2_src, 0, temp, 0, temp.Length);
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(temp))
{
MameMainMotion.IoSupport.File_WriteAllBytesFromStre("nvram\\" + Machine.sName + ".nv",ms);
}
}
public static void machine_reset_neogeo()
{

View File

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

View File

@ -1,12 +1,11 @@
using cpu.m68000;
using cpu.z80;
using System.IO;
namespace MAME.Core
{
public unsafe partial class PGM
{
public unsafe static void SaveStateBinary(BinaryWriter writer)
public unsafe static void SaveStateBinary(System.IO.BinaryWriter writer)
{
int i, j;
writer.Write(pgm_tx_videoram, 0, 0x2000);
@ -58,7 +57,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary(BinaryReader reader)
public static void LoadStateBinary(System.IO.BinaryReader reader)
{
int i, j;
pgm_tx_videoram = reader.ReadBytes(0x2000);

View File

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

View File

@ -2,13 +2,12 @@
using cpu.m68000;
using cpu.m6805;
using cpu.z80;
using System.IO;
namespace MAME.Core
{
public unsafe partial class Taito
{
public static void SaveStateBinary_tokio(BinaryWriter writer)
public static void SaveStateBinary_tokio(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw0);
@ -57,7 +56,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_tokio(BinaryReader reader)
public static void LoadStateBinary_tokio(System.IO.BinaryReader reader)
{
int i;
dsw0 = reader.ReadByte();
@ -106,7 +105,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
}
public static void SaveStateBinary_bublbobl(BinaryWriter writer)
public static void SaveStateBinary_bublbobl(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw0);
@ -170,7 +169,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_bublbobl(BinaryReader reader)
public static void LoadStateBinary_bublbobl(System.IO.BinaryReader reader)
{
int i;
dsw0 = reader.ReadByte();
@ -234,7 +233,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
}
public static void SaveStateBinary_boblbobl(BinaryWriter writer)
public static void SaveStateBinary_boblbobl(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw0);
@ -288,7 +287,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_boblbobl(BinaryReader reader)
public static void LoadStateBinary_boblbobl(System.IO.BinaryReader reader)
{
int i;
dsw0 = reader.ReadByte();
@ -341,7 +340,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
}
public static void SaveStateBinary_bub68705(BinaryWriter writer)
public static void SaveStateBinary_bub68705(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw0);
@ -399,7 +398,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_bub68705(BinaryReader reader)
public static void LoadStateBinary_bub68705(System.IO.BinaryReader reader)
{
int i;
dsw0 = reader.ReadByte();
@ -457,7 +456,7 @@ namespace MAME.Core
Sound.mixerstream.output_sampindex = reader.ReadInt32();
Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
}
public static void SaveStateBinary_opwolf(BinaryWriter writer)
public static void SaveStateBinary_opwolf(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dswa);
@ -594,7 +593,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_opwolf(BinaryReader reader)
public static void LoadStateBinary_opwolf(System.IO.BinaryReader reader)
{
int i;
dswa = reader.ReadByte();

View File

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

View File

@ -1,11 +1,10 @@
using cpu.z80;
using System.IO;
namespace MAME.Core
{
public partial class Tehkan
{
public unsafe static void SaveStateBinary_pbaction(BinaryWriter writer)
public unsafe static void SaveStateBinary_pbaction(System.IO.BinaryWriter writer)
{
int i;
writer.Write(dsw1);
@ -46,7 +45,7 @@ namespace MAME.Core
writer.Write(Sound.mixerstream.output_sampindex);
writer.Write(Sound.mixerstream.output_base_sampindex);
}
public static void LoadStateBinary_pbaction(BinaryReader reader)
public static void LoadStateBinary_pbaction(System.IO.BinaryReader reader)
{
int i;
dsw1 = reader.ReadByte();

View File

@ -0,0 +1,11 @@
using System.IO;
namespace MAME.Core
{
public interface IMAMEIOSupport
{
bool File_Exists(string path);
byte[] File_ReadAllBytes(string path);
void File_WriteAllBytesFromStre(string path, MemoryStream ms);
}
}

View File

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

View File

@ -1,5 +1,4 @@
using System.IO;

namespace MAME.Core
{
public unsafe class AY8910
@ -558,7 +557,7 @@ namespace MAME.Core
}
return ay8910info.regs[r];
}
public void SaveStateBinary(BinaryWriter writer)
public void SaveStateBinary(System.IO.BinaryWriter writer)
{
int i;
writer.Write(ay8910info.register_latch);
@ -580,7 +579,7 @@ namespace MAME.Core
writer.Write(ay8910info.rng);
writer.Write(ay8910info.vol_enabled, 0, 3);
}
public void LoadStateBinary(BinaryReader reader)
public void LoadStateBinary(System.IO.BinaryReader reader)
{
int i;
ay8910info.register_latch = reader.ReadInt32();

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
using System.IO;

namespace MAME.Core
{
public class Taitosnd
@ -201,7 +200,7 @@ namespace MAME.Core
{
return (ushort)(taitosound_comm_r(0) << 8);
}
public static void SaveStateBinary(BinaryWriter writer)
public static void SaveStateBinary(System.IO.BinaryWriter writer)
{
writer.Write(tc0140syt.slavedata, 0, 4);
writer.Write(tc0140syt.masterdata, 0, 4);
@ -211,7 +210,7 @@ namespace MAME.Core
writer.Write(tc0140syt.nmi_enabled);
writer.Write(tc0140syt.nmi_req);
}
public static void LoadStateBinary(BinaryReader reader)
public static void LoadStateBinary(System.IO.BinaryReader reader)
{
tc0140syt.slavedata = reader.ReadBytes(4);
tc0140syt.masterdata = reader.ReadBytes(4);

View File

@ -1,5 +1,4 @@
using System.IO;

namespace MAME.Core
{
public unsafe class Upd7759
@ -362,7 +361,7 @@ namespace MAME.Core
{
return (byte)upd7759_busy_r(0);
}
public static void SaveStateBinary(BinaryWriter writer)
public static void SaveStateBinary(System.IO.BinaryWriter writer)
{
writer.Write(chip.pos);
writer.Write(chip.step);
@ -389,7 +388,7 @@ namespace MAME.Core
writer.Write(chip.romoffset);
writer.Write(chip.rombase);
}
public static void LoadStateBinary(BinaryReader reader)
public static void LoadStateBinary(System.IO.BinaryReader reader)
{
chip.pos = reader.ReadUInt32();
chip.step = reader.ReadUInt32();

View File

@ -1,16 +1,17 @@
using System.IO;

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

View File

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,5 +1,4 @@
using System.IO;

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

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace StoicGooseUnity
@ -95,21 +94,21 @@ namespace StoicGooseUnity
}
#endregion
public static void Write(this BinaryWriter bw, byte* bufferPtr, int offset, int count)
public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count)
{
// 使用指针复制数据到临时数组
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组
bw.Write(TempBuffer_src, 0, count);
}
public static void Write(this FileStream fs, byte* bufferPtr, int offset, int count)
public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
{
// 使用指针复制数据到临时数组
Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count);
// 使用BinaryWriter写入临时数组
fs.Write(TempBuffer_src, 0, count);
}
public static int Read(this FileStream fs, byte* bufferPtr, int offset, int count)
public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count)
{
// 使用BinaryWriter写入临时数组
count = fs.Read(TempBuffer_src, offset, count);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

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

View File

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

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

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

View File

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

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