If you're reading this, it means you're using this: https://github.com/Yanis002/melonDS/tree/memview, here's a guide on how to use this tool.
- Current address, this is selectable
- Search bar, enter an address to jump wherever you want, it supports
0xprefix. It will execute the search once the length of the text in the input is 8 or 10 if using0xprefix - Value setter, enter any value to set
- Address where the value should be set
- Size of the value to set, options are 8 bits (1 byte), 16 bits (2 bytes) and 32 bits (4 bytes)
Setbutton, to execute the set- "Address on focus" will fill the address field (6.) depending on which item you focused (aka clicked on)
- Memory region, choices are:
- Default, the default range is 0x02000000 to 0x03000000
- ITCM, from 0x01FF8000 to 0x02000000
- Main, from 0x02000000 to the start of DTCM (by default 0x027C0000 but this can change depending on the game)
- DTCM, starts at 0x027C0000 by default but can be different, ends at start + 0x4000 (0x027C4000 by default)
- Shared WRAM, from 0x03000000 to 0x03008000
- Palettes, from 0x05000000 to 0x06000000
- OAM, from 0x07000000 to 0x08000000
- ARM9-BIOS, from 0xFFFF0000 to 0xFFFF1000
- Update/refresh rate, allows you to choose the amount of time it takes to refresh the memory viewer's values, by default it's 20ms, minimum is 5ms and maximum is 10000ms. Be careful! Lower means more CPU usage (in my experience, 5ms made it go from 4% to 8%, not that bad but worth mentioning it)
- The scene, aka the memory viewer itself.
- click on a value to select it
- double click or press enter to enter editing mode
- you can navigate using the arrows
- if you're in editing mode, you can navigate to the previous or next byte if the cursor on the left or the right of the byte (so on the edges)
- pressing a key when the cursor is on the left will erase the whole value, only the second digit if it's at the middle
- it will switch to the next byte once the byte got 2 digits
- to exit editing mode, press enter or escape
- in you search for an address that is in a different memory region, it will automatically switch to the right one, for example, we're in ITCM and we search for 0x027E0764, it will switch to the DTCM region
This is using QGraphicsView, a custom QGraphicsScene, QGraphicsTextItem and a custom text item class for the value items. There's also a QThread to refresh periodically the items and basically we always show 256 items (+ the 16 addresses on the left, each hex column prefix at the top and the 16 decoded strings texts on the right), this is just an attempt to save resources as much as I can.
I had to make derived classes for the scene and the text item because I needed to override some of the functions (and add signals for the items), basically it was just convenient this way.
Also why doing it this way? I chose these features from Qt because I used them before and thought it would be perfect for this, the alternative would have been using QLabels everywhere and it didn't seem like a good idea considering how much we need to handle, I was concerned it would have a big hit on the performances and that is not ok.
The rest is very obvious, like reading the NDS memory regions, updating each item's text every N milliseconds etc etc, + the implementation of each element of the UI, hopefully the code is self-explanatory if you really want to dig into it, feel free if there's questions or suggestions!