Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Bananmos
Posts: 496
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Bananmos » Sun May 03, 2020 7:19 am

Was already planning on eventually doing something like this for the CHR viewer (to allow it to display PRG ROM as tiles), makes sense to have something similar for the sprite viewer, too.

So, here you go! (next appveyor build will have it)
Thanks a lot! Just used this new feature to easily track down an annoying bug triggering when trying to use a metasprites with all 64 sprites. :)

I did run into a few minor issues however:
* The feature that makes the sprite viewer automatically show the pattern table for sprites as set by $2000 is generally convenient. But as my sprite table is at $1000 and I often find myself setting breakpoints in code where $2000 has been temporarily set to zero to disable NMIs, and with no way to override this setting I am left with the wrong tiles showing until I make the debugger stop somewhere else in my code.

* The 2x setting in the PPU viewer looks pretty useful as a means to zoom. But for all the views that stack two pixel images, it ends up being too tall for a 1080p display. OTOH, the widget that end up on the sides are unaffected by the scaling. Have you considered re-arranging the UI to stack the pixel images horizontally and have the widgets on the bottom? It would solve this problem with 1080p screens for everything but the 4x nametable viewer (but with vertical mirroring as I'm using, the lower one is redundant to me anyway and would best be removed completely in 2x mode)

* Sometimes, I accidentally open a new PPU Viewer window despite already having one open, and this appears to cause Mesen to hang and requiring a force kill with the Windows task manager.

None of these features are deal-breaker by any means - just figured I would mention them :)

And this is unrelated to the PPU Viewer, but despite having set the .dbg files to auto-import, Mesen doesn't seem to actually do this. I have to re-load the .dbg file manually every time I do a new build and fire up Mesen.
Do you know what's going wrong here?

The ability to show CHR from PRG-ROM sounds neat feature! Ideally, the format would be semi-configurable, as CHR data in PRG-ROM data often tends to be stored differently to the native format to make unrolled loops more efficient. For example, a common pattern is to have each row / plane in a separate array, to avoid having to increment / decrement the index registers for every byte copied:
WriteScrambledTile:
lda tileDataP0R0,x
sta $2007
[...]
lda tileDataP0R7,x
sta $2007
lda tileDataP1R0,x
sta $2007
[...]
lda tileDataP0R7,x
sta $2007
rts
But I realise this configurability might be difficult to achieve in practice... and could probably only work if the separated arrays are 256-byte-aligned.

Finally, I noticed you just added support for OAM corruption in Mesen. I know it's still a beta feature, but that's really useful! I spent quite a bit of time tweaking my NMI code to stay within the safe hblank region, and have been careful not to touch it since. The event viewer already helps a lot with this, but having the OAM corruption emulated is great to see the effect of it. As expected, the latest forced blanking code I'm prototyping right now causes a flickerfest when turning the feature on... which is a good reminder to myself why it's still prototype code... :P

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

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Sour » Sun May 03, 2020 12:25 pm

I'll add a dropdown/toggle to pick between auto/8px/16px sprites when I have a chance.
Bananmos wrote:
Sun May 03, 2020 7:19 am
* The 2x setting in the PPU viewer looks pretty useful as a means to zoom. But for all the views that stack two pixel images, it ends up being too tall for a 1080p display.
The PPU viewer in general is a bit annoying to deal with, layout-wise. And the 2x zoom option is essentially a patch to allow at least some level of zooming, but as you can tell, it's not ideal.
Ideally I think I would probably split the ppu viewer into separate windows (to not be forced to keep all of them the same size, which limits what I can do quite a bit in terms of layout..), remove the 2x zoom options and instead implement zoom like I did in Mesen-S' viewers (which I ported back to mesen's event viewer a while ago) - basically you can zoom freely with ctrl-+/- or the ctrl+mouse wheel, and then scroll around the picture with click+drag, which in my opinion works a lot better, is less restrictive and is much more flexible in terms of layout. Changing all this isn't what I would call trivial, though..
* Sometimes, I accidentally open a new PPU Viewer window despite already having one open, and this appears to cause Mesen to hang and requiring a force kill with the Windows task manager.
Having too many windows opened (and having them set to refresh at a high FPS) can sometimes cause the windows message queue to get filled with draw requests faster than the application can process them.
I've added some logic over on Mesen-S to try to limit the odds of this ever causing a lockup, though (by reducing the refresh speed based on roughly how long the refreshes are taking.) I'll try to copy that fix over to Mesen soon and let you know.
And this is unrelated to the PPU Viewer, but despite having set the .dbg files to auto-import, Mesen doesn't seem to actually do this. I have to re-load the .dbg file manually every time I do a new build and fire up Mesen.
Is the .dbg file called "myrom.dbg" (not the lack of .nes in the name here) for a rom called "myrom.nes"? Is it in the same folder as the "myrom.nes" file?
Finally, I noticed you just added support for OAM corruption in Mesen. I know it's still a beta feature, but that's really useful!
Glad it's already useful to someone! Like you said, this is very much a work in progress and still doesn't quite react exactly like the hardware does for all scenarios. Are you testing on NTSC? Or PAL? I don't think we've tested/confirmed that this behavior occurs for PAL consoles, yet.

