2016-12-05 17:02:29 +00:00
|
|
|
/*
|
2024-06-15 15:01:19 +00:00
|
|
|
Copyright 2016-2024 melonDS team
|
2016-12-05 17:02:29 +00:00
|
|
|
|
|
|
|
This file is part of melonDS.
|
|
|
|
|
|
|
|
melonDS is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with melonDS. If not, see http://www.gnu.org/licenses/.
|
|
|
|
*/
|
2016-05-16 15:48:40 +00:00
|
|
|
|
|
|
|
#ifndef NDS_H
|
|
|
|
#define NDS_H
|
|
|
|
|
2023-11-09 20:54:51 +00:00
|
|
|
#include <memory>
|
2022-01-07 13:00:43 +00:00
|
|
|
#include <string>
|
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 16:57:22 +00:00
|
|
|
#include <optional>
|
2023-11-02 20:04:09 +00:00
|
|
|
#include <functional>
|
2022-01-07 13:00:43 +00:00
|
|
|
|
2023-08-18 20:50:57 +00:00
|
|
|
#include "Platform.h"
|
2018-09-15 00:47:34 +00:00
|
|
|
#include "Savestate.h"
|
2016-05-16 15:48:40 +00:00
|
|
|
#include "types.h"
|
2023-11-09 17:57:16 +00:00
|
|
|
#include "NDSCart.h"
|
2023-11-08 21:21:21 +00:00
|
|
|
#include "GBACart.h"
|
2023-11-28 22:16:41 +00:00
|
|
|
#include "SPU.h"
|
|
|
|
#include "SPI.h"
|
|
|
|
#include "RTC.h"
|
|
|
|
#include "Wifi.h"
|
|
|
|
#include "AREngine.h"
|
|
|
|
#include "GPU.h"
|
|
|
|
#include "ARMJIT.h"
|
2023-12-06 14:19:24 +00:00
|
|
|
#include "MemRegion.h"
|
|
|
|
#include "ARMJIT_Memory.h"
|
|
|
|
#include "ARM.h"
|
2023-12-15 13:54:41 +00:00
|
|
|
#include "CRC32.h"
|
2023-11-28 22:16:41 +00:00
|
|
|
#include "DMA.h"
|
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 16:57:22 +00:00
|
|
|
#include "FreeBIOS.h"
|
2016-05-16 15:48:40 +00:00
|
|
|
|
2018-12-11 14:56:34 +00:00
|
|
|
// when touching the main loop/timing code, pls test a lot of shit
|
|
|
|
// with this enabled, to make sure it doesn't desync
|
|
|
|
//#define DEBUG_CHECK_DESYNC
|
|
|
|
|
2023-11-25 17:32:09 +00:00
|
|
|
namespace melonDS
|
|
|
|
{
|
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 16:57:22 +00:00
|
|
|
struct NDSArgs;
|
|
|
|
class Firmware;
|
2017-01-30 17:36:11 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-02-03 17:47:40 +00:00
|
|
|
Event_LCD = 0,
|
2017-04-06 17:44:34 +00:00
|
|
|
Event_SPU,
|
2017-05-01 20:27:05 +00:00
|
|
|
Event_Wifi,
|
2023-10-30 17:37:49 +00:00
|
|
|
Event_RTC,
|
2017-01-30 17:36:11 +00:00
|
|
|
|
2017-06-26 09:02:10 +00:00
|
|
|
Event_DisplayFIFO,
|
2017-04-11 18:21:31 +00:00
|
|
|
Event_ROMTransfer,
|
2017-07-15 17:29:10 +00:00
|
|
|
Event_ROMSPITransfer,
|
|
|
|
Event_SPITransfer,
|
2017-07-15 17:46:27 +00:00
|
|
|
Event_Div,
|
|
|
|
Event_Sqrt,
|
2017-04-11 18:21:31 +00:00
|
|
|
|
2019-06-18 12:12:37 +00:00
|
|
|
// DSi
|
2019-07-24 16:48:52 +00:00
|
|
|
Event_DSi_SDMMCTransfer,
|
|
|
|
Event_DSi_SDIOTransfer,
|
2019-08-04 00:16:16 +00:00
|
|
|
Event_DSi_NWifi,
|
2020-10-26 20:54:08 +00:00
|
|
|
Event_DSi_CamIRQ,
|
|
|
|
Event_DSi_CamTransfer,
|
2021-06-06 16:27:26 +00:00
|
|
|
Event_DSi_DSP,
|
2020-08-17 17:15:45 +00:00
|
|
|
|
2017-01-30 17:36:11 +00:00
|
|
|
Event_MAX
|
|
|
|
};
|
|
|
|
|
2023-11-02 20:04:09 +00:00
|
|
|
typedef std::function<void(u32)> EventFunc;
|
|
|
|
#define MemberEventFunc(cls,func) std::bind(&cls::func,this,std::placeholders::_1)
|
2023-11-28 22:16:41 +00:00
|
|
|
struct SchedEvent
|
|
|
|
{
|
|
|
|
std::map<u32, EventFunc> Funcs;
|
|
|
|
u64 Timestamp;
|
|
|
|
u32 FuncID;
|
|
|
|
u32 Param;
|
|
|
|
};
|
2016-12-04 02:20:50 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IRQ_VBlank = 0,
|
|
|
|
IRQ_HBlank,
|
|
|
|
IRQ_VCount,
|
|
|
|
IRQ_Timer0,
|
|
|
|
IRQ_Timer1,
|
|
|
|
IRQ_Timer2,
|
|
|
|
IRQ_Timer3,
|
|
|
|
IRQ_RTC,
|
|
|
|
IRQ_DMA0,
|
|
|
|
IRQ_DMA1,
|
|
|
|
IRQ_DMA2,
|
|
|
|
IRQ_DMA3,
|
|
|
|
IRQ_Keypad,
|
|
|
|
IRQ_GBASlot,
|
|
|
|
IRQ_Unused14,
|
|
|
|
IRQ_Unused15,
|
|
|
|
IRQ_IPCSync,
|
|
|
|
IRQ_IPCSendDone,
|
|
|
|
IRQ_IPCRecv,
|
2021-04-24 22:48:02 +00:00
|
|
|
IRQ_CartXferDone,
|
2020-09-08 18:19:37 +00:00
|
|
|
IRQ_CartIREQMC, // IRQ triggered by game cart (example: Pokémon Typing Adventure, BT controller)
|
2016-12-04 02:20:50 +00:00
|
|
|
IRQ_GXFIFO,
|
|
|
|
IRQ_LidOpen,
|
|
|
|
IRQ_SPI,
|
2019-06-16 13:05:18 +00:00
|
|
|
IRQ_Wifi,
|
|
|
|
|
|
|
|
// DSi IRQs
|
|
|
|
IRQ_DSi_DSP = 24,
|
|
|
|
IRQ_DSi_Camera,
|
|
|
|
IRQ_DSi_Unk26,
|
|
|
|
IRQ_DSi_Unk27,
|
|
|
|
IRQ_DSi_NDMA0,
|
|
|
|
IRQ_DSi_NDMA1,
|
|
|
|
IRQ_DSi_NDMA2,
|
|
|
|
IRQ_DSi_NDMA3,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// DSi ARM7-side IE2/IF2
|
|
|
|
IRQ2_DSi_GPIO18_0 = 0,
|
|
|
|
IRQ2_DSi_GPIO18_1,
|
|
|
|
IRQ2_DSi_GPIO18_2,
|
2019-06-18 20:54:07 +00:00
|
|
|
IRQ2_DSi_Unused3,
|
2019-06-16 13:05:18 +00:00
|
|
|
IRQ2_DSi_GPIO33_0,
|
|
|
|
IRQ2_DSi_Headphone,
|
2023-04-04 10:31:58 +00:00
|
|
|
IRQ2_DSi_BPTWL,
|
2019-06-16 13:05:18 +00:00
|
|
|
IRQ2_DSi_GPIO33_3, // "sound enable input"
|
|
|
|
IRQ2_DSi_SDMMC,
|
|
|
|
IRQ2_DSi_SD_Data1,
|
|
|
|
IRQ2_DSi_SDIO,
|
|
|
|
IRQ2_DSi_SDIO_Data1,
|
|
|
|
IRQ2_DSi_AES,
|
|
|
|
IRQ2_DSi_I2C,
|
|
|
|
IRQ2_DSi_MicExt
|
2016-12-04 02:20:50 +00:00
|
|
|
};
|
|
|
|
|
2023-10-30 17:37:49 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CPUStop_DMA9_0 = (1<<0),
|
|
|
|
CPUStop_DMA9_1 = (1<<1),
|
|
|
|
CPUStop_DMA9_2 = (1<<2),
|
|
|
|
CPUStop_DMA9_3 = (1<<3),
|
|
|
|
CPUStop_NDMA9_0 = (1<<4),
|
|
|
|
CPUStop_NDMA9_1 = (1<<5),
|
|
|
|
CPUStop_NDMA9_2 = (1<<6),
|
|
|
|
CPUStop_NDMA9_3 = (1<<7),
|
|
|
|
CPUStop_DMA9 = 0xFFF,
|
|
|
|
|
|
|
|
CPUStop_DMA7_0 = (1<<16),
|
|
|
|
CPUStop_DMA7_1 = (1<<17),
|
|
|
|
CPUStop_DMA7_2 = (1<<18),
|
|
|
|
CPUStop_DMA7_3 = (1<<19),
|
|
|
|
CPUStop_NDMA7_0 = (1<<20),
|
|
|
|
CPUStop_NDMA7_1 = (1<<21),
|
|
|
|
CPUStop_NDMA7_2 = (1<<22),
|
|
|
|
CPUStop_NDMA7_3 = (1<<23),
|
|
|
|
CPUStop_DMA7 = (0xFFF<<16),
|
|
|
|
|
|
|
|
CPUStop_Wakeup = (1<<29),
|
|
|
|
CPUStop_Sleep = (1<<30),
|
|
|
|
CPUStop_GXStall = (1<<31),
|
|
|
|
};
|
|
|
|
|
2021-01-02 10:38:06 +00:00
|
|
|
struct Timer
|
2016-12-05 16:08:24 +00:00
|
|
|
{
|
|
|
|
u16 Reload;
|
2017-01-31 02:54:51 +00:00
|
|
|
u16 Cnt;
|
|
|
|
u32 Counter;
|
|
|
|
u32 CycleShift;
|
2021-01-02 10:38:06 +00:00
|
|
|
};
|
2016-12-05 16:08:24 +00:00
|
|
|
|
2021-08-31 00:28:34 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
Mem9_ITCM = 0x00000001,
|
|
|
|
Mem9_DTCM = 0x00000002,
|
|
|
|
Mem9_BIOS = 0x00000004,
|
|
|
|
Mem9_MainRAM = 0x00000008,
|
|
|
|
Mem9_WRAM = 0x00000010,
|
|
|
|
Mem9_IO = 0x00000020,
|
|
|
|
Mem9_Pal = 0x00000040,
|
|
|
|
Mem9_OAM = 0x00000080,
|
|
|
|
Mem9_VRAM = 0x00000100,
|
|
|
|
Mem9_GBAROM = 0x00020000,
|
|
|
|
Mem9_GBARAM = 0x00040000,
|
|
|
|
|
|
|
|
Mem7_BIOS = 0x00000001,
|
|
|
|
Mem7_MainRAM = 0x00000002,
|
|
|
|
Mem7_WRAM = 0x00000004,
|
|
|
|
Mem7_IO = 0x00000008,
|
|
|
|
Mem7_Wifi0 = 0x00000010,
|
|
|
|
Mem7_Wifi1 = 0x00000020,
|
|
|
|
Mem7_VRAM = 0x00000040,
|
|
|
|
Mem7_GBAROM = 0x00000100,
|
|
|
|
Mem7_GBARAM = 0x00000200,
|
|
|
|
|
|
|
|
// TODO: add DSi regions!
|
|
|
|
};
|
|
|
|
|
2022-01-07 13:00:43 +00:00
|
|
|
// supported GBA slot addon types
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GBAAddon_RAMExpansion = 1,
|
2024-07-21 15:01:30 +00:00
|
|
|
GBAAddon_RumblePak = 2,
|
2022-01-07 13:00:43 +00:00
|
|
|
};
|
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
class SPU;
|
|
|
|
class SPIHost;
|
|
|
|
class RTC;
|
|
|
|
class Wifi;
|
2022-01-07 13:00:43 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
class AREngine;
|
|
|
|
class GPU;
|
|
|
|
class ARMJIT;
|
2022-01-07 13:00:43 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
class NDS
|
|
|
|
{
|
2023-12-05 15:47:16 +00:00
|
|
|
private:
|
2023-11-28 22:16:41 +00:00
|
|
|
#ifdef JIT_ENABLED
|
|
|
|
bool EnableJIT;
|
|
|
|
#endif
|
2024-08-05 01:23:49 +00:00
|
|
|
#ifdef GDBSTUB_ENABLED
|
|
|
|
bool EnableGDBStub = false;
|
|
|
|
#endif
|
2023-12-05 15:47:16 +00:00
|
|
|
|
2023-12-15 13:54:41 +00:00
|
|
|
public: // TODO: Encapsulate the rest of these members
|
2024-06-15 11:52:47 +00:00
|
|
|
void* UserData;
|
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
int ConsoleType;
|
|
|
|
int CurCPU;
|
2017-02-01 20:35:00 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
SchedEvent SchedList[Event_MAX] {};
|
|
|
|
u8 ARM9MemTimings[0x40000][8];
|
|
|
|
u32 ARM9Regions[0x40000];
|
|
|
|
u8 ARM7MemTimings[0x20000][4];
|
|
|
|
u32 ARM7Regions[0x20000];
|
2016-11-24 17:31:49 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 NumFrames;
|
|
|
|
u32 NumLagFrames;
|
|
|
|
bool LagFrameFlag;
|
2016-12-23 20:22:22 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
// no need to worry about those overflowing, they can keep going for atleast 4350 years
|
|
|
|
u64 ARM9Timestamp, ARM9Target;
|
|
|
|
u64 ARM7Timestamp, ARM7Target;
|
|
|
|
u32 ARM9ClockShift;
|
2017-09-30 18:05:56 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 IME[2];
|
|
|
|
u32 IE[2];
|
|
|
|
u32 IF[2];
|
|
|
|
u32 IE2;
|
|
|
|
u32 IF2;
|
|
|
|
Timer Timers[8];
|
2018-12-14 01:36:57 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 CPUStop;
|
2018-12-12 15:33:40 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u16 PowerControl9;
|
2016-12-05 16:08:24 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u16 ExMemCnt[2];
|
2023-12-26 21:09:39 +00:00
|
|
|
alignas(u32) u8 ROMSeed0[2*8];
|
|
|
|
alignas(u32) u8 ROMSeed1[2*8];
|
2017-01-30 17:36:11 +00:00
|
|
|
|
2023-12-15 13:54:41 +00:00
|
|
|
protected:
|
|
|
|
// These BIOS arrays should be declared *before* the component objects (JIT, SPI, etc.)
|
|
|
|
// so that they're initialized before the component objects' constructors run.
|
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 16:57:22 +00:00
|
|
|
std::array<u8, ARM9BIOSSize> ARM9BIOS;
|
|
|
|
std::array<u8, ARM7BIOSSize> ARM7BIOS;
|
2023-12-15 13:54:41 +00:00
|
|
|
bool ARM9BIOSNative;
|
|
|
|
bool ARM7BIOSNative;
|
|
|
|
public: // TODO: Encapsulate the rest of these members
|
2023-11-28 22:16:41 +00:00
|
|
|
u16 ARM7BIOSProt;
|
2016-11-24 17:31:49 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u8* MainRAM;
|
|
|
|
u32 MainRAMMask;
|
2016-12-03 17:29:19 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
const u32 MainRAMMaxSize = 0x1000000;
|
2016-12-04 02:20:50 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
const u32 SharedWRAMSize = 0x8000;
|
|
|
|
u8* SharedWRAM;
|
2017-06-25 15:35:45 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
MemRegion SWRAM_ARM9;
|
|
|
|
MemRegion SWRAM_ARM7;
|
2020-02-24 17:31:44 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 KeyInput;
|
|
|
|
u16 RCnt;
|
2017-01-22 19:34:59 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
// JIT MUST be declared before all other component objects,
|
|
|
|
// as they'll need the memory that it allocates in its constructor!
|
|
|
|
// (Reminder: C++ fields are initialized in the order they're declared,
|
|
|
|
// regardless of what the constructor's initializer list says.)
|
|
|
|
melonDS::ARMJIT JIT;
|
|
|
|
ARMv5 ARM9;
|
|
|
|
ARMv4 ARM7;
|
|
|
|
melonDS::SPU SPU;
|
|
|
|
SPIHost SPI;
|
|
|
|
melonDS::RTC RTC;
|
|
|
|
melonDS::Wifi Wifi;
|
|
|
|
NDSCart::NDSCartSlot NDSCartSlot;
|
|
|
|
GBACart::GBACartSlot GBACartSlot;
|
|
|
|
melonDS::GPU GPU;
|
|
|
|
melonDS::AREngine AREngine;
|
2017-03-20 16:39:42 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
const u32 ARM7WRAMSize = 0x10000;
|
|
|
|
u8* ARM7WRAM;
|
2016-11-03 00:38:58 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
virtual void Reset();
|
|
|
|
void Start();
|
2018-11-04 22:21:58 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
/// Stop the emulator.
|
|
|
|
virtual void Stop(Platform::StopReason reason = Platform::StopReason::External);
|
2016-05-16 15:48:40 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
bool DoSavestate(Savestate* file);
|
2018-11-04 22:21:58 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
void SetARM9RegionTimings(u32 addrstart, u32 addrend, u32 region, int buswidth, int nonseq, int seq);
|
|
|
|
void SetARM7RegionTimings(u32 addrstart, u32 addrend, u32 region, int buswidth, int nonseq, int seq);
|
2017-01-17 01:29:25 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
void LoadBIOS();
|
2023-12-15 13:54:41 +00:00
|
|
|
|
|
|
|
/// @return \c true if the loaded ARM9 BIOS image is a known dump
|
|
|
|
/// of a native DS-compatible ARM9 BIOS.
|
|
|
|
[[nodiscard]] bool IsLoadedARM9BIOSKnownNative() const noexcept { return ARM9BIOSNative; }
|
|
|
|
[[nodiscard]] const std::array<u8, ARM9BIOSSize>& GetARM9BIOS() const noexcept { return ARM9BIOS; }
|
|
|
|
void SetARM9BIOS(const std::array<u8, ARM9BIOSSize>& bios) noexcept;
|
|
|
|
|
|
|
|
[[nodiscard]] const std::array<u8, ARM7BIOSSize>& GetARM7BIOS() const noexcept { return ARM7BIOS; }
|
|
|
|
void SetARM7BIOS(const std::array<u8, ARM7BIOSSize>& bios) noexcept;
|
|
|
|
|
|
|
|
/// @return \c true if the loaded ARM7 BIOS image is a known dump
|
|
|
|
/// of a native DS-compatible ARM9 BIOS.
|
|
|
|
[[nodiscard]] bool IsLoadedARM7BIOSKnownNative() const noexcept { return ARM7BIOSNative; }
|
2023-11-28 22:16:41 +00:00
|
|
|
|
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 16:57:22 +00:00
|
|
|
[[nodiscard]] NDSCart::CartCommon* GetNDSCart() { return NDSCartSlot.GetCart(); }
|
|
|
|
[[nodiscard]] const NDSCart::CartCommon* GetNDSCart() const { return NDSCartSlot.GetCart(); }
|
|
|
|
virtual void SetNDSCart(std::unique_ptr<NDSCart::CartCommon>&& cart);
|
|
|
|
[[nodiscard]] bool CartInserted() const noexcept { return NDSCartSlot.GetCart() != nullptr; }
|
|
|
|
virtual std::unique_ptr<NDSCart::CartCommon> EjectCart() { return NDSCartSlot.EjectCart(); }
|
|
|
|
|
|
|
|
[[nodiscard]] u8* GetNDSSave() { return NDSCartSlot.GetSaveMemory(); }
|
|
|
|
[[nodiscard]] const u8* GetNDSSave() const { return NDSCartSlot.GetSaveMemory(); }
|
|
|
|
[[nodiscard]] u32 GetNDSSaveLength() const { return NDSCartSlot.GetSaveMemoryLength(); }
|
|
|
|
void SetNDSSave(const u8* savedata, u32 savelen);
|
|
|
|
|
|
|
|
const Firmware& GetFirmware() const { return SPI.GetFirmwareMem()->GetFirmware(); }
|
|
|
|
Firmware& GetFirmware() { return SPI.GetFirmwareMem()->GetFirmware(); }
|
|
|
|
void SetFirmware(Firmware&& firmware) { SPI.GetFirmwareMem()->SetFirmware(std::move(firmware)); }
|
2023-11-28 22:16:41 +00:00
|
|
|
|
2023-12-15 13:53:31 +00:00
|
|
|
const Renderer3D& GetRenderer3D() const noexcept { return GPU.GetRenderer3D(); }
|
|
|
|
Renderer3D& GetRenderer3D() noexcept { return GPU.GetRenderer3D(); }
|
|
|
|
void SetRenderer3D(std::unique_ptr<Renderer3D>&& renderer) noexcept
|
|
|
|
{
|
|
|
|
if (renderer != nullptr)
|
|
|
|
GPU.SetRenderer3D(std::move(renderer));
|
|
|
|
}
|
|
|
|
|
2023-12-12 10:07:22 +00:00
|
|
|
virtual bool NeedsDirectBoot() const;
|
2023-11-28 22:16:41 +00:00
|
|
|
void SetupDirectBoot(const std::string& romname);
|
|
|
|
virtual void SetupDirectBoot();
|
|
|
|
|
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 16:57:22 +00:00
|
|
|
[[nodiscard]] GBACart::CartCommon* GetGBACart() { return (ConsoleType == 1) ? nullptr : GBACartSlot.GetCart(); }
|
|
|
|
[[nodiscard]] const GBACart::CartCommon* GetGBACart() const { return (ConsoleType == 1) ? nullptr : GBACartSlot.GetCart(); }
|
|
|
|
|
|
|
|
/// Inserts a GBA cart into the emulated console's Slot-2.
|
|
|
|
///
|
|
|
|
/// @param cart The GBA cart, most likely (but not necessarily) returned from GBACart::ParseROM.
|
|
|
|
/// To insert an accessory that doesn't use a ROM image
|
|
|
|
/// (e.g. the Expansion Pak), create it manually and pass it here.
|
|
|
|
/// If \c nullptr, the existing cart is ejected.
|
|
|
|
/// If this is a DSi, this method does nothing.
|
|
|
|
///
|
|
|
|
/// @post \c cart is \c nullptr and this NDS takes ownership
|
|
|
|
/// of the cart object it held, if any.
|
|
|
|
void SetGBACart(std::unique_ptr<GBACart::CartCommon>&& cart) { if (ConsoleType == 0) GBACartSlot.SetCart(std::move(cart)); }
|
|
|
|
|
|
|
|
u8* GetGBASave() { return GBACartSlot.GetSaveMemory(); }
|
|
|
|
const u8* GetGBASave() const { return GBACartSlot.GetSaveMemory(); }
|
|
|
|
u32 GetGBASaveLength() const { return GBACartSlot.GetSaveMemoryLength(); }
|
|
|
|
void SetGBASave(const u8* savedata, u32 savelen);
|
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
void LoadGBAAddon(int type);
|
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 16:57:22 +00:00
|
|
|
std::unique_ptr<GBACart::CartCommon> EjectGBACart() { return GBACartSlot.EjectCart(); }
|
2023-11-28 22:16:41 +00:00
|
|
|
|
|
|
|
u32 RunFrame();
|
|
|
|
|
|
|
|
bool IsRunning() const noexcept { return Running; }
|
|
|
|
|
|
|
|
void TouchScreen(u16 x, u16 y);
|
|
|
|
void ReleaseScreen();
|
|
|
|
|
|
|
|
void SetKeyMask(u32 mask);
|
|
|
|
|
2023-12-12 10:07:22 +00:00
|
|
|
bool IsLidClosed() const;
|
2023-11-28 22:16:41 +00:00
|
|
|
void SetLidClosed(bool closed);
|
|
|
|
|
2023-12-12 10:07:22 +00:00
|
|
|
virtual void CamInputFrame(int cam, const u32* data, int width, int height, bool rgb) {}
|
2023-11-28 22:16:41 +00:00
|
|
|
void MicInputFrame(s16* data, int samples);
|
|
|
|
|
|
|
|
void RegisterEventFunc(u32 id, u32 funcid, EventFunc func);
|
|
|
|
void UnregisterEventFunc(u32 id, u32 funcid);
|
|
|
|
void ScheduleEvent(u32 id, bool periodic, s32 delay, u32 funcid, u32 param);
|
|
|
|
void CancelEvent(u32 id);
|
|
|
|
|
|
|
|
void debug(u32 p);
|
|
|
|
|
|
|
|
void Halt();
|
|
|
|
|
|
|
|
void MapSharedWRAM(u8 val);
|
|
|
|
|
|
|
|
void UpdateIRQ(u32 cpu);
|
|
|
|
void SetIRQ(u32 cpu, u32 irq);
|
|
|
|
void ClearIRQ(u32 cpu, u32 irq);
|
|
|
|
void SetIRQ2(u32 irq);
|
|
|
|
void ClearIRQ2(u32 irq);
|
2023-12-12 10:07:22 +00:00
|
|
|
bool HaltInterrupted(u32 cpu) const;
|
2023-11-28 22:16:41 +00:00
|
|
|
void StopCPU(u32 cpu, u32 mask);
|
|
|
|
void ResumeCPU(u32 cpu, u32 mask);
|
|
|
|
void GXFIFOStall();
|
|
|
|
void GXFIFOUnstall();
|
|
|
|
|
2023-12-12 10:07:22 +00:00
|
|
|
u32 GetPC(u32 cpu) const;
|
2023-11-28 22:16:41 +00:00
|
|
|
u64 GetSysClockCycles(int num);
|
2024-07-30 23:13:06 +00:00
|
|
|
void NocashPrint(u32 cpu, u32 addr, bool appendNewline = true);
|
2023-11-28 22:16:41 +00:00
|
|
|
|
|
|
|
void MonitorARM9Jump(u32 addr);
|
|
|
|
|
2023-12-12 10:07:22 +00:00
|
|
|
virtual bool DMAsInMode(u32 cpu, u32 mode) const;
|
|
|
|
virtual bool DMAsRunning(u32 cpu) const;
|
2023-11-28 22:16:41 +00:00
|
|
|
virtual void CheckDMAs(u32 cpu, u32 mode);
|
|
|
|
virtual void StopDMAs(u32 cpu, u32 mode);
|
|
|
|
|
|
|
|
void RunTimers(u32 cpu);
|
|
|
|
|
|
|
|
virtual u8 ARM9Read8(u32 addr);
|
|
|
|
virtual u16 ARM9Read16(u32 addr);
|
|
|
|
virtual u32 ARM9Read32(u32 addr);
|
|
|
|
virtual void ARM9Write8(u32 addr, u8 val);
|
|
|
|
virtual void ARM9Write16(u32 addr, u16 val);
|
|
|
|
virtual void ARM9Write32(u32 addr, u32 val);
|
|
|
|
|
|
|
|
virtual bool ARM9GetMemRegion(u32 addr, bool write, MemRegion* region);
|
|
|
|
|
|
|
|
virtual u8 ARM7Read8(u32 addr);
|
|
|
|
virtual u16 ARM7Read16(u32 addr);
|
|
|
|
virtual u32 ARM7Read32(u32 addr);
|
|
|
|
virtual void ARM7Write8(u32 addr, u8 val);
|
|
|
|
virtual void ARM7Write16(u32 addr, u16 val);
|
|
|
|
virtual void ARM7Write32(u32 addr, u32 val);
|
|
|
|
|
|
|
|
virtual bool ARM7GetMemRegion(u32 addr, bool write, MemRegion* region);
|
|
|
|
|
|
|
|
virtual u8 ARM9IORead8(u32 addr);
|
|
|
|
virtual u16 ARM9IORead16(u32 addr);
|
|
|
|
virtual u32 ARM9IORead32(u32 addr);
|
|
|
|
virtual void ARM9IOWrite8(u32 addr, u8 val);
|
|
|
|
virtual void ARM9IOWrite16(u32 addr, u16 val);
|
|
|
|
virtual void ARM9IOWrite32(u32 addr, u32 val);
|
|
|
|
|
|
|
|
virtual u8 ARM7IORead8(u32 addr);
|
|
|
|
virtual u16 ARM7IORead16(u32 addr);
|
|
|
|
virtual u32 ARM7IORead32(u32 addr);
|
|
|
|
virtual void ARM7IOWrite8(u32 addr, u8 val);
|
|
|
|
virtual void ARM7IOWrite16(u32 addr, u16 val);
|
|
|
|
virtual void ARM7IOWrite32(u32 addr, u32 val);
|
|
|
|
|
2023-12-05 15:47:16 +00:00
|
|
|
#ifdef JIT_ENABLED
|
|
|
|
[[nodiscard]] bool IsJITEnabled() const noexcept { return EnableJIT; }
|
|
|
|
void SetJITArgs(std::optional<JITArgs> args) noexcept;
|
2023-12-06 14:12:56 +00:00
|
|
|
#else
|
|
|
|
[[nodiscard]] bool IsJITEnabled() const noexcept { return false; }
|
|
|
|
void SetJITArgs(std::optional<JITArgs> args) noexcept {}
|
2023-12-05 15:47:16 +00:00
|
|
|
#endif
|
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
private:
|
|
|
|
void InitTimings();
|
|
|
|
u32 SchedListMask;
|
|
|
|
u64 SysTimestamp;
|
|
|
|
u8 WRAMCnt;
|
|
|
|
u8 PostFlag9;
|
|
|
|
u8 PostFlag7;
|
|
|
|
u16 PowerControl7;
|
|
|
|
u16 WifiWaitCnt;
|
|
|
|
u8 TimerCheckMask[2];
|
|
|
|
u64 TimerTimestamp[2];
|
|
|
|
DMA DMAs[8];
|
|
|
|
u32 DMA9Fill[4];
|
|
|
|
u16 IPCSync9, IPCSync7;
|
|
|
|
u16 IPCFIFOCnt9, IPCFIFOCnt7;
|
|
|
|
FIFO<u32, 16> IPCFIFO9; // FIFO in which the ARM9 writes
|
|
|
|
FIFO<u32, 16> IPCFIFO7;
|
|
|
|
u16 DivCnt;
|
2023-12-26 21:09:39 +00:00
|
|
|
alignas(u64) u32 DivNumerator[2];
|
|
|
|
alignas(u64) u32 DivDenominator[2];
|
|
|
|
alignas(u64) u32 DivQuotient[2];
|
|
|
|
alignas(u64) u32 DivRemainder[2];
|
2023-11-28 22:16:41 +00:00
|
|
|
u16 SqrtCnt;
|
2023-12-26 21:09:39 +00:00
|
|
|
alignas(u64) u32 SqrtVal[2];
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 SqrtRes;
|
|
|
|
u16 KeyCnt[2];
|
|
|
|
bool Running;
|
|
|
|
bool RunningGame;
|
|
|
|
u64 LastSysClockCycles;
|
|
|
|
u64 FrameStartTimestamp;
|
|
|
|
u64 NextTarget();
|
|
|
|
u64 NextTargetSleep();
|
|
|
|
void CheckKeyIRQ(u32 cpu, u32 oldkey, u32 newkey);
|
|
|
|
void Reschedule(u64 target);
|
|
|
|
void RunSystemSleep(u64 timestamp);
|
|
|
|
void RunSystem(u64 timestamp);
|
|
|
|
void HandleTimerOverflow(u32 tid);
|
|
|
|
u16 TimerGetCounter(u32 timer);
|
|
|
|
void TimerStart(u32 id, u16 cnt);
|
|
|
|
void StartDiv();
|
|
|
|
void DivDone(u32 param);
|
|
|
|
void SqrtDone(u32 param);
|
|
|
|
void StartSqrt();
|
|
|
|
void RunTimer(u32 tid, s32 cycles);
|
|
|
|
void UpdateWifiTimings();
|
|
|
|
void SetWifiWaitCnt(u16 val);
|
|
|
|
void SetGBASlotTimings();
|
|
|
|
void EnterSleepMode();
|
2024-08-05 01:23:49 +00:00
|
|
|
template <CPUExecuteMode cpuMode>
|
2023-11-28 22:16:41 +00:00
|
|
|
u32 RunFrame();
|
2024-08-05 01:23:49 +00:00
|
|
|
|
2023-11-28 22:16:41 +00:00
|
|
|
public:
|
2024-06-15 11:52:47 +00:00
|
|
|
NDS(NDSArgs&& args, void* userdata = nullptr) noexcept : NDS(std::move(args), 0, userdata) {}
|
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 16:57:22 +00:00
|
|
|
NDS() noexcept;
|
2023-11-28 22:16:41 +00:00
|
|
|
virtual ~NDS() noexcept;
|
|
|
|
NDS(const NDS&) = delete;
|
|
|
|
NDS& operator=(const NDS&) = delete;
|
|
|
|
NDS(NDS&&) = delete;
|
|
|
|
NDS& operator=(NDS&&) = delete;
|
|
|
|
// The frontend should set and unset this manually after creating and destroying the NDS object.
|
|
|
|
[[deprecated("Temporary workaround until JIT code generation is revised to accommodate multiple NDS objects.")]] static NDS* Current;
|
|
|
|
protected:
|
2024-06-15 11:52:47 +00:00
|
|
|
explicit NDS(NDSArgs&& args, int type, void* userdata) noexcept;
|
2023-11-28 22:16:41 +00:00
|
|
|
virtual void DoSavestateExtra(Savestate* file) {}
|
|
|
|
};
|
2016-05-16 15:48:40 +00:00
|
|
|
|
2023-11-25 17:32:09 +00:00
|
|
|
}
|
2016-05-16 15:48:40 +00:00
|
|
|
#endif // NDS_H
|