Mesen - Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Mesen - Emulator

Post by Sour »

As some of you already know, I've been working on an updated version of Mesen for a pretty long time, and it's mostly ready.

This rewrites the UI completely, among other things. The emulation code is mostly the same as before, with minor improvements, refactoring and some optimizations. The new UI runs on .NET 6 and should run a lot more smoothly than the old WinForms UI, especially on Linux.

This also merges both Mesen and Mesen-S into a single emulator, which supports the NES, SNES, GB(C) and PC Engine.
PC Engine emulation was added and CD-ROM games are also supported. Some PCE emulation issues still exist, but it should generally be pretty decent.

Debug tools are essentially identical for all consoles and for the most part are similar to what was available in Mesen/Mesen-S. Everything that Mesen/Mesen-S supported should be available (excluding some fairly minor features/options), along with some new features and improvements.

This is still a preview and not quite finished (although all the features I intended to include in the first release have been implemented)
Please don't expect subsequent updates to be fully compatible with this build (e.g your settings might be lost, save states/movies might not be compatible, etc.)

On Windows, you'll need to install the .NET 6 Runtime (and I don't think it's been tested on anything other than Windows 10)
On Linux and macOS, you'll need the .NET 6 runtime and SDL2. (Mono is no longer used/needed, just launch the executable directly after installing .NET 6)

