Washi1337 / Emux

GameBoy emulator written in C#
GNU General Public License v3.0
71 stars 21 forks source link

Upgrade Emux.GameBoy to .netstandard 2.0 #2

Closed andy840119 closed 6 years ago

andy840119 commented 6 years ago
  1. change Emux.GameBoy to .netstandard 2.0
  2. upgrade project to .net 4.6.1
Washi1337 commented 6 years ago

Hello,

Thanks for the PR and taking interest in the project!

I merged the MonoGame support branch with the master branch, which resulted in some conflicts with your PR. My apologies for not merging these two branches earlier, as it would probably have avoided some conflicts. I must have forgotten to do so.

Most importantly, if Emux.GameBoy.dll would be targeting .NET Standard 2.0, the Emux.NAudio.dll back-end (that is used by both the WPF app and the MonoGame app to prevent code duplication) must also be .NET Standard 2.0 or use the appropriate .NET Framework version. Would you be so kind to change that there as well? NAudio fortunately has a .NET Standard version so I would prefer if this project would also target .NET Standard.

Also some minor things about your PR. Since you removed the file AssemblyInfo.cs, would you please add the following to the csproj?

<Title>Emux.GameBoy</Title>
<Version>0.1.0.0</Version>
<Description>GameBoy emulator engine</Description>

Also why do we need a dependency on System.Reflection.Emit.Lightweight ?

Thanks, Washi

andy840119 commented 6 years ago

System.Reflection.Emit.Lightweight should be added because DynamicMethod (in Emux.GameBoy.Utilities) need it :3

Also upgrade project Emux.NAudio to .netStandart Now Emux.MonoGame can be compiled

And also have a question, is mono already support .netcoreapp? 🤔 🤔 🤔

Washi1337 commented 6 years ago

Ah yes I forgot about that. Fair enough.

The MonoGame project is already a .NET Core application so yes it runs fine :)

Unfortunately, NAudio is not supported on other platforms yet such as Linux. Will probably have to switch audio back-ends for that.

Thanks again for taking the time again.

andy840119 commented 6 years ago

Technically NAudio should support other platform like mac and linux.

https://github.com/ppy/osu This project( a rhyton game) is use .netcoreApp and NAudio and it can run on mac and windows. I guess linux is also supported. 🤔 🤔

https://github.com/ppy/osu-framework This project also have a framework. If i have enough time i guess i will make Emux client based on this framework.

Washi1337 commented 6 years ago

As far as I know osu! is not based on NAudio but uses the managed bindings for Unseen's Bass library, which is cross platform. I might have a look at that as well in the near future. However, if you make the NAudio back-end work on other platforms that would be great!

andy840119 commented 6 years ago

https://www.youtube.com/watch?v=SJ2lHVplDPw&lc=z22md52zwwemvjibz04t1aokgvmbtwuumtcjjfzaxkp2rk0h00410.1538928837012736

I made a little demo to running Emux on osu-framework. Surprisingly it is easier than i thought 🤔 🤔 🤔 🤔

Windows is executable but in macos i need to rewrite timer to check it is work or not.

Washi1337 commented 6 years ago

That is actually pretty awesome. Good job so far!

What is up with the audio though? It seems to be out of tone? Nvm I forgot that's just the sound of the GameBoy being limited :')

Are you referring to the WinMmTimer that is implementing the clock for the emulated gameboy? I do not have much knowledge about OpenTK or the osu! framework library, but you should be able to recreate the clock like I did with the MonoGame application. The clock needs to run at 60 FPS, which means you can reuse the update loop that also runs at that frequency (or even higher).

Refer to https://github.com/Washi1337/Emux/blob/master/Emux.GameBoy/Cpu/IClock.cs https://github.com/Washi1337/Emux/blob/master/Emux.MonoGame/EmuxHost.cs For the interface definition and a sample implementation using MonoGame.

andy840119 commented 6 years ago

image Oops NAudio really crash on macos 🤔🤔🤔 I need to check how NAudio and Bass Library works on osu framework

Washi1337 commented 6 years ago

The buffer is full because NAudio is not cross platform. Even though it is compiled as a .NET Core application, it has strong ties with Windows libraries. For example, the DirectSoundOut class that is used by Emux to playback the wave patterns in real time is dependent on DirectX. Because it is not supported, the sound buffer will never be played, and since Emux keeps on filling up the buffer with new sound data, it will get full pretty fast. I tried this already with Linux as well :)

What I am trying to say here is that if you want audio support on other platforms, you'll need a different back-end such as Bass. NAudio is not going to cut it.