AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/Manager/AppEmu.cs

58 lines
1.5 KiB
C#
Raw Normal View History

2024-07-05 11:24:59 +08:00
using MyNes;
using MyNes.Core;
2024-07-03 14:43:11 +08:00
using System.IO;
2024-07-04 21:06:41 +08:00
using UnityEngine;
2024-07-03 14:43:11 +08:00
namespace AxibugEmuOnline.Client.Manager
{
2024-07-04 21:06:41 +08:00
public class AppEmu : IFileManager
{
2024-07-05 11:24:59 +08:00
public IVideoProvider UguiVideo { get; private set; }
public IAudioProvider Audio { get; private set; }
2024-07-04 21:06:41 +08:00
2024-07-03 14:43:11 +08:00
public void Init()
2024-07-04 10:41:48 +08:00
{
2024-07-04 21:06:41 +08:00
MyNesMain.Initialize(this);
NesEmu.LoadGame("E:/rzg4.nes", out var successed, true);
2024-07-05 11:24:59 +08:00
UguiVideo = MyNesMain.VideoProvider;
Audio = MyNesMain.AudioProvider;
2024-07-04 21:06:41 +08:00
var fps_nes_missle = 1.0 / 59.0;
NesEmu.SetFramePeriod(ref fps_nes_missle);
}
public void Update()
{
2024-07-05 11:24:59 +08:00
UguiVideo.Update();
Audio.Update();
2024-07-04 21:06:41 +08:00
double t = Time.deltaTime;
NesEmu.SetFramePeriod(ref t);
}
public void Dispose()
{
MyNesMain.Shutdown();
}
public Stream OpenDatabaseFile()
{
var databaseFile = Resources.Load<TextAsset>("NesCoreRes/database");
MemoryStream ms = new MemoryStream(databaseFile.bytes);
return ms;
}
public Stream OpenPaletteFile()
{
var defaultPalett = Resources.Load<TextAsset>("NesCoreRes/Palettes/default_ntsc.pal");
MemoryStream ms = new MemoryStream(defaultPalett.bytes);
return ms;
}
public string GetWorkingFolderPath()
{
return $"{Application.persistentDataPath}/MyNes";
}
2024-07-03 14:43:11 +08:00
}
}