forked from sin365/AxibugEmuOnline
Compare commits
No commits in common. "1ffa708e7121e605e3e6f44327997e8cef4f391f" and "902dc95d1980d3bcc5eeb369bd2a1ff16057c79c" have entirely different histories.
1ffa708e71
...
902dc95d19
@ -1,6 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using AxiReplay;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
@ -12,7 +11,7 @@ using VirtualNes.Core.Debug;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class NesEmulator : EmuCore<ControllerState>
|
||||
public class NesEmulator : IEmuCore
|
||||
{
|
||||
public VideoProvider VideoProvider;
|
||||
public AudioProvider AudioProvider;
|
||||
@ -123,31 +122,32 @@ namespace AxibugEmuOnline.Client
|
||||
NesCore = null;
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private ControllerState m_lastState;
|
||||
#endif
|
||||
//推进帧
|
||||
protected override bool OnPushEmulatorFrame(ControllerState inputData)
|
||||
public override bool PushEmulatorFrame()
|
||||
{
|
||||
if (NesCore == null || IsPause) return false;
|
||||
|
||||
NesCore.pad.Sync(inputData);
|
||||
m_coreSupporter.SampleInput(NesCore.FrameCount);
|
||||
var controlState = m_coreSupporter.GetControllerState();
|
||||
|
||||
//如果未收到Input数据,核心帧不推进
|
||||
if (!controlState.valid) return false;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (controlState != m_lastState) App.log.Info($"[LOCALDEBUG]{NesCore.FrameCount}-->{controlState}");
|
||||
m_lastState = controlState;
|
||||
#endif
|
||||
|
||||
NesCore.pad.Sync(controlState);
|
||||
NesCore.EmulateFrame(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override ControllerState ConvertInputDataFromNet(ReplayStep step)
|
||||
{
|
||||
return m_coreSupporter.FromNet(step);
|
||||
}
|
||||
protected override ulong InputDataToNet(ControllerState inputData)
|
||||
{
|
||||
return m_coreSupporter.ToNet(inputData);
|
||||
}
|
||||
|
||||
protected override ControllerState GetLocalInput()
|
||||
{
|
||||
return m_coreSupporter.GetControllerState();
|
||||
}
|
||||
|
||||
|
||||
public override unsafe void AfterPushFrame()
|
||||
{
|
||||
@ -164,13 +164,6 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
StopGame();
|
||||
}
|
||||
|
||||
public override Texture OutputPixel => VideoProvider.OutputPixel;
|
||||
public override RawImage DrawCanvas => VideoProvider.Drawer;
|
||||
public override void GetAudioParams(out int frequency, out int channels)
|
||||
{
|
||||
AudioProvider.GetAudioParams(out frequency, out channels);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
@ -202,5 +195,13 @@ namespace AxibugEmuOnline.Client
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
|
||||
public override Texture OutputPixel => VideoProvider.OutputPixel;
|
||||
public override RawImage DrawCanvas => VideoProvider.Drawer;
|
||||
public override void GetAudioParams(out int frequency, out int channels)
|
||||
{
|
||||
AudioProvider.GetAudioParams(out frequency, out channels);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,9 @@
|
||||
#pragma warning disable CS0618 // 类型或成员已过时
|
||||
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugProtobuf;
|
||||
using AxiReplay;
|
||||
using System;
|
||||
using AxibugProtobuf;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// use <see cref="EmuCore{INPUTDATA}"/> instead
|
||||
/// </summary>
|
||||
[Obsolete("不可直接继承,需要继承EmuCore类型")]
|
||||
public abstract class IEmuCore : MonoBehaviour
|
||||
{
|
||||
/// <summary> 获得模拟器核心中的状态快照对象 </summary>
|
||||
@ -42,79 +33,12 @@ namespace AxibugEmuOnline.Client
|
||||
public abstract RomPlatformType Platform { get; }
|
||||
/// <summary> 获取当前模拟器帧序号,在加载快照和Reset后,应当重置为0 </summary>
|
||||
public abstract uint Frame { get; }
|
||||
|
||||
/// <summary> 模拟器核心推帧 </summary>
|
||||
public abstract bool PushEmulatorFrame();
|
||||
/// <summary> 模拟器核心推帧结束 </summary>
|
||||
public abstract void AfterPushFrame();
|
||||
public abstract void GetAudioParams(out int frequency, out int channels);
|
||||
public abstract Texture OutputPixel { get; }
|
||||
public abstract RawImage DrawCanvas { get; }
|
||||
}
|
||||
|
||||
public abstract class EmuCore<INPUTDATA> : IEmuCore
|
||||
{
|
||||
public sealed override bool PushEmulatorFrame()
|
||||
{
|
||||
if (SampleInputData(out var inputData))
|
||||
{
|
||||
return OnPushEmulatorFrame(inputData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong m_lastTestInput;
|
||||
protected bool SampleInputData(out INPUTDATA inputData)
|
||||
{
|
||||
bool result = false;
|
||||
inputData = default(INPUTDATA);
|
||||
|
||||
if (InGameUI.Instance.IsNetPlay)
|
||||
{
|
||||
ReplayStep replayData;
|
||||
int frameDiff;
|
||||
bool inputDiff;
|
||||
|
||||
if (App.roomMgr.netReplay.TryGetNextFrame((int)Frame, out replayData, out frameDiff, out inputDiff))
|
||||
{
|
||||
if (inputDiff)
|
||||
{
|
||||
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} TryGetNextFrame remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " +
|
||||
$"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}");
|
||||
}
|
||||
|
||||
inputData = ConvertInputDataFromNet(replayData);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
var localState = GetLocalInput();
|
||||
var rawData = InputDataToNet(localState);
|
||||
if (m_lastTestInput != rawData)
|
||||
{
|
||||
m_lastTestInput = rawData;
|
||||
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
|
||||
}
|
||||
App.roomMgr.SendRoomSingelPlayerInput(Frame, rawData);
|
||||
}
|
||||
//单机模式
|
||||
else
|
||||
{
|
||||
inputData = GetLocalInput();
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract INPUTDATA GetLocalInput();
|
||||
protected abstract INPUTDATA ConvertInputDataFromNet(ReplayStep step);
|
||||
protected abstract ulong InputDataToNet(INPUTDATA inputData);
|
||||
/// <summary> 模拟器核心推帧 </summary>
|
||||
protected abstract bool OnPushEmulatorFrame(INPUTDATA InputData);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618 // 类型或成员已过时
|
||||
|
||||
@ -32,21 +32,15 @@ namespace AxibugEmuOnline.Client.Filters
|
||||
#endregion
|
||||
#region TV_Effect_Param
|
||||
public FilterParameter<EnumWrapMode> WrapMode = EnumWrapMode.SimpleWrap;
|
||||
[Range(0f, 2f)]
|
||||
public FloatParameter maskDark = 0.5f;
|
||||
[Range(0f, 2f)]
|
||||
public FloatParameter maskLight = 1.5f;
|
||||
[Range(-8f, -16f)]
|
||||
public FloatParameter hardScan = -8.0f;
|
||||
[Range(-3f, 1f)]
|
||||
public FloatParameter hardPix = -3.0f;
|
||||
public Vector2Parameter warp = new Vector2(0.03125f, 0.04166f);
|
||||
[Range(1f, 16f)]
|
||||
public FloatParameter resScale = 4f;
|
||||
[Range(0.5f, 5f)]
|
||||
public FloatParameter scale = 1f;
|
||||
[Range(0f, 1f)]
|
||||
public FloatParameter fade = 1f;
|
||||
public Vector2Parameter warp = new Vector2(1.0f / 32.0f, 1.0f / 24.0f);
|
||||
public Vector2Parameter res;
|
||||
public FloatParameter resScale;
|
||||
public FloatParameter scale;
|
||||
public FloatParameter fade;
|
||||
#endregion
|
||||
|
||||
Material m_bleedMat;
|
||||
@ -134,8 +128,8 @@ namespace AxibugEmuOnline.Client.Filters
|
||||
m_tvEffectMat.SetFloat("maskDark", maskDark.GetValue());
|
||||
m_tvEffectMat.SetFloat("maskLight", maskLight.GetValue());
|
||||
m_tvEffectMat.SetFloat("hardScan", hardScan.GetValue());
|
||||
m_tvEffectMat.SetFloat("hardPix", hardPix.GetValue());
|
||||
m_tvEffectMat.SetVector("warp", warp.GetValue());
|
||||
m_tvEffectMat.SetVector("res", res.GetValue());
|
||||
m_tvEffectMat.SetFloat("resScale", resScale.GetValue());
|
||||
m_tvEffectMat.SetFloat("scale", scale.GetValue());
|
||||
m_tvEffectMat.SetFloat("fade", fade.GetValue());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user