Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

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

Re: Mesen - NES Emulator

Post by rainwarrior »

Are breakpoints/watch entries supposed to persist when I close and reopen Mesen? They always seem to clear for me, and I could swear that didn't happen before...

I thought it might be the "Workspace > Import settings > Reset workspace" but that doesn't seem to affect it. If I reload the ROM with Ctrl+T the DBG gets correctly reimported and all the symbols update, but the watch/breakpoint persists. They only seem to disappear when I close the program.

Also, while I'm here, is there any way to attach a name/note to a breakpoint? It's usually pretty hard to remember them just by address or order in the list.

(Using 9.7.79)
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Mesen - NES Emulator

Post by koitsu »

Breakpoints and watchpoints used to work when exiting/relaunching Mesen (or closing/opening a ROM). If that's not working now, that sounds like a bug.

Edit: Yeah, they seem missing for me as well in the existing project I have, using Mesen Dev-0.9.7.72. Damn, I had about 10-12 breakpoints in there too. :\
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

rainwarrior wrote:Are breakpoints/watch entries supposed to persist when I close and reopen Mesen?
Yes, that was a bug - noticed that earlier myself, it should be fixed now (let me know if you still have issues with the next appveyor build)

Also, a few watch-related changes:
-Improved watch window usability - should now be easier to add new entries, less odd behavior like what gauauu reported a few days ago where starting to type with a "{" caused issues, etc.
-Added Move up/down right-click options (and shortcuts)
-Added Import/Export right-click options
-Fixed an issue with expression parsing and improved expression validity checks
-Added support for binary values in expressions (% prefix)
-Added a standalone "watch window" that is a copy of the watch (and synced with it), but can be resized/moved around independently from the rest of the debugger.

The main thing left now would be the ability to select the way to output each expression independently (hex, signed, binary, etc.). A right-click menu for this seems like it might be a bit annoying to manage. What do you think of having a prefix for it? e.g:
D:[$00] to display the result of "[$00]" as an unsigned decimal value
S:[$00] to display the result of "[$00]" as a signed decimal
B:[$00] to display the result of "[$00]" as a binary expression (%10101...)
H:[$00] to display the result of "[$00]" as a hex string

Would that be intuitive/easy to manage? I would also add binary/signed to the right-click options to select a default view for all expressions, like it currently does for the hex view (so the prefixes would be entirely optional)
koitsu wrote:Edit: Yeah, they seem missing for me as well in the existing project I have, using Mesen Dev-0.9.7.72. Damn, I had about 10-12 breakpoints in there too. :\
Sorry!

Edit:
rainwarrior wrote:Also, while I'm here, is there any way to attach a name/note to a breakpoint? It's usually pretty hard to remember them just by address or order in the list.
Had missed that. The only way to give a breakpoint a name of sorts at the moment is to label the corresponding memory address, which is probably not ideal. I could add an optional name/description field in the UI and have it display in the breakpoint list/etc easily enough, though.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - NES Emulator

Post by tepples »

Sour wrote:The main thing left now would be the ability to select the way to output each expression independently (hex, signed, binary, etc.). A right-click menu for this seems like it might be a bit annoying to manage. What do you think of having a prefix for it? e.g:
D:[$00] to display the result of "[$00]" as an unsigned decimal value
S:[$00] to display the result of "[$00]" as a signed decimal
B:[$00] to display the result of "[$00]" as a binary expression (%10101...)
H:[$00] to display the result of "[$00]" as a hex string
Or draw from the likelihood that debugger users will be familiar with printf format strings: %u[$00], %d[$00], %b[$00], %x[$00]
(N.B. %b does not exist in standard C.)
or %c[$00] to display as a character in the current codepage
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Ah, thanks! Currently in the middle of some testing but I will check the updated build soon.

As for the prefix thoughts, I think maybe also add an optional number of bytes to the prefix (S2 S4 etc.). It becomes important with 24 or 32 bit types, especially with signed representation, though also with hex it would be good to be able to specify number of digits. Currently hex seems to just expand to cover the size of the value, and automatically pads with extra 0s if {} is involved?

Like I've been using expressions to make 24 bit types out of [] and {}, but signed representation was a feature I couldn't kludge together. (Sometimes just typed stuff like "256-[var]" and had "[var]" next to it to kinda look at both at once, but it was awkward.)
tepples wrote:%c[$00] to display as a character in the current codepage
This wouldn't look so clean if you were using expressions other than just []. It can't be a modifier on a single term, it has to apply to the whole expression. e.g. "%c[var]+25"? I think the colon idea does a good job of visually making the division clear.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

A few thoughts on the movie feature, and the event viewer:

Using the movie recording feature I've noticed that if I use randomized RAM, the movie will be desynched when playing back if the game depends on starting RAM values. (e.g. the golf game I'm working on randomly generates a completely different set of holes, so the movie is useless for that).

