Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

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

Re: Mesen - NES Emulator

Post by Sour »

Here's a build with the trace logger improvements: download
It adds an (optional) formatting string that lets you customize how each row is constructed (field order, padding, hex vs decimal, etc.), a couple more formatting options and fixes some bugs with the CPU flag display (it also contains other debugger changes I've done to the code since 0.9.5, too)

If you setup the trace logger this way, you should get more or less what you were looking for (between your messages here & your PM):
traceloggerconfig.png
You can customize the output to your needs by changing the "Format" field - there's a tooltip that explains how it works on the right.

I also made the pause icon slightly transparent, I can't really make it any more transparent than this (else it becomes too hard to notice it) - there is already an option to turn off the icon completely (in the debugger's options menu), if you would rather not see it at all.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

Sour wrote:Here's a build with the trace logger improvements: download
It adds an (optional) formatting string that lets you customize how each row is constructed (field order, padding, hex vs decimal, etc.), a couple more formatting options and fixes some bugs with the CPU flag display (it also contains other debugger changes I've done to the code since 0.9.5, too)

If you setup the trace logger this way, you should get more or less what you were looking for (between your messages here & your PM):
traceloggerconfig.png
You can customize the output to your needs by changing the "Format" field - there's a tooltip that explains how it works on the right.
Thank you so much Sour! For some reason Mesen doesn't like this f[FrameCount][Align, 7]A:[A,h] X:[X,h] Y:[Y,h] S:[SP,h] [P,8] [PC,h] [ByteCode, 12h] [Disassembly][EffectiveAddress] [MemoryValue,h]. It shows "f5513Align, 7]A:A0..." always removing the first opening bracket of the Align tag. After editing my line a bit I think that you may have made a typo in the notes about how the Align command is susposed to be used. Thank you so much Sour for the extreemly helpful emulator!! :mrgreen: :D
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

unregistered wrote: It shows "f5513Align, 7]A:A0..." always removing the first opening bracket of the Align tag.
That's because you added a space after the comma - I should probably tweak it to ignore spaces inside tags, but for now you should be able to fix it by removing the extra spaces (you have another one in the "ByteCode" tag, too)
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

Sour wrote:
unregistered wrote: It shows "f5513Align, 7]A:A0..." always removing the first opening bracket of the Align tag.
That's because you added a space after the comma - I should probably tweak it to ignore spaces inside tags, but for now you should be able to fix it by removing the extra spaces (you have another one in the "ByteCode" tag, too)
Thank you so much! It works incredibly now!! :mrgreen: :D
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

Last night, after discovering your new Show zeropage addresses as 2 bytes checkbox, I checked it and the 00 was added to the low byte (i.e. $21 becomes $2100). I can't figure out how to add 00 to the high byte. :oops:

edit: Thank you so much for this added checkbox! It will be so helpful if I can get it to work correctly. :D

Now this line is working so good for me:
f[FrameCount][Align,7] [A,h] [X,h] [Y,h] S:[SP,h] [P,8] $[PC,h]:[ByteCode,11h]|[Disassembly][EffectiveAddress] [MemoryValue,h] (note: there is a space between [EffectiveAddress] and [MemoryValue,h])
because there isn't A: X: Y: (saves 6 characters) and you add a $ infront of each byte in ByteCode (3 extra characters) plus I added an extra space before $[PC,h] (1 extra character) so that is a savings of two characters per line (when compared to FCEUX) and it is easy for me to read! :mrgreen: :D

edit2: ...guess that would be a savings of four characters per line because [P,8] doesn't have any extra characters preceeding it. :)
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

unregistered wrote:I checked it and the 00 was added to the low byte (i.e. $21 becomes $2100). I can't figure out how to add 00 to the high byte.
Yea, that's my bad, didn't test it properly and added the extra 0s at the end instead of the beginning, I'll fix it and try to upload a new build when I get a chance.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

^thanks :)

:idea: Try this Format Override line:

Code: Select all

f[FrameCount][Align,7] [A,h][X,h][Y,h] S:[SP,h] [P,8]  $[PC,h]:[ByteCode,11h]|[Disassembly][EffectiveAddress] [MemoryValue,h]
only edit: :idea: or this one:

Code: Select all

