summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorRoman971 <32455037+Roman971@users.noreply.github.com>2020-09-01 03:06:44 +0200
committerGitHub <noreply@github.com>2020-08-31 21:06:44 -0400
commitb8da64ee01c252c1e6df2792741565117e83f93e (patch)
tree47f66239a1f0de956929cdb0842f911a0aa72fa2 /src/code
parentb4ac94a8fd4ba35163504edd939ef85d087c4fa5 (diff)
Improve PHYSICAL/VIRTUAL macros and match Interface_LoadActionLabel (#371)
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c2
-rw-r--r--src/code/z_parameter.c8
-rw-r--r--src/code/z_play.c14
-rw-r--r--src/code/z_player_lib.c2
-rw-r--r--src/code/z_room.c4
-rw-r--r--src/code/z_scene.c4
6 files changed, 14 insertions, 20 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 6905dc4f3..4f51d9485 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -805,7 +805,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
}
void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) {
- gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment);
+ gSegments[6] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[actor->objBankIndex].segment);
}
void Actor_Init(Actor* actor, GlobalContext* globalCtx) {
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 07a632db2..51e802faf 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -2055,8 +2055,6 @@ void func_80086D5C(s32* buf, u16 size) {
u32 sDoActionTextures[] = { 0x07000000, 0x07000180 };
-#ifdef NON_MATCHING
-// 0x80000000 is reused in the 2 *_TO_VIRTUAL macros when it shouldn't
void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 arg2) {
if (action >= 0x1D) {
action = 0x0A;
@@ -2077,14 +2075,10 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 a
&interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2145);
osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK);
} else {
- gSegments[7] = PHYSICAL_TO_VIRTUAL(interfaceCtx->do_actionSegment);
+ gSegments[7] = VIRTUAL_TO_PHYSICAL(interfaceCtx->do_actionSegment);
func_80086D5C(SEGMENTED_TO_VIRTUAL(sDoActionTextures[arg2]), 0x180 / 4);
}
}
-#else
-void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 arg2);
-#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadActionLabel.s")
-#endif
void Interface_SetDoAction(GlobalContext* globalCtx, u16 action) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
diff --git a/src/code/z_play.c b/src/code/z_play.c
index a75b99846..1a1b8431a 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -453,9 +453,9 @@ void Gameplay_Update(GlobalContext* globalCtx) {
ActorOverlayTable_LogPrint();
}
- gSegments[4] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment);
- gSegments[5] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
- gSegments[2] = PHYSICAL_TO_VIRTUAL(globalCtx->sceneSegment);
+ gSegments[4] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment);
+ gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
+ gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
if (func_8008E6AC(&globalCtx->sub_7B8, &input[1]) != 0) {
if ((globalCtx->transitionMode == 0) && (globalCtx->sceneLoadFlag != 0)) {
@@ -1076,9 +1076,9 @@ void Gameplay_Draw(GlobalContext* globalCtx) {
OPEN_DISPS(gfxCtx, "../z_play.c", 3907);
- gSegments[4] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment);
- gSegments[5] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
- gSegments[2] = PHYSICAL_TO_VIRTUAL(globalCtx->sceneSegment);
+ gSegments[4] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment);
+ gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
+ gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
gSPSegment(oGfxCtx->polyOpa.p++, 0x00, NULL);
gSPSegment(oGfxCtx->polyXlu.p++, 0x00, NULL);
@@ -1491,7 +1491,7 @@ void Gameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s32 spawn) {
if (globalCtx->sceneSegment == NULL) {
__assert("this->sceneSegment != NULL", "../z_play.c", 4960);
}
- gSegments[2] = PHYSICAL_TO_VIRTUAL(globalCtx->sceneSegment);
+ gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
Gameplay_InitScene(globalCtx, spawn);
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 1cd544e2c..ea71bae7a 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -509,7 +509,7 @@ void func_800907E4(GlobalContext* globalCtx, Player* player, Vec3f* arg2, s32 ar
sp4C = (player->exchangeItemId != 0) ? 6.0f : 14.0f;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 0x961);
- gSegments[6] = PHYSICAL_TO_VIRTUAL(player->getItemModel);
+ gSegments[6] = VIRTUAL_TO_PHYSICAL(player->getItemModel);
gSPSegment(oGfxCtx->polyOpa.p++, 0x06, player->getItemModel);
gSPSegment(oGfxCtx->polyXlu.p++, 0x06, player->getItemModel);
diff --git a/src/code/z_room.c b/src/code/z_room.c
index 5de946fdc..7a25609d4 100644
--- a/src/code/z_room.c
+++ b/src/code/z_room.c
@@ -596,7 +596,7 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) {
if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) {
roomCtx->status = 0;
roomCtx->curRoom.segment = roomCtx->unk_34;
- gSegments[3] = PHYSICAL_TO_VIRTUAL2(roomCtx->unk_34);
+ gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34);
Scene_ExecuteCommands(globalCtx, roomCtx->curRoom.segment);
func_8008E750(globalCtx, PLAYER);
@@ -613,7 +613,7 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) {
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) {
if (room->segment != NULL) {
- gSegments[3] = PHYSICAL_TO_VIRTUAL(room->segment);
+ gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment);
if (room->mesh->polygon.type >= ARRAY_COUNTU(sRoomDrawHandlers)) {
__assert("this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125);
}
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index 23ef3a510..436fc72c6 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -76,7 +76,7 @@ void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) {
objectCtx->spaceEnd = (void*)((s32)objectCtx->spaceStart + spaceSize);
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP);
- gSegments[4] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
+ gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
}
void Object_UpdateBank(ObjectContext* objectCtx) {
@@ -255,7 +255,7 @@ void func_800987F8(GlobalContext* globalCtx, SceneCmd* cmd) {
void func_8009883C(GlobalContext* globalCtx, SceneCmd* cmd) {
if (cmd->specialFiles.keepObjectId != 0) {
globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.keepObjectId);
- gSegments[5] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
+ gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
}
if (cmd->specialFiles.cUpElfMsgNum != 0) {