There seems to be no UI for movie playback, so it's hard to figure out things like how long it's been playing or how long it has to go, or whether I've accidentally cancelled playback with other input, etc. In particular I'd probably like to be able to display:
  • If the movie is in progress, or finished
  • What frame of the movie I'm on
  • How many frames are in the movie total
Additionally I'd probably want to be able to automatically pause as soon as the movie ends, both to know that it's stopped, but also to prevent from accidentally doing unintended input after it completes.


The "history viewer" is great, though maybe it could be combined nicely with the movie feature? Like if I loaded a movie to play back, maybe it could load into the event viewer, which I could use to preview it and jump around before I start using the movie to debug something or make a video recording, etc. (I guess it would take a long time to re-render the cache of history from the movie though...)

The event viewer could really use the ability to advance/rewind frame by frame, I think, and to see a frame count (not just minutes/seconds). I love the preview, since I can leave the game paused while I peruse the history without destroying the current state. The scaling looks really weird in this window though, no matter what size I make it there are weird artifacts that look like the image was rendered at some smaller resolution than 256x240 and then nearest-neighbour rescaled up?

The export menu mentions "segment", is it possible to capture a smaller piece of a movie than the whole thing? Does it automatically start a new segment after 300 minutes or something? I would assume a movie that doesn't start from power-on would have a stavestate up front, which would fix that desynch issue, but maybe that would be appropriate for all movies, not just ones that start from the middle)

At the moment I really wanted to just save a movie file so I could replay a thing that just happened, and then capture an AVI of it. Unfortunately it's desynched, but it's what got me thinking about the lack of movie playback UI, 'cause it's a 30 minute movie and I have no way to really skip forward in it, or know how far along it is other than watching it (which is why I think it might be neat if a played movie would just "load" into the history viewer).
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Oh, one more thing, if I close Mesen while an active AVI recording is still happening it will crash.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

Yea, movies will desync on random RAM - it's been a "todo" in the code for a long time. Most movie-related features/improvements are more or less pending me getting to building TAS tools eventually..

There's already an option (enabled by default) to pause when the movie ends, and I'm pretty sure there's an option to show a play button while a movie is playing (both are in the preferences' general tab iirc).

Loading a movie into the history viewer is actually something that's been on my list ever since I added the history viewer.

The segments are created when state is loaded by the user, it's not related to the rewind limit (although this probably breaks in some fashion if you do reach the rewind limit). Creating a smaller segment for export is possible, just a matter of having a UI for it. IIRC, all history viewer movies currently contain a save state, even those starting from power on.

Some of this shouldn't be too hard to fix, I'll take a look.
About the scaling issue in the history viewer, are you at a DPI setting other than 100% in windows? That could be the cause.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Sour wrote:About the scaling issue in the history viewer, are you at a DPI setting other than 100% in windows? That could be the cause.
No, it's at 100%. I see this the same on two different machines, one is Win7, one is Win10.

It's kind of weird, seems to be intermittent behaviour... I've attached a screenshot (ROM) where you can see that it looks like it was rescaled once at some lower resolution, and now rescaled again to the window size (nearest-neighbour both times)

Playing with it, it seems to be duplicatable when I start playing something in the history viewer at small size, hit pause, and then resize it to be a larger window... so maybe it's just the event viewer not redrawing when it's paused... which is maybe not a real problem. I thought I was seeing it while it was playing too, though, but I may have been wrong, maybe I was just seeing the 1 intended layer of scaling artifacts at that point.

Though it would be nice if I could snap/set the event viewer to 1x/2x/3x size. I suppose the real issue that I'm dealing with here is I just can't get a clean view of the event viewer because of that last nearest-neighbour upscale to the window size. I've tried really hard to manually size the video to 1x or 2x but can't ever seem to find the right spot? (Almost feels like the correct integer is somehow inaccessible... that can't be true, can it?)
Attachments
history_viewer_scaling2.png
Last edited by rainwarrior on Wed Jan 30, 2019 3:28 pm, edited 2 times in total.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Sour wrote:Yea, movies will desync on random RAM ... IIRC, all history viewer movies currently contain a save state, even those starting from power on.
Oh, that's interesting... does the RAM randomization apply after the savestate, replacing its contents? Would my existing desynching movies be able to work after the fix, or do they not have the needed information in the savestate?
Sour wrote:There's already an option (enabled by default) to pause when the movie ends, and I'm pretty sure there's an option to show a play button while a movie is playing (both are in the preferences' general tab iirc).
Ah, I see both. Somehow I missed them when I went looking, sorry.
Sour wrote:The segments are created when state is loaded by the user, it's not related to the rewind limit (although this probably breaks in some fashion if you do reach the rewind limit). Creating a smaller segment for export is possible, just a matter of having a UI for it.
That makes me think it would be really great to be able to "export savetate" from the history viewer, too. Though I suppose this is already possible by saving movie, playing it back and making savestates during playback... as long as the movie doesn't desync ;)


