Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Sour
Posts: 739
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Sat Mar 17, 2018 8:49 pm

That's most likely because the builds I post on the forums are usually "Windows-only" builds that don't contain the Linux code (my bad for not mentioning it). So you're most likely running the new UI code with the old C++ core library, which is probably causing the crashes.

Try this build: download
It's the same as the one I posted in the other thread a couple of days ago, but contains the Linux build as well.
Last edited by Sour on Sun Mar 18, 2018 5:24 pm, edited 1 time in total.

User avatar
gauauu
Posts: 657
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Mesen - NES Emulator

Post by gauauu » Sun Mar 18, 2018 5:56 am

Awesome, I'll try it later tonight. Thanks!

Jiggers
Posts: 4
Joined: Mon Mar 19, 2018 12:44 pm

Re: Mesen - NES Emulator

Post by Jiggers » Mon Mar 19, 2018 1:13 pm

I'm really loving this emulator lately! Its the only one that will run my game and reload the saves. :D

However, as I'm fiddling with my game, the bytes in the rom keep changing... and I can't re-load save states anymore. Even just changing a 1 to a 0 keeps me from re-loading. Bug-testing is rather difficult when I can only use SRAM saves.

Is there any way to disable this rom check when reloading a save state? Or is it possible to add an option to disable it?

tepples
Posts: 21752
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - NES Emulator

Post by tepples » Mon Mar 19, 2018 1:38 pm

If PC and stack have addresses on them, and those addresses have changed because you added or deleted something earlier in the ROM, how useful are your saved states?

User avatar
gauauu
Posts: 657
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Mesen - NES Emulator

Post by gauauu » Mon Mar 19, 2018 1:54 pm

tepples wrote:If PC and stack have addresses on them, and those addresses have changed because you added or deleted something earlier in the ROM, how useful are your saved states?
That's why he mentioned just flipping a single bit. Often when you're editing levels, for example, the code and structure of the game stays exactly the same, but a tile or two changes. It's really helpful to have the ability to reload right to where you left off in testing after tweaking a byte of level data.

User avatar
rainwarrior
Posts: 7676
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior » Mon Mar 19, 2018 2:41 pm

tepples wrote:If PC and stack have addresses on them, and those addresses have changed because you added or deleted something earlier in the ROM, how useful are your saved states?
Actually I find this an extremely useful feature (or lack of feature, in this case) of FCEUX.

Very often I was making code or data changes that didn't move those critical things around, and could use the same savestate to quickly get back to the thing I was trying to test after making a change.

If savestates are normally taken just before NMI, the only code that needs to have a stable location is the main thread's wait loop, I suppose, but whatever the particular condition was, my program was meeting it, and because of that it was VERY helpful for testing.


Another thing related to savestates, I notice that it normally automatically takes a savestate of a game when I quite. However, if I double click on an NES ROM to open it, it will not reload that state? It seems the only way to get back to it is to open Mesen on its own, and then navigate its recent games UI? It seems if I double click to open a file (the normal way I open a ROM), I have already obliterated the previously saved state and have no way to get it back. Is there an option for this that I missed?

tepples
Posts: 21752
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - NES Emulator

Post by tepples » Mon Mar 19, 2018 3:47 pm

Data in ROM, such as the current level or metatile decompression pointers, can also move around from build to build even if you aren't modifying code. This renders pointers in RAM invalid.

One possible workaround is to construct the saved state within the program under test by specializing its level loading code. It's similar to how I'd add durable breakpoints to a program by sta $4444.

Sour
Posts: 739
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Mon Mar 19, 2018 4:20 pm

Jiggers wrote:Or is it possible to add an option to disable it?
I can add an option for it - up until 0.9.3 or so there was no CRC check when saving/loading states, but I added a CRC to states when I added to option to manually load/save a state to any file. This allows Mesen to load the game that matches the CRC when you pick a state for another game.
3-4 people have asked for this in recent weeks - it's not hard to just disable the check (by adding an option), I'll try to get this done soon.
rainwarrior wrote:It seems the only way to get back to it is to open Mesen on its own, and then navigate its recent games UI?
That's how it works at the moment, yes - it's hard to broaden the scope without potentially causing some use cases to become less intuitive (e.g someone might argue that they expect the game to start from the beginning when they open it via file associations). I could add an option to make it so Mesen always tries to load any existing savestate that was taken when the game was unloaded? (no matter how you try to load the game)

tepples
Posts: 21752
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - NES Emulator

Post by tepples » Mon Mar 19, 2018 4:27 pm

Or a command line option --load-newest-save-state that an IDE could be configured to invoke perhaps?

User avatar
rainwarrior
Posts: 7676
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior » Tue Mar 20, 2018 6:04 pm

Sour wrote:
rainwarrior wrote:It seems the only way to get back to it is to open Mesen on its own, and then navigate its recent games UI?
That's how it works at the moment, yes - it's hard to broaden the scope without potentially causing some use cases to become less intuitive (e.g someone might argue that they expect the game to start from the beginning when they open it via file associations). I could add an option to make it so Mesen always tries to load any existing savestate that was taken when the game was unloaded? (no matter how you try to load the game)
I was thinking it might be nice if there was a "last session" entry in the "Load State" menu, so whatever method was used to start the game, maybe that previous savestate would always be easy to get back to, even if you have already started playing.

I am a little bit confused, because there seems to be a slot 1-7 for saving, but there's a slot 8 for loading? Some of my games seem to have stuff in that slot, but I haven't figured out how it gets filled. At first I thought it might be what I was just asking for above, access to the thing that was saved when I quit, but I can't figure out where this savestate actually comes from.


