Mesen - 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 - Emulator

Post by rainwarrior »

gzip wrote: Sun Jan 29, 2023 9:45 pm* No longer called Nametable Viewer, is that because it's NES only language?
* Missing field: Attribute Data
"Nametable" actually seems to come from Texas Instruments VDPs (e.g. MSX, SMS, Genesis) originally, but we adopted it long ago in NESDev for whatever reason. (Probably an early emulator made by someone who learned on an MSX?)

"Palette index" gives the attribute data for the tile. The display mode dropdown also has an attribute viewer.
gzip wrote: Sun Jan 29, 2023 9:45 pm* Missing field: Pallete Address
It's called "index" here, and it does correspond directly to an address in the palette RAM memory view.
gzip wrote: Sun Jan 29, 2023 9:45 pm* 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
There is a right click menu that does exactly that in all three of those panels.
SNESPlayer
Posts: 37
Joined: Wed Dec 08, 2021 11:18 pm

Re: Mesen - Emulator

Post by SNESPlayer »

ISSOtm wrote: Sun Jan 29, 2023 6:42 pm
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)
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*

(Your remark about GDB reminds me that I ought to translate my GDB tutorial one day...)
One of the banes of C# development on Linux is that nearly all docs are assuming that you'll debug or trace through Visual Studio on Windows or maybe Rider (which is why seeing people developing C# on Linux is either rare or discouraged entirely). A solution to this problem might be to build manually Samsung's netcoredbg: https://github.com/Samsung/netcoredbg

It has a few modes of operation, including being compatible with GDB and VSCode's DAP. Give it a try and see if this makes any difference, here's an accompanying CLI too https://github.com/Samsung/netcoredbg/b ... ocs/cli.md

If you were already using Samsung's netcoredbg, then there isn't much else sadly.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Mesen - Emulator

Post by gzip »

rainwarrior wrote: Sun Jan 29, 2023 11:34 pm
gzip wrote: Sun Jan 29, 2023 9:45 pm* Missing field: Attribute Data
"Palette index" gives the attribute data for the tile. The display mode dropdown also has an attribute viewer.
Palette Index actually looks like a new field that was not available before. In 0.9.9 the Attribute Data field gives the hex value for the corresponding entry in the attribute table. I don't see that anywhere in 2.0.0. The attribute view also omits this info. If the hex value is not useful then that's a different question.
rainwarrior wrote: Sun Jan 29, 2023 11:34 pm
gzip wrote: Sun Jan 29, 2023 9:45 pm* Missing field: Pallete Address
It's called "index" here, and it does correspond directly to an address in the palette RAM memory view.
Ok so now it can jump directly to Palette RAM instead of prefixing $3F to the index field to yield the PPU address.

This brings up another issue which is that the Palette RAM view in Memory Viewer no longer has a right click option to View in PPU Memory.
rainwarrior wrote: Sun Jan 29, 2023 11:34 pm
gzip wrote: Sun Jan 29, 2023 9:45 pm* 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
There is a right click menu that does exactly that in all three of those panels.
I think you're referring to the graphical area on the left side, right click for "View in Memory Viewer F1", but there are other address fields which only contain Copy in the right-click menu and there's no way to easily jump to the corresponding address:

Tilemap Viewer
  • Tilemap Address (equivalent to existing right click)
  • Tileset Address
-Selected Tile
  • Tilemap Address (equivalent to existing right click)
  • Tile Address (PPU)
  • Tile Address (CHR)
  • Palette Address
  • Attribute Address
Sprite Viewer
-Selected Sprite
  • Tile Address (PPU) (equivalent to existing right click)
  • Tile Address (CHR) (sometimes equivalent to existing right click, depending on CHR banking)
  • Palette Address
Tile Viewer
  • Address (equivalent to existing right click)
-Selected Tile
  • Tile Address (PPU) (equivalent to existing right click)
  • Tile Address (CHR) (sometimes equivalent to existing right click, depending on CHR banking)
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Mesen - Emulator

Post by Pokun »

rainwarrior wrote: Sun Jan 29, 2023 11:34 pm
gzip wrote: Sun Jan 29, 2023 9:45 pm* No longer called Nametable Viewer, is that because it's NES only language?
* Missing field: Attribute Data
"Nametable" actually seems to come from Texas Instruments VDPs (e.g. MSX, SMS, Genesis) originally, but we adopted it long ago in NESDev for whatever reason. (Probably an early emulator made by someone who learned on an MSX?)
I guess tilemap is easier to understand than nametable (I was confused by the terminology myself first time I heard it).