f[FrameCount][Align,8][A,h][X,h][Y,h] S:[SP,h] [P,8]  $[PC,h]:[ByteCode,11h]|[Disassembly][EffectiveAddress] [MemoryValue,h]
edited again (sorry): Notes for others: this one will keep everything the same as the first Format Override line suggested in this post, except [FrameCount] will be able to reach 9,999,999 (without the line moving down 1 column). Note: Anything over 999,999 frames will cause no spacing between [FrameCount] and [A,h] but, it won't be difficult to read, I think, because [A,h] changes often and [FrameCount] only changes once at the beginning of each frame. I would just turn the wheel on my mouse a bit to scroll Notepad up and down to see where the start of [A,h] is, if I needed to. :) And... Notepad, Programmer's Notepad, and, I guess, every other text editor :?: starts the cursor at the left margin on column 01; Mesen starts the column number at 00, but that's ok because you just need to add 1 to the number after Align, so, in my example above, [A,h] always starts at column 09 in Notepad. :) And... the "f" at the start (taken from FCEUX trace log files) allows me to easily find a frame number in Notepad. :)

in Notepad, click View>Status Bar to show the cursor's line and column location
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

This one is the same amount of characters... the small "r" for "registers" will make that hexidecimal group less confusing sometimes, for me at least, and it will be obvious where the registers start despite the FrameCount. :mrgreen: :)

Code: Select all

f[FrameCount][Align,8]r[A,h][X,h][Y,h] s[SP,h] [P,8]  $[PC,h]:[ByteCode,11h]|[Disassembly][EffectiveAddress] [MemoryValue,h]
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

This build should fix the issues you had. It fixes the bug with 2-byte display for zero page addresses and makes the parser for the format string more lenient w/ regards to spaces (and it should display "[Invalid tag]" in the output for most scenarios where it can't make sense of the tag)
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

THANK YOU, SOUR, VERY MUCH! :D

Code: Select all

f[FrameCount][Align,8]a>[A,h][X,h][Y,h] [P,8]`[SP,h]  $[PC,h]:[ByteCode,11h]|[Disassembly][EffectiveAddress] [MemoryValue,h]
I don't know if anyone cares, but here is the Format Override that makes me really happy. :D If it gets changed again, I'm not going to post it here anymore; I promise. :) The ">" is like an arrow showing me where the accumulator byte is. X and Y bytes follow the accumulator byte. The "`" is from the key to the left of the 1 key (on the left of the keyboard). Needed a nonspace character that would allow a quick search for a stack pointer value. Searching `ff will find only every instance in the trace log file where the stack is clear. And that character's small high diagonal mark makes the file more interesting for me. :) All the extra space on each line allows more room for commenting.
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Mesen - NES Emulator

Post by nesrocks »

I have finally tried this emulator's debugger more seriously (for rom hacking purposes). It seems incredible and feature rich, thank you so much for all this work! I'll keep recommending this emulator to everybody.

1a- One thing that I need a lot when rom hacking is to keep resetting data/code verification and I can't find a way to reset it easily. The reason I need this is that it makes it easier to find specific bytes related to the current moment in the game. I pause the emulator, I clear the code/data logs, then I frame advance or unpause/pause it to the point where I know that what I want has been read or executed. This way I can more easily find it in the debugger or on the memory editor.
1b- Also, a way to manually load and save cdl files that aren't the same name as the rom, is this possible currently?

2- Another thing was that I felt like double clicking the code on the debugger should open the memory editor, but I imagine that I could get used to pressing F1, which isn't bad for the workflow, maybe even better than double clicking. It's just that using the mouse is more intuitive.

3- Also, I am used to selecting savestate slots and then having a hotkey to save to current slot and another to load from current slot. That way I can work on a single savestate really quickly with the load and save hotkeys very close to the buttons I use, giving equal ergonomic usability to all slots. I understand this is a personal preference, but maybe if a lot of people chime in about this, it would show that it is an important feature. I see it has "select next slot" and "select previous slot" but I really wish there was a hotkey for each selectable slot (1 through 9).

4- One more thing: is there any way I can rearrange the elements in the middle of the Debugger window so that I can fit the memory editor, the emulator and the debugger on a full hd display all at once without overlapping? Example of the overlapping:
https://i.imgur.com/KbyFXJA.png
5- Also, notice the unused space on the left of the address on the left column after I made the font smaller. I can't move the addresses to the left to occupy that area.

6- Sorry for so many things! One more: is there a way to save the windows positions so when I reopen mesen my workspace is the way I left it? The debugger window and memory editor window seem to always open in random positions.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered »

nesrocks, click Options>Preferences then click "Shortcut Keys" at the top and scroll down a bit and there's "Save State -Slot #" and you can set up to two different key presses for saving to slots 0 through 10. Below that is "Load State - Slot #". Hope this helps you with issue 3. :) I was able to assign the Pause key for pausing the game along side the Esc key. So happy! :D
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Mesen - NES Emulator

Post by nesrocks »

Thanks! But... That's not how I use it with other emulators. I use numbers 1 through 9 simply to select a slot (not save or load), and then I use Q to save to current slot and E to load from current slot. I don't want the savestate to be saved or loaded when pressing the numbers, I just want to select it. So the numbers work more like a savestates manager. Reason being: I more often save and load than I change active savestate slots. The closest to this workflow that mesen has is the increase/decrease savestate slot hotkeys, which is how I set it up for now (1 decreases, 2 increases, Q saves and E loads), but it would be just better to select the slot directly with a number key.
I use tab for pausing and left control for frame advancing. This goes more than 10 years back from my tool-assisted speedrun background and it's how I've used emulators ever since.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
Sour
Posts: 890
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - NES Emulator

Post by Sour »

Thanks for the feedback!

Some answers:
1/1b) In the debugger's menu, in Tools->Code/Data Logger, you can reset/load/save CDL files. If you want to reset the CDL data for a specific portion of PRG, you can select it (in the code window or hex editor) and then do right-click -> mark selection as -> unidentified code/data. Do you need something more beyond this?

