From 3ec227f690582592ac6ff8a9142a7dd14cdf8667 Mon Sep 17 00:00:00 2001
From: sin365 <353374337@qq.com>
Date: Tue, 19 Nov 2024 13:52:37 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Assets/Script/NesEmulator/NesEmulator.cs | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
index c329c7b..d6b06c0 100644
--- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
@@ -12,10 +12,14 @@ namespace AxibugEmuOnline.Client
{
public class NesEmulator : MonoBehaviour, IEmuCore
{
+ //模拟器核心实例化对象
public NES NesCore { get; private set; }
+ //视频驱动(这里是Unity接收模拟器画面数据的并渲染出来的实现)
public VideoProvider VideoProvider;
+ //音频驱动(这里是Unity接收模拟器音频数据的并播放出来的实现)
public AudioProvider AudioProvider;
+ //是否暂停
public bool m_bPause;
private void Start()
@@ -25,6 +29,10 @@ namespace AxibugEmuOnline.Client
AudioProvider.NesEmu = this;
}
+ ///
+ /// 指定ROM开始游戏
+ ///
+ ///
public void StartGame(RomFile rom)
{
StopGame();
@@ -45,12 +53,18 @@ namespace AxibugEmuOnline.Client
}
}
+ ///
+ /// 停止游戏
+ ///
public void StopGame()
{
NesCore?.Dispose();
NesCore = null;
}
+ ///
+ /// Unity的逐帧驱动
+ ///
private unsafe void Update()
{
if (m_bPause) return;
@@ -67,6 +81,7 @@ namespace AxibugEmuOnline.Client
}
}
+ //是否跳帧,单机无效
private void FixEmulatorFrame()
{
var skipFrameCount = App.roomMgr.netReplay.GetSkipFrameCount();
@@ -79,6 +94,7 @@ namespace AxibugEmuOnline.Client
}
ControllerState lastState;
+ //往服务器推送帧数(单机不需要)
private bool PushEmulatorFrame()
{
Supporter.SampleInput(NesCore.FrameCount);
@@ -133,11 +149,19 @@ namespace AxibugEmuOnline.Client
return NesCore.GetState();
}
+ ///
+ /// 获取即时存档
+ ///
+ ///
public byte[] GetStateBytes()
{
return NesCore.GetState().ToBytes();
}
+ ///
+ /// 加载即时存档
+ ///
+ ///
public void LoadStateFromBytes(byte[] data)
{
State st = new State();
@@ -146,6 +170,9 @@ namespace AxibugEmuOnline.Client
}
+ ///
+ /// 编辑器用
+ ///
[Conditional("UNITY_EDITOR")]
[ContextMenu("ImportNesDB")]
public void ImportNesDB()
From b4680b74a38fc3032b25d62ee0731c9030110ad5 Mon Sep 17 00:00:00 2001
From: sin365 <353374337@qq.com>
Date: Tue, 19 Nov 2024 13:54:23 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
index d6b06c0..8991bb1 100644
--- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
@@ -94,7 +94,7 @@ namespace AxibugEmuOnline.Client
}
ControllerState lastState;
- //往服务器推送帧数(单机不需要)
+ //推进帧
private bool PushEmulatorFrame()
{
Supporter.SampleInput(NesCore.FrameCount);