2024-07-24 14:27:10 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using VirtualNes.Core;
|
|
|
|
using VirtualNes.Core.Debug;
|
|
|
|
|
|
|
|
namespace AxibugEmuOnline.Client
|
|
|
|
{
|
|
|
|
public class NesEmulator : MonoBehaviour
|
|
|
|
{
|
2024-07-25 11:03:58 +08:00
|
|
|
private NES m_nesIns;
|
|
|
|
|
2024-07-24 14:27:10 +08:00
|
|
|
private void Start()
|
|
|
|
{
|
2024-07-26 17:52:33 +08:00
|
|
|
StartGame("Kirby.nes");
|
2024-07-24 14:27:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void StartGame(string romName)
|
|
|
|
{
|
2024-07-25 11:03:58 +08:00
|
|
|
StopGame();
|
|
|
|
|
2024-07-24 14:27:10 +08:00
|
|
|
Supporter.Setup(new CoreSupporter());
|
|
|
|
Debuger.Setup(new CoreDebuger());
|
2024-07-25 11:03:58 +08:00
|
|
|
m_nesIns = new NES(romName);
|
|
|
|
m_nesIns.Command(NESCOMMAND.NESCMD_HWRESET);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void StopGame()
|
|
|
|
{
|
|
|
|
m_nesIns?.Dispose();
|
|
|
|
m_nesIns = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
m_nesIns?.EmulateFrame(true);
|
2024-07-24 14:27:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|