Nametable is seemingly more common in the Nes homebrew community than in other homebrew communities, but it's definitely not unique to Nesdev and TI VDPs. Nintendo and possibly Sega both officially use this terminology (in addition to various alternatives like Screen Map).
I doubt Texas Instruments actually came up with nametable though. "Name" (which is synonymous to "character index" in the context of video hardware) is also used in other situations for weird things in English, such as a comic artist's story board which is called a "name".

Mapper/mapping is a similar thing that people tend to think is a Nes term as it's so commonly used in the Nes community (thanks to the Nes having millions of them), but is also very common in the MSX community. The MSX "memory mapper" is the official term for the RAM mapping hardware that any MSX2 with more than 64 kB RAM basically needs to have, and "ROM mapper" has the same meaning as in the Nes community.

And I mean "sprite" also originates in the TI VDPs and is used everywhere.
Last edited by Pokun on Tue Jan 31, 2023 1:50 pm, edited 1 time in total.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

rainwarrior wrote: Sun Jan 29, 2023 4:24 pmWhen 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.
Thanks! This is fixed.

gzip wrote: Sun Jan 29, 2023 9:45 pm...
Thanks for the feedback!
  • No longer called Nametable Viewer: This was on purpose to use a general purpose term that's not unique to a specific console.
  • Missing field: Attribute Data: Like rainwarrior mentioned, this is basically available via the "palette index" value. The "attribute data" value contains the data for the adjacent 16x16 blocks, I'm not sure if it's actually useful enough to add.
  • Hide Unused Tiles doesn't seem to work: This was because the dropdown was being shown for CHR RAM games (when selecting the "PPU memory" type) - this feature is only supported for CHR ROM games. This is fixed.
  • Missing option: Display using last know palette: This was omitted on purpose - the feature requires a fair bit of code, which would likely have to be implemented for each console individually and has a performance impact. I decided it was not worth the trouble to reimplement this one.
  • Feature Request: Arrows navigate the current selection (increments of 8px): Good idea and would match the behavior of the palette selection control in the tile viewer. I'll try to add this, should be simple enough.
  • Feature Request: Copy/paste tile/selection: The reason this isn't available is that neither .NET 6 nor Avalonia currently offer any crossplatform way of adding image data to the clipboard. There's been some discussion over on the Avalonia repository to add support for this, and I'm hoping to add this once/if they do.
  • Tile editor: Thanks for all the ideas - I've added them to my list of future improvement ideas for now. The tile editor is a fairly minor feature, and it's probably not used by a ton of people, either. Turning it into a full-fledged tile editor is probably not something I want to get into atm, but most of these are probably fairly simple to implement.
  • Missing option: Byte Code Display > Under and Missing option: PRG Address Display > Below CPU Address: These were excluded on purpose, I've never seen anyone actually using this, and I think this is something I might have implemented before I ever released Mesen to the public..
  • Palette RAM view in Memory Viewer no longer has a right click option to View in PPU Memory.: Fixed this, thanks.
  • 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: I can see this being useful - I'll add it to the list of future improvement ideas.
  • Re: importing debugger data from the old mesen: While not necessarily impossible to do, it's not a goal at the moment. The format for a lot of stuff has changed, and some things might no longer match 1:1. It's probably fairly easy to export the mlb file from the old version and fix it manually with search-and-replace before importing it into the new version. Are you asking because you have a large amount of debugger data for a variety of games you've reverse-engineered? This is basically the only scenario where I could see why you would want to do this.
Hopefully that covered everything.

ISSOtm wrote: Sun Jan 29, 2023 6:42 pm 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.
This is most likely just the result of the UI making a call to the core while the core is already deadlocked, causing the UI thread to get deadlocked, too. gdb should be able to pause & display the call stack for all native threads, which would probably be enough to figure out the cause.
If you have a list of steps that reproduces the issue each time with a given rom, let me know and I can try to reproduce this locally again.
ISSOtm wrote: Sun Jan 29, 2023 6:42 pmAh, but the ROM in question wasn't involving DMAs at all.
If you have a specific rom/game where I can try to reproduce this one, let me know. At the moment the only scenario where I've seen this is the dma call.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Mesen - Emulator

Post by gzip »

