Commit Graph

1973 Commits

Author SHA1 Message Date
740305cc25 Don't reset the VRAM cache if saving a state (#1944)
- This fixes a flickering bug in melonDS DS
2024-01-08 15:20:48 +01:00
8143f54956 Protect savestates while the threaded software renderer is running (#1864)
* First crack at ensuring the render thread doesn't touch GPU state while it's being serialized

* Get rid of the semaphore wait

* Add some extra fields into GPU3D's serialization

* Oops, TempVertexBuffer is already serialized

* Move vertex serialization into its own method

* Lock the GPU3D state when rendering on the render thread or serializing it

* Revert "Lock the GPU3D state when rendering on the render thread or serializing it"

This reverts commit 2f49a551c1.

* Add comments that describe the synchronization within GPU3D_Soft

- I need to understand it before I can solve my actual problem
- Now I do

* Revert "Revert "Lock the GPU3D state when rendering on the render thread or serializing it""

This reverts commit 1977566a6d.

* Let's try locking the GPU3D state throughout NDS::RunFrame

- Just to see what happens

* Slim down the lock's scope

* Narrow the lock's scope some more

* Remove the lock entirely

* Try protecting the GPU3D state with just a mutex

- I'll clean this up once I know it works

* Remove a duplicate method definition

* Add a missing `noexcept` specifier

* Remove an unused function

* Cut some non-hardware state from `GPU3D`'s savestate

* Assume that the next frame after loading a savestate won't be identical

* Actually, it _is_ worth it

* Don't serialize the clip matrix

- It's recalculated anyway

* Serialize `RenderPolygonRAM` as an array of indexes

* Clean up some comments

- I liked the dialogue style, but oh well

* Try restarting the render thread instead of using the lock

- Let's see what happens

* Put the lock back

* Fix some polygon and vertex indexes being saved incorrectly

- Taking the difference between two pointers results in the number of elements, not the number of bytes

* Remove `SoftRenderer::StateBusy` since it turns out we don't need it

- The real synchronization was the friends we made along the way
2024-01-07 23:39:43 +01:00
f68f55d002 Reset the JIT when loading savestate (#1937)
The effect of this change is simply to call JitEnableWrite(), which is
necessary on apple silicon
2024-01-03 14:42:08 +01:00
d1cbc41115 Slight fixups with FATStorage (#1934)
* Reload the SD card for `CartSD` and all subclasses

* Make `ROMManager::LoadDLDISDCard` delegate to `GetDLDISDCardArgs`

* Add a method overload for `CartSD::SetSDCard`

* Initialize new SD card images with the correct size

* Sync the old card to the host (if applicable) when move-assigning a new one

* Only sync the old card to the host if it's not read-only

* Remove static state in `FATStorage`

- Replace `FF_ReadStorage` and `FF_WriteStorage` with lambda functions
- Keep open and use the single `File` handle throughout the `FATStorage`'s life
2024-01-03 13:32:17 +01:00
8bfc6df8de TitleManagerDialog: Fix wrong color format 2023-12-31 13:52:58 +01:00
a4b2b0c40d Resolve or silence some warnings (#1905)
* Resolve some warnings

- Their frequent appearance in the build logs is driving me nuts

* Silence warnings about `offsetof`

* Don't apply `-Wno-invalid-offset` to C, only to C++
2023-12-28 14:54:31 +01:00
345b7439e4 integrate OSD into ScreenPanel and make it nicer 2023-12-28 14:40:37 +01:00
5a08118c87 sfjsh 2023-12-27 21:28:03 +01:00
cbd65a131e Add alignas specifiers to some arrays based on how they're accessed (#1933)
* Align some two-element `u32` arrays as `u64`s

- To pacify "unaligned read/write" warnings from UBSan

* Align some more arrays based on how they're accessed
2023-12-26 22:09:39 +01:00
ab8938a695 fix OSD scaling on hiDPI screens 2023-12-26 19:32:38 +01:00
f905b6fb93 separate EmuThread to its own file 2023-12-26 19:24:14 +01:00
fd1e4379b9 Merge branch 'master' of github.com:melonDS-emu/melonDS 2023-12-26 19:04:31 +01:00
7f437d48db start cleaning up: move OpenGL stuff out of EmuThread 2023-12-26 19:04:01 +01:00
d55a384c88 Apply some quick hotfixes (#1931) 2023-12-26 16:34:04 +01:00
740489f7a4 Don't call Reset on nullptr 2023-12-26 08:49:02 +01:00
ac3153d86b "Incorrectly" link libslirp to stop its broken build system fucking up
our linker flags
2023-12-26 08:14:30 +01:00
f16de402cf Screen.cpp: include missing headers 2023-12-26 04:26:38 +01:00
5c90cb939d oops 2023-12-25 22:52:44 +01:00
80c6dd524b add convenience method to Window class for OSD messages 2023-12-25 16:34:29 +01:00
6a1232b9a9 move MainWindow and Screen stuff to separate files; WIP 2023-12-24 15:11:30 +01:00
f580d20a7b Support GBA .sav file with appended .rtc (#1927)
* Support GBA .sav file with appended .rtc

* Change comment
2023-12-24 01:09:43 +01:00
de4ae9dd92 fix possible crash 2023-12-23 23:59:59 +01:00
989b93c92a do not access NDS object emulation is paused 2023-12-22 23:30:59 +01:00
521fc249a3 Don't try to call transferLayout on non-GL ScreenPanel 2023-12-22 02:17:26 +01:00
752b37ed82 Attempt to get rid of leftover QSharedMemory instance after crash 2023-12-22 01:35:45 +01:00
084747abc5 Reset DS object directly after creation 2023-12-21 22:15:12 +01:00
ed650f2b46 call Reset on 3D renderer object 2023-12-21 21:43:57 +01:00
fd3c349735 Check Q_OS_UNIX define instead 2023-12-20 21:38:55 +01:00
6c6318b63b Fix generic icon when using Wayland 2023-12-20 21:38:55 +01:00
01f8ad009e Wrap the EnableJIT initialization in an #ifdef (#1922) 2023-12-20 14:25:49 +01:00
4b4239de62 Set NDS::EnableJIT in the constructor (#1921) 2023-12-19 15:15:35 +01:00
1bec2a9293 Fix an incorrect use of std::move (#1919)
- When I adapted `GBACart::ParseROM` to use `unique_ptr` instead of a plain pointer, I forgot to remove the code that copied the SRAM data
- That code was made unnecessary because of the move
2023-12-16 00:05:43 +01:00
eedb0ba478 Add a call to std::move that I missed (#1917) 2023-12-15 20:52:35 +01:00
e1821d0023 Simplify the SRAM's representation in NDSCartArgs (#1914)
* Simplify the SRAM's representation in  `NDSCartArgs`

- I overthought this one.
- I could've just checked `args && args->SRAM`, but then some other poor bastard might make this mistake.
- Don't mix `pair`, `optional`, and `unique_ptr` all at once, kids.

* Fix a `nullptr` read
2023-12-15 14:56:10 +01:00
24c402af51 Fix detection of native NDS ARM BIOS images (#1910)
* Fix detection of native NDS ARM BIOS images

- Instead of checking for built-in BIOS images, now the altered methods check for native ones
- The CRC32 must match exactly; patched BIOS images will result in `false`

* Encapsulate `NDS::ARM9BIOS` and `ARM7BIOS`

- Also compute the checksum only when setting the BIOS
2023-12-15 14:54:41 +01:00
c867a7f1c0 Make the initial 3D renderer configurable via NDSArgs (#1913)
* Allow 3D renderers to be created without passing `GPU` to the constructor

* Make the initial 3D renderer configurable via `NDSArgs`

* Fix a compiler error
2023-12-15 14:53:31 +01:00
6f47c9ed4c Support emulating R4 Revolution/M3DS Simply cartridges. (#1854)
* Support emulating R4 Revolution/M3DS Simply cartridges.

* NDSCartR4: Write state information to savestate file.

* NDSCart: Use strncmp instead of strcmp for R4 detection.

* NDSCartR4: stylistic improvements

* NDSCartR4: rudimentary Ace3DS support

* NDSCartR4: fix boot when firmware enabled

* NDSCartR4: Fix for namespace changes

---------

Co-authored-by: RSDuck <RSDuck@users.noreply.github.com>
2023-12-15 08:19:53 +01:00
9bfc9c08ff Sprinkle const around where appropriate (#1909)
* Sprinkle `const` around where appropriate

- This will make it easier to use `NDS` objects in `const` contexts (e.g. `const` parameters or methods)

* Remove the `const` qualifier on `DSi_DSP::DSPRead16`

- MMIO reads can be non-pure, so this may not be `const` in the future
2023-12-12 11:07:22 +01:00
2cba2e783a fix default emu settings tab (#1912) 2023-12-12 00:04:04 +01:00
81219a9f5d Fix some conflicts with windows.h in some configurations
Fixes build in the MSYS2 Clang/ClangARM64 environments.
2023-12-11 10:59:05 +01:00
082310d5d5 hopefully reset all GPU3D attributes properly 2023-12-08 23:42:08 +01:00
6949100446 Fix GBA<->DS comm not working when using FreeBIOS
Thanks CasualPokePlayer for pointing this out
2023-12-08 18:34:38 +01:00
5ef35a4ccf Don't try to poke at the header on deinit if MPQueue is nullptr 2023-12-08 17:39:56 +01:00
5dac65f52e Fix some minor instances of undefined behavior 2023-12-08 17:19:00 +01:00
bbecab6cb0 Correctly use the refactored JitEnableWrite 2023-12-08 17:19:00 +01:00
72d4eba477 Rearrange some #includes 2023-12-08 17:19:00 +01:00
7cef13031f Add some headers that were transitively included by the JIT 2023-12-08 17:19:00 +01:00
399a6af91c Move some constants to MemConstants.h 2023-12-08 17:19:00 +01:00
53e5aa6298 Exclude JIT-related declarations more aggressively 2023-12-08 17:19:00 +01:00
733769303c Add override to the ARM64 JIT's destructor 2023-12-08 17:19:00 +01:00