Code is here: https://www.github.com/SourMesen/Mesen2
Dev builds for Windows/Linux are linked in the readme: https://github.com/SourMesen/Mesen2#development-builds
(for macOS, you'll need to build it yourself)

Please report issues here if (when) you find any.
This has only been tested by a handful of people over the last few months, and there are definitely features/options that haven't been tested since they've been implemented, so I fully expect there will be some fairly silly bugs found once more people use it.

To stay focused on completing what's left (and not get 100 issues about missing mappers in the NES core in the meantime), the issues tab on the repository is disabled, for now.
For the same reason, I'm not going to be accepting/reviewing any pull requests, either.

The main goal at the moment is to fix bugs/crashes in the new version. Any feedback about the UI is welcome, too.
Emulation accuracy fixes will have to wait until later down the road, unless they're regressions vs the old versions or very simple to fix.
Feature/change requests will also have to wait (unless they're obvious improvements and easy to implement)
Last edited by Sour on Thu Feb 02, 2023 9:56 pm, edited 1 time in total.
User avatar
Gilbert
Posts: 564
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: Mesen - Emulator

Post by Gilbert »

Sour wrote: Wed Jan 25, 2023 8:08 pm This also merges both Mesen and Mesen-S into a single emulator, which supports the NES, SNES, GB(C) and PC Engine.
PC Engine emulation was added and CD-ROM games are also supported. Some PCE emulation issues still exist, but it should generally be pretty decent.
This.Is.Just.Great!

Will download it now.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Mesen - Emulator

Post by tokumaru »

Can't wait to try it! Thanks for your awesome work, man!
User avatar
Vectrex2809
Posts: 102
Joined: Mon Jul 14, 2014 6:05 am
Location: Tokyo, Japan

Re: Mesen - Emulator

Post by Vectrex2809 »

PC Engine on a familiar UI?! THANK YOU SO MUCH!!! Looks like it's finally time to give PCEdev a shot
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - Emulator

Post by tepples »

As Microsoft used to tell the Firefox team: "Congratulations on shipping!"

Things I noticed that are improvements:

1. MUCH faster than Winforms-based Mesen.

Things I noticed that may need investigation:

1. Help > Report a bug points to a 404 (you may want to change this once a new site goes live)
2. NES: Assigning a key to microphone and pressing that key doesn't trigger the microphone (ROM: 240p Test Suite pre-0.23 > Input test > FC controllers & mic)
3. GB: Joypad interrupt on Super Game Boy isn't issued at all (ROM: Telling LYs)
4. GB: Joypad interrupt on Game Boy and Game Boy Color is always issued on the same scanline (ROM: Telling LYs)
5. GB: INC HL with H=$FE during mode 2 (OAM scan) on pre-GBC models doesn't corrupt OAM (this is GB's counterpart to NES $2003 foolery)
6. GB: Wave RAM can be read while a note is playing (ROM: Demotronic by Megaboys)
7. GB: Possible inconsistency with initial value of NR52 ($FF26) across power cycle and reload ROM, which I may characterize later (this can affect tuning in LSDJ)
8. GB: Load ROM in GB mode then switch to SGB mode and Reset, Power Cycle, or Reload ROM, and occasionally the ding is heard and the screen doesn't appear
User avatar
carmiker
Posts: 12
Joined: Wed Sep 16, 2020 4:16 am
Contact:

Re: Mesen - Emulator

Post by carmiker »

Great news. It's also nice to see another take on emulating the PCE.
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Mesen - Emulator

Post by jeffythedragonslayer »

I do have source view setup now in Mesen2, and I found the line responsible for not allowing me to set breakpoints in it: SourceViewView.axaml.cs:86

Code: Select all

IsEnabled = () => ActionLocation.RelAddress != null || ActionLocation.AbsAddress != null,
Not sure why these are null...
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Re: Mesen - Emulator

Post by jeffythedragonslayer »

I fixed most of my issues with both the Disassembly and Source views. I can now see my comments, labels, variable names, set breakpoints - all in both. This block in UI\Debugger\Integration\DbgImporter.cs turned out to be the culprit:

Code: Select all

if(row.Contains("type=rw")) {
        //TODOv2 fix this
        //Assume a RW segment inside the .sfc file is SPC code
        isRam = true;
        memType = MemoryType.SpcRam;
}
It thought my stuff was in ARAM this whole time! When I hacked my .dbg file to make the segs be type=r instead of type=rw, things got a lot better. :P
User avatar
Reaper_Man
Posts: 51
Joined: Sat Jun 17, 2006 2:31 pm
Location: Bogota, Colombia

Re: Mesen - Emulator

Post by Reaper_Man »

Rise from your grave...
This is excellent news! I'm looking forward to giving it a spin later.
did you ever figure out what was causing the AVI desync issues when rewinding or loading a savestate while recording? That's probably one of the first things I'm going to test.

EDIT: bug seems to still exist, unfortunately. Video can be found here (ZMBV codec). Savestate is loaded 60 times and you can hear that the sound is a second or so behind the video.
User avatar
Aclectico
Posts: 5
Joined: Thu Aug 09, 2018 10:56 am

Re: Mesen - Emulator

Post by Aclectico »

Great to hear about the updates. Do you have any long term plans on the enhancement pack (or HD Pack) side of things? When you mentioned features would have to wait, I assume enhancement packs would fall under that category. I know there are a couple of packs that have been in development for a year or two now that have relied on the mkwong98 fork. That variant added a few features such as a pack loading notification. It also added an "addition" condition that allows pack authors to add artwork beyond native sprite boxes. It's been crucial for a pack I have been working on for quite a while.
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Mesen - Emulator

Post by Pokun »

Fantastic to have you back!
I remember you did Game Boy as part of Super Game Boy in Mesen-S, but to think PC-Engine would also be emulated and have the same great debugging tools is absolutely marvelous! It runs some of my homebrew that didn't run correctly on older emulators, so I can tell it's already more accurate than Magic Engine at least. Good job! I can see it stealing Mednafen's place as the best PCE emulator for both developers and gamers some time in the future.
ndiddy
Posts: 33
Joined: Tue Oct 24, 2017 11:07 pm

Re: Mesen - Emulator

Post by ndiddy »

It's fantastic to see a new release. Since nobody else has called it out yet, I think the Mode 7 perspective visualization is really neat, nice work! Mesen was the sole thing making me stay on Windows (all the other WIndows-only programs I use can run acceptably in a VM), so I'll definitely be checking out the Linux version.
User avatar
Dwedit
Posts: 4922
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Mesen - Emulator

Post by Dwedit »

I just tested out Game Boy emulation, my basic test cases were Prehistorik Man and GBC games which used high color modes, and they worked perfectly. Demotronic refuses to run though. (No Boy! No Demo!)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

Thanks for all the feedback!

tepples wrote: Wed Jan 25, 2023 10:32 pmThings I noticed that may need investigation:
Thanks, 2 & 3 should be fixed with the latest code. 4-7 will probably have to wait for now.

Reaper_Man wrote: Thu Jan 26, 2023 10:58 amdid you ever figure out what was causing the AVI desync issues when rewinding or loading a savestate while recording? That's probably one of the first things I'm going to test.
I just did some changes that should fix the desync when loading a state, and another desync that occurred when pausing/resuming the emulation. Rewind is tougher and I haven't been able to figure out where the extra frames are coming from exactly, this will most likely have to wait until later.

Aclectico wrote: Thu Jan 26, 2023 11:43 amDo you have any long term plans on the enhancement pack (or HD Pack) side of things?
I don't really have long term plans in general, period. :p More seriously though, I'm not familiar with most of the changes that were done on forks, I know some changes were done to hd packs, but not what they were exactly. Assuming nothing was done that impacted a lot of code outside of the hd pack stuff and that it doesn't have negative impacts on performance, it should probably be ok to merge them in eventually, but it'll probably be a little while until I can take a proper look.

ndiddy wrote: Thu Jan 26, 2023 6:24 pmI think the Mode 7 perspective visualization is really neat, nice work!
This is entirely rainwarrior's idea, I just implemented essentially the same thing after he made a proof of concept for it on a fork of Mesen-S :p

Dwedit wrote: Thu Jan 26, 2023 7:33 pmDemotronic refuses to run though. (No Boy! No Demo!)
Thanks, I'll add it to my list of things to look at. Game boy emulation is something I added to Mesen-S ~3 years ago just before I stopped working on it, so there's still a fair amount of accuracy issues with it that need to be fixed.
fred
Posts: 67
Joined: Fri Dec 30, 2011 7:15 am
Location: Sweden

Re: Mesen - Emulator

Post by fred »

Sour, our lord and savior :D Been using mesen-s extensively for digging in snes games. Its debugging capabilities have definitely made me spoiled lol, going over to mame feels so clunky, and let's not even get started on mega drive debugging! What a nightmare.

I'll start using mesen2 and see how it goes!

Edit: The added memory search is much appreciated! This finally obsoletes the need for having bizhawk on the side!
Post Reply