Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement EGG::Heap #156

Merged
merged 1 commit into from
Oct 11, 2024
Merged

Implement EGG::Heap #156

merged 1 commit into from
Oct 11, 2024

Conversation

vabold
Copy link
Owner

@vabold vabold commented Oct 7, 2024

Function addresses still need to be added, but the heaps are in a usable state. Closes #2.

@@ -11,6 +11,8 @@ namespace Host {
/// @brief The main entry point for the program.
/// @addr{0x80008EF0}
int KSystem::main(int argc, char **argv) {
EGG::Heap::initialize();
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to match base game. Can you elaborate?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This function call must happen before any allocations can be made. Otherwise, the current heap is set to nullptr, and the program segfaults.

In the base game, RKSystem::main calls RKSystem::initialize, which calls RKSystem::initMemory. initMemory is the function responsible for calling EGG::Heap::initialize and creating heaps out of the arenas. However, the base game also doesn't handle options until much later. For context, see 8000a8f0, and examine where it gets called from RKSystem::initialize - it's after.

Rather than overhaul the option parsing code (which we will need to do later), I instead opt for the simpler approach of just initializing memory immediately in KSystem::main.

source/egg/core/Heap.hh Show resolved Hide resolved
source/egg/core/Heap.hh Outdated Show resolved Hide resolved
source/egg/core/Heap.cc Outdated Show resolved Hide resolved
source/egg/core/Heap.cc Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.cc Show resolved Hide resolved
source/egg/core/ExpHeap.cc Show resolved Hide resolved
source/egg/core/ExpHeap.cc Show resolved Hide resolved
source/egg/core/ExpHeap.cc Show resolved Hide resolved
source/egg/core/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/ExpHeap.cc Show resolved Hide resolved
source/abstract/memory/HeapCommon.cc Show resolved Hide resolved
source/abstract/memory/List.cc Show resolved Hide resolved
source/abstract/memory/List.cc Show resolved Hide resolved
source/abstract/memory/List.cc Show resolved Hide resolved
source/abstract/memory/List.cc Show resolved Hide resolved
source/abstract/memory/Memory.hh Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/ExpHeap.hh Outdated Show resolved Hide resolved
source/egg/core/Heap.hh Outdated Show resolved Hide resolved
@vabold vabold force-pushed the heap branch 2 times, most recently from a35527f to 4243d23 Compare October 11, 2024 17:32
@vabold vabold merged commit b67b119 into main Oct 11, 2024
8 checks passed
@vabold vabold deleted the heap branch October 11, 2024 17:56
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.

Implement EGG::Heap
2 participants