Following up on the other changes:
  • Breakpoints/watch being erased on close seems fixed.
  • New watch window is awesome!
  • I like that it's shared with the debugger instead of two separate instances.)
  • Watch up/down works well.
  • Watch import and export too! Nice!
  • Binary number literal prefix is interesting... makes me realize I never listed binary as a display option for values.
  • The ? help button on the watch panel in the debugger is great for quick reference, though it'd be nice to have somewhere in the watch window too.
This is all very nice! Dunno what was fixed about expression evaluation but I'm sure it's for the good. :)
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

The screen's HUD scales along with the picture when resizing occurs while paused, the main window does this, too. It's been like this for a very long time, I vaguely recall it being annoying to fix, but I could be wrong.

I'll look into adding scaling shortcuts for the history viewer (and checking to ensure it's displaying properly - off the top of my head, I thought it was meant to open to be the same scale as the main window itself, but I could be remembering incorrectly)
rainwarrior wrote:Oh, that's interesting... does the RAM randomization apply after the savestate, replacing its contents?
It shouldn't - was the video that was desyncing taken using the history viewer? If so, I would have expected it to work, but it's possible there's a problem somewhere w/ regards to random RAM. RAM randomization is applied at power on only, so loading a movie should be doing Power On -> Randomize -> Load state (and overwrite all that randomization with what is in the state instead)
rainwarrior wrote:That makes me think it would be really great to be able to "export savetate" from the history viewer, too
You can also do "Resume gameplay from here" to load the state in the main window and then take a save state manually. It might be fairly easy to have an export save state option, though.
rainwarrior wrote:The ? help button on the watch panel in the debugger is great for quick reference, though it'd be nice to have somewhere in the watch window too.
Yea, I meant to fit that in somewhere too, but in my rush to get it done, I forgot :p
rainwarrior wrote:This is all very nice! Dunno what was fixed about expression evaluation but I'm sure it's for the good.
Mostly just silly things, like stuff such as "$$$$30", "[$00]44" being "valid", even though it's fairly unclear what they actually resolve to.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Sour wrote:The screen's HUD scales along with the picture when resizing occurs while paused, the main window does this, too. It's been like this for a very long time, I vaguely recall it being annoying to fix, but I could be wrong.
That in itself isn't really a problem, so if it's just that, then I'd say it doesn't need to be fixed. It was just confusing in tandem with the second step of nearest-neighbour scaling to window size, I think, but if I could just get a 1x/2x/3x window size for that it wouldn't be an issue.
Sour wrote:off the top of my head, I thought it was meant to open to be the same scale as the main window itself, but I could be remembering incorrectly)
It appears to remember the last size used, even after closing and reopening the program.
Sour wrote:was the video that was desyncing taken using the history viewer? If so, I would have expected it to work, but it's possible there's a problem somewhere w/ regards to random RAM. RAM randomization is applied at power on only, so loading a movie should be doing Power On -> Randomize -> Load state (and overwrite all that randomization with what is in the state instead)
Yes, the video was made with history viewer, and checking in the debugger it appears to initialize all RAM to 0. (Random RAM was the setting used while playing.) Maybe the save state gets taken before the randomization happened?
Sour wrote:
rainwarrior wrote:That makes me think it would be really great to be able to "export savetate" from the history viewer, too
You can also do "Resume gameplay from here" to load the state in the main window and then take a save state manually. It might be fairly easy to have an export save state option, though.
The resume gameplay feature is very good, but what I meant was being able to pick a state from the middle without destroying everything that happens after it would be very useful too. Like I found myself thinking hard about whether I wanted to lose a bunch of stuff to look at an older event or not. (Though the main problem was just the movie save having failed.)
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

rainwarrior wrote:Yes, the video was made with history viewer, and checking in the debugger it appears to initialize all RAM to 0. (Random RAM was the setting used while playing.) Maybe the save state gets taken before the randomization happened?
Turns out I was just remembering things incorrectly - originally history viewer movies all had save states while I was in the middle of coding it, but I removed the save state from the first segment if segment starts from power on and the ROM does not have the battery flag set. A quick fix for now would be to force a save state if the ram setting is set to random, since movies can't properly handle that at the moment.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - NES Emulator

Post by rainwarrior »

Sour wrote: A quick fix for now would be to force a save state if the ram setting is set to random, since movies can't properly handle that at the moment.
Since there's 3 different settings, it's probably just be best to always save state? Otherwise the user would have to know/guess which the movie was record with.

With FCEUX there was an opposition to starting from power-on with a savestate in the format, don't know the rationale, but FM2 also has a bunch of annotation data for settings, and when the randomize RAM option was added, it included an annotation with the seed used... but IMO just using a savestate seems simpler and easier? I doubt many would care about the file size being a couple KB larger.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - NES Emulator

Post by tepples »

Tool-assisted speedrunners might prefer a separate representation for a power-up state so that they can verify that the power-up state is indeed a power-up state, not a cheated save state.
Post Reply