Mesen - Emulator
Moderator: Moderators
- ISSOtm
- Posts: 58
- Joined: Fri Jan 04, 2019 5:31 pm
- Location: France, right of a pile of consoles
- Contact:
Re: Mesen - Emulator
Thank you very much Sour!! I'm glad GB Mesen is not dead—SGB LLE is already hard to come by, but one with such debugging tools is gonna be awesome.
I'm currently packaging it for Arch Linux (edit: done!), so installing there will be simpler; I just opened a PR that fixes some build errors I encountered along the way. Thank you for the lighter dependencies, by the way!
If I can suggest one thing: currently, "Store the data in my user profile" sets the data path to `~/Mesen2`, which is fine; however, it would be ideal to follow the "XDG base directories" spec (digest), and instead place the `Mesen2` directory in `$XDG_CONFIG_DIR/`, or `~./config/` if the env var doesn't exist.)
I'm currently packaging it for Arch Linux (edit: done!), so installing there will be simpler; I just opened a PR that fixes some build errors I encountered along the way. Thank you for the lighter dependencies, by the way!
If I can suggest one thing: currently, "Store the data in my user profile" sets the data path to `~/Mesen2`, which is fine; however, it would be ideal to follow the "XDG base directories" spec (digest), and instead place the `Mesen2` directory in `$XDG_CONFIG_DIR/`, or `~./config/` if the env var doesn't exist.)
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
https://github.com/ISSOtm
ASMu is laifu <3
-
- Posts: 611
- Joined: Mon Jan 23, 2006 7:47 am
- Location: Germany
- Contact:
Re: Mesen - Emulator
Since it's a multi-system emulator now, should the thread perhaps be moved to "Other Retro Dev"?
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Re: Mesen - Emulator
This is the primary emulator subforum here, and moving it to 'Other Retro Dev' would suggest it is for non-NES use cases. I think this is the best place for this thread to be.
- ISSOtm
- Posts: 58
- Joined: Fri Jan 04, 2019 5:31 pm
- Location: France, right of a pile of consoles
- Contact:
Re: Mesen - Emulator
Here is my own feedback about the emulator itself. Given my background, it will all be related to GB, even when I fail to mention it.
It seems much faster than Mesen-S! I used to get lag with a bunch of windows open, but that seems to be a thing no more. Neat!
Also the new debugger code overlays are quite useful.
Here is a QoL feature request for GB:
Currently, the debugger breaks when writing to BGPD / OBPD during Mode 3; however, doing so with auto-increment enabled still performs the increment. I wrote an Evil™ palette engine that does this to skip colour #0 of OBJ palettes, and does not bother to check for Mode 3 (since the values are unused anyway).
The request is thus: *not* breaking on OBPD writes during Mode 3 if OBPI points to a "colour #0" byte.
I'm also not sure if you have seen the .sym file specification? We've created one recently to encourage consistency across implementations; feedback is welcome as well.
The GB register viewer's LCD panel does not seem to show GBC palette registers? (Arguably BGPD and OBPD are redundant with the palette viewer, but BGPI and OBPI aren't.)
For the monospace fonts, on Linux, I'd recommend defaulting to `monospace`. That's (AFAIK always) an alias to the system's preferred monospace font.
I got the debugger to break on an "Invalid VRAM access" (great!), but then clicking the "resume" or "step" buttons didn't do anything visible besides increasing the cycle counter; in particular, PC didn't move. Unfocusing the application to type this then coming back apparently locked it up entirely around 60% CPU usage (plus 80 from X11, for some reason).
The "call stack" functionality seems to be confused by stack manipulation functions. These two in particular:
I also seem to be able to somewhat reliably make Mesen unresponsive through loading a ROM and marking regions of memory as code or data.
It seems much faster than Mesen-S! I used to get lag with a bunch of windows open, but that seems to be a thing no more. Neat!
Also the new debugger code overlays are quite useful.
Here is a QoL feature request for GB:
Currently, the debugger breaks when writing to BGPD / OBPD during Mode 3; however, doing so with auto-increment enabled still performs the increment. I wrote an Evil™ palette engine that does this to skip colour #0 of OBJ palettes, and does not bother to check for Mode 3 (since the values are unused anyway).
The request is thus: *not* breaking on OBPD writes during Mode 3 if OBPI points to a "colour #0" byte.
I'm also not sure if you have seen the .sym file specification? We've created one recently to encourage consistency across implementations; feedback is welcome as well.
The GB register viewer's LCD panel does not seem to show GBC palette registers? (Arguably BGPD and OBPD are redundant with the palette viewer, but BGPI and OBPI aren't.)
For the monospace fonts, on Linux, I'd recommend defaulting to `monospace`. That's (AFAIK always) an alias to the system's preferred monospace font.
I got the debugger to break on an "Invalid VRAM access" (great!), but then clicking the "resume" or "step" buttons didn't do anything visible besides increasing the cycle counter; in particular, PC didn't move. Unfocusing the application to type this then coming back apparently locked it up entirely around 60% CPU usage (plus 80 from X11, for some reason).
The "call stack" functionality seems to be confused by stack manipulation functions. These two in particular:
Code: Select all
ChangeBank:
pop hl
push af
jr SaveBank
RestoreBank::
pop hl
pop af
SaveBank:
ldh [rCurBank], a
ld [$2000], a
jp hl
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
https://github.com/ISSOtm
ASMu is laifu <3
Re: Mesen - Emulator
If it helps here is the .cue file that failed:
https://www.dropbox.com/s/rd33n8irl208n ... D.cue?dl=0
I also had a issue setting up 6 button controller for the PC engine. I selected PS4 controller setup initially. No problem with the 2 button controller. But with 6 I can even clear all buttons and it will still rapid-fire D-Pad inputs in the 2 games I tried.
https://imgur.com/zsGou59
- Jarhmander
- Formerly ~J-@D!~
- Posts: 569
- Joined: Sun Mar 12, 2006 12:36 am
- Location: Rive nord de Montréal
Re: Mesen - Emulator
Nice, thank you! Will vote for your package once I install it and play around a bit.
((λ (x) (x x)) (λ (x) (x x)))
Re: Mesen - Emulator
Not all PCE games support the 6 button controllers. In fact, most don't.
It's just normal that if you use a 6 button controller in a game that doesn't support it (including the CD System/Bios interface), you'll end up with erratic behaviour.
The real 6 button controller for the PCE contains a switch to switch back to 2 button mode, so you may still use it in games that support only the original controller. So, you should keep using 2 button mode unless the game supports it.
Re: Mesen - Emulator
I've changed this to be like the original Mesen (stored in .config instead), didn't even realize it was different until now :p
Also changed the default fonts to use DejaVu Sans (Mono) or Noto Sans (Mono) if they are found (to be able to properly populate the dropdowns) and then fall back "monospace" and "sans-serif" if they can't (which makes the dropdown look empty, but at least uses a more appropriate font)
I've fixed a crash that occurred when debugging the GB core while in SGB mode, and fixed another bug that could crash the game when the debugger tried to access some values in memory. I'm not sure if these fixes are related to what you were experiencing though - I couldn't reproduce the exact issues you described. Can you still reproduce the crashes? I wasn't able to reproduce any crash via the "Invalid VRAM access" breakpoints, nor did it crash while I was spamming the mark as code/data shortcuts. (I didn't test this on Linux, though, if you're still getting the crashes with the latest commit on your end, I'll try reproducing it on my Linux VM)ISSOtm wrote: ↑Sat Jan 28, 2023 1:27 pm but then clicking the "resume" or "step" buttons didn't do anything visible besides increasing the cycle counter; in particular, PC didn't move.
[...]
I also seem to be able to somewhat reliably make Mesen unresponsive through loading a ROM and marking regions of memory as code or data.
Re: the call stack, it's likely I can't fix it - stack manipulation will always cause issues with it, it tries its best to keep up, but a lot of scenarios will confuse it. I haven't forgotten the other points you've mentioned, but haven't gotten to any of them yet.
Thanks again for the PR and also the Arch package!
Thanks, I'll take a look.
- ISSOtm
- Posts: 58
- Joined: Fri Jan 04, 2019 5:31 pm
- Location: France, right of a pile of consoles
- Contact:
Re: Mesen - Emulator
On one hand, thank you! On the other (maybe unrelated) hand, Mesen now crashes with the following when configuration exists (the "first start" dialog opens if appropriate, and the exception occurs after closing it). I have tried wiping the directory, but that doesn't fix it.
Code: Select all
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Mesen.Config.ConfigManager.LoadConfig()
at Mesen.Config.ConfigManager.get_Config()
at Mesen.ViewModels.MainWindowViewModel..ctor()
at Mesen.Windows.MainWindow..ctor()
at Mesen.App.OnFrameworkInitializationCompleted()
at Avalonia.Controls.AppBuilderBase`1.Setup() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 289
at Avalonia.Controls.AppBuilderBase`1.SetupWithLifetime(IApplicationLifetime lifetime) in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 148
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 208
at Mesen.Program.Main(String[] args)
I will see if I can figure out a setup to debug on my Linux machine; that should simplify troubleshooting. If you have any pointers regarding how to debug the program, though, that would be very appreciated.
The most annoying problem in that case was that the call stack showed a bunch of functions that weren't on it anymore; the best thing that I think can be done, I believe, is to pop off entries when SP goes past them, even if not by `ret`. That said, this can be taken care of later, there are likely more urgent things to take care ofSour wrote: ↑Sat Jan 28, 2023 11:17 pm Re: the call stack, it's likely I can't fix it - stack manipulation will always cause issues with it, it tries its best to keep up, but a lot of scenarios will confuse it. I haven't forgotten the other points you've mentioned, but haven't gotten to any of them yet.
Oh yeah, speaking of, there is now another PR waiting for you. That one adds CI for Windows and Linux ^^
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
https://github.com/ISSOtm
ASMu is laifu <3
Re: Mesen - Emulator
Did the debugger BRK fix ever make it into Mesen2? I had added "BRK" to the list of control flow instructions, so that the debugger would not try to continue disassembling past a BRK instruction. This helped when disassembling Dragon Warrior 4.
I had also added in a ";" shortcut key for adding comments to a disassembly, that PR got merged into mkwong's and novasquirrel's fork.
I had also added in a ";" shortcut key for adding comments to a disassembly, that PR got merged into mkwong's and novasquirrel's fork.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: Mesen - Emulator
Thanks, this is fixed now.
Generally, when I'm investigating crashes on Linux, I build with -O0 -g to get debug symbols, and then launch Mesen through GDB and trigger the crash. This usually lets GDB print out the current call stack, etc. (I forgot the exact commands - "bt" I think? I'm assuming you probably know this better than I do)
Although, I think I figured out what you were describing with the cycle counter only incrementing each time you pressed resume, since I just got the same behavior. On the CGB, if a DMA is causing multiple invalid vram accesses, each access will cause the debugger to break once. This isn't exactly a bug, but I realize it might be a bit annoying to deal with, as is.
Thank you! I've updated the builds a bit and linked to the Windows & Linux (clang - ubuntu 20.04) builds from the readme (+ updated mesen.ca to link to the new repo instead) Also, I checked again, and as usual, clang seems to be produce code that's about 20% faster than GCC (for reasons I will never understand :p)
This should be fixed already - BRK is marked as an unconditional jump in NesDisUtils.cpp, so the disassembler should stop whenever it sees one. The shortcut to add comments isn't there at the moment, but I do have it on my list of things to add in the future.
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Mesen - Emulator
When changing the "hexadecimal display" to "decimal display" in the watch panel of the debugger, the value does not update if currently paused. Execution must resume for it to apply.
Re: Mesen - Emulator
I tried the first one (CRC32: 68789807) and it worked flawlessly for me with the arcade card set.bogaa wrote: ↑Sat Jan 28, 2023 12:21 am- I did try CD ROM and it worked.
- Super CD ROM did not work
- Arcade CD ROM did not work
I did get a other iso and that worked flawless Is there a data base to verify your iso?
Here are the once I tried. I had no issue running it with Bizhawk.. But I should investigate more before I do posts sry
Only CD ROM worked
No database match. Akumajou_Dracula_X_-_Chi_no_Rinne_(NTSC-J)_[KMCD3005]
File/ROM SHA-1: 980682ADE83FF82314AECC91C04092EE1848DFDB
File/ROM CRC32: 68789807
Everything worked
No database match. Akumajou Dracula X - Chi no Rondo (JP) Worked
File/ROM SHA-1: 8728C4600691F31768FBEB75B2F508A00A758A18
File/ROM CRC32: A62E216F
You not only have to set system card, you also have to specify a super CD system card 3 ROM (arcade card uses the same ROM as super CD system card 3). It will prompt for it when you try to load the game that needs it, I can't find a way to do it manually though (this goes for other BIOS/bootstrap-ROMs as well like the Game Boy boot-ROM or FDS BIOS).
The system card error screen in Akumajou Dracula X is one of the coolest in any PC-Engine game as you get to play an (intentionally) "broken" version of the game called Akumajyo Dracula X (peke).
- ISSOtm
- Posts: 58
- Joined: Fri Jan 04, 2019 5:31 pm
- Location: France, right of a pile of consoles
- Contact:
Re: Mesen - Emulator
Well, the problem is that it's not a crash, but rather a lock-up, so no definitive stack trace; what's more, the entire UI becomes unresponsive, which seems to point at the lock-up occurring in the C# code. My research into how to debug C# on Linux seems to point at having to use either VS (therefore Windows, over SSH) or VS Code, neither option being really viable for me at the moment. *grumbles something about Microsoft dropping support for LLDB in favour of their own programs*Sour wrote: ↑Sun Jan 29, 2023 2:15 pm Generally, when I'm investigating crashes on Linux, I build with -O0 -g to get debug symbols, and then launch Mesen through GDB and trigger the crash. This usually lets GDB print out the current call stack, etc. (I forgot the exact commands - "bt" I think? I'm assuming you probably know this better than I do)
(Your remark about GDB reminds me that I ought to translate my GDB tutorial one day...)
Ah, but the ROM in question wasn't involving DMAs at all. It was writing to OBPD (`ldh [c], a`) during Mode 3, which (correctly) broke on "bad VRAM access", but any command to resume execution (Escape to resume, step instruction, etc.) only reported "executed 2 cycles", increased the "elapsed cycles" count by 2, however PC did not move from the offending instruction.Sour wrote: ↑Sun Jan 29, 2023 2:15 pm Although, I think I figured out what you were describing with the cycle counter only incrementing each time you pressed resume, since I just got the same behavior. On the CGB, if a DMA is causing multiple invalid vram accesses, each access will cause the debugger to break once. This isn't exactly a bug, but I realize it might be a bit annoying to deal with, as is.
It may have been related to the bug you just fixed, but unfortunately a recent new build error means I am not able to test at this moment. The shiny new CI seems to have caught it as well, at least. (I also left you a note about how to simplify the Linux jobs a bit.)
Great! Just checked it out, and it looks good. It's hard to say why Clang may be generating more performant code than GCC without profiling, but it may involve e.g. more aggressive optimisation passes in LLVM, or squeezing more out of LTO.Sour wrote: ↑Sun Jan 29, 2023 2:15 pm I've updated the builds a bit and linked to the Windows & Linux (clang - ubuntu 20.04) builds from the readme (+ updated mesen.ca to link to the new repo instead) Also, I checked again, and as usual, clang seems to be produce code that's about 20% faster than GCC (for reasons I will never understand :p)
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
https://github.com/ISSOtm
ASMu is laifu <3
Re: Mesen - Emulator
This is looking great! A few things I noted (and some feature requests that might be obvious/easy):
Tilemap Viewer:
Tilemap Viewer:
- No longer called Nametable Viewer, is that because it's NES only language?
- Missing field: Attribute Data
- Missing the tile editor (edit: I see it now in right click menu, the various Edit tiles options are nice!)
- Hide Unused Tiles doesn't seem to work
- Missing option: Display using last know palette
- Feature Request: Click and drag for selection, then F2 opens Tile Editor with everything in the selection
- Feature Request: Arrows navigate the current selection (increments of 8px)
- Feature Request: Copy/paste tile/selection
- Feature Request: Keys 1-4 select the corresponding palette entry for the current palette
- Feature Request: Shift + Up/Down/Left/Right = Nudge everything 1 px in that direction
- Feature Request: Ctrl + Up/Down = flip vertical
- Feature Request: Ctrl + Left/Right = flip horizontal
- Feature Request: Ctrl + Shift + Left/Right = Rotate 90 deg left/right
- Missing field: Pallete Address
- Color Selector is missing (edit: I see it now in right-click menu, makes sense since click now selects a color)
- Workspace is now JSON, need an option to import the old XML format
- Exporting labels as mlb from 0.9.9 and then importing them into 2.0.0 produces errors with no labels imported
- Missing option: Byte Code Display > Under
- Missing option: PRG Address Display > Below CPU Address
- Any time a memory address is double clicked (or maybe right clicked) in any of the above viewers then jump to that address in Memory Viewer