summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorKenix3 <kenixwhisperwind@gmail.com>2020-06-04 23:25:57 -0400
committerKenix3 <kenixwhisperwind@gmail.com>2020-06-04 23:25:57 -0400
commitcb8b9a20206782d171916a32adf5dd5409825350 (patch)
treea140cbb621f59e8ba4e5d4d5f5d0ad20d237ea68 /src/code
parent5c97d35841f99bbb23dffa797475f16ec1e3403b (diff)
z_lib now uses SEGMENTED_TO_VIRTUAL macro
Additionally removed some TODO comments in z_scene and defining gRspSegmentPhysAddrs array size as NUM_SEGMENTS
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_lib.c8
-rw-r--r--src/code/z_scene.c7
2 files changed, 5 insertions, 10 deletions
diff --git a/src/code/z_lib.c b/src/code/z_lib.c
index 101af60d9..a6e9c4e76 100644
--- a/src/code/z_lib.c
+++ b/src/code/z_lib.c
@@ -607,18 +607,16 @@ f32 Lib_PushAwayVec3f(Vec3f* start, Vec3f* pusher, f32 distanceToApproach) {
void Lib_Nop801004FC(void) {}
void* Lib_PtrSegToVirt(void* ptr) {
- // UB to cast the pointer to u32
- return (void*)PHYSICAL_TO_VIRTUAL((u32)gRspSegmentPhysAddrs[((u32)ptr << 4) >> 28] + ((u32)ptr & 0xFFFFFF));
+ return SEGMENTED_TO_VIRTUAL(ptr);
}
void* Lib_PtrSegToVirtNull(void* ptr) {
- // UB to cast the pointer to u32 in order to bitshift.
+ // UB: to cast the pointer to u32 in order to bitshift.
if (((u32)ptr >> 28) == 0) {
return ptr;
}
- // UB to cast the pointer to u32
- return (void*)PHYSICAL_TO_VIRTUAL((u32)gRspSegmentPhysAddrs[((u32)ptr << 4) >> 28] + ((u32)ptr & 0xFFFFFF));
+ return SEGMENTED_TO_VIRTUAL(ptr);
}
void* Lib_PtrSegToK0(void* ptr) {
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index 9d0f89fd1..24628cdd2 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -65,7 +65,7 @@ void Scene_Init(GlobalContext* ctxt, SceneContext* sceneCtxt) {
sceneCtxt->objectVramEnd = (void*)((u32)sceneCtxt->objectVramStart + spaceSize);
// TODO: Second argument here is an object enum
sceneCtxt->mainKeepIndex = Scene_LoadObject(sceneCtxt, 1);
- // TODO: Segment number enum
+ // TODO: Segment number enum?
gRspSegmentPhysAddrs[4] = PHYSICAL_TO_VIRTUAL(sceneCtxt->objects[sceneCtxt->mainKeepIndex].vramAddr);
}
@@ -159,7 +159,6 @@ void Scene_HeaderCommand00(GlobalContext* ctxt, SceneCmd* entry) {
s16 temp16;
u8 unk20;
- // TODO: UB to cast a u32 to pointer
ctxt->linkActorEntry = (ActorEntry*)Lib_PtrSegToVirt(entry->spawnList.segment) +
ctxt->setupEntranceList[ctxt->curSpawn].spawn;
if ( (ctxt->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
@@ -180,7 +179,6 @@ void Scene_HeaderCommand00(GlobalContext* ctxt, SceneCmd* entry) {
actorOverlayTable[0].initInfo->objectId = temp16;
Scene_LoadObject(&ctxt->sceneContext, temp16);
- // TODO: UB to cast pointer to u32
ctxt->sceneContext.objects[ctxt->sceneContext.objectCount].vramAddr = objectVramAddr;
}
@@ -234,7 +232,7 @@ void Scene_HeaderCommand07(GlobalContext* ctxt, SceneCmd* entry) {
if (entry->specialFiles.keepObjectId != 0) {
ctxt->sceneContext.keepObjectId = Scene_LoadObject(&ctxt->sceneContext,
entry->specialFiles.keepObjectId);
- // TODO: Segment number enum
+ // TODO: Segment number enum?
gRspSegmentPhysAddrs[5] =
PHYSICAL_TO_VIRTUAL(ctxt->sceneContext.objects[ctxt->sceneContext.keepObjectId].vramAddr);
}
@@ -298,7 +296,6 @@ void Scene_HeaderCommand0B(GlobalContext *ctxt, SceneCmd *entry) {
// TODO: This 0x22 is OBJECT_EXCHANGE_BANK_MAX - 1 in OOT
if (i < 0x22) {
- // TODO: UB to cast pointer to u32
firstObject[i + 1].vramAddr = nextPtr;
}
i++;