TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.14k stars 380 forks source link

Port an NDS emulator #1688

Closed SuuperW closed 4 years ago

SuuperW commented 4 years ago

I have pushed a branch named DesHawk, as I am integrating DeSmuME into BizHawk. I would appreciate any constructive comments from anyone with knowledge in this area, suggestions about a better way to do something, or potential problems with my approach.

I have also created a DesHawk branch on the DeSmuME repo. (https://github.com/TASVideos/desmume/tree/DesHawk)

Spikestuff commented 4 years ago

Well, it's very great at having Graphical Glitches in (only going on a list of Published TASes):

And Dementium has a louder than intended sound in the first minute(ish) of the chapter.

Can you instead attempt to add something like melonDS instead?

zeromus commented 4 years ago

Yeah, you should probably integrate one of the other NDS emulator cores without these bugs. I wish you the best of luck.

adelikat commented 4 years ago

Please fork the desmume project, then add the fork as a submodule, so we can get upstream updates easier. (If you need help with submodules, let me know). Also preferrably, that fork live in the TASVideos organization, I can set that up

zeromus commented 4 years ago

desmume is already on the tasvideos repository. it can be added as a submodule already. upstream is us.

adelikat commented 4 years ago

oh right. rad.

alyosha-tas commented 4 years ago

woah desume in bizhawk that sounds great! Hope it works out.

Sonia-7 commented 4 years ago

I'd also rather see melonDS instead, since I've experienced less emulation bugs there. One example is Etrian Odyssey's text. It displays correctly in melonDS, but in Desmume you need to fix them through a hack (unless if you change the renderer to OpenGL 3.2).

Hopefully it wouldn't be much harder than adding Desmume.

NarryG commented 4 years ago

@Sonia-7 Melon does take a bit of work to compile under MSVC (normal toolchain is msys2) but I've done it and it works fine. Melon has a super simple codebase so I would think it'd be easier to port.

vadosnaprimer commented 4 years ago

I'd rather we have a thing that's actually good. If desmume is added, there will always be demand for melonds anyway, and if that one gets added next, it'd be default, so why not start with a better core altogether? Also melonds is in active developement, while desmume looks more dead than alive, including emulation accuracy improvements.

MSVC is not even a requirement for us to be honest.

SuuperW commented 4 years ago

Allrighty, I will attempt to use MelonDS. I haven't done anything at all with it yet, but the code looks like at first glance it'll be easier to work with.

SuuperW commented 4 years ago

@NarryG you said you got MelonDS to compile under MSVS, can you provide the files or instructions? I have little understanding of how this stuff works.

Or any way I can get to actually working with the code and integrating with BizHawk. I hate how much crap goes into getting C++ to compile. The only way I was able to get DeSmuME to compile was using/copying the pre-existing Windows VS project file.

InfamousKnight commented 4 years ago

I've managed to get it to compile under msys2. Just follow the building guide on melonds github. Its under the readme file.

It will not run on the desktop application, you will need to run it under msys2 as it has the libraries in its environment. Run ./melonds on build folder which you should already be in once installation is complete.

vadosnaprimer commented 4 years ago

BTW bizhawk does ship basic msys dlls so they don't have to be statically linked.

InfamousKnight commented 4 years ago

And I was wrong saying you can only run it through msys2. In the dist folder will be the application.

Wish best of luck to you as well. I dont like the interface of desmume or its bugs. Melonds shouldnt have as many desync issues as well.

zeromus commented 4 years ago

It's implausible that melonds will have fewer desync issues if it hasn't been vetted carefully for tasworthiness. Desmume has already been deeply vetted; whatever problems it has have occurred since 0.9.11 and are not likely to be large (but nobody has ever debugged it in detail, to my knowledge). So do not get your hopes up.

SuuperW commented 4 years ago

I finally found the time to figure some stuff out, and have gotten to where I can write code in MelonDS to call from BizHawk.

Btw, why does MelonDS not ship with ARM7/9 bios and firmware files? Is there any issue with including them with BizHawk, or maybe including them inside a MelonDS.dll?

NarryG commented 4 years ago

Those are copyrighted files. They can't be included for that reason. Desmume uses its own reverse engineered bios which is why it doesn't need one.

zeromus commented 4 years ago

desmume's HLE bios could be ported to melonds without too much trouble.

SuuperW commented 4 years ago

I have pushed a new branch, DSHawk, which uses MelonDS.

Again, I'd appreciate any constructive feedback.

One specific question I have: Why do the printf calls in MelonDS not print to the BizHawk console window? I can get it to by changing the project's type to console application, but I don't recall having to do anything when I was working with DeSmuME.

zeromus commented 4 years ago

Desmume has special code in it which attaches stdout to the console. See OpenConsole() in console.cpp

vadosnaprimer commented 4 years ago

Hawk related functionality that deviates from default core behavior should be made optional, so the standalone emulator works exactly like before, in terms of both usage and coding. Also avoid magic numbers.

ghost commented 4 years ago

problem with melonDS currently is that it runs Mortal Kombat really bad/slow compared to other emulators. On the good side it emulates the graphics the best out of all other DS emulators including Drastic. I didnt see any other issues with the emulator though.

Spikestuff commented 4 years ago

problem with melonDS currently is that it runs Mortal Kombat really bad/slow compared to other emulators.

And did you mention that on melonDS? Cause I'm looking at the issue tracker on melonDS and there's nothing mentioned about it at the time of writing this.

Maybe if something was mentioned about it, it would've been taken care of just like the other issues that as a bonus sometimes actually fixed multiple games at once. This issue you're not presenting there, instead you're presenting here doesn't help Arisotura at all.

ghost commented 4 years ago

They know about it from the forums I just wanted to inform people here. I will think about adding an issue about it there.

zeromus commented 4 years ago

One random game that barely matters and theres no point in tasing isn't really helpful to this discussion. The only reason mortal kombat on the nds matters is because desmume had major problems with it for so long, there will be a lot of small children with too much time on their hands saying melonds will finally execute a fatality on desmume by fixing it. That's why you brought it up here. It isn't relevant.

SuuperW commented 4 years ago

Hawk related functionality that deviates from default core behavior should be made optional, so the standalone emulator works exactly like before, in terms of both usage and coding. Also avoid magic numbers.

@vadosnaprimer Is this in reference to something specific I have done?

vadosnaprimer commented 4 years ago

These: https://github.com/Arisotura/melonDS/pull/527/commits/ce32a666a29146f483a2a1a0459d8f4f2962fc48 https://github.com/Arisotura/melonDS/pull/527/commits/ff0e3eafe5764211bb200c1acce81fe4a940a09e

Spikestuff commented 4 years ago

// Will need to do something about this (and GL_GetProcAddress) for OpenGL support.

Just mentioning this now. Arisotura has OpenGL as a lesser priority to Soft (or actual DS).

Even though it's pretty functional and can support HiRes I don't recommend implementing it mainly from the encoder's perspective of keeping everything at the native res since every other system except N64 does this.

There'll probably be the HiRes people that wants this feature but honestly it's not worth placing in.

SuuperW commented 4 years ago

I'm one of the people that wants HiRes.

Spikestuff commented 4 years ago

Fine, I'll mention the other half. There's a few feature bugs that's on that OpenGL that needs to be ironed out if you want to consider it properly.

And apparently people are getting my favourite DeSmuME bug in melonDS which is black scrambled pixels in Pokemon (which has been "removed" in later builds of DeSmuME but only in OpenGL and not soft).

But hey, if you want broken Buzzy Beetles for instance then be my guest.

You shouldn't consider it for a v1 think about it down the line if you want to go that route.

DarkLegend1987 commented 4 years ago

Hi im a beta tester debbuger wait for the melón Ds for the bizhawk is a better emu than dsemu me can run many games withdow Bugs or glitch that include Golden sun dark dawn

DarkLegend1987 commented 4 years ago

Yeah that is the trouble melón Ds use real bios files but like the other cores you develop try to modify some from dsemume to melón Ds because its a better emu to be the hawk client NDS Core

DarkLegend1987 commented 4 years ago

Yeah the DSemume have bugs with high render games like Golden sun dark dawn, kingdom hearts and other 128mb up to 256mb add as submodule is good because you can upgrade later

SuuperW commented 4 years ago

I've just pushed a new .dll file, and I think it's ready to be merged into the master branch. Am I missing anything?

vadosnaprimer commented 4 years ago

Please post the archive for efficiency.

SuuperW commented 4 years ago

The archive of what?

vadosnaprimer commented 4 years ago

Hawk build + core dll.

SuuperW commented 4 years ago

archive.zip

I fail to see how this makes anything more convenient or efficient, but here ya go.

vadosnaprimer commented 4 years ago

It doesn't launch. Run this script https://github.com/TASVideos/BizHawk/blob/DSHawk/Dist/BuildAndPackage_Release.bat

Efficiency is for people who don't have Visual Studio 2019 installed to build bizhawk just to test that single dll.

SuuperW commented 4 years ago

That script fails to build. Some error messages I get:

BizHawk\Dist>IF NOT EXIST C:\Program Files (x86)\MSBuild\14.0\bin\amd64\nul goto MISSINGMSBUILD
'Files' is not recognized as an internal or external command, operable program or batch file.

seems harmless, the file exists

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.CSharp.CurrentVersion.targets(133,9): warning MSB3884: Could not find rule set file "MinimumRecommendedRules.ruleset". [BizHawk\Version\Version.csproj] I have no idea what this rule set is.

Consoles\Nintendo\NDS\MelonDS_InputPollable.cs(14,29): error CS1043: { or ; expected [BizHawk\BizHawk.Emulation.Cores\BizHawk.Emulation.Cores.csproj] There is a { exactly where it says it expects it; similar errors appear in other places in MelonDS code. I have no idea why.

vadosnaprimer commented 4 years ago

I'm getting this IStOMuE

SuuperW commented 4 years ago

I have fixed that bug.

InfamousKnight commented 4 years ago

How exciting! Unless linux support can easily be implemented, I might go back to windows just for this.

vadosnaprimer commented 4 years ago

khVWvj0

vadosnaprimer commented 4 years ago

It's been working for you perfectly fine all this time, right? I can't even get to launching a game yet...

JM13LoD

It says "wrong descriptor". Other cores load fine.

SuuperW commented 4 years ago

Yes, it works for me. Where is this latest error you're getting? Can you post the call stack? Does it show up when you just try to load an NDS ROM?

vadosnaprimer commented 4 years ago

The stack is ridiculously useless, just like the error itself is ridiculous. If I comment out the problematic line is loads fine.

    mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath)  Unknown
    mscorlib.dll!System.IO.__ConsoleStream.Write(byte[] buffer, int offset, int count)  Unknown
    mscorlib.dll!System.IO.StreamWriter.Flush(bool flushStream, bool flushEncoder)  Unknown
    mscorlib.dll!System.IO.StreamWriter.Write(char[] buffer, int index, int count)  Unknown
    mscorlib.dll!System.IO.TextWriter.SyncTextWriter.WriteLine(string value)    Unknown
    mscorlib.dll!System.Console.WriteLine(string value) Unknown
>   EmuHawk.exe!BizHawk.Client.EmuHawk.MainForm.FrameBufferResized() Line 1001  C#
    EmuHawk.exe!BizHawk.Client.EmuHawk.MainForm.Render() Line 2078  C#
    EmuHawk.exe!BizHawk.Client.EmuHawk.MainForm.ProgramRunLoop() Line 501   C#
    EmuHawk.exe!BizHawk.Client.EmuHawk.Program.SubMain(string[] args) Line 230  C#
    EmuHawk.exe!BizHawk.Client.EmuHawk.Program.Main(string[] args) Line 83  C#
    [Native to Managed Transition]  
    mscoreei.dll!000007fef38c7b2d() Unknown
    mscoree.dll!000007fef39b5b21()  Unknown
    kernel32.dll!0000000076db59ed() Unknown
    ntdll.dll!0000000076fec541()    Unknown

Someone else should check this.

vadosnaprimer commented 4 years ago

Somehow it also requires bizhawk\output\melon dir to exist even if it's empty. The game loads fine with that empty dir there (if I comment out the line above) but fails to find the bios if I remove the dir.

SuuperW commented 4 years ago

Derp, I should have realized that myself. I pushed a fix.

vadosnaprimer commented 4 years ago

Is it completely impossible to have the firmware files in the dedicated firmware folder? Also I don't understand where it's getting the files from if the dir is empty...