Skip to content

Conversation

@JesseTG
Copy link
Contributor

@JesseTG JesseTG commented Nov 27, 2023

This PR extracts some of the mess that's in #1883 into a delta that's easier to review. That PR contains several other changes that I intend to introduce once this one is merged.

This PR refactors the NDS and DSi namespaces to be objects that can be created and destroyed at will.

Marked as a draft because it crashes the emulator upon boot, so I'd like to fix that first. I'd also like to fix the build on other platforms besides my own. Fixed those builds.

- Remove all global/`static` variables in `NDS` and related classes
- Rely more on virtual dispatch when we need to pick methods at runtime
- Pass `NDS&` or `DSi&` to its constituent components where necessary
- Introduce some headers or move some definitions to break `#include` cycles
- Move it to before the components are initialized so the `map`s inside are initialized
- Fields in C++ are initialized in the order they're declared
- Explicitly qualify some member types in NDS, since they share the same name as their classes
- This was causing the build to fail on macOS
@JesseTG JesseTG marked this pull request as ready for review November 27, 2023 15:23
Copy link
Member

@RSDuck RSDuck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@Arisotura
Copy link
Member

looks good to me

@Arisotura Arisotura merged commit e973236 into melonDS-emu:master Nov 28, 2023
kvnp pushed a commit to kvnp/melonDS that referenced this pull request Dec 25, 2023
* First crack at refactoring NDS and DSi into objects

- Remove all global/`static` variables in `NDS` and related classes
- Rely more on virtual dispatch when we need to pick methods at runtime
- Pass `NDS&` or `DSi&` to its constituent components where necessary
- Introduce some headers or move some definitions to break `#include` cycles

* Refactor the frontend to accommodate the core's changes

* Move up `SchedList`'s declaration

- Move it to before the components are initialized so the `map`s inside are initialized
- Fields in C++ are initialized in the order they're declared

* Fix a crash when allocating memory

* Fix JIT-free builds

* Fix GDB-free builds

* Fix Linux builds

- Explicitly qualify some member types in NDS, since they share the same name as their classes

* Remove an unnecessary template argument

- This was causing the build to fail on macOS

* Fix ARM and Android builds

* Rename `Constants.h` to `MemConstants.h`

* Add `NDS::IsRunning()`

* Use an `#include` guard instead of `#pragma once`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants