Mesen - NES Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Mesen - NES Emulator

Post by tokumaru » Tue Jan 08, 2019 11:21 am

...and Mesen is now included in the group of programs that mysteriously refuse to run on my computer. Double click, busy cursor, then nothing. No error messages or anything. It's probably not Mesen's fault, as this was already happening with Microsoft Store apps (Calculator, Calendar, even the Store itself, which don't get past the splash screen), but it's really frustrating that my installation of Windows 10 keeps doing this. I can't do anything if Windows won't give me any hints as to what the problem might be. Maybe it's time I formatted this thing already...

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

Re: Mesen - NES Emulator

Post by tepples » Tue Jan 08, 2019 12:11 pm

Does it also fail to print anything if you start Mesen.exe from the Command Prompt?

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

Re: Mesen - NES Emulator

Post by Sour » Tue Jan 08, 2019 2:10 pm

I would have guessed that your .NET installation might be broken, but the calculator/etc most likely use UWP (and may or not use .NET at all). You could try running Visual NES to see if it opens up properly (it pretty much uses the same UI vs core pattern as Mesen does, minus the need for DirectX/etc.).

Beyond that, you could try creating a new profile on your computer and seeing if applications work any better with that profile, too.

unregistered
Posts: 1038
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Thu Jan 10, 2019 6:00 pm

hi Sour,

I am creating labels in your debugger, by pressing F2, and I have failed to find a discussion here about how to create 16bit labels. We have this pointer called "p43" and so I've tried:

1.) Naming $43 and $44 "p43" but, Mesen doesn't allow identical labels.
2.) Naming $43 "p43+0" and $44 "p43+1" but, Mesen doesn't allow the + in label names.
3.) After 1 and 2, I failed to find a discussion about "16bit labels" so I visited your appveyor and downloaded the latest Mesen to see if 16bit labels had been added, but haven't discovered 16bit labels.
4.) In the newest Mesen, I tried to change the address on the Edit Label screen to values such as "{43}" or "43, 44" but, haven't been successful in creating a 16bit label.

Therefore, I suggest providing some simple way to create multibyte labels... like if I choose label name "p43" for 2 bytes, would expect to receive "p43+0" for $43 and "p43+1" for $44. :) Maybe you've already implemented 16bit labels; could you explain how to use them? :)


Thank you so much for reading through my Mesen distress. :)

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

Re: Mesen - NES Emulator

Post by Sour » Thu Jan 10, 2019 10:14 pm

Somehow, something about the way you wrote this made me realize I could actually implement this relatively easily (despite thinking it would be relatively complex up until now), so I did!
multibytelabels.png
This adds a "Length" field to all labels (so works for both 2-byte words and plain old arrays).
It also works w/ CA65 integration - so all symbols from a CA65 project will now have their proper length in the disassembly, etc.

One thing I was wondering is if it was better to show "+0" for the first index or to only show the label's name - in the end I opted to show the "+0", since it makes it obvious that the label is a multi-byte label.

The main thing left to complete this would be adding this length field to the ".mlb" file format - will take a look at that later.

The next appveyor build should have these changes - if you find any issues with it, let me know!

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Mesen - NES Emulator

Post by tokumaru » Thu Jan 10, 2019 10:24 pm

Cool addition!

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

Re: Mesen - NES Emulator

Post by rainwarrior » Fri Jan 11, 2019 2:22 am

:beer: :mrgreen: Good one!

unregistered
Posts: 1038
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Fri Jan 11, 2019 1:57 pm

YEAY SOUR! THANK YOU SO MUCH! :D

I love how it creates p43+0 and p43+1 while keeping the label p43 in the label list! Great work; this is so much fun! :beer: :D So happy my writing could make a difference... thank you for telling me! :D

unregistered
Posts: 1038
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Fri Jan 11, 2019 3:06 pm

um... Sour, this isn't a "problem" but, maybe it's an issue? When naming a function the length value was still there... so after pressing F2 again I increased length to 2 and that didn't make any changes; however, after pressing F2 again, and increasing length to 4 it created two identical labels both ending with "+2". This isn't a "problem" because switching length back to 1 removed those extra labels.

I thought an easy solution would be to eliminate the length option if the address is 16bits... but I just think, now, that that would allow only zeropage addresses to use length. Maybe only allow length for RAM labels; is that even possible?

I haven't tried to use length on a non - zeropage RAM address.

unregistered
Posts: 1038
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: Mesen - NES Emulator

Post by unregistered » Fri Jan 11, 2019 3:41 pm

