forked from sin365/AxibugEmuOnline
重新组织PersisdentPath路径,现在每个模拟器核心具有单独的隔离路径
修复Nes核心,读取SRAM失败的bug(SRAM是NES原生存档数据) 暂时移除ROMDB,因为目前发现这个映射并不准确 将
This commit is contained in:
parent
b6e6e750d4
commit
ad5b792fcd
@ -49,11 +49,19 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
static string s_persistentRoot =
|
||||||
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
|
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
|
||||||
public static string PersistentDataPath => "ux0:data/AxibugEmu";
|
"ux0:data/AxibugEmu";
|
||||||
#else
|
#else
|
||||||
public static string PersistentDataPath => Application.persistentDataPath;
|
Application.persistentDataPath;
|
||||||
#endif
|
#endif
|
||||||
|
public static string PersistentDataPath(RomPlatformType emuPlatform)
|
||||||
|
{
|
||||||
|
return s_persistentRoot + "/" + emuPlatform.ToString();
|
||||||
|
}
|
||||||
|
public static string PersistentDataRoot() => s_persistentRoot;
|
||||||
|
|
||||||
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
public static void Init(bool isTest = false, string testSrvIP = "", bool bUseLocalWebApi = false, string mLocalWebApi = "")
|
||||||
{
|
{
|
||||||
log = new LogManager(OnLogOut);
|
log = new LogManager(OnLogOut);
|
||||||
@ -100,8 +108,8 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
private static void PSP2Init()
|
private static void PSP2Init()
|
||||||
{
|
{
|
||||||
//PSVita最好手动创建目录
|
//PSVita最好手动创建目录
|
||||||
if (!Directory.Exists(PersistentDataPath))
|
if (!Directory.Exists("ux0:data/AxibugEmu"))
|
||||||
Directory.CreateDirectory(PersistentDataPath);
|
Directory.CreateDirectory("ux0:data/AxibugEmu");
|
||||||
|
|
||||||
#if UNITY_PSP2
|
#if UNITY_PSP2
|
||||||
//创建PSV弹窗UI
|
//创建PSV弹窗UI
|
||||||
|
@ -9,7 +9,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
public class CacheManager
|
public class CacheManager
|
||||||
{
|
{
|
||||||
static readonly string CacheDirPath = $"{App.PersistentDataPath}/Caches";
|
static readonly string CacheDirPath = $"{App.PersistentDataRoot()}/Caches";
|
||||||
static readonly string TextureCacheDirPath = $"{CacheDirPath}/Texture";
|
static readonly string TextureCacheDirPath = $"{CacheDirPath}/Texture";
|
||||||
|
|
||||||
public void GetSpriteCache(string url, Action<Sprite, string> callback)
|
public void GetSpriteCache(string url, Action<Sprite, string> callback)
|
||||||
|
@ -21,8 +21,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// <summary> 指示该Rom文件的存放路径 </summary>
|
/// <summary> 指示该Rom文件的存放路径 </summary>
|
||||||
public string LocalFilePath =>
|
public string LocalFilePath =>
|
||||||
IsUserRom ?
|
IsUserRom ?
|
||||||
$"{App.PersistentDataPath}/UserRoms/{Platform}/{FileName}" :
|
$"{App.PersistentDataPath(Platform)}/UserRoms/{FileName}" :
|
||||||
$"{App.PersistentDataPath}/RemoteRoms/{Platform}/{FileName}";
|
$"{App.PersistentDataPath(Platform)}/RemoteRoms/{FileName}";
|
||||||
|
|
||||||
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
/// <summary> 指示该Rom文件是否已下载完毕 </summary>
|
||||||
public bool RomReady => hasLocalFile;
|
public bool RomReady => hasLocalFile;
|
||||||
|
@ -61,7 +61,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// <summary> 清除所有下载的Rom文件 </summary>
|
/// <summary> 清除所有下载的Rom文件 </summary>
|
||||||
public void ClearRomFile()
|
public void ClearRomFile()
|
||||||
{
|
{
|
||||||
var path = $"{App.PersistentDataPath}/RemoteRoms/{m_platform}";
|
var path = $"{App.PersistentDataPath(m_platform)}/RemoteRoms";
|
||||||
if (Directory.Exists(path)) Directory.Delete(path, true);
|
if (Directory.Exists(path)) Directory.Delete(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SaveSRAMToFile(byte[] sramContent, string romName)
|
public void SaveSRAMToFile(byte[] sramContent, string romName)
|
||||||
{
|
{
|
||||||
string sramDirectoryPath = $"{App.PersistentDataPath}/sav";
|
string sramDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{Config.path.szSavePath}";
|
||||||
Directory.CreateDirectory(sramDirectoryPath);
|
Directory.CreateDirectory(sramDirectoryPath);
|
||||||
romName = Path.GetFileNameWithoutExtension(romName);
|
romName = Path.GetFileNameWithoutExtension(romName);
|
||||||
File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
|
File.WriteAllBytes($"{sramDirectoryPath}/{romName}.sav", sramContent);
|
||||||
@ -56,7 +56,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SaveDISKToFile(byte[] diskFileContent, string romName)
|
public void SaveDISKToFile(byte[] diskFileContent, string romName)
|
||||||
{
|
{
|
||||||
string diskFileDirectoryPath = $"{App.PersistentDataPath}/dsv";
|
string diskFileDirectoryPath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/dsv";
|
||||||
Directory.CreateDirectory(diskFileDirectoryPath);
|
Directory.CreateDirectory(diskFileDirectoryPath);
|
||||||
romName = Path.GetFileNameWithoutExtension(romName);
|
romName = Path.GetFileNameWithoutExtension(romName);
|
||||||
File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
|
File.WriteAllBytes($"{diskFileDirectoryPath}/{romName}.dsv", diskFileContent);
|
||||||
@ -65,14 +65,14 @@ namespace AxibugEmuOnline.Client
|
|||||||
public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
|
public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
|
||||||
public void PrepareDirectory(string directPath)
|
public void PrepareDirectory(string directPath)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory($"{App.PersistentDataPath}/{directPath}");
|
Directory.CreateDirectory($"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveFile(byte[] fileData, string directPath, string fileName)
|
public void SaveFile(byte[] fileData, string directPath, string fileName)
|
||||||
{
|
{
|
||||||
PrepareDirectory(directPath);
|
PrepareDirectory(directPath);
|
||||||
|
|
||||||
var fileFullpath = $"{App.PersistentDataPath}/{directPath}/{fileName}";
|
var fileFullpath = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
|
||||||
File.WriteAllBytes(fileFullpath, fileData);
|
File.WriteAllBytes(fileFullpath, fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = File.ReadAllBytes($"{App.PersistentDataPath}/{directPath}/{fileName}");
|
var path = $"{App.PersistentDataPath(AxibugProtobuf.RomPlatformType.Nes)}/{directPath}/{fileName}";
|
||||||
|
var data = File.ReadAllBytes(path);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
}
|
||||||
@ -88,7 +89,6 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetMapperNo(ROM rom, out int mapperNo)
|
public bool TryGetMapperNo(ROM rom, out int mapperNo)
|
||||||
|
@ -216,6 +216,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
return ControllerMapper;
|
return ControllerMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose()
|
||||||
|
{
|
||||||
|
StopGame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -319,6 +319,12 @@ namespace VirtualNes.Core
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void QueueClear()
|
||||||
|
{
|
||||||
|
queue.Clear();
|
||||||
|
exqueue.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void QueueFlush()
|
private void QueueFlush()
|
||||||
{
|
{
|
||||||
while (queue.wrptr != queue.rdptr)
|
while (queue.wrptr != queue.rdptr)
|
||||||
@ -651,5 +657,11 @@ namespace VirtualNes.Core
|
|||||||
public int rdptr;
|
public int rdptr;
|
||||||
public int wrptr;
|
public int wrptr;
|
||||||
public QUEUEDATA[] data = new QUEUEDATA[8192];
|
public QUEUEDATA[] data = new QUEUEDATA[8192];
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
rdptr = 0;wrptr = 0;
|
||||||
|
data = new QUEUEDATA[8192];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,6 +355,7 @@ namespace VirtualNes.Core
|
|||||||
private void LoadDISK()
|
private void LoadDISK()
|
||||||
{
|
{
|
||||||
//todo : 磁碟机读取支持
|
//todo : 磁碟机读取支持
|
||||||
|
Debuger.LogError($"磁碟机尚未支持");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSRAM()
|
private void LoadSRAM()
|
||||||
@ -1070,6 +1071,10 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
SaveSRAM();
|
||||||
|
SaveDISK();
|
||||||
|
SaveTurboFile();
|
||||||
|
|
||||||
cpu?.Dispose();
|
cpu?.Dispose();
|
||||||
ppu?.Dispose();
|
ppu?.Dispose();
|
||||||
apu?.Dispose();
|
apu?.Dispose();
|
||||||
@ -1081,7 +1086,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (rom.IsNSF()) return;
|
if (rom.IsNSF()) return;
|
||||||
if (rom.IsSAVERAM()) return;
|
if (!rom.IsSAVERAM()) return;
|
||||||
|
|
||||||
for (i = 0; i < SAVERAM_SIZE; i++)
|
for (i = 0; i < SAVERAM_SIZE; i++)
|
||||||
{
|
{
|
||||||
@ -1841,10 +1846,11 @@ namespace VirtualNes.Core
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
cpu.SetDmaCycles(state.reg.cpureg.DMA_cycles);
|
|
||||||
emul_cycles = state.reg.cpureg.emul_cycles;
|
emul_cycles = state.reg.cpureg.emul_cycles;
|
||||||
base_cycles = state.reg.cpureg.base_cycles;
|
base_cycles = state.reg.cpureg.base_cycles;
|
||||||
|
|
||||||
|
cpu.SetDmaCycles(state.reg.cpureg.DMA_cycles);
|
||||||
|
|
||||||
// LOAD PPU STATE
|
// LOAD PPU STATE
|
||||||
MMU.PPUREG[0] = state.reg.ppureg.reg0;
|
MMU.PPUREG[0] = state.reg.ppureg.reg0;
|
||||||
MMU.PPUREG[1] = state.reg.ppureg.reg1;
|
MMU.PPUREG[1] = state.reg.ppureg.reg1;
|
||||||
@ -1857,6 +1863,8 @@ namespace VirtualNes.Core
|
|||||||
MMU.PPU56Toggle = state.reg.ppureg.toggle56;
|
MMU.PPU56Toggle = state.reg.ppureg.toggle56;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apu.QueueClear();
|
||||||
|
|
||||||
//RAM STATE
|
//RAM STATE
|
||||||
{
|
{
|
||||||
// SAVE RAM STATE
|
// SAVE RAM STATE
|
||||||
|
@ -244,11 +244,11 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
FileNameCheck(fname);
|
FileNameCheck(fname);
|
||||||
|
|
||||||
if (Supporter.S.TryGetMapperNo(this, out int mapperNo))
|
//if (Supporter.S.TryGetMapperNo(this, out int mapperNo))
|
||||||
{
|
//{
|
||||||
Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}");
|
// Debuger.Log($"ROMDB Set Mapper #{mapper:000} to #{mapperNo:000}");
|
||||||
mapper = mapperNo;
|
// mapper = mapperNo;
|
||||||
}
|
//}
|
||||||
|
|
||||||
RomPatch.DoPatch(ref crc, ref lpPRG, ref lpCHR, ref mapper, ref header);
|
RomPatch.DoPatch(ref crc, ref lpPRG, ref lpCHR, ref mapper, ref header);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
public bool bIpsPath = true;
|
public bool bIpsPath = true;
|
||||||
|
|
||||||
public string szRomPath = "roms";
|
public string szRomPath = "roms";
|
||||||
public string szSavePath = "save";
|
public string szSavePath = "sav";
|
||||||
public string szStatePath = "state";
|
public string szStatePath = "state";
|
||||||
public string szSnapshotPath = "snapshot";
|
public string szSnapshotPath = "snapshot";
|
||||||
public string szMoviePath = "movie";
|
public string szMoviePath = "movie";
|
||||||
|
Loading…
Reference in New Issue
Block a user