Some doc on actor overlays alloc types (#1266)

* Some doc on actor overlays alloc types

* Line breaks between defines at the top of actor.h

* plain english

* `ACTOR_ALLOC_` -> `ACTOROVL_ALLOC_`

* More line breaks

* `ACTOR_OVERLAY_ABSOLUTE_SPACE_SIZE` -> `ACTOROVL_ABSOLUTE_SPACE_SIZE`

* Document bug about Scarecrow's Song not setting the flag to restore Nayru's Love

* Try to document the check for needing to actor_kill to leave the absolute space being too broad

* "which overlay uses" (bad english) -> simplify to "which uses"

* Run formatter
This commit is contained in:
Dragorn421
2022-06-20 13:17:09 -07:00
committed by GitHub
parent b602276fef
commit 017a3aaf5c
18 changed files with 539 additions and 463 deletions
+9 -7
View File
@@ -2630,11 +2630,11 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) {
}
if (actorOverlay->loadedRamAddr != NULL) {
if (actorOverlay->allocType & ALLOCTYPE_PERMANENT) {
if (actorOverlay->allocType & ACTOROVL_ALLOC_PERSISTENT) {
if (HREG(20) != 0) {
osSyncPrintf("オーバーレイ解放しません\n"); // "Overlay will not be deallocated"
}
} else if (actorOverlay->allocType & ALLOCTYPE_ABSOLUTE) {
} else if (actorOverlay->allocType & ACTOROVL_ALLOC_ABSOLUTE) {
if (HREG(20) != 0) {
// "Absolute magic field reserved, so deallocation will not occur"
osSyncPrintf("絶対魔法領域確保なので解放しません\n");
@@ -2696,20 +2696,22 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
osSyncPrintf("既にロードされています\n"); // "Already loaded"
}
} else {
if (overlayEntry->allocType & ALLOCTYPE_ABSOLUTE) {
ASSERT(overlaySize <= AM_FIELD_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c", 6934);
if (overlayEntry->allocType & ACTOROVL_ALLOC_ABSOLUTE) {
ASSERT(overlaySize <= ACTOROVL_ABSOLUTE_SPACE_SIZE, "actor_segsize <= AM_FIELD_SIZE", "../z_actor.c",
6934);
if (actorCtx->absoluteSpace == NULL) {
// "AMF: absolute magic field"
actorCtx->absoluteSpace = ZeldaArena_MallocRDebug(AM_FIELD_SIZE, "AMF:絶対魔法領域", 0);
actorCtx->absoluteSpace =
ZeldaArena_MallocRDebug(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0);
if (HREG(20) != 0) {
// "Absolute magic field reservation - %d bytes reserved"
osSyncPrintf("絶対魔法領域確保 %d バイト確保\n", AM_FIELD_SIZE);
osSyncPrintf("絶対魔法領域確保 %d バイト確保\n", ACTOROVL_ABSOLUTE_SPACE_SIZE);
}
}
overlayEntry->loadedRamAddr = actorCtx->absoluteSpace;
} else if (overlayEntry->allocType & ALLOCTYPE_PERMANENT) {
} else if (overlayEntry->allocType & ACTOROVL_ALLOC_PERSISTENT) {
overlayEntry->loadedRamAddr = ZeldaArena_MallocRDebug(overlaySize, name, 0);
} else {
overlayEntry->loadedRamAddr = ZeldaArena_MallocDebug(overlaySize, name, 0);
@@ -180,11 +180,15 @@ void ArrowFire_Fly(ArrowFire* this, PlayState* play) {
void ArrowFire_Update(Actor* thisx, PlayState* play) {
ArrowFire* this = (ArrowFire*)thisx;
if (play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || play->msgCtx.msgMode == MSGMODE_SONG_PLAYED) {
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(&this->actor);
} else {
this->actionFunc(this, play);
return;
}
this->actionFunc(this, play);
}
void ArrowFire_Draw(Actor* thisx, PlayState* play2) {
@@ -181,11 +181,15 @@ void ArrowIce_Fly(ArrowIce* this, PlayState* play) {
void ArrowIce_Update(Actor* thisx, PlayState* play) {
ArrowIce* this = (ArrowIce*)thisx;
if (play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || play->msgCtx.msgMode == MSGMODE_SONG_PLAYED) {
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(&this->actor);
} else {
this->actionFunc(this, play);
return;
}
this->actionFunc(this, play);
}
void ArrowIce_Draw(Actor* thisx, PlayState* play) {
@@ -179,11 +179,15 @@ void ArrowLight_Fly(ArrowLight* this, PlayState* play) {
void ArrowLight_Update(Actor* thisx, PlayState* play) {
ArrowLight* this = (ArrowLight*)thisx;
if (play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || play->msgCtx.msgMode == MSGMODE_SONG_PLAYED) {
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(&this->actor);
} else {
this->actionFunc(this, play);
return;
}
this->actionFunc(this, play);
}
void ArrowLight_Draw(Actor* thisx, PlayState* play) {
@@ -78,6 +78,12 @@ void MagicDark_DiamondUpdate(Actor* thisx, PlayState* play) {
if (1) {}
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
//! This happens with all magic effects actors, but is especially visible with Nayru's Love as it lasts longer than
//! other magic actors, and the Nayru's Love actor is supposed to be spawned back after ocarina effects actors are
//! done. But with warp songs, whether the player warps away or not, the actor won't be spawned back.
if ((msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(thisx);
return;
@@ -99,10 +99,14 @@ void MagicFire_UpdateBeforeCast(Actor* thisx, PlayState* play) {
MagicFire* this = (MagicFire*)thisx;
Player* player = GET_PLAYER(play);
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(&this->actor);
return;
}
if (this->actionTimer > 0) {
this->actionTimer--;
} else {
@@ -119,10 +123,15 @@ void MagicFire_Update(Actor* thisx, PlayState* play) {
if (1) {}
this->actor.world.pos = player->actor.world.pos;
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(&this->actor);
return;
}
if (this->action == DF_ACTION_EXPAND_SLOWLY) {
this->collider.info.toucher.damage = this->actionTimer + 25;
} else if (this->action == DF_ACTION_STOP_EXPANDING) {
@@ -131,7 +131,11 @@ void MagicWind_Shrink(MagicWind* this, PlayState* play) {
void MagicWind_Update(Actor* thisx, PlayState* play) {
MagicWind* this = (MagicWind*)thisx;
if (play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK || play->msgCtx.msgMode == MSGMODE_SONG_PLAYED) {
// See `ACTOROVL_ALLOC_ABSOLUTE`
//! @bug This condition is too broad, the actor will also be killed by warp songs. But warp songs do not use an
//! actor which uses `ACTOROVL_ALLOC_ABSOLUTE`. There is no reason to kill the actor in this case.
if ((play->msgCtx.msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) || (play->msgCtx.msgMode == MSGMODE_SONG_PLAYED)) {
Actor_Kill(thisx);
return;
}
@@ -71,7 +71,7 @@ void OceffSpot_Destroy(Actor* thisx, PlayState* play) {
LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2);
Magic_Reset(play);
if ((gSaveContext.nayrusLoveTimer != 0) && (play->actorCtx.actorLists[ACTORCAT_PLAYER].length != 0)) {
player->stateFlags3 |= PLAYER_STATE3_6;
player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
}
@@ -61,7 +61,7 @@ void OceffStorm_Destroy(Actor* thisx, PlayState* play) {
Magic_Reset(play);
if (gSaveContext.nayrusLoveTimer != 0) {
player->stateFlags3 |= PLAYER_STATE3_6;
player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
}
@@ -41,7 +41,7 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play) {
Magic_Reset(play);
if (gSaveContext.nayrusLoveTimer != 0) {
player->stateFlags3 |= PLAYER_STATE3_6;
player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
}
@@ -41,7 +41,7 @@ void OceffWipe2_Destroy(Actor* thisx, PlayState* play) {
Magic_Reset(play);
if (gSaveContext.nayrusLoveTimer != 0) {
player->stateFlags3 |= PLAYER_STATE3_6;
player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
}
@@ -44,7 +44,7 @@ void OceffWipe3_Destroy(Actor* thisx, PlayState* play) {
Magic_Reset(play);
if (gSaveContext.nayrusLoveTimer != 0) {
player->stateFlags3 |= PLAYER_STATE3_6;
player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
}
@@ -39,6 +39,9 @@ void OceffWipe4_Destroy(Actor* thisx, PlayState* play) {
OceffWipe4* this = (OceffWipe4*)thisx;
Magic_Reset(play);
//! @bug `PLAYER_STATE3_RESTORE_NAYRUS_LOVE` is not set, unlike other Oceff actors.
//! This means playing Scarecrow's Song interrupts Nayru's Love without restoring it later.
}
void OceffWipe4_Update(Actor* thisx, PlayState* play) {
@@ -9383,7 +9383,7 @@ void Player_Init(Actor* thisx, PlayState* play2) {
if (gSaveContext.nayrusLoveTimer != 0) {
gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1;
func_80846A00(play, this, 1);
this->stateFlags3 &= ~PLAYER_STATE3_6;
this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
if (gSaveContext.entranceSound != 0) {
@@ -10169,11 +10169,11 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
func_80848C74(play, this);
}
if ((this->stateFlags3 & PLAYER_STATE3_6) && (gSaveContext.nayrusLoveTimer != 0) &&
if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) &&
(gSaveContext.magicState == MAGIC_STATE_IDLE)) {
gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1;
func_80846A00(play, this, 1);
this->stateFlags3 &= ~PLAYER_STATE3_6;
this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE;
}
if (this->stateFlags2 & PLAYER_STATE2_15) {