^edit: Sorry, that function starts at $D3D3 and it has two reverse branches to $D3D5 later on in its code... so the two identical labels ending with "+2" were correct. (Also noticed that every function call ended its label with "+0".) So non-zeropage RAM addresses should work just fine with length >1. :)

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

Re: Mesen - NES Emulator

Post by Sour » Fri Jan 11, 2019 7:47 pm

You mean it did something like this? (this code makes no sense, but just for illustrative purposes)

Code: Select all

mylabel:
  LDA #$00
  LDX #$00
  BNE mylabel+2
  LDY #$00
  BNE mylabel+2
Where "mylabel+2" would normally be a branch to the 2nd line (the "LDX #$00" instruction)

In that case, it's probably ok, I think. This isn't likely to happen (and it's not actually giving false information, either). Multi-byte labels in PRG ROM are useful for hardcoded byte arrays, etc., so I can't really disable them altogether.

Internally, the debugger is creating multiple labels (e.g: mylabel+0, mylabel+1, mylabel+2, mylabel+3), but I made it so only the first label is shown, and without displaying the "+0", which is why it still says "mylabel:" rather than "mylabel+0:" on the first line. Otherwise the display for non-disassembled data arrays was a mess, e.g:

Code: Select all

mydata+0:
  .db $00
mydata+1:
  .db $00
mydata+2:
  .db $00
mydata+3:
  .db $00
Instead of just:

Code: Select all

mydata:
  .db $00 $00 $00 $00

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Mesen - NES Emulator

Post by tokumaru » Sun Jan 13, 2019 12:11 am

tepples wrote:Does it also fail to print anything if you start Mesen.exe from the Command Prompt?
Yup. Nothing at all.
Sour wrote:I would have guessed that your .NET installation might be broken, but the calculator/etc most likely use UWP (and may or not use .NET at all). You could try running Visual NES to see if it opens up properly (it pretty much uses the same UI vs core pattern as Mesen does, minus the need for DirectX/etc.).
Visual NES does work!! :?
Beyond that, you could try creating a new profile on your computer and seeing if applications work any better with that profile, too.
That didn't work for the Windows Store Apps, and I don't really feel like wasting any more time trying to fix this... I'll just format the hard drive and start from scratch. Thanks for the help.

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

Re: Mesen - NES Emulator

Post by Sour » Sun Jan 13, 2019 6:07 am

One more thing that might be worth trying is starting up Mesen with these command line options to disable all directx components:
Mesen /novideo /noaudio /noinput

If this works, the problem is most likely directx related

Fiskbit
Posts: 75
Joined: Sat Nov 18, 2017 9:15 pm

Re: Mesen - NES Emulator

Post by Fiskbit » Mon Jan 14, 2019 12:13 am

I've been using Mesen for my development more lately and have been keeping a list of issues and wants as I encounter them. Most of this is from version 0.9.7.37. Apologies if any of these are already known or fixed. (Also, FYI, I did wind up finding a good use case for sub-instruction breakpoints in the form of DMC DMA debugging. Was really useful!)

Bugs:
- OAM decay emulation seems to have an issue with 32-bit signed integer overflow. While developing my decay tests, I found that the emulator would break and report decay on cycle 2147480649.
- I think DMC DMA timings when occurring on write cycles aren't quite correct. When DMC DMA lands on the first of two consecutive write cycles, it should take 4 cycles (and be delayed by 2 cycles), but I think Mesen is taking 3. I posted a test ROM that fails in Mesen because of this.
- Disabling sub-instruction breakpoints prevents DMC DMA reads from triggering breakpoints. I don't know if this is something you intended, but it caused me confusion when I was trying to break on these and it wasn't working on 0.9.7.37.

Things I found somewhat confusing or annoying:
- Resetting while paused will unpause if the debugger is open. I remember this sort of thing being difficult for you to improve when I last made suggestions around the debugger and pausing, and I don't remember if this was something you decided was unreasonably invasive to fix. Not a huge deal, but I often do this in FCEUX to start debugging from first instruction, and it's more convenient than going through the menus to enable/disable "Break on power/reset".
- Selecting "Edit in Memory Viewer" in the debugger takes me to CPU memory, but I would expect PRG ROM, instead, like FCEUX. I'm not even sure what behavior to expect when editing ROM in CPU memory.
- When the emulator isn't paused, the selected byte in the Memory Tools loses its highlight when the window isn't selected, which makes it hard to keep track of the byte when interacting with the emulator or debugger windows to see how its value changes.
- Highlighting a field in the debugger, such as the cycle count, and copying with ctrl+C doesn't work; the currently selected instruction is copied, instead. I was manually transcribing these until I realized I could highlight and right click to copy.
- When creating a breakpoint by clicking in the code view in a 24 KB mapper 0 ROM on an address $C000-FFFF, the breakpoint claims to be on an address $8000-BFFF.
- There's no way to see which saved state slots are actually filled so I know which to save to or can load from, especially since trying to load a state that doesn't exist hangs the emulator for several seconds.

Improvements I'd love to see:
- I really need to be able to load a saved state even after modifying a ROM to enable fast development. I know I've mentioned this one before, but it remains the biggest hurdle for me when using Mesen.
- When DMA occurs within an instruction, I don't think there's a way to tell which cycles belong to the instruction and which belong to the DMA (or it's not clear).
- There are options for stepping by PPU cycle, scanline, frame, and instruction, but not CPU cycle. I see I can do this with the 'Break in...' menu, but with sub-instruction debugging, it would be useful to have this more conveniently accessible.
- Can you add a hotkey for "Go To... Program Counter"? FCEUX has a handy button, while in Mesen, I need to either hit ctrl+G and type in the PC value or go Search -> Go To... -> Program Counter, neither of which are very convenient.
- A highlight on the currently-hovered tile in the Nametable Viewer and Sprite Viewer like in the CHR Viewer (although perhaps without the click-highlight behavior; there doesn't seem to be a way to not have some tile be selected in the CHR Viewer).
- A right-click option for the Nametable Viewer to add a breakpoint on the selected tile.
- A right-click option for the Event Viewer to add a breakpoint on the selected dot.
- A breakpoint condition for an instruction being jumped to (via branch, jmp, jsr, rts), or the previous PC being outside some range, would be extremely useful.
- Breakpoints on PPU state change, such as various flags flipping (sprite 0 hit, vblank, etc). The debugger makes the state visible, but I don't see a way to set breakpoints on it.
- It'd be really nice to be able to see some more internal state, like 'this is a write cycle'.
- Show the current dot in the Event Viewer when snapped. Currently, it only shows the current scanline.

Nice-to-haves:
- An option in the Sprite Viewer to see outlines showing the positions of all of the sprites in the Screen Preview.
- An option in the Memory Tools to highlight the row (xxx0) and column (0x) indicators for the currently selected byte would probably make it a bit easier to track which byte I'm on.
- A way to see the values of the PPU's t/v/x/w/flags registers in the event viewer across each dot on a given frame. It'd be helpful and informative to mouse around and see how this stuff is changing dot-to-dot, how writes impact the registers, and so on. I can dig into this with the debugger, but not nearly as easily.


Despite the length of this list, I've been really enjoying this emulator and its tools and really appreciate all the work you've put into it. It's been extremely useful for the projects I've been doing. Thanks!

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

Re: Mesen - NES Emulator

Post by Sour » Mon Jan 14, 2019 5:45 am

Fiskbit wrote:There's no way to see which saved state slots are actually filled so I know which to save to or can load from, especially since trying to load a state that doesn't exist hangs the emulator for several seconds.
The emulator shouldn't be hanging on loading a save state that doesn't exist - are you sure it's not a matter of trying to load a state for an older version of the ROM? In this case, Mesen will search through your NES files to try and find a matching ROM, which can take a while if you have a huge rom collection.
Fiskbit wrote:I really need to be able to load a saved state even after modifying a ROM to enable fast development. I know I've mentioned this one before, but it remains the biggest hurdle for me when using Mesen.
There's been an option for this for a while now (Preferences->Save Data->Allow save states to be loaded on modified roms), does it not work in this scenario? (This should also fix the freeze problem with load states, I think)
Fiskbit wrote:Can you add a hotkey for "Go To... Program Counter"? FCEUX has a handy button, while in Mesen, I need to either hit ctrl+G and type in the PC value or go Search -> Go To... -> Program Counter, neither of which are very convenient.
There is one, but it's called "Show Next Statement" (Alt+* by default, iirc), for historical reasons (and because that's how it's called in VS)
Fiskbit wrote:It'd be really nice to be able to see some more internal state, like 'this is a write cycle'.
The new "show instruction progress" feature does tell you whether you're on a exec, read, write, dummy read or dummy write cycle. Was there anything else you wanted to see specifically?
Fiskbit wrote:(although perhaps without the click-highlight behavior; there doesn't seem to be a way to not have some tile be selected in the CHR Viewer)
This is mostly because the tile can be selected to edit it on the right-hand side, though I guess highlighting the tile on the left side isn't entirely necessary.

Thanks for the list! Most of it should be relatively easy to fix, I'll let you know if I have any questions.

Post Reply