605 Commits
Author SHA1 Message Date
SourMesen af2342818c Debugger: Profiler/Trace logger/Watch - Fixed empty window/missing options for all consoles/games with a single CPU (#266)
This was caused by the Avalonia 12.1 upgrade
2026-08-27 19:01:10 +09:00
SourMesen a33b8b2712 Debugger: GSU - Added profiler support (#261)
This is implemented by pretending every 16 bytes in ROM is a different function, allowing the profiler to display cycle counts for each individual "function" in the UI
Also fixes a missing call to ResetFlags for the merge opcode for FX3
2026-08-27 19:00:55 +09:00
SourMesen 8ac7e1df7d Lua: Fixed address value in memory callbacks when using memory types other than the default cpu memory type (#265)
Also fixed a few scenarios where the PPU memory write callbacks did not allow the Lua script to change the value about to be written (because the callback was called too late)
2026-08-27 19:00:22 +09:00
SourMesen 4c27ebf26f UI: Update to Avalonia 12.1 (#249)
Allows drag and drop to work on Linux
2026-08-15 16:56:22 +09:00
SourMesen ad0a1b9849 Lua: Misc. fixes & improvements (#250)
-Fixed getAccessCounters documentation (swapped param order)
-Fixed file watcher not being disabled properly when closing the script window, causing the script to run if changed on the disk, even if the script window is closed
-Prevent file watcher from triggering from writes done by the script window itself (which caused the script to be reloaded 2 or 3 times in a row)
-Fixed UI freezes when using emu.log() on a large table
-Fixed crash when 100k character limit (in the last 500 lines) for script log was reached (out of bounds read/write)
-Added "fps" value to "getState"
-Slightly improved getAccessCounters/getCdlData performance
-Added a new drawPixels API to improve performance when a script needs to draw a lot of individual pixels
2026-08-10 22:42:34 +09:00
SourMesen 9219fab3ed Debugger: Profiler - Keep track of cycles executed while the CPU is halted (#243)
Also adds a "cpu usage" meter in the debugger window which appears when software makes uses of halt/wai/etc.
2026-08-01 12:10:12 +09:00
SourMesen 05d74e7e40 Debugger: GBA - Show byte code as a single 16/32-bit value (#242)
Misc fixes:
-Fixed issues with the opcode tooltip not appearing for some GBA instructions (esp. when the condition code ends with an 's', e.g: rsbcs, movls, subcs)
-Fixed byte code not being lower case when the "use lower case" option is enabled
2026-08-01 12:09:15 +09:00
SourMesen fd32321313 Debugger: Added "copy to clipboard" option for tilemap, tile, sprite and event viewer (#240) 2026-08-01 12:08:49 +09:00
SourMesen 918379b7a7 Debugger: Tilemap viewer - Added option to pick background color (#238)
Also, minor bug fixes for WS:
-Fixed tilemap viewer for sometimes using the wrong background color
-Fixed the 4-bit RGB color values in the palette viewer having the R and B values swapped
2026-07-28 19:55:12 +09:00
SourMesen 8fc682325c Debugger: Lua - Added getPressedKeys API (#236)
Also:
-Improved emu.log() to support tables/array and numeric values, instead of only strings.
-Fixed duplicate save state key name for GB
-Fixed TrimRight logic not working properly when the string had a single non-space character followed by spaces (e.g TrimRight("A ") returned "A ")
2026-07-28 19:54:00 +09:00
SourMesen 112b6f3d09 Debugger: SuperGrafx - Added VPC options and VDC1/VDC2 filter in the event viewer (#234) 2026-07-28 19:52:25 +09:00
Adrian "asie" Siekierka ec5f14d95e WS: WonderWitch/NOR flash + extended 2003 mapper emulation support (#100) 2026-07-18 19:30:57 +09:00
SourMesen 40335ce735 UI: Update to Avalonia 12, .NET 10 and replace ReactiveUI with MVVM community toolkit (#142)
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
2026-07-03 16:04:42 +09:00
Takumi Grainger c8f8bc31c3 NES: Add FCNS controller (#193)
Also fixes presets/clear buttons for NTT, Pachinko & Hypershot, and improves layout for all controller config popups (buttons/borders are aligned, etc.)
2026-06-28 13:34:30 +09:00
Adrian "asie" Siekierka 083057e37a Debugger: WS - Expand ELF importer layout support. (#184)
Added support for ELF files which do not have special handling for WS platform banking and instead only map the 20-bit CPU memory space.
2026-06-20 22:59:03 +09:00
SourMesen 95ceb59d48 Debugger: Enforce 64kb maximum length for labels in all scenarios (#177)
When importing labels via .dbg/.elf/etc. files, the 64kb length limit for labels was ignored.
This prevents several performance problems when a label is defined as having a length of e.g 1+mb
2026-06-16 22:35:17 +09:00
SourMesen dc2cda6c51 Debugger: Memory search usability improvements (#173)
-Removed the confusing/hard-to-use "previous refresh value" "compare to" option
-The "last value" column now shows the values that "previous search value" will compare against
-Added "update values" button to apply an empty filter that does not hide any addresses, but updates the "last value" that will be used for subsequent filters
2026-06-15 17:47:49 -07:00
SourMesen 7c29fb4006 Debugger: Tilemap viewer - NES - Fixed the "Changes" highlight mode for NT/AT data (#159)
Did not work at all following a change done ~3 years ago to improve the tilemap viewer's performance
2026-06-02 23:11:49 -07:00
Fiskbit e222f0fcad NES: Fix header editor units bugs. (#157)
The header editor was treating MB units as KB, and its error checking was showing errors for MB sizes between 8 and 59 that were not a multiple of 4 because it was treating them as KB sizes.
2026-06-02 23:02:39 -07:00
SourMesen c3e4a3e77b Debugger: Find all occurrences - Fixed duplicated results when searching a function label that contains a multi-line comment (#134) 2026-05-24 19:36:50 -07:00
SourMesen a13ae9a461 Code: Added naming style CI checks for C#/UI code (#132) 2026-05-22 20:43:13 +09:00
Adrian "asie" SiekierkaandSour 22424d7412 WS: Initial cartridge RTC implementation (#98)
* GBA: Separate S3511A RTC emulation code from GBA interface emulation code.

* WS: Initial cartridge RTC implementation.

* WS: Expose cartridge RTC state to register viewer.

* Code: Fix formatting.

* WS: Update Core.vcxproj.

* Fix compilation error, remove unused method

---------

Co-authored-by: Sour <[email protected]>
2026-05-19 05:50:19 -07:00
FiskbitandSour b82eb7b213 NES: Improve OAM corruption accuracy. (#122)
* NES: Improve OAM corruption accuracy.

Our understanding of OAM row corruption has significantly improved since Mesen's implementation of the feature that was based on oam_flicker_test.nes results. This change improves the accuracy of the two OAM corruption emulation options.

Primary OAM (OAM1) and secondary OAM (OAM2) live in the same block of memory, made up of 9-byte rows where the first 8 bytes are consecutive OAM1 bytes and the last byte is an OAM2 byte. The PPU accesses OAM on every dot. On some dots, it uses the OAM1 address ($2003), and on other dots, it uses its internal OAM2 address. If the address changes during an OAM access (the 2nd half of a dot) and this causes the selected row to change, then it can trigger either analog corruption (the new row gets 'random' data) or a row copy (the old row's 9 bytes are copied to the new row). More information can be found at nesdev.org/wiki/OAM_internals.

Address selection is fairly simple. When rendering is off, OAM1ADDR is always selected. When rendering is on, OAM1ADDR is selected on odd dots in 1-256, and otherwise OAM2ADDR is selected.

Corruption occurs on the NES in 3 situations:
1. Writing to $2003 on NTSC PPUs, because writes are not synchronized at all and so the CPU open bus value and the new value can both cause the row to change mid-access. Depending on the timing, this can do nothing, cause analog corruption, or cause row copy. This was fixed in PAL PPUs, but we don't know about Dendy.
2. Toggling rendering on an OAM2ADDR dot. Depending on the direction and the timing, this can do nothing or cause analog corruption of or row copy to the new row.
3. On 2C02E and later PPUs, having a row mismatch if rendering is enabled at the start of pre-render. This always causes a row copy from the OAM1ADDR row to the OAM2ADDR row and is required for Huge Insect to spawn enemies in level 1. (2C02C PPUs have some corruption in this situation, too, but it is not yet understood.)

This change adds support for OAM corruption in situations 1 and 2 using the "Enable PPU $2003/rendering-toggle OAM corruption" setting, which is off by default. This does not take alignment into account at all and only does row copy, not analog corruption. Recommended for developers, but probably undesirable for actual users. This setting was previously called "Enable PPU OAM row corruption emulation". Note that situation 1 ($2003 writes) is not perfectly matching blargg's oam_read test results in the most vulnerable alignment yet, suggesting there is more research to be done on this.

Situation 3 is now supported under the "Disable PPU frame-start OAM corruption (2C02D and earlier)" setting, so this corruption happens by default. Mesen was already doing some corruption here to support Huge Insect, with the previous version of this setting being called "Disable PPU OAMADDR bug emulation". These changes make the corruption more accurate and apply in more situations, so there is a chance it will break some user software, but because it is required for a game, we've opted to have it on by default. This feature should match hardware very closely, as it doesn't have the timing and analog aspects seen in situations 1 and 2.

To support these, sprite rendering was reworked a bit to more accurately manage the OAM1 and OAM2 addresses during rendering. This should make sprite rendering behavior more accurate when rendering is toggled mid-frame, although there are still inaccuracies that come up if you do this. The OAM2 address can also now be seen in the register viewer below $2003.

This was tested against a suite of NES tests, AccuracyCoin $2004 Stress Test, and oam_flicker_test.nes/oam_flicker_test_reenable.nes. The $2003-based corruption causes a few tests to change behavior when enabled (which is expected), but oam_read and related tests are not failing exactly right yet. Tests otherwise pass.

* Changes based on code review.

* Removed _spriteAddrL/_spriteAddrH members, use local variables instead.

* Simplify firstVisibleSpriteAddr assignment

---------

Co-authored-by: Sour <[email protected]>
2026-05-19 03:17:34 -07:00
SourMesen af51f139fc Debugger: Fixed tooltips wrapping some texts on 2 lines when not needed (#128)
This was most likely caused by the recent Avalonia upgrade
2026-05-18 23:59:02 +09:00
Adrian "asie" Siekierka 5bb64aacf0 WS: Initial Pocket Challenge V2 support (#95)
The Pocket Challenge V2 is an education handheld based on the ASWAN SoC, as used in the WonderSwan. It uses the same boot ROM (with an early exit), but has some implementation changes:

    The LCD icon segment area is not present (on the display panel only).
    There is no onboard internal EEPROM.
    The input keypad layout differs.
    The headphone output is always used with a custom onboard DAC, as opposed to relying on the SoC's own PWM DAC for the internal speaker.

This PR implements support for all of this. Support for the PCv2-exclusive cartridge mapper (KARNAK) will be added by a separate PR.
2026-05-17 01:11:02 +09:00
Adrian "asie" SiekierkaandSour 2f5ccd6983 UI: Update Avalonia to 11.3.14. (#105)
* UI: Update Avalonia to 11.3.14.

- AvaloniaEdit is updated to 11.4.1.
- Avalonia.ReactiveUI is held back at 11.3.8, as later updates require
  separate adaptation work.
- Dock is updated to 11.3.12.1.

* Revert Dock upgrade (currently causes a large number of binding warnings which make the debugger take 3-4 seconds to display the content of the dock control after the window is opened when VS is attached to the process)

---------

Co-authored-by: Sour <[email protected]>
2026-05-15 19:47:05 -07:00
SourMesen e9f48e23e8 Netplay: Fixed game crashing when connecting to server (#113)
The server would send a save state taken inside the PpuFrameDone event when a config change was detected, which is not safe. PpuFrameDone runs in the middle of CPU instructions, which could easily cause game crashes or desyncs.
2026-05-14 15:54:57 -07:00
Adrian "asie" Siekierka e886371fcc Debugger: WS - Update default debugger labels (#99)
The Wonderful toolchain ships an XML-based hardware MMIO definition format;
I have added an output format to it which outputs sequences of addLabel()
function calls. Coupled with some manual additions, this creates a set of
default labels which is a perfect match for toolchain code; in addition,
it benefits from existing comments from said definition set.
2026-05-13 23:40:06 +09:00
NovaSquirrel 8e7e4c2ff9 SNES: Add SPC dumper tool (#89)
* SNES: Add SPC dumper tool

* SNES: SPC dumper fixes
2026-05-08 17:31:34 -07:00
SourMesen e391fd8f9a Code: Add auto-formatting rules for C++ (clang-format) and enforce in CI via "clang-format" and "dotnet format" (#78)
* Code: Add auto-formatting rules for C++ projects (clang-format) and enforce code style via "clang-format" and "dotnet format"

* fix ui format warnings
2026-04-30 06:03:55 -07:00
SourMesen 4b8669d34b Debugger: Tilemap viewer - Fixed "edit tile" behavior on SNES when the tilemap is using 16x16 (or 16x8) tiles (#72)
Also, added support for horizontal/vertical mirroring when editing the mirrored tiles from the tilemap.
2026-04-27 09:18:53 -07:00
SourMesen 8e4dd329ac Debugger: Lua - Added new APIs: getCpuState, setCpuState, getMasterClock, getCpuCycleCount (#58)
getCpuState/setCpuState allow the same functionality as getState/setState, but limited to only the CPU's state, making them much faster (some performance optimizations to the serialization & Lua code were also done)
getMasterClock/getCpuCycleCount are very fast alternatives to getState when all the script needs is a cycle count.
2026-04-26 18:00:08 -07:00
SourMesen 9616f36f89 Debugger: Console-specific scanline/cycle refresh values (#65)
* Debugger: Console-specific scanline/cycle refresh values

* Fixed some issues with min/max values when switching console types
2026-04-26 17:06:01 -07:00
SourMesen 6dcd959e76 Debugger: NES - Header editor - Support PRG/CHR sizes below 1 KB (#52)
+Fixed some incorrect/missing validations
+Disable save button when an error message is shown
+Fixed .nes load logic ignoring PRG/CHR sizes from NES 2.0 headers (was getting overriden by game DB)
2026-04-26 03:27:13 -07:00
SourMesen c322a20e52 Debugger: Memory viewer - Improved performance on Linux (#60)
* Debugger: Memory viewer - Improved performance on Linux
SKTypeface.FromFamilyName appears to be very fast on Windows (1ms for 1000 calls), while it's slow on Linux (4ms per call). This was called 3 times for each memory viewer refresh, causing performance issues on Linux.

* Fixed warning, enable options to treat all warnings as errors
2026-04-24 19:41:02 -07:00
Fiskbit 0d65cfc770 Tool: Makes header editor work with archived/soft-patched ROMs. (#31)
The NES header editor is currently unable to save a ROM if it was loaded from an archive (such as .zip) or if the ROM was soft-patched. This is because the editor reloads the ROM from disk to then apply the new header and save a copy, but the C# compnent is not able to open archives or apply patches. If the ROM file is in an archive, it throws an Unexpected Error and fails.

This change instead makes the editor use the current PRG and CHR ROM. This means it doesn't need to reload the ROM, so it can save it regardless of how it was loaded. It also means that it saves any changes that have been made to the ROM in the session, either by self-flashing or by editing them via tools, which could be seen as a pro or a con. Also, because Mesen does not currently use misc ROM, it is unable to include that in the saved ROM, but this is something we could feasibly add later.

This change was written by Sour.
2026-04-14 19:51:02 -07:00
Fiskbit cb08123856 Merge pull request #35 from NovaSquirrel/labels-in-ram-code
Debugger: Assume SPC memory based on segment name, not type
2026-04-14 13:52:55 -07:00
NovaSquirrel 18cd2785ee Debugger: Try to load dbg files when running FDS games 2026-04-14 02:12:06 -04:00
NovaSquirrel 8f70b112c2 Debugger: Assume SPC memory based on segment name, not type 2026-04-14 00:34:19 -04:00
Takumi Grainger c6f62d8738 UI: Update default FDS BIOS labels (#28)
* Update FDS BIOS labels

* More FDS BIOS label cleanup

* Clarify CounterLogic and SetScroll

* More FDS BIOS label tweaks

* Update inputs for FDS BIOS ReadKeyboard label
2026-04-12 18:09:06 -07:00
Adrian Siekierka b71c057be5 Debugger: WS - Update ELF import for newest toolchain version 2026-03-29 10:09:19 +02:00
NovaSquirrel 2ea2ed729c Debugger: Add "Vertical" tile layout option 2026-02-26 23:20:18 -05:00
Sour 5f6c362a93 WS: EEPROM - Add delay when processing read/write/erase commands 2025-07-13 20:58:09 +09:00
Sour 4db2004745 Debugger: NES - Keep emulation paused when opening the header editor if no other debug tools are opened 2025-07-12 08:54:35 +09:00
Sour daebb7a459 Debugger: GBA - Fixed CPSR value not updating when mode changes 2025-07-07 22:45:44 +09:00
Sour a59caeec90 Debugger: Event Viewer - Fixed missing labels for port reads/writes on WS/SMS 2025-07-01 22:37:51 +09:00
Sour fb1efceeb6 UI: Update to Avalonia 11.3.1
Fixed issues with window resize logic, fixed watch focus issues, fixed binding problems in netplay windows
2025-06-20 15:56:02 +09:00
Sour aeed6e0693 PCE: Added support for CD+G discs
Adds support for subcode reads via 1807 (when a .sub file is provided) and implements the subcode irq
2025-06-15 19:32:44 +09:00
Sour 32756fbf88 Debugger: Change BG color for breakpoint margin + visual hint that it can be clicked 2025-05-16 11:56:10 +09:00
Sour ef73b737e0 Debugger: SDCC - Fixed missing source files when files are in the same folder as the .cdb file 2025-05-15 19:55:29 +09:00