Bananmos
Posts: 496
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Bananmos » Mon May 04, 2020 5:52 am

Sour wrote:
Sun May 03, 2020 12:25 pm

Is the .dbg file called "myrom.dbg" (not the lack of .nes in the name here) for a rom called "myrom.nes"? Is it in the same folder as the "myrom.nes" file?
Doh! It was named myrom.nes.dbg... I've updated my built batch script and it seems to work fine now :)
Glad it's already useful to someone! Like you said, this is very much a work in progress and still doesn't quite react exactly like the hardware does for all scenarios. Are you testing on NTSC? Or PAL? I don't think we've tested/confirmed that this behavior occurs for PAL consoles, yet.
It was quite a few years since I did this tweaking to avoid OAM corruption, but it was on an NTSC console. Even longer ago, I primarily used a PAL console, and I'm pretty sure the issue doesn't exist on PAL, as I have no recollection of it ever being a problem.

I think the main gap in PAL emulation is still that the DMC cycle steal emulation is not correctly emulated. If ever there's a suitable test ROM for it I'd be happy to run it on my PAL console.

The test ROM would likely need to be a bit more elaborate than my old demo I posted before, where I was just relying on tweaking delay loops with visual feedback, and all this was way before Blargg's work on sync:ing the NMI to rendering.

Bananmos
Posts: 496
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Bananmos » Sat May 09, 2020 10:04 am

So I'm trying to use the new super-useful assert feature with modulo to check my sprite page index is always divisible by 4, but can't get it to work.

* Doing "assert(Y % 4 == 0)" just plain doesn't do anything. And when I try to type "%" in the debugger, it wont even accept the condition - so guess the modulo operator is not supported yet?

* Doing the common work-around of a bitwise-and with "assert(Y & 3 == 0)" does seem to trigger the assert in the debugger... but even for values that are clearly multiples of 4. So not sure what's going on here?

Would be great to have some way of doing modulo on my asserted values... :)

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

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Sour » Sat May 09, 2020 10:25 am

Ah, I probably broke the modulo operator back when I added support binary values (e.g "x == %00010001"). Might have to change the operator for one of them, but I'll try and see if it's simple to keep them both in with the '%' operator.

I think the assert(Y & 3 == 0) part is an order of operation problem? It's doing 3 == 0 -> false/0, and then Y & 0, which is always 0, so the assert always triggers. "(Y & 3) == 0" should work, though.

Bananmos
Posts: 496
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Bananmos » Sun May 10, 2020 9:05 am

Sour wrote:
Sat May 09, 2020 10:25 am
Ah, I probably broke the modulo operator back when I added support binary values (e.g "x == %00010001"). Might have to change the operator for one of them, but I'll try and see if it's simple to keep them both in with the '%' operator.
Ah, I see. No worries about using a different operator if it makes things simpler. I'm happy to use something like "Y MOD 4", and keeping the widepsread % prefix for 6502 binary numbers is probably more important than the aesthetics of module.
Sour wrote:
Sat May 09, 2020 10:25 am
I think the assert(Y & 3 == 0) part is an order of operation problem? It's doing 3 == 0 -> false/0, and then Y & 0, which is always 0, so the assert always triggers. "(Y & 3) == 0" should work, though.
Ah, the old ordering gotcha! Shall use parantheses more carefully in the future :)

User avatar
za909
Posts: 206
Joined: Fri Jan 24, 2014 9:05 am
Location: Hungary

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by za909 » Sat May 16, 2020 10:39 am

Hi, I'd like to make a suggestion. During my DPCM-PCM endeavors I really could've used some of the still hidden stats of the APU, namely the 8-bit DPCM buffer state, which if I am not mistaken is implemented as a bit shifter, so there is no separate bits remaining counter. Seeing the state of this would've made determining timings a bit easier, since I had no idea when the buffer was going to run out of bits and start an IRQ/ DMC DMA read.

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

Re: Mesen Debugger - Feedback/Feature Requests? (2018 edition)

Post by Sour » Tue May 19, 2020 7:43 pm

Bananmos wrote:
Sun May 10, 2020 9:05 am
Ah, I see. No worries about using a different operator if it makes things simpler. I'm happy to use something like "Y MOD 4", and keeping the widepsread % prefix for 6502 binary numbers is probably more important than the aesthetics of module
The modulo operator should be fixed as of the latest commit/appveyor builds (both this and binary notation still use %) - let me know if you still have issues with it.
za909 wrote:
Sat May 16, 2020 10:39 am
During my DPCM-PCM endeavors I really could've used some of the still hidden stats of the APU, namely the 8-bit DPCM buffer state, which if I am not mistaken is implemented as a bit shifter, so there is no separate bits remaining counter.
Thanks for the suggestion. At this point, I'm likely to eventually scrap the APU viewer and replace it by a much more versatile tool like the register viewer that exists in Mesen-S, which would easily allow me to show a lot more state (for the APU or other components, e.g maybe some specific common mappers, etc.), without it also being a nightmare in terms of UI/layout (doesn't help that Mono on Linux sizes everything differently a bit which makes this more painful still.) I'll keep this in mind for when I do replace the APU viewer, though.

Post Reply