When playing back an input movie to record an AVI, if I have the play icon enabled, it appears in the AVI (despite none of the other UI overlay stuff appearing, e.g. pause, FPS, frame counter). Input display also does this, apparently. Is there a rule for which stuff appears in the recording and which doesn't? Text overlay is omitted, but not graphical icons?


I notice it supports the DosBox ZMBV codec. ZMBV is good enough for my needs, though I might also recommend this one:
https://en.wikipedia.org/wiki/Lagarith


Also, some emulators will pause emulation whenever you use the menu (FCEUX, Nestopia, Retroarch), others don't (Nintendulator, puNES). I can see why someone would want either behaviour, but for me I'm used to this being a pause action. I don't know if it's possible to automatically pause and unpause whenever the menu is open, but that would be a nice option for me, because I find I expect/want the pause a lot for this case, and it ends up being an extra step to pause first (or an extra several steps to back out of the menu, pause, then try again).


Advancing frame by frame seems to have the game completely muted. It would be useful if it would play a frame worth of audio, though. The immediate sound feedback in this case can be a very good indicator of state (especially if trying to debug music/sfx stuff), and is something I used quite a bit in FCEUX.

Sour
Posts: 739
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Tue Mar 20, 2018 6:31 pm

A "last session" option shouldn't be too hard to add. Slot 8 is the auto-save slot (saves every 5 mins by default) - I should probably make this clearer in the UI (and should probably expand the number of slots to ~10 now that UI shortcuts can be customized)

What records and what doesn't is a bit of a mess, I will admit - the text & counters are added on top outside the actual emulation core and aren't recorded. The icons and controller input are recorded and appear in screenshots (mostly as a side-effect of how the rendering "pipeline" works). Ideally I'd prefer if none of them were recorded at all, although arguably some people might want to record all of them.

The main reason Lagarith isn't included is its size - it's 400+kb worth of code, compared to ZMBV & Camstudio which, combined, fit within 500 lines or so. I try not to add large libraries unless there is really a large benefit to including them (e.g 7zip, lua, etc.).

The pause-while-in-menu is something that was requested a few months ago on Github but I haven't gotten to it yet. It used to be that way (when "Pause when in background" was enabled), but it didn't work as reliably as I wanted (and I think the Mono port didn't like it at all), so I scrapped the behavior at some point - I can take a look at getting it working properly again.

For sound while frame advancing, I'll have to take a look - at the moment, pausing empties the sound buffer, and since a single frame usually isn't enough to refill it past the threshold for playback to start (defaults to 50ms), no sound is played. It shouldn't be overly hard to fix it, though, I think.

User avatar
rainwarrior
Posts: 7676
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior » Tue Mar 20, 2018 7:23 pm

Sour wrote:The main reason Lagarith isn't included is its size - it's 400+kb worth of code, compared to ZMBV & Camstudio which, combined, fit within 500 lines or so. I try not to add large libraries unless there is really a large benefit to including them (e.g 7zip, lua, etc.).
Oh, ZMBV is fine. I was just suggesting Lagarith because it had been my default for a long while, but testing them both now, it seems that ZMBV is smaller and Lagarith is faster. I think I care about the file size more, so I should probably switch. ;)

I guess the ideal thing would be to get the list of installed codecs from the user, but that's probably not easy/possible to do cross-platform.

mkwong98
Posts: 221
Joined: Mon May 30, 2011 9:01 pm

Re: Mesen - NES Emulator

Post by mkwong98 » Wed Mar 21, 2018 10:25 am

After reading this viewtopic.php?f=3&t=9873, I wonder if it is possible to add information in the HD pack to tell the emulator which tiles are used as sprite mask and only enables the sprite limit on those scan lines.

Sour
Posts: 739
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Wed Mar 21, 2018 2:22 pm

mkwong98 wrote:After reading this viewtopic.php?f=3&t=9873, I wonder if it is possible to add information in the HD pack to tell the emulator which tiles are used as sprite mask and only enables the sprite limit on those scan lines.
Mesen already has a global option for this: Emulation -> Advanced -> "Automatically re-enable sprite limit as needed to prevent graphical glitches when possible".

It will re-enable the sprite limit on a per-scanline basis based on certain heuristics - it works with the majority of games that abuse the sprite limit to hide sprites.

Sour
Posts: 739
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour » Wed Mar 21, 2018 6:58 pm

Here's another build with a few tweaks: download

Changes:
-Added an option to ignore the hash checks when loading a save state (Preferences->Save Data). This will only work with states that were saved with this build (because I kept a restriction that the save state must be for a game with the same mapper ID, which should be fine for homebrew, and prevent potential crashes)
-Increased the number of save state slots to 10, and clearly identified the auto save slot in the UI
-Added a "Load Last Session" option in the File menu (and a shortcut binding for it) that reloads the state from the last time the game was closed in the emulator (including data that is no longer shown in the game selection screen). This can be used any number of times and it will always reload the same state, until the game changes, or "Power Off" is used
-Added a couple more auto-pause options, one to pause when in menus & configuration dialogs, another to pause when in debugging tools. Having the main debugger window opened will override these, though (I might be able to fix that relatively easily, now that I think about it, though)
rainwarrior wrote:I guess the ideal thing would be to get the list of installed codecs from the user, but that's probably not easy/possible to do cross-platform.
Yea, Linux support is essentially why I didn't use the Win32 AVI API for this, otherwise it would have been a lot simpler. To be fair, though, re-encoding to a better codec using ffmpeg is usually very simple (and with today's CPUs, very fast, too)

Post Reply