forked from sin365/AxibugEmuOnline
主项目和VirtualNES.Core核心 NS下不再依赖system.io进行文件读写
This commit is contained in:
parent
d7fe849bb1
commit
36b614c4a7
@ -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;
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
using DG.Tweening.Plugins.Core.PathCore;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Unity.Android.Gradle.Manifest;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.Analytics.IAnalytic;
|
||||
|
||||
namespace AxiIO
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
@ -11,7 +11,7 @@ using Essgee.Metadata;
|
||||
using Essgee.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@ -189,29 +189,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 +756,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 +777,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
@ -197,11 +196,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 +217,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();
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@ using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@ -178,7 +177,7 @@ namespace AxibugEmuOnline.Client
|
||||
var db = Resources.Load<RomDB>("NES/ROMDB");
|
||||
db.Clear();
|
||||
|
||||
var xmlStr = File.ReadAllText("nes20db.xml");
|
||||
var xmlStr = System.IO.File.ReadAllText("nes20db.xml");
|
||||
var xml = XDocument.Parse(xmlStr);
|
||||
var games = xml.Element("nes20db")?.Elements("game");
|
||||
System.Diagnostics.Debug.Assert(games != null, nameof(games) + " != null");
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
@ -16,24 +15,24 @@ public sealed class DatabaseHandler
|
||||
{
|
||||
string wsc = "Bandai - WonderSwan Color.dat";
|
||||
GetDatBytes(wsc, out byte[] loadedData);
|
||||
using (MemoryStream stream = new MemoryStream(loadedData))
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
|
||||
{
|
||||
var root = new XmlRootAttribute("datafile") { IsNullable = true };
|
||||
var serializer = new XmlSerializer(typeof(DatFile), root);
|
||||
var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore });
|
||||
datFiles.Add(Path.GetFileName(wsc), (DatFile)serializer.Deserialize(reader));
|
||||
datFiles.Add(System.IO.Path.GetFileName(wsc), (DatFile)serializer.Deserialize(reader));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
string ws = "Bandai - WonderSwan.dat";
|
||||
GetDatBytes(ws, out byte[] loadedData);
|
||||
using (MemoryStream stream = new MemoryStream(loadedData))
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
|
||||
{
|
||||
var root = new XmlRootAttribute("datafile") { IsNullable = true };
|
||||
var serializer = new XmlSerializer(typeof(DatFile), root);
|
||||
var reader = XmlReader.Create(stream, new() { DtdProcessing = DtdProcessing.Ignore });
|
||||
datFiles.Add(Path.GetFileName(ws), (DatFile)serializer.Deserialize(reader));
|
||||
datFiles.Add(System.IO.Path.GetFileName(ws), (DatFile)serializer.Deserialize(reader));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ using StoicGoose.Common.Utilities;
|
||||
using StoicGoose.Core.Machines;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@ -22,7 +21,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
readonly static int maxRecentFiles = 15;
|
||||
readonly static int statusIconSize = 12;
|
||||
|
||||
readonly static List<(string description, string extension, Func<string, Stream> streamReadFunc)> supportedFileInformation = new()
|
||||
readonly static List<(string description, string extension, Func<string, System.IO.Stream> streamReadFunc)> supportedFileInformation = new()
|
||||
{
|
||||
("WonderSwan ROMs", ".ws", GetStreamFromFile),
|
||||
("WonderSwan Color ROMs", ".wsc", GetStreamFromFile),
|
||||
@ -312,7 +311,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
// graphicsHandler.DrawFrame();
|
||||
//};
|
||||
|
||||
internalEepromPath = Path.Combine(Program.InternalDataPath, $"{machineType.Name}.eep");
|
||||
internalEepromPath = System.IO.Path.Combine(Program.InternalDataPath, $"{machineType.Name}.eep");
|
||||
}
|
||||
|
||||
//private void InitializeWindows()
|
||||
@ -408,11 +407,14 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
|
||||
if (!emulatorHandler.IsRunning)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
if (AxiIO.File.Exists(filename))
|
||||
{
|
||||
using var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var data = new byte[stream.Length];
|
||||
stream.Read(data, 0, data.Length);
|
||||
//using var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
//var data = new byte[stream.Length];
|
||||
//stream.Read(data, 0, data.Length);
|
||||
|
||||
var data = AxiIO.File.ReadAllBytes(filename);
|
||||
|
||||
emulatorHandler.Machine.LoadBootstrap(data);
|
||||
}
|
||||
emulatorHandler.Machine.UseBootstrap = Program.Configuration.General.UseBootstrap;
|
||||
@ -421,23 +423,31 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
|
||||
private void LoadInternalEeprom()
|
||||
{
|
||||
if (!emulatorHandler.IsRunning && File.Exists(internalEepromPath))
|
||||
if (!emulatorHandler.IsRunning && AxiIO.File.Exists(internalEepromPath))
|
||||
{
|
||||
using var stream = new FileStream(internalEepromPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var data = new byte[stream.Length];
|
||||
stream.Read(data, 0, data.Length);
|
||||
//using var stream = new FileStream(internalEepromPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
//var data = new byte[stream.Length];
|
||||
//stream.Read(data, 0, data.Length);
|
||||
|
||||
var data = AxiIO.File.ReadAllBytes(internalEepromPath);
|
||||
|
||||
emulatorHandler.Machine.LoadInternalEeprom(data);
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream GetStreamFromFile(string filename)
|
||||
private static System.IO.Stream GetStreamFromFile(string filename)
|
||||
{
|
||||
return new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
//return new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
byte[] data = AxiIO.File.ReadAllBytes(filename);
|
||||
return new System.IO.MemoryStream(data);
|
||||
}
|
||||
|
||||
private static Stream GetStreamFromFirstZippedFile(string filename)
|
||||
private static System.IO.Stream GetStreamFromFirstZippedFile(string filename)
|
||||
{
|
||||
return new ZipArchive(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)).Entries.FirstOrDefault()?.Open();
|
||||
//return new ZipArchive(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)).Entries.FirstOrDefault()?.Open();
|
||||
|
||||
byte[] data = AxiIO.File.ReadAllBytes(filename);
|
||||
return new ZipArchive(new System.IO.MemoryStream(data)).Entries.FirstOrDefault()?.Open();
|
||||
}
|
||||
|
||||
private bool LoadAndRunCartridge(string filename)
|
||||
@ -450,8 +460,8 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
emulatorHandler.Shutdown();
|
||||
}
|
||||
|
||||
using var inputStream = supportedFileInformation.FirstOrDefault(x => x.extension == Path.GetExtension(filename)).streamReadFunc(filename) ?? GetStreamFromFile(filename);
|
||||
using var stream = new MemoryStream();
|
||||
using var inputStream = supportedFileInformation.FirstOrDefault(x => x.extension == System.IO.Path.GetExtension(filename)).streamReadFunc(filename) ?? GetStreamFromFile(filename);
|
||||
using var stream = new System.IO.MemoryStream();
|
||||
inputStream.CopyTo(stream);
|
||||
stream.Position = 0;
|
||||
|
||||
@ -462,7 +472,7 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
graphicsHandler.IsVerticalOrientation = isVerticalOrientation = emulatorHandler.Machine.Cartridge.Metadata.Orientation == CartridgeMetadata.Orientations.Vertical;
|
||||
inputHandler.SetVerticalOrientation(isVerticalOrientation);
|
||||
|
||||
CurrRomName = Path.GetFileName(filename);
|
||||
CurrRomName = System.IO.Path.GetFileName(filename);
|
||||
|
||||
LoadRam();
|
||||
|
||||
@ -490,12 +500,15 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
private void LoadRam()
|
||||
{
|
||||
//var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav");
|
||||
var path = Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
|
||||
if (!File.Exists(path)) return;
|
||||
var path = System.IO.Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
|
||||
//if (!File.Exists(path)) return;
|
||||
if (!AxiIO.File.Exists(path)) return;
|
||||
|
||||
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var data = new byte[stream.Length];
|
||||
stream.Read(data, 0, data.Length);
|
||||
//using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
//var data = new byte[stream.Length];
|
||||
//stream.Read(data, 0, data.Length);
|
||||
|
||||
var data = AxiIO.File.ReadAllBytes(path);
|
||||
if (data.Length != 0)
|
||||
emulatorHandler.Machine.LoadSaveData(data);
|
||||
}
|
||||
@ -511,8 +524,10 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
var data = emulatorHandler.Machine.GetInternalEeprom();
|
||||
if (data.Length == 0) return;
|
||||
|
||||
using var stream = new FileStream(internalEepromPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
|
||||
stream.Write(data, 0, data.Length);
|
||||
//using var stream = new FileStream(internalEepromPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
|
||||
//stream.Write(data, 0, data.Length);
|
||||
|
||||
AxiIO.File.WriteAllBytes(internalEepromPath, data);
|
||||
}
|
||||
|
||||
private void SaveRam()
|
||||
@ -521,10 +536,12 @@ public class UStoicGoose : MonoBehaviour, IEmuCore
|
||||
if (data.Length == 0) return;
|
||||
|
||||
//var path = Path.Combine(Program.SaveDataPath, $"{Path.GetFileNameWithoutExtension(Program.Configuration.General.RecentFiles.First())}.sav");
|
||||
var path = Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
|
||||
var path = System.IO.Path.Combine(Program.SaveDataPath, $"{CurrRomName}.sav");
|
||||
|
||||
using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
|
||||
stream.Write(data, 0, data.Length);
|
||||
//using var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
|
||||
//stream.Write(data, 0, data.Length);
|
||||
|
||||
AxiIO.File.WriteAllBytes(path, data);
|
||||
}
|
||||
|
||||
|
||||
@ -603,25 +620,25 @@ static class Program
|
||||
shaderDirectoryName = "Shaders";
|
||||
noIntroDatDirectoryName = "No-Intro";
|
||||
mutexName = $"Unity_{GetVersionDetails()}";
|
||||
programDataDirectory = Path.Combine(CustonDataDir, "AxibugEmu");
|
||||
programConfigPath = Path.Combine(programDataDirectory, jsonConfigFileName);
|
||||
programDataDirectory = System.IO.Path.Combine(CustonDataDir, "AxibugEmu");
|
||||
programConfigPath = System.IO.Path.Combine(programDataDirectory, jsonConfigFileName);
|
||||
Configuration = LoadConfiguration(programConfigPath);
|
||||
Log.WriteLine(Path.Combine(programDataDirectory, logFileName));
|
||||
Log.WriteLine(System.IO.Path.Combine(programDataDirectory, logFileName));
|
||||
programApplicationDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
programAssetsDirectory = Path.Combine(programApplicationDirectory, assetsDirectoryName);
|
||||
Directory.CreateDirectory(DataPath = programDataDirectory);
|
||||
Directory.CreateDirectory(InternalDataPath = Path.Combine(programDataDirectory, internalDataDirectoryName));
|
||||
Directory.CreateDirectory(SaveDataPath = Path.Combine(programDataDirectory, saveDataDirectoryName));
|
||||
Directory.CreateDirectory(CheatsDataPath = Path.Combine(programDataDirectory, cheatDataDirectoryName));
|
||||
Directory.CreateDirectory(DebuggingDataPath = Path.Combine(programDataDirectory, debuggingDataDirectoryName));
|
||||
programAssetsDirectory = System.IO.Path.Combine(programApplicationDirectory, assetsDirectoryName);
|
||||
AxiIO.Directory.CreateDirectory(DataPath = programDataDirectory);
|
||||
AxiIO.Directory.CreateDirectory(InternalDataPath = System.IO.Path.Combine(programDataDirectory, internalDataDirectoryName));
|
||||
AxiIO.Directory.CreateDirectory(SaveDataPath = System.IO.Path.Combine(programDataDirectory, saveDataDirectoryName));
|
||||
AxiIO.Directory.CreateDirectory(CheatsDataPath = System.IO.Path.Combine(programDataDirectory, cheatDataDirectoryName));
|
||||
AxiIO.Directory.CreateDirectory(DebuggingDataPath = System.IO.Path.Combine(programDataDirectory, debuggingDataDirectoryName));
|
||||
|
||||
//if (!Directory.Exists(ShaderPath = Path.Combine(programAssetsDirectory, shaderDirectoryName)))
|
||||
// throw new DirectoryNotFoundException("Shader directory missing");
|
||||
|
||||
if (!Directory.Exists(NoIntroDatPath = Path.Combine(programAssetsDirectory, noIntroDatDirectoryName)))
|
||||
throw new DirectoryNotFoundException("No-Intro .dat directory missing");
|
||||
if (!AxiIO.Directory.Exists(NoIntroDatPath = System.IO.Path.Combine(programAssetsDirectory, noIntroDatDirectoryName)))
|
||||
throw new Exception("No-Intro .dat directory missing");
|
||||
}
|
||||
catch (DirectoryNotFoundException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -674,7 +691,7 @@ static class Program
|
||||
|
||||
private static Configuration LoadConfiguration(string filename)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filename));
|
||||
AxiIO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filename));
|
||||
|
||||
Configuration configuration;
|
||||
//if (!File.Exists(filename) || (configuration = filename.DeserializeFromFile<Configuration>()) == null)
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
||||
@ -5,7 +5,6 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
||||
@ -4,7 +4,6 @@ using AxibugEmuOnline.Client.Event;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
using AxibugEmuOnline.Client.Tools;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
|
||||
//using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using VirtualNes.Core.Debug;
|
||||
|
||||
@ -28,13 +27,13 @@ namespace VirtualNes.Core
|
||||
private int m_nNsfSongMode;
|
||||
private bool m_bMoviePlay;
|
||||
private bool m_bMovieRec;
|
||||
private Stream m_fpMovie;
|
||||
private System.IO.Stream m_fpMovie;
|
||||
private uint m_MovieControl;
|
||||
private int m_MovieStepTotal;
|
||||
private int m_MovieStep;
|
||||
private bool m_bTapePlay;
|
||||
private bool m_bTapeRec;
|
||||
private Stream m_fpTape;
|
||||
private System.IO.Stream m_fpTape;
|
||||
private double m_TapeCycles;
|
||||
private byte m_TapeIn;
|
||||
private byte m_TapeOut;
|
||||
@ -1110,7 +1109,7 @@ namespace VirtualNes.Core
|
||||
return;
|
||||
|
||||
int i = 0;
|
||||
Stream fp = null;
|
||||
System.IO.Stream fp = null;
|
||||
DISKFILEHDR ifh;
|
||||
byte[] lpDisk = rom.GetPROM();
|
||||
byte[] lpWrite = rom.GetDISK();
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using VirtualNes.Core.Debug;
|
||||
|
||||
namespace VirtualNes.Core
|
||||
@ -29,7 +28,7 @@ namespace VirtualNes.Core
|
||||
|
||||
public ROM(string fname)
|
||||
{
|
||||
Stream fp = null;
|
||||
System.IO.Stream fp = null;
|
||||
byte[] temp = null;
|
||||
byte[] bios = null;
|
||||
long FileSize = 0;
|
||||
@ -218,7 +217,7 @@ namespace VirtualNes.Core
|
||||
}
|
||||
|
||||
Supporter.S.GetRomPathInfo(fname, out fullpath, out path);
|
||||
name = Path.GetFileNameWithoutExtension(fullpath);
|
||||
name = System.IO.Path.GetFileNameWithoutExtension(fullpath);
|
||||
if (!bNSF)
|
||||
{
|
||||
mapper = (header.control1 >> 4) | (header.control2 & 0xF0);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace VirtualNes.Core
|
||||
@ -84,22 +83,22 @@ namespace VirtualNes.Core
|
||||
}
|
||||
public class StateReader
|
||||
{
|
||||
private MemoryStream m_dataStream;
|
||||
private System.IO.MemoryStream m_dataStream;
|
||||
|
||||
public long Remain => m_dataStream.Length - 1 - m_dataStream.Position;
|
||||
|
||||
public StateReader(byte[] bytes)
|
||||
{
|
||||
m_dataStream = new MemoryStream(bytes);
|
||||
m_dataStream = new System.IO.MemoryStream(bytes);
|
||||
}
|
||||
|
||||
public void Skip(uint count)
|
||||
{
|
||||
m_dataStream.Seek(count, SeekOrigin.Current);
|
||||
m_dataStream.Seek(count, System.IO.SeekOrigin.Current);
|
||||
}
|
||||
public void Skip(long count)
|
||||
{
|
||||
m_dataStream.Seek(count, SeekOrigin.Current);
|
||||
m_dataStream.Seek(count, System.IO.SeekOrigin.Current);
|
||||
}
|
||||
|
||||
public byte[] Read_bytes(int length)
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
|
||||
namespace VirtualNes.Core
|
||||
namespace VirtualNes.Core
|
||||
{
|
||||
public static class Supporter
|
||||
{
|
||||
@ -15,15 +13,15 @@ namespace VirtualNes.Core
|
||||
|
||||
public interface ISupporterImpl
|
||||
{
|
||||
Stream OpenRom(string fname);
|
||||
System.IO.Stream OpenRom(string fname);
|
||||
void GetRomPathInfo(string fname, out string fullPath, out string directPath);
|
||||
Stream OpenFile_DISKSYS();
|
||||
System.IO.Stream OpenFile_DISKSYS();
|
||||
void SaveSRAMToFile(byte[] sramContent, string romName);
|
||||
void SaveDISKToFile(byte[] diskFileContent, string romName);
|
||||
EmulatorConfig Config { get; }
|
||||
void PrepareDirectory(string directPath);
|
||||
void SaveFile(byte[] fileData, string directPath, string fileName);
|
||||
Stream OpenFile(string directPath, string fileName);
|
||||
System.IO.Stream OpenFile(string directPath, string fileName);
|
||||
bool TryGetMapperNo(ROM rom, out int mapperNo);
|
||||
ControllerState GetControllerState();
|
||||
void SampleInput(uint frameCount);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user