Sour wrote: Mon Jan 30, 2023 7:38 pm
  • Tile editor: Thanks for all the ideas - I've added them to my list of future improvement ideas for now. The tile editor is a fairly minor feature, and it's probably not used by a ton of people, either. Turning it into a full-fledged tile editor is probably not something I want to get into atm, but most of these are probably fairly simple to implement.
I use Tile Editor quite a bit. This is one of the features that got me started with Mesen over FCEUX. There's nothing like editing tiles "live". I agree that there's a limit to what should be implemented but hopefully these ease-of-use features can make it in at some point.
Sour wrote: Mon Jan 30, 2023 7:38 pm Missing option: Byte Code Display > Under and Missing option: PRG Address Display > Below CPU Address: These were excluded on purpose, I've never seen anyone actually using this, and I think this is something I might have implemented before I ever released Mesen to the public.
The first one I use to save space for an already narrow code window. The second one I also use but can get to the PRG address through Memory Viewer as well (Right click line > Edit in Memory Viewer, then Right click > View in PRG ROM). Neither is a huge loss.
Sour wrote: Mon Jan 30, 2023 7:38 pmFeature Request: Copy/paste tile/selection: The reason this isn't available is that neither .NET 6 nor Avalonia currently offer any crossplatform way of adding image data to the clipboard. There's been some discussion over on the Avalonia repository to add support for this, and I'm hoping to add this once/if they do.
I could see that being a problem if copy/pasting between apps but within Mesen itself couldn't you just do this with the raw byte data?
Sour wrote: Mon Jan 30, 2023 7:38 pmRe: importing debugger data from the old mesen: While not necessarily impossible to do, it's not a goal at the moment. The format for a lot of stuff has changed, and some things might no longer match 1:1. It's probably fairly easy to export the mlb file from the old version and fix it manually with search-and-replace before importing it into the new version. Are you asking because you have a large amount of debugger data for a variety of games you've reverse-engineered? This is basically the only scenario where I could see why you would want to do this.
Correct. An example is the Zelda Debug File. (I'd really like to see more of these released in the future.) Maybe a quick conversion guide if nothing else.

Thanks for adding all the feature requests to the future ideas queue.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Mesen - Emulator

Post by rainwarrior »

gzip wrote: Mon Jan 30, 2023 12:49 pmPalette Index actually looks like a new field that was not available before. In 0.9.9 the Attribute Data field gives the hex value for the corresponding entry in the attribute table. I don't see that anywhere in 2.0.0. The attribute view also omits this info. If the hex value is not useful then that's a different question.
The palette index is the attribute data for that tile, though maybe you're hoping for the packed byte belonging to 4 tiles at once? That could be useful as well. (I'm realizing I did make use of this in FCEUX a lot in the past. It helps when trying to verify the source of the data elsewhere, like when you're trying to ensure your software sets up the background correctly, or trying to reverse engineer where the data came from.)

For NES I'd also suggest an additional "view attribute in memory viewer" right click menu option to find that byte, too. On the other platforms I don't think they're stored apart like NES, though.
Pokun wrote: Mon Jan 30, 2023 2:39 pmNintendo and possibly Sega both officially use this terminology [nametable]...
I'm curious about examples. The only place I can remember Nintendo using "name" in a related way was in the SNES manual where it refers to "CHR name" for a tile's index and "name base address" as the position of CHR index 0. This seems compatible with the concept of a "nametable" but I don't think I've seen an example of them ever using that term specifically.

Sega definitely does use "name table" in its official developer manual, but this terminology comes directly from TI.

TI also used the term "pattern table" for the concept which Nintendo seems to only refer to as CHR, but we similarly seem to have adopted for NESDev (but less pervasive in its use).
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Mesen - Emulator

Post by tepples »

rainwarrior wrote: Mon Jan 30, 2023 8:26 pm For NES I'd also suggest an additional "view attribute in memory viewer" right click menu option to find that byte, too. On the other platforms I don't think they're stored apart like NES, though.
Another platform with attributes "stored apart" would be Game Boy Color, which stores low bytes of tilemap entries in bank 0 and high bytes in bank 1.
rainwarrior wrote: Mon Jan 30, 2023 8:26 pm TI also used the term "pattern table" for the concept which Nintendo seems to only refer to as CHR, but we similarly seem to have adopted for NESDev (but less pervasive in its use).
I have tended to interpret "CHR" as a name for a data format and "pattern table" as a range of memory addresses to which CHR data is written. For example, the pattern tables on Game Boy Color are VRAM bank 0 address $8000-$97FF and VRAM bank 1 address $8000-$97FF.
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Mesen - Emulator

Post by Sour »

gzip wrote: Mon Jan 30, 2023 8:20 pm The first one I use to save space for an already narrow code window. The second one I also use but can get to the PRG address through Memory Viewer
The debugger's layout is customizable now, at least, so hopefully this should help with optimizing the space in other ways.
If all you need is to know the PRG address itself, it's in the tooltip whenever you put your mouse over the row's address. You can also show them permanently via the dropdown labelled "Margin" in the option bar (at the cost of horizontal space of course)

gzip wrote: Mon Jan 30, 2023 8:20 pm I could see that being a problem if copy/pasting between apps but within Mesen itself couldn't you just do this with the raw byte data?
I'm not sure I'm following you - where would you paste the tile/etc's image inside Mesen itself? Or do you mean, copy a tile and somehow paste it as data in the memory viewer? Or something akin?

gzip wrote: Mon Jan 30, 2023 8:20 pm Maybe a quick conversion guide if nothing else.
In theory, if you export your old workspace labels to .mlb in the old Mesen, and then replace the first part of each row as follows:

Code: Select all

G:   ->   NesMemory:
P:   ->   NesPrgRom:
R:   ->   NesInternalRam:
S:   ->   NesSaveRam:
W:   ->   NesWorkRam:
Everything else about the format is the same, it's just the "name" of each memory type (the first field before the colon) that's changed. This should allow you to import the labels back into the new version.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Mesen - Emulator

Post by gzip »

rainwarrior wrote: Mon Jan 30, 2023 8:26 pmThe palette index is the attribute data for that tile, though maybe you're hoping for the packed byte belonging to 4 tiles at once?
Yes, that's what I'm referring to. It's there 0.9.9. It's a very tedious byte to edit I might add. I for one would find it useful to have a simple Attribute Editor window akin to NES Palette Table Calculator.
rainwarrior wrote: Mon Jan 30, 2023 8:26 pmFor NES I'd also suggest an additional "view attribute in memory viewer" right click menu option to find that byte, too. On the other platforms I don't think they're stored apart like NES, though.
The Attribute view of Tilemap Viewer should jump to the correct attribute for right click > View in Memory Viewer. As of now it jumps to the tile index instead (which should only apply to the Default and Grayscale modes).
Sour wrote: Mon Jan 30, 2023 9:48 pm The debugger's layout is customizable now, at least, so hopefully this should help with optimizing the space in other ways.
If all you need is to know the PRG address itself, it's in the tooltip whenever you put your mouse over the row's address. You can also show them permanently via the dropdown labelled "Margin" in the option bar (at the cost of horizontal space of course)
Ah, the user can drag around the various panes now, that's nice. Yes, the new tooltip meets the use case, as does the Margin option given enough space.
Sour wrote: Mon Jan 30, 2023 9:48 pmI'm not sure I'm following you - where would you paste the tile/etc's image inside Mesen itself? Or do you mean, copy a tile and somehow paste it as data in the memory viewer? Or something akin?
In Tile Viewer right click on a tile and select copy, then right click on another tile and paste over it. This would be very useful in combination with arbitrary selections, like 4 tiles at a time for a block. It would be akin to finding that tile in memory, copying the 16 bytes, and then pasting them at another tile location in memory. I've used that exact process before and it's tedious.
Sour wrote: Mon Jan 30, 2023 9:48 pm In theory, if you export your old workspace labels to .mlb in the old Mesen, and then replace the first part of each row as follows...
I'll give this a shot.
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Mesen - Emulator

Post by gzip »

Sour wrote: Mon Jan 30, 2023 9:48 pm

Code: Select all

G:   ->   NesMemory:
P:   ->   NesPrgRom:
R:   ->   NesInternalRam:
S:   ->   NesSaveRam:
W:   ->   NesWorkRam:
This does work but why change the labels at all if that's all that's preventing backwards compatibility?

Btw, is there any way to import/export breakpoints?
User avatar
ISSOtm
Posts: 58
Joined: Fri Jan 04, 2019 5:31 pm
Location: France, right of a pile of consoles
Contact:

Re: Mesen - Emulator

Post by ISSOtm »

Pokun wrote: Mon Jan 30, 2023 2:39 pm I guess tilemap is easier to understand than nametable (I was confused by the terminology myself first time I heard it).
FWIW, hailing from GBDev, I find it so; especially more due to the term's use in the wider game dev community.
Pokun wrote: Mon Jan 30, 2023 2:39 pm Nametable is seemingly more common in the Nes homebrew community than in other homebrew communities, but it's definitely not unique to Nesdev and TI VDPs. Nintendo and possibly Sega both officially use this terminology (in addition to various alternatives like Screen Map).
I believe the known GBC manual also uses the term "character" and either "character table" or "nametable", at least in referring to the SNES functionality, but I think also the GB(C) one. The terms have fallen entirely out of use in GBDev nowadays, however. We also use "tile ID" rather than "name".
Pokun wrote: Mon Jan 30, 2023 2:39 pm Mapper/mapping is a similar thing that people tend to think is a Nes term as it's so commonly used in the Nes community (thanks to the Nes having millions of them), but is also very common in the MSX community.
Again FWIW, "mappers" is also a term used very often in GBDev to designate the MBC and other similar chips in the cartridge.
Sour wrote: Mon Jan 30, 2023 7:38 pm
ISSOtm wrote: Sun Jan 29, 2023 6:42 pm 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.
This is most likely just the result of the UI making a call to the core while the core is already deadlocked, causing the UI thread to get deadlocked, too. gdb should be able to pause & display the call stack for all native threads, which would probably be enough to figure out the cause.
If you have a list of steps that reproduces the issue each time with a given rom, let me know and I can try to reproduce this locally again.
Apologies for not sharing the ROM, but I have been given it privately and so shouldn't post it publicly. I will try to GDB the issue, hopefully it's in the C++ core then. (As an aside, should I find a satisfactory patch to allow compiling the core dylib on Linux in debug mode and/or with ASan/TSan, would you be interested in a PR?)
The French Lord of Laziness (and a huge Legend of Zelda fan)
https://github.com/ISSOtm
ASMu is laifu <3
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Mesen - Emulator

Post by Pokun »

Sour wrote: Mon Jan 30, 2023 7:38 pm The tile editor is a fairly minor feature, and it's probably not used by a ton of people, either. Turning it into a full-fledged tile editor is probably not something I want to get into atm, but most of these are probably fairly simple to implement.
I just want to say that I strongly agree with Gzip here. The tile editing feature was one of the cooler features in Mesen that I haven't seen elsewhere IIRC. Being able to edit tiles and see the result live on the screen is an incredibly useful feature when you just want to try adding a few pixels here and there to see if it looks better and don't want to recompile the CHR files every time. I'm glad it's back, thank you for your hard work!

I also agree with Gzip and Rainwarrior that being able to see the packed bits of the whole attribute-byte is useful.


I have a suggestion how to make the NES attribute grid a little better. Currently it just shows a red grid covering every 2x2 tile, but it would be useful if you could also see the borders between the full 4x4 tile areas covered by each attribute byte. Currently you have to hover the mouse and look where the attribute address changes or count every 2 attribute squares from the edge.
My suggestion is to use a checkered pattern of two different colors to make it easy to see.
Here is a rough sketch of the idea:
Attribute grid example
Attribute grid example
attrigrid.png (1.59 KiB) Viewed 9147 times
Here the grey tile grid is also enabled.
Red and blue is a good example because I think even the colorblind can tell those apart unless you are monochromatically colorblind (in which case we may need different brightness on the colors).
gzip
Posts: 23
Joined: Sat Mar 13, 2021 2:29 pm
Contact:

Re: Mesen - Emulator

Post by gzip »

I had a similar idea to Pokun with changing the grid. The selection size should also be bigger in the Attribute view. I put a few screens together to summarize the proposals.

Current Attribute view:
tilemap_viewer_current.png

Proposed changes:
tilemap_viewer_proposed.png
In (rough) order of complexity:

1) Change Memory Viewer address (or add two entries like for breakpoint)
2) Add Attribute Data field
3) Change size of selection outline
4) Add new Attribute Viewer window to edit a single attribute byte at a time


And a proposed grid change:
attr_grid.png
attr_grid.png (7.48 KiB) Viewed 9122 times
Classico
Posts: 1
Joined: Tue Jan 31, 2023 7:55 pm

Re: Mesen - Emulator

Post by Classico »

Video filters don't work with PC Engine and PC Engine CD-Rom games
Post Reply