mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-10-31 23:55:06 -04:00
bugfix and add to value viewer
This commit is contained in:
parent
b62231a3ca
commit
0afb36d416
@ -1,5 +1,6 @@
|
||||
#include "valueViewer.h"
|
||||
#include "../../UIWidgets.hpp"
|
||||
#include "soh/Enhancements/stairs.h"
|
||||
|
||||
extern "C" {
|
||||
#include <z64.h>
|
||||
@ -14,6 +15,10 @@ s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...);
|
||||
|
||||
ImVec4 WHITE = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
static u32 stairsOutMaxFree;
|
||||
static u32 stairsOutFree;
|
||||
static u32 stairsOutAlloc;
|
||||
|
||||
std::vector<ValueTableElement> valueTable = {
|
||||
{ "Time", "gSaveContext.dayTime", "TIME:", TYPE_U16, false, []() -> void* { return &gSaveContext.dayTime; }, WHITE },
|
||||
{ "Age", "gSaveContext.linkAge", "AGE:", TYPE_S32, false, []() -> void* { return &gSaveContext.linkAge; }, WHITE },
|
||||
@ -34,6 +39,9 @@ std::vector<ValueTableElement> valueTable = {
|
||||
{ "Text ID", "play->msgCtx.textId", "TEXTID:", TYPE_U16, true, []() -> void* { return &gPlayState->msgCtx.textId; }, WHITE },
|
||||
{ "Analog Stick X", "play->state.input->cur.stick_x", "AX:", TYPE_S8, true, []() -> void* { return &gPlayState->state.input->cur.stick_x; }, WHITE },
|
||||
{ "Analog Stick Y", "play->state.input->cur.stick_y", "AY:", TYPE_S8, true, []() -> void* { return &gPlayState->state.input->cur.stick_y; }, WHITE },
|
||||
{ "Stairs: outMaxFree", "", "STAIR-OM:", TYPE_U32, true, []() -> void* { StairsArena_GetSizes(&stairsOutMaxFree, &stairsOutFree, &stairsOutAlloc); return &stairsOutMaxFree; }, WHITE },
|
||||
{ "Stairs: outFree", "", "STAIR-OF:", TYPE_U32, true, []() -> void* { StairsArena_GetSizes(&stairsOutMaxFree, &stairsOutFree, &stairsOutAlloc); return &stairsOutFree; }, WHITE },
|
||||
{ "Stairs: outAlloc", "", "STAIR-OA:", TYPE_U32, true, []() -> void* { StairsArena_GetSizes(&stairsOutMaxFree, &stairsOutFree, &stairsOutAlloc); return &stairsOutAlloc; }, WHITE },
|
||||
/* TODO: Find these (from GZ)
|
||||
"XZ Units Traveled (Camera based speed variable)" f32 0x801C9018
|
||||
"Movement Angle" x16 0x801DBB1C
|
||||
|
@ -14,6 +14,7 @@ extern "C" {
|
||||
#include <libultraship/bridge.h>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include "soh/Enhancements/enhancementTypes.h"
|
||||
#include "soh/Enhancements/stairs.h"
|
||||
|
||||
extern "C" {
|
||||
#include <z64.h>
|
||||
|
@ -457,7 +457,7 @@ std::unordered_map<u16, size_t> actorOverlaySizes = {
|
||||
std::unordered_set<u16> registeredStairOverlays;
|
||||
|
||||
std::unordered_map<uintptr_t, void*> generalPtrMap;
|
||||
std::unordered_map<u16, void*> actorPtrMap;
|
||||
std::unordered_map<u16, void*> overlayRPtrMap;
|
||||
std::unordered_map<u16, void*> overlayPtrMap;
|
||||
std::unordered_map<u16, void*> mallocRPtrMap;
|
||||
|
||||
@ -482,6 +482,10 @@ s32 Stairs_RegisterOverlay(u16 id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
s32 Stairs_GetOverlayRegistered(u16 id) {
|
||||
return registeredStairOverlays.contains(id);
|
||||
}
|
||||
|
||||
s32 Stairs_UnregisterOverlay(u16 id) {
|
||||
if (registeredStairOverlays.contains(id)) {
|
||||
registeredStairOverlays.erase(id);
|
||||
@ -537,9 +541,9 @@ void* StairsArena_MallocGeneral(size_t size, uintptr_t id) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* StairsArena_MallocActor(size_t size, u16 id) {
|
||||
void* ptr = __osMalloc(&sStairsArena, size);
|
||||
actorPtrMap[id] = ptr;
|
||||
void* StairsArena_MallocROverlay(size_t size, u16 id) {
|
||||
void* ptr = __osMallocR(&sStairsArena, size);
|
||||
overlayRPtrMap[id] = ptr;
|
||||
|
||||
// StairsArena_CheckPointer(ptr, size, "stairs_malloc", "確保"); // "Secure"
|
||||
return ptr;
|
||||
@ -560,7 +564,7 @@ void* StairsArena_MallocR(size_t size) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* StairsArena_MallocRGeneral(size_t size, u16 id) {
|
||||
void* StairsArena_MallocRGeneral(size_t size, uintptr_t id) {
|
||||
void* ptr = __osMallocR(&sStairsArena, size);
|
||||
mallocRPtrMap[id] = ptr;
|
||||
|
||||
@ -593,12 +597,12 @@ void StairsArena_FreeGeneral(uintptr_t id) {
|
||||
generalPtrMap[id] = nullptr;
|
||||
}
|
||||
|
||||
void StairsArena_FreeActor(u16 id) {
|
||||
void* ptr = actorPtrMap[id];
|
||||
void StairsArena_FreeMallocROverlay(u16 id) {
|
||||
void* ptr = overlayRPtrMap[id];
|
||||
if (ptr) {
|
||||
__osFree(&sStairsArena, ptr);
|
||||
}
|
||||
actorPtrMap[id] = nullptr;
|
||||
overlayRPtrMap[id] = nullptr;
|
||||
}
|
||||
|
||||
void StairsArena_FreeOverlay(u16 id) {
|
||||
@ -656,7 +660,7 @@ void StairsArena_Cleanup() {
|
||||
__osMallocCleanup(&sStairsArena);
|
||||
registeredStairOverlays.clear();
|
||||
generalPtrMap.clear();
|
||||
actorPtrMap.clear();
|
||||
overlayRPtrMap.clear();
|
||||
overlayPtrMap.clear();
|
||||
mallocRPtrMap.clear();
|
||||
absolutePtr = nullptr;
|
||||
|
@ -18,6 +18,7 @@ extern "C" {
|
||||
|
||||
u16 Stairs_GetAllocType(u16 id);
|
||||
s32 Stairs_RegisterOverlay(u16 id);
|
||||
s32 Stairs_GetOverlayRegistered(u16 id);
|
||||
s32 Stairs_UnregisterOverlay(u16 id);
|
||||
s32 Stairs_RegisterAbsoluteSpace();
|
||||
s32 Stairs_GetAbsoluteSpace();
|
||||
@ -40,12 +41,12 @@ void StairsArena_Cleanup();
|
||||
u8 StairsArena_IsInitalized();
|
||||
|
||||
void* StairsArena_MallocGeneral(size_t size, uintptr_t id);
|
||||
void* StairsArena_MallocActor(size_t size, u16 id);
|
||||
void* StairsArena_MallocROverlay(size_t size, u16 id);
|
||||
void* StairsArena_MallocOverlay(size_t size, u16 id);
|
||||
void* StairsArena_MallocRGeneral(size_t size, u16 id);
|
||||
void* StairsArena_MallocRGeneral(size_t size, uintptr_t id);
|
||||
void* StairsArena_MallocRAbsolute(size_t size);
|
||||
void StairsArena_FreeGeneral(uintptr_t id);
|
||||
void StairsArena_FreeActor(u16 id);
|
||||
void StairsArena_FreeMallocROverlay(u16 id);
|
||||
void StairsArena_FreeOverlay(u16 id);
|
||||
void StairsArena_FreeMallocR(u16 id);
|
||||
void StairsArena_FreeAbsolute();
|
||||
|
@ -3147,7 +3147,7 @@ void Actor_FreeOverlay(ActorDBEntry* dbEntry) {
|
||||
}
|
||||
|
||||
if (CVarGetInteger("gStairs", 1)) {
|
||||
if (!Stairs_RegisterOverlay(dbEntry->id)) {
|
||||
if (Stairs_GetOverlayRegistered(dbEntry->id)) {
|
||||
u16 allocType = Stairs_GetAllocType(dbEntry->id);
|
||||
|
||||
if (allocType & STAIRS_ACTOROVL_ALLOC_PERSISTENT) {
|
||||
@ -3213,10 +3213,10 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
||||
|
||||
} else if (allocType & STAIRS_ACTOROVL_ALLOC_ABSOLUTE) {
|
||||
if (Stairs_RegisterAbsoluteSpace()) {
|
||||
StairsArena_MallocRAbsolute(overlaySize);
|
||||
StairsArena_MallocRAbsolute(STAIRS_ACTOROVL_ABSOLUTE_SPACE_SIZE);
|
||||
}
|
||||
} else if (allocType & STAIRS_ACTOROVL_ALLOC_PERSISTENT) {
|
||||
StairsArena_MallocRGeneral(overlaySize, dbEntry->id);
|
||||
StairsArena_MallocROverlay(overlaySize, dbEntry->id);
|
||||
} else {
|
||||
StairsArena_MallocOverlay(overlaySize, dbEntry->id);
|
||||
}
|
||||
@ -3249,10 +3249,9 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
||||
}
|
||||
|
||||
if ((CVarGetInteger("gStairs", 1))) {
|
||||
Actor* ptr = StairsArena_MallocGeneral(dbEntry->instanceSize, (uintptr_t)actor);
|
||||
if (ptr == NULL) {
|
||||
Actor_FreeOverlay(dbEntry);
|
||||
actor = NULL;
|
||||
if (StairsArena_MallocGeneral(dbEntry->instanceSize, (uintptr_t)actor) == NULL) {
|
||||
// Actor_FreeOverlay(dbEntry);
|
||||
// actor = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -3399,7 +3398,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) {
|
||||
newHead = Actor_RemoveFromCategory(play, actorCtx, actor);
|
||||
|
||||
if (CVarGetInteger("gStairs", 1)) {
|
||||
StairsArena_FreeActor((uintptr_t)actor);
|
||||
StairsArena_FreeGeneral((uintptr_t)actor);
|
||||
}
|
||||
|
||||
ZELDA_ARENA_FREE_DEBUG(actor);
|
||||
|
Loading…
Reference in New Issue
Block a user