dev_basemynes #3
@ -25,5 +25,7 @@ namespace MyNes.Core
|
||||
void SignalToggle(bool started);
|
||||
|
||||
void SetVolume(int Vol);
|
||||
|
||||
void Update();
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,7 @@ namespace MyNes.Core
|
||||
void ToggleFPS(bool show_fps);
|
||||
|
||||
void ApplyFilter();
|
||||
|
||||
void Update();
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,9 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ac8cd27a180bf3e489b2ca27c821bffe, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
AS: {fileID: 1379369699}
|
||||
DrawImage: {fileID: 730321751}
|
||||
DO: {fileID: 1379369700}
|
||||
DO: {fileID: 0}
|
||||
Fps: {fileID: 1680039028}
|
||||
--- !u!1 &708549044
|
||||
GameObject:
|
||||
@ -610,7 +611,6 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 1379369698}
|
||||
- component: {fileID: 1379369699}
|
||||
- component: {fileID: 1379369700}
|
||||
m_Layer: 5
|
||||
m_Name: Audio
|
||||
m_TagString: Untagged
|
||||
@ -733,19 +733,6 @@ AudioSource:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!114 &1379369700
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1379369697}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f25db9f5a7339c34f94e6e978be38c82, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Gain: 0.05
|
||||
--- !u!1 &1680039027
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2,10 +2,12 @@ using MyNes.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using UnityEditor.PackageManager.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
@ -20,25 +22,47 @@ namespace AxibugEmuOnline.Client
|
||||
public bool AllowFrequencyChange => true;
|
||||
|
||||
private bool m_isPlaying;
|
||||
private AudioSource m_as;
|
||||
private int samples_added;
|
||||
|
||||
private Queue<(float[], int)> queues = new Queue<(float[], int)>();
|
||||
|
||||
private Queue<float> _buffer = new Queue<float>();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
m_as = NesCoreProxy.Instance.AS;
|
||||
m_as.clip = AudioClip.Create("nes wav", 48000 * 2, 1, 48000, true, OnAudioFilterRead);
|
||||
m_as.loop = true;
|
||||
m_as.playOnAwake = false;
|
||||
m_as.spatialBlend = 0f;
|
||||
|
||||
m_as.Play();
|
||||
}
|
||||
|
||||
public void Update() { }
|
||||
|
||||
|
||||
private void OnAudioFilterRead(float[] data)
|
||||
{
|
||||
lock (_buffer)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
data[i] = _buffer.Count > 0 ? _buffer.Dequeue() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SubmitSamples(ref short[] buffer, ref int samples_a)
|
||||
{
|
||||
NesCoreProxy.Instance.DO.Play(buffer.Take(samples_a).SelectMany(s => toBytes(s)).ToArray());
|
||||
}
|
||||
|
||||
public byte[] toBytes(short value)
|
||||
lock (_buffer)
|
||||
{
|
||||
byte[] temp = new byte[2];
|
||||
//temp[0] = (byte)(value >> 8);
|
||||
temp[0] = temp[1] = (byte)((uint)value & 0xFFu);
|
||||
|
||||
return temp;
|
||||
foreach (var a in buffer.Take(samples_a).ToArray())
|
||||
{
|
||||
var floatData = (float)a / 124;
|
||||
_buffer.Enqueue(floatData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TogglePause(bool paused)
|
||||
|
@ -66,8 +66,9 @@ public class DefaultAudioOutput : MonoBehaviour
|
||||
{
|
||||
_pipeStream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private class PipeStream : Stream
|
||||
public class PipeStream : Stream
|
||||
{
|
||||
private readonly Queue<byte> _buffer = new Queue<byte>();
|
||||
private long _maxBufferLength = 8192;
|
||||
@ -180,5 +181,3 @@ public class DefaultAudioOutput : MonoBehaviour
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Client
|
||||
return color;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
public void Update()
|
||||
{
|
||||
var colors = m_texRawBuffer.Select(w => GetColor((uint)w)).ToArray();
|
||||
m_rawBufferWarper.SetPixels(colors);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using MyNes.Core;
|
||||
using MyNes;
|
||||
using MyNes.Core;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
@ -6,15 +7,15 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
{
|
||||
public class AppEmu : IFileManager
|
||||
{
|
||||
public UguiVideoProvider UguiVideo { get; private set; }
|
||||
public AudioProvider Audio { get; private set; }
|
||||
public IVideoProvider UguiVideo { get; private set; }
|
||||
public IAudioProvider Audio { get; private set; }
|
||||
|
||||
public void Init()
|
||||
{
|
||||
MyNesMain.Initialize(this);
|
||||
NesEmu.LoadGame("E:/rzg4.nes", out var successed, true);
|
||||
UguiVideo = MyNesMain.VideoProvider as UguiVideoProvider;
|
||||
Audio = MyNesMain.AudioProvider as AudioProvider;
|
||||
UguiVideo = MyNesMain.VideoProvider;
|
||||
Audio = MyNesMain.AudioProvider;
|
||||
|
||||
var fps_nes_missle = 1.0 / 59.0;
|
||||
NesEmu.SetFramePeriod(ref fps_nes_missle);
|
||||
@ -22,7 +23,8 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
|
||||
public void Update()
|
||||
{
|
||||
UguiVideo.Draw();
|
||||
UguiVideo.Update();
|
||||
Audio.Update();
|
||||
|
||||
double t = Time.deltaTime;
|
||||
NesEmu.SetFramePeriod(ref t);
|
||||
|
@ -10,6 +10,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public static NesCoreProxy Instance { get; private set; }
|
||||
|
||||
public AudioSource AS;
|
||||
public RawImage DrawImage;
|
||||
public DefaultAudioOutput DO;
|
||||
public Text Fps;
|
||||
|
@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Network
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Performance.Profile-Analyzer.Editor", "Unity.Performance.Profile-Analyzer.Editor.csproj", "{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugEmuOnline.Client", "AxibugEmuOnline.Client.csproj", "{59C211A4-B928-7505-AF2E-6C604DAB3622}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Scheduler", "Unity.Services.Core.Scheduler.csproj", "{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.VSCode.Editor", "Unity.VSCode.Editor.csproj", "{5A8F066D-8FFA-AFC1-1E8E-0DE9AEAE676F}"
|
||||
@ -71,8 +73,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.TestTools.CodeCoverag
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Settings.Editor", "Unity.Settings.Editor.csproj", "{541572F4-E051-F4F8-9B39-87BFA550E13A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxibugEmuOnline.Client", "AxibugEmuOnline.Client.csproj", "{59C211A4-B928-7505-AF2E-6C604DAB3622}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Registration", "Unity.Services.Core.Registration.csproj", "{A5C76622-FE9B-BD41-A430-5208CCE95FDA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Services.Core.Telemetry", "Unity.Services.Core.Telemetry.csproj", "{7F93B805-8A3C-D81B-FEE7-A4CE542AB2D2}"
|
||||
@ -219,6 +219,10 @@ Global
|
||||
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F57AB79F-532A-EBC2-871B-64C9FD27FEA9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2598AAB1-DA3E-A2AE-B060-D1BAF7BBE4BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -235,10 +239,6 @@ Global
|
||||
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{541572F4-E051-F4F8-9B39-87BFA550E13A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{59C211A4-B928-7505-AF2E-6C604DAB3622}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A5C76622-FE9B-BD41-A430-5208CCE95FDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
Loading…
Reference in New Issue
Block a user