2) Double-clicking is already used for a couple of others things, so I can't easily make it do another one on top of that :\ Double-click on the address in the left margin will add/edit a label, double-click on an address/label in the code will scroll to that address. You can remap the F1 shortcut to anything else if that helps (but not mouse buttons)

3) I can add some more shortcuts to select a specific slot if that helps, though I may have to start categorizing them because the list is starting to be rather long...

5) The issue you're having with the margin (and overall weird looking code window) is very likely due to selecting a font that's not a monospace font. The UI will let you select any font, but it will only work properly with monospace fonts - try Courrier New, Consolas (this is the default), Lucida Console, etc, and it should look much better, even at font sizes (you can download & install monospace fonts easily enough if you don't like any of the ones you have installed).

4) If you reduce the font size in the hex editor's window, you should get pretty close to fitting all 3 windows side-by-side in 1920px. The debugger's minimum size is a bit high for no good reason when using smaller font sizes - I could probably make it about 100-200px smaller without too many issues.

6) I know the main emulation window remembers its position, but that might be the only one - I think everything else only remembers their size. I'll make each window remember it's position, too.

Hope that helps,
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Mesen - NES Emulator

Post by nesrocks »

Thanks for the information! I understand most of what I said are small things but I feel like they add up in the end when doing practical, lots of work. I hope this doesn't sound like I'm too nitpicky. Most of the issues are gone for me now, I'm just going to comment on all of them anyway.

1 - I hadn't seen that! I guess clicking the menu feels slow to me, but doing Ctrl+A, Ctrl+3 on the memory editor sounds fast enough. It beats having a window open just for this, like in fceux.
2 - Clicking the opcode on the debugger does nothing on my version. Maybe use that? Not the best solution because it would mean you can't go to EVERY byte, but close enough really. Anyway, hitting F1 isn't bad either. On that note, I find it interesting that you can edit the ROM bytes by looking at CPU Memory View. I'll have to get used to that too (F1 always brings to CPU Memory view).
3 - I may get used to the increase/decrease setup, since I don't change slots that often. So maybe it's ok for me like this (unless a massive mob of users chime in about this, it's probably just ok to leave it like that). As for me, I just need more testing, but I feel I can adapt easily.
4 - Indeed, I can almost fit it now with a smaller font. I'd say it's even good enough for use, although my OCD complains that there's empty space under "Input button setup" meaning all those elements on the middle column could be rearranged to make the whole window not as wide. So there's still some overlap.
https://i.imgur.com/eTPnwUd.png

5 - True! Thank you! Maybe add a warning that mono-spaced fonts are recommended?
6 - Thank you! Remembering how the user left things is always great for improving the workflow. Reduces the amount of trouble adjusting everything between sessions. For example, I can notice that the memory editor resets to CPU Memory View on every session. I work most exclusively with PRG ROM View, so remembering that setting would be good (this clashes a bit with how F1 works by bringing CPU Memory view, but okay). But as a rule of thumb, remembering everything is the way to go.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
Post Reply