Commit Graph

2266 Commits

Author SHA1 Message Date
Jaklyy
6cee0a7ad7 no idea how that one slipped in 2023-12-20 23:15:07 -05:00
Jaklyy
8cc42490de fix build but also sw renderer crashes now 2023-12-20 21:54:03 -05:00
Jaklyy
4c2e03af53 Merge branch 'master' of https://github.com/melonDS-emu/melonDS into RDLines 2023-12-20 20:55:35 -05:00
Nadia Holmquist Pedersen
fd3c349735 Check Q_OS_UNIX define instead 2023-12-20 21:38:55 +01:00
Daniel Simon
6c6318b63b Fix generic icon when using Wayland 2023-12-20 21:38:55 +01:00
Jesse Talavera
01f8ad009e
Wrap the EnableJIT initialization in an #ifdef (#1922) 2023-12-20 14:25:49 +01:00
Jaklyy
1054011c90 wip 2023-12-19 22:52:54 -05:00
Jesse Talavera
4b4239de62
Set NDS::EnableJIT in the constructor (#1921) 2023-12-19 15:15:35 +01:00
Jesse Talavera
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
Jesse Talavera
eedb0ba478
Add a call to std::move that I missed (#1917) 2023-12-15 20:52:35 +01:00
Jesse Talavera
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
Jesse Talavera
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
Jesse Talavera
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
Adrian Siekierka
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
Jaklyy
2217a34d39 misc improvements 2023-12-14 23:00:12 -05:00
Jaklyy
a46316d71f improved timings for the first 50 scanlines 2023-12-14 15:18:39 -05:00
Jesse Talavera
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
Jaklyy
24eecec50f implement first draft of improved timing structure 2023-12-12 00:01:26 -05:00
Jaklyy
2cba2e783a
fix default emu settings tab (#1912) 2023-12-12 00:04:04 +01:00
Nadia Holmquist Pedersen
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
Jaklyy
0d6a8e0fb9 ok this one actually works 2023-12-10 19:22:30 -05:00
Jaklyy
2bf033e0bc optimize per pixel timing counting 2023-12-10 18:51:00 -05:00
Jaklyy
785fab024f dont use templates
bigger code <<< slower code
2023-12-10 13:03:54 -05:00
Jaklyy
63a39b130e refactor framebuffers to be more similar to hw
allows for emulation of niche scanline glitches
2023-12-10 12:18:46 -05:00
Jaklyy
c45d3320d0 tentative timings for "empty" polys scanlines, fix swapped polys breaking 2023-12-09 15:56:36 -05:00
Jaklyy
92ca04e479 i forgot i changed those-- oops
no wonder edge marking was broken
how did this even still work
2023-12-09 10:58:23 -05:00
Jaklyy
447cd50422 holds true when slopes are vertical and y > 50 2023-12-09 08:54:13 -05:00
Jaklyy
8e2c9cbff6 wip initial draft 2023-12-09 08:54:13 -05:00
RSDuck
082310d5d5 hopefully reset all GPU3D attributes properly 2023-12-08 23:42:08 +01:00
Nadia Holmquist Pedersen
6949100446 Fix GBA<->DS comm not working when using FreeBIOS
Thanks CasualPokePlayer for pointing this out
2023-12-08 18:34:38 +01:00
Nadia Holmquist Pedersen
5ef35a4ccf Don't try to poke at the header on deinit if MPQueue is nullptr 2023-12-08 17:39:56 +01:00
Nadia Holmquist Pedersen
890a66c0eb I'm sick of this interfering with debugging 2023-12-08 17:27:06 +01:00
Jesse Talavera-Greenberg
5dac65f52e Fix some minor instances of undefined behavior 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
bbecab6cb0 Correctly use the refactored JitEnableWrite 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
72d4eba477 Rearrange some #includes 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
7cef13031f Add some headers that were transitively included by the JIT 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
399a6af91c Move some constants to MemConstants.h 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
53e5aa6298 Exclude JIT-related declarations more aggressively 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
733769303c Add override to the ARM64 JIT's destructor 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
582a421447 Don't set the JIT args if the JIT is off 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
644d190e98 Add stubs for NDS::IsJITEnabled and SetJITArgs for when the JIT is excluded 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
f4377e4f0f Remove a loose qualifier 2023-12-08 17:19:00 +01:00
Jesse Talavera-Greenberg
2a35af5bb9 Soften restrictions around ARMJIT_Memory::RemapNWRAM
- If in NDS mode, return instead of `assert`ing
- Use `static_cast` and `ConsoleType` instead of `dynamic_cast`
2023-12-08 17:19:00 +01:00
CasualPokePlayer
1b7b5106e2 FreeBIOS: Ensure upper 16 bits are cleared in the initial crc16 value.
Fixes Castlevania: Dawn of Sorrow's checksumming which uses crc16 swi and has garbage in the upper 16 bits of r0.
The official BIOS would seem to implicitly clear these upper 16 bits.
2023-12-06 16:51:22 +01:00
Jesse Talavera
090627b3c1
Remove the last ConfigEntry state (#1902)
* Get rid of `ConfigEntry::ExternalBIOSEnable`

- Now the BIOS files themselves are checked
- The frontend's `Config::ExternalBIOSEnable` is not affected

* Add `JITArgs`

* Pass the JIT status to the `ARM` constructors

* Encapsulate `NDS::EnableJIT`

* Pass `JITArgs` to `ARMJIT`'s constructor

* Remove the `JIT_*` `ConfigEntry`s in favor of members

- Allow all the JIT args to be set with `NDS::SetJITArgs`
- Encapsulate the JIT-related parameters in `ARMJIT` so they can reset the block cache if changed
- Update the active (or newly-created) console in the frontend with adjusted JIT args

* Make audio bit depth and interpolation configurable in `NDSArgs`

- Define enums for both
- Give those settings default values in `NDSArgs`
- Remove `ConfigEntry::AudioBitDepth`
- Initialize these settings in the relevant SPU constructors

* Move the last DSi-specific logic in `Reset` to its own subclass

* Remove `ConfigEntry::DSi_FullBIOSBoot`

- Add members to `DSi` instead for getting and setting this
- Update the frontend to accommodate these changes

* Oops, missed a spot

* Remove `ConfigEntry::Firm_MAC` and `Platform::GetConfigArray`

- Also move the MAC parsing code to `ROMManager`

* Remove the last `ConfigEntry` state

- Make GDB support configurable via members

* Add some `#ifdef`s that I'd almost forgotten
2023-12-05 16:47:16 +01:00
Jesse Talavera
ae91d89f7c
Use a constexpr-friendly cosine implementation (#1903) 2023-12-05 12:41:28 +01:00
Jesse Talavera
2e8cca9ca1
Initialize the framebuffers within the constructor (#1901) 2023-12-04 17:57:51 +01:00
Jesse Talavera
bb42c8b639
Refactor how save data (including SD cards) is initialized (#1898)
* Remove `FATStorage::Open` and `FATStorage::Close`

- That's what the constructor and destructor are for, respectively

* Add `FATStorage::IsReadOnly`

* Slight cleanup of `FATStorage`

- Make it move-constructible and move-assignable
- Represent the absence of a sync directory with `std::optional`, not an empty string
- Add `FATStorageArgs` for later use

* Refactor `CartHomebrew` to accept an optional `FATStorageArgs`

- `CartHomebrew` uses it to load an SD card image
- Not passing a `FATStorage` directly because we won't know if we need to load the card until we parse the ROM
- Store the `FATStorage` inside a `std::optional` instead of a pointer
- `CartHomebrew::Reset` no longer reloads the SD card; the frontend needs to set it with the `SetSDCard` method

* Close `NANDImage::CurFile` when move-assigning

- Whoops

* Add `Args.h`

- To construct a `NDS` or `DSi` with arguments
- Mostly intended for system files

* Fix incorrect `final` placement

* Refactor how `DSi`'s NAND and SD card are set

- Provide them via a `DSiArgs` argument in the constructor
- Give `DSi_MMCStorage` ownership of the `NANDImage` or `FATStorage` as needed, and expose getters/setters
- Replace `DSi_SDHost::Ports` with a `array<unique_ptr, 2>` to reduce the risk of leaks
- Store `DSi_MMCStorage`'s disk images in a `std::variant`
- The SD card and NAND image are no longer reset in `Reset()`; the frontend will need to do that itself

* Add getters/setters on `DSi` itself for its storage media

* Remove newly-unused `Platform::ConfigEntry`s

* Use `DSi::SetNAND` in the frontend

* Add `EmuThread::NeedToRecreateConsole`

* Document `NDSArgs` and give its fields default values

* Refactor how system files are loaded upon construction

- Pass `NDSArgs&&` into `NDS`'s constructor
- Use `std::array` for the emulator's BIOS images and the built-in FreeBIOS, to simplify copying and comparison
- Initialize the BIOS, firmware, and SD cards from `NDSArgs` or `DSiArgs`
- Add a new default constructor for `NDS` (not `DSi`) that initializes the DS with default system files
- Embed `FirmwareMem::Firmware` directly instead of in a `unique_ptr`
- `SPIHost` now takes a `Firmware&&` that it forwards to `FirmwareMem`
- Add `Firmware` getters/setters plus `const` variants for `NDS`, `Firmware`, and `FirmwareMem`
- Simplify installation of firmware

* Initialize the DSi BIOS in the constructor

- Change `DSi::ARM9iBIOS` and `ARM7iBIOS` to `std::array`

* Update the frontend to reflect the core's changes

* Remove `DSi_SDHost::CloseHandles`

* Pass `nullopt` instead of the empty string when folder sync is off

* Deduplicate ROM extraction logic

- `LoadGBAROM` and `LoadROM` now delegate to `LoadROMData`
- Also use `unique_ptr` instead of `new[]`

* Oops, missed some `get()`'s

* Move `NDS::IsLoadedARM9BIOSBuiltIn` to the header

- So it's likelier to be inlined
- Same for the ARM7 version

* Remove `NDS::SetConsoleType`

* Add `NDS::SetFirmware`

* Move `GBACart::SetupSave` to be `protected`

- It was only ever used inside the class

* Rename `GBACart::LoadSave` to `SetSaveMemory`

- Same for the cart slot

* Declare `GBACartSlot` as a friend of `GBACart::CartCommon`

* Revise `GBACartSlot`'s getters and setters

- Rename `InsertROM` and `LoadROM` to `SetCart`
- Add a `GetCart` method

* Clean up getters and setters for NDS and GBA carts

* Clean up how carts are inserted into the slots

- Remove setters that operate directly on pointers, to simplify error-handling (use ParseROM instead)
- Add overloads for all carts that accept a `const u8*` (to copy the ROM data) and a `unique_ptr<u8[]>` (to move the ROM data)
- Store all ROM and RAM data in `unique_ptr`
- Default-initialize all fields
- Simplify constructors and destructors, inheriting where applicable

* Refactor GBA save data insertion

- Make `SetupSave` private and non-virtual and move its logic to be in `SetSaveMemory`
- Add overloads for setting save data in the constructor
- Update the SRAM completely in `SetSaveMemory`

* Clean up `NDSCart::CartCommon::SetSaveMemory`

- Move its declaration next to the other `SaveMemory` methods
- Move its (empty) implementation to the header

* Add some comments

* Add Utils.cpp and Utils.h

* Rename some functions in Utils for clarity

* Add `GBACart::ParseROM` and `NDSCart::ParseROM` overloads that accept `unique_ptr<u8[]>`

- The `u8*` overloads delegate to these new overloads
- Also move `SetupSave` for both kinds of carts to be private non-virtual methods

* Finalize the `NDSCart` refactor

- Add `NDSCartArgs` to pass to `ParseROM`
- Add SRAM arguments for all retail carts
- Initialize SRAM inside the constructor
- Delegate to other constructors where possible

* Replace `ROMManager::NDSSave` and `GBASave` with `unique_ptr`

* Make both cart slots return the previously-inserted cart in `EjectCart`

- Primarily intended for reusing carts when resetting the console

* Make `NDS::EjectCart` return the old cart

* Initialize both cart slots with the provided ROM (if any)

* Make `NDS::EjectGBACart` return the ejected cart

* Clean up some comments in Args.h

* Rename `ROMManager::LoadBIOS` to `BootToMenu`

- Clarifies the intent

* Add `ROMManager::LoadDLDISDCard`

* Add a doc comment

* Refactor how the `NDS` is created or updated

- Rewrite `CreateConsole` to read from `Config` and load system files, but accept carts as arguments
- Fail without creating an `NDS` if any required system file doesn't load
- Add `UpdateConsole`, which delegates to `CreateConsole` if switching modes or starting the app
- Use `std::variant` to indicate whether a cart should be removed, inserted, or reused
- Load all system files (plus SD cards) in `UpdateConsole`
- Eject the cart and reinsert it into the new console if applicable

* Respect some more `Config` settings in the `Load*` functions

* Remove `InstallNAND` in favor of `LoadNAND`

* Fix some potential bugs in `LoadROMData`

* Oops, forgot to delete the definition of `InstallNAND`

* Add functions to get `FATStorageArgs`

- Not the cards themselves, but to get the arguments you _would_ use to load the cards

* Refactor `ROMManager::LoadROM`

- Load the ROM and save data before trying to initialize the console

* Clean up `ROMManager::Reset` and `BootToMenu`

- Let `EmuThread::UpdateConsole` do the heavy lifting

* Clean up `LoadGBAROM`

* Remove some unused functions

* Set the default DSi BIOS to be broken in `DSiArgs`

* Respect `Config::DSiFullBIOSBoot` when loading DSi BIOS files

* Remove some more unused functions

* Remove redundant `virtual` specifiers

* Refactor `NDSCart::CartCommon::Type()` to return a member instead of a constant

- One less virtual dispatch
- The cart type is read in `NDSCartSlot::DoSavestate`, which is a path downstream (due to rewinding)

* Remove a hash that I computed for debugging purposes

* Make `ByteSwap` `constexpr`

* Remove an unused `#include`

* Remove unnecessary functions from the NDS carts

- Mostly overrides that added nothing

* Default-initialize all NDSCart fields

* Make `GBACart::Type()` not rely on virtual dispatch

- `GBACartSlot::DoSavestate` calls it, and savestates can be a hot path downstream

* Don't forget to reset the base class in `CartGameSolarSensor::Reset()`

* Remove redundant `virtual` specifiers

* Default-initialize some fields in `GBACart`

* Fix ROMs not loading from archives in the frontend

- Whoops

* Change how the `Firmware` member is declared

* Forgot an include in Utils.cpp

* Rename `FirmwareMem::Firmware` to `FirmwareData` to fix a build error on Linux

- One of these days I'll convince you people to let me use `camelCaseMemberNames`

* Add `override` to places in `DSi_MMCStorage` that warrant it

* Fix firmware saving on the frontend

- Remove `GetConfigString` and `ConfigEntry::WifiSettingsPath` while I'm at it

* Add a non-const `GetNAND()`
2023-12-04 17:57:22 +01:00
Jesse Talavera
da8d413ad9
Slight cleanup to SPU (#1900)
* Move `SPUChannel` and `SPUCaptureUnit` to be stored inside `array`s instead of allocated separately

* Default-initialize most of `SPU`'s fields

* Generate the interpolation tables at compile-time with `constexpr`

- Now it's faster and thread-safe

* Slight cleanup in SPU

- Iniitialize most fields in the class declaration

* Mark `SPU` as `explicit`
2023-12-04 17:56:01 +01:00
Jesse Talavera-Greenberg
7caddf9615
Clean up the 3D renderer for enhanced flexibility (#1895)
* Give `GPU2D::Unit` a virtual destructor

- Undefined behavior avoided!

* Add an `array2d` alias

* Move various parts of `GPU2D::SoftRenderer` to `constexpr`

- `SoftRenderer::MosaicTable` is now initialized at compile-time
- Most of the `SoftRenderer::Color*` functions are now `constexpr`
- The aforementioned functions are used with a constant value in at least one place, so they'll be at least partially computed at compile-time

* Generalize `GLRenderer::PrepareCaptureFrame`

- Declare it in the base `Renderer3D` class, but make it empty

* Remove unneeded `virtual` specifiers

* Store `Framebuffer`'s memory in `unique_ptr`s

- Reduce the risk of leaks this way

* Clean up how `GLCompositor` is initialized

- Return it as an `std::optional` instead of a `std::unique_ptr`
- Make `GLCompositor` movable
- Replace `GLCompositor`'s plain arrays with `std::array` to simplify moving

* Pass `GPU` to `GLCompositor`'s important functions instead of passing it to the constructor

* Move `GLCompositor` to be a field within `GLRenderer`

- Some methods were moved up and made `virtual`

* Fix some linker errors

* Set the renderer in the frontend

* Remove unneeded `virtual` specifiers

* Remove `RenderSettings` in favor of just exposing the relevant member variables

* Update the frontend to accommodate the core changes

* Add `constexpr` and `const` to places in the interpolator

* Qualify references to `size_t`

* Construct the `optional` directly instead of using `make_optional`

- It makes the Linux build choke
- I think it's because `GLCompositor`'s constructor is `private`
2023-11-29 15:23:11 +01:00