Merge pull request #676 from notyourav/v

label some asm functions
This commit is contained in:
Theo 2023-12-29 01:01:37 -08:00 committed by GitHub
commit c2f081600b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
89 changed files with 274 additions and 272 deletions

View File

@ -10,41 +10,43 @@ CheckBits: @ 0x08000F10
ldr r3, _08000F50 @ =ram_CheckBits
bx r3
thumb_func_start sub_08000F14
sub_08000F14: @ 0x08000F14
// sum 3 drop probability vectors
thumb_func_start SumDropProbabilities
SumDropProbabilities: @ 0x08000F14
push {r4, r5, r6}
movs r4, #0x1e
movs r4, #30 // vector addition for 16 shorts in reverse
_08000F18:
ldrsh r5, [r1, r4]
ldrsh r6, [r2, r4]
adds r5, r5, r6
ldrsh r6, [r3, r4]
adds r5, r5, r6
strh r5, [r0, r4]
ldrsh r5, [r1, r4] // row 1
ldrsh r6, [r2, r4] // + row 2
adds r5, r6
ldrsh r6, [r3, r4] // + row 3
adds r5, r6
strh r5, [r0, r4] // store in output
subs r4, #2
bpl _08000F18
pop {r4, r5, r6}
bx lr
thumb_func_start sub_08000F2C
sub_08000F2C: @ 0x08000F2C
// sum 3 drop probabilities, clamp to 0, return scalar sum
thumb_func_start SumDropProbabilities2
SumDropProbabilities2: @ 0x08000F2C
push {r4, r5, r6, r7}
movs r4, #0x1e
movs r7, #0
movs r4, #30
movs r7, #0 // sum
_08000F32:
ldrsh r5, [r1, r4]
ldrsh r6, [r2, r4]
adds r5, r5, r6
ldrsh r6, [r3, r4]
adds r5, r5, r6
bpl _08000F40
ldrsh r5, [r1, r4] // row 1
ldrsh r6, [r2, r4] // + row 2
adds r5, r6
ldrsh r6, [r3, r4] // + row 3
adds r5, r6
bpl positive_drop_chance // clamp to 0
movs r5, #0
_08000F40:
strh r5, [r0, r4]
adds r7, r7, r5
positive_drop_chance:
strh r5, [r0, r4] // store in output
adds r7, r5
subs r4, #2
bpl _08000F32
adds r0, r7, #0
adds r0, r7, #0 // return sum
pop {r4, r5, r6, r7}
bx lr
.align 2, 0

View File

@ -18,7 +18,7 @@ EnemyUpdate: @ 0x080011C4
bne _080011EA
bl DeleteThisEntity
_080011DC:
bl EntityIsDeleted
bl EntityDisabled
cmp r0, #0
bne _0800120A
adds r0, r4, #0

View File

@ -18,7 +18,7 @@ ProjectileUpdate: @ 0x08016AE4
bne _08016B0A
bl DeleteThisEntity
_08016AFC:
bl EntityIsDeleted
bl EntityDisabled
cmp r0, #0
bne _08016B22
adds r0, r4, #0

View File

@ -6,7 +6,9 @@
#include "color.h"
#include "sprite.h"
#define MAX_ENTITIES 71
#define MAX_ENTITIES 72
#define MAX_MANAGERS 32
#define MAX_AUX_PLAYER_ENTITIES 7
/** Kinds of Entity's supported by the game. */
typedef enum {
@ -38,6 +40,8 @@ typedef enum {
typedef enum {
ENT_DID_INIT = 0x1, /**< Graphics and other data loaded. */
ENT_SCRIPTED = 0x2, /**< Execute in a scripted environment. */
ENT_UNUSED1 = 0x4, /**< Unused delete flag. */
ENT_UNUSED2 = 0x8, /**< Unused delete flag. */
ENT_DELETED = 0x10, /**< Queue deletion next frame. */
ENT_PERSIST = 0x20, /**< Persist between rooms. */
ENT_COLLIDE = 0x80, /**< Collide with other Entity's. */
@ -238,6 +242,15 @@ typedef struct LinkedList {
Entity* first;
} LinkedList;
/**
* LinkedList's which point to allocate Entities.
* These work together with Entity.prev and Entity.next fields
* to allow the iteration of all Entity's.
*/
extern LinkedList gEntityLists[9];
extern Entity gAuxPlayerEntities[MAX_AUX_PLAYER_ENTITIES];
extern Entity gEntities[MAX_ENTITIES];
typedef void(EntityAction)(Entity*);
typedef void (*EntityActionPtr)(Entity*);
typedef void (*const* EntityActionArray)(Entity*);
@ -283,7 +296,7 @@ Entity* CreateEnemy(u32 id, u32 type);
Entity* CreateNPC(u32 id, u32 type, u32 type2);
Entity* CreateObject(u32 id, u32 type, u32 type2);
Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
Entity* CreateItemGetEntity(void);
Entity* CreateAuxPlayerEntity(void);
Entity* CreateFx(Entity* parent, u32 type, u32 type2);
/// @}
@ -389,9 +402,12 @@ Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2);
void SetEntityPriority(Entity* entity, u32 prio);
/**
* Check if entity will be deleted next frame.
* Check if entity is disabled. Entities are disabled if:
* - They are deleted.
* - There is an event and the entity doesn't have priority
* (n/a if entity is in action 0).
*/
bool32 EntityIsDeleted(Entity* entity);
bool32 EntityDisabled(Entity* entity);
/**
* Check if system or entity is blocking updates.
@ -477,18 +493,10 @@ void SetInitializationPriority(void);
/**
* Reset the system update priority.
*/
void ResetSystemPriority(void);
void ClearEventPriority(void);
void sub_0805E958(void);
/**
* LinkedList's which point to allocate Entities.
* These work together with Entity.prev and Entity.next fields
* to allow the iteration of all Entity's.
*/
extern LinkedList gEntityLists[9];
extern Entity gItemGetEntities[7];
typedef struct {
u8 unk_0;
u8 unk_1;

View File

@ -5,8 +5,10 @@
#include "entity.h"
#include "structures.h"
#define MESSAGE_ACTIVE 0x7f
typedef struct {
u8 doTextBox;
u8 state;
u8 unk;
u8 textSpeed;
u8 unk3; // HI?

View File

@ -720,7 +720,7 @@ s32 AddInteractableObject(Entity*, u32, u32);
void RemoveInteractableObject(Entity*);
s32 GetInteractableObjectIndex();
void sub_08078AC0(u32, u32, u32);
void sub_08078B48(void);
void PausePlayer(void);
void sub_08078E84(Entity*, Entity*);
void sub_08078FB0(Entity*);
void sub_080792BC(s32, u32, u32);

View File

@ -191,7 +191,7 @@ extern ItemBehavior gActiveItems[MAX_ACTIVE_ITEMS];
static_assert(sizeof(gActiveItems) == 0x70);
typedef struct {
u8 sys_priority; // system requested priority
u8 event_priority; // system requested priority
u8 ent_priority; // entity requested priority
u8 queued_priority;
u8 queued_priority_reset;

View File

@ -132,8 +132,8 @@ SECTIONS {
. = 0x000010A0; gRoomTransition = .;
. = 0x00001150; gRand = .;
. = 0x00001160; gPlayerEntity = .;
. = 0x000011E8; gItemGetEntities = .;
. = 0x000015A0; gUnk_030015A0 = .;
. = 0x000011E8; gAuxPlayerEntities = .;
. = 0x000015A0; gEntities = .;
. = 0x00003BE0; gCarriedEntity = .;
. = 0x00003C70; gUnk_03003C70 = .;
. = 0x00003D70; gEntityLists = .;

View File

@ -63,8 +63,8 @@ void CollisionMain(void) {
u32 prio;
// pick highest priority
prio = gPriorityHandler.sys_priority;
if (gPriorityHandler.sys_priority <= gPriorityHandler.ent_priority)
prio = gPriorityHandler.event_priority;
if (gPriorityHandler.event_priority <= gPriorityHandler.ent_priority)
prio = gPriorityHandler.ent_priority;
// if any priority is set, dont do collision

View File

@ -747,7 +747,7 @@ void Fuse_Action0(void) {
}
void Fuse_Action1(void) {
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
MenuFadeIn(4, 0);
gFuseInfo.fusionState = FUSION_STATE_4;
gFuseInfo.action = 2;
@ -773,7 +773,7 @@ void Fuse_Action2(void) {
}
void Fuse_Action3(void) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
if (gFuseInfo.entity != NULL) {
gFuseInfo.entity->updatePriority = gFuseInfo.prevUpdatePriority;
}

View File

@ -52,7 +52,7 @@ void sub_080535AC(void) {
void sub_080535F4(void) {
if (gFadeControl.active == 0) {
ResetSystemPriority();
ClearEventPriority();
gMenu.overlayType = 2;
}
}
@ -234,7 +234,7 @@ void sub_08053758(void) {
gScreen.bg1.control = 0x1c4e;
gScreen.bg2.control = 0x1dc1;
SoundReq(BGM_STORY);
ResetSystemPriority();
ClearEventPriority();
SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100);
}
@ -344,7 +344,7 @@ void sub_08053A1C(void) {
}
void sub_08053A5C(void) {
if (((gMessage.doTextBox & 0x7f) == 0) && --gMenu.transitionTimer == 0) {
if (((gMessage.state & MESSAGE_ACTIVE) == 0) && --gMenu.transitionTimer == 0) {
gMenu.overlayType++;
SetFade(FADE_IN_OUT | FADE_INSTANT, 8);
}
@ -451,7 +451,7 @@ void sub_08053B74(void) {
gMenu.overlayType++;
gUpdateVisibleTiles = 1;
LoadRoomEntityList(gUnk_080FCDE0);
ResetSystemPriority();
ClearEventPriority();
ResetEntityPriority();
SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100);
}

View File

@ -240,7 +240,7 @@ void AcroBandit_Type0Action5(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
if (gEntCount < MAX_ENTITIES - 4) {
if (gEntCount < MAX_ENTITIES - 5) {
u32 tmp = Random();
tmp &= 3;

View File

@ -247,7 +247,7 @@ void BusinessScrub_Action5(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
u32 subtype;
if ((gMessage.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0 && sub_0802915C(this) && !sub_08056338()) {
if (offer->price <= gSave.stats.rupees) {
if (BusinessScrub_CheckRefillFitsBag(this)) {
/* Bag full. */
@ -316,11 +316,11 @@ void BusinessScrub_Action6(Entity* this) {
}
void BusinessScrub_Action7(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
this->action = 4;
this->subAction = gMessage.doTextBox & 0x7f;
this->subAction = gMessage.state & MESSAGE_ACTIVE;
this->timer = 1;
if (!CheckLocalFlag(offer->local_flag)) {
SetLocalFlag(offer->local_flag);

View File

@ -270,7 +270,7 @@ void ChuchuBoss_OnDeath(ChuchuBossEntity* this) {
Entity* child;
Entity* parent;
sub_08078B48();
PausePlayer();
if (super->type == 0) {
if (super->subAction != 12) {
super->subAction = 12;
@ -464,7 +464,7 @@ void sub_08026090(ChuchuBossEntity* this) {
}
CopyPosition(super->child, super);
} else {
sub_08078B48();
PausePlayer();
if (super->timer-- == 0) {
gRoomControls.camera_target = &gPlayerEntity;
DeleteThisEntity();
@ -543,7 +543,7 @@ void sub_0802626C(ChuchuBossEntity* this) {
gPauseMenuOptions.disabled = 1;
gUnk_080CC20C[this->unk_84->unk_03](this);
if (gPlayerEntity.action != PLAYER_ROOMTRANSITION && gPlayerEntity.action != PLAYER_ROOM_EXIT) {
sub_08078B48();
PausePlayer();
}
}
@ -1127,7 +1127,7 @@ void sub_08026E1C(ChuchuBossEntity* this) {
}
if ((sub_08027C54(this)) && this->unk_84->unk_04 == 2) {
sub_08027C7C(this, 0x3f);
sub_08078B48();
PausePlayer();
}
}
@ -1156,7 +1156,7 @@ void sub_08026FA4(ChuchuBossEntity* this) {
ChuchuBossEntity* pEVar3;
ChuchuBossEntity* pEVar4;
sub_08078B48();
PausePlayer();
COLLISION_OFF(super);
pEVar4 = (ChuchuBossEntity*)super->child;
pEVar3 = (ChuchuBossEntity*)super->parent;
@ -1362,7 +1362,7 @@ void sub_080272D4(ChuchuBossEntity* this) {
if (sub_08027C54(super->child) == 0 || ((ChuchuBossEntity*)super->child)->unk_84->unk_04 != 2) {
SoundReq(SFX_BOSS_HIT);
} else {
sub_08078B48();
PausePlayer();
gRoomControls.camera_target = super->child;
gPauseMenuOptions.disabled = 1;
gRoomControls.camera_target->subAction = 9;

View File

@ -81,7 +81,7 @@ void FireballGuy_Action2(Entity* this) {
/* Can we create enough new entities? */
count = typeEntityCount[this->type];
if (MAX_ENTITIES + 1 - count <= gEntCount)
if (MAX_ENTITIES - count <= gEntCount)
return;
/* Create 2-5 new MiniFireballGuy */

View File

@ -145,7 +145,7 @@ void Gleerok(GleerokEntity* this) {
}
void Gleerok_OnDeath(GleerokEntity* this) {
sub_08078B48();
PausePlayer();
switch (super->type) {
case 2:
@ -420,7 +420,7 @@ void sub_0802D3B8(GleerokEntity* this) {
void sub_0802D650(GleerokEntity* this) {
#ifdef EU
sub_08078B48();
PausePlayer();
#endif
gUnk_080CD7E4[super->subAction](this);
@ -1014,7 +1014,7 @@ void sub_0802E0B8(GleerokEntity* this) {
if (this->unk_79 > 1) {
super->health = 0;
super->action = 0;
sub_08078B48();
PausePlayer();
SoundReq(SFX_BOSS_DIE);
return;
} else {

View File

@ -113,17 +113,17 @@ void OctorokBoss_Hit(OctorokBossEntity* this) {
if (super->subAction != 3) {
gRoomControls.camera_target = &this->heap->tailObjects[0]->base;
this->heap->field_0x7 = 0x5a;
sub_08078B48();
PausePlayer();
}
} else {
if (this->heap->field_0x7 != 0) {
this->heap->field_0x7--;
sub_08078B48();
PausePlayer();
}
}
OctorokBoss_Hit_SubActions[super->subAction](this);
if (super->subAction > 3) {
sub_08078B48();
PausePlayer();
}
sub_0800445C(super);
SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD);
@ -136,7 +136,7 @@ void OctorokBoss_Hit_SubAction0(OctorokBossEntity* this) {
if (this->bossPhase == 4) {
super->subAction = 4;
gPauseMenuOptions.disabled = 1;
sub_08078B48();
PausePlayer();
SoundReq(SFX_BOSS_DIE);
} else {
if (IS_FROZEN(this) == FALSE) {
@ -442,7 +442,7 @@ void OctorokBoss_Intro(OctorokBossEntity* this) {
OctorokBoss_Intro_SubAction0, OctorokBoss_Intro_SubAction1, OctorokBoss_Intro_SubAction2,
OctorokBoss_Intro_SubAction3, OctorokBoss_Intro_SubAction4, OctorokBoss_Intro_SubAction5,
};
sub_08078B48();
PausePlayer();
gPauseMenuOptions.disabled = 1;
sub_08036F60(this);
OctorokBoss_Intro_SubActions[super->subAction](this);
@ -796,7 +796,7 @@ void OctorokBoss_Action1_Attack(OctorokBossEntity* this) {
gPlayerEntity.spriteSettings.draw = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.collisionLayer = 2;
sub_08078B48();
PausePlayer();
PutAwayItems();
gPlayerEntity.parent = super;
sub_08036914(&gPlayerEntity, (u8) - (this->angle.HALF.HI + 0x80), 0x3800);

View File

@ -105,7 +105,7 @@ void sub_080450A8(Entity* this) {
/* Can we create enough new entities? */
count = typeEntityCount[this->type];
if (MAX_ENTITIES + 1 - count <= gEntCount)
if (MAX_ENTITIES - count <= gEntCount)
return;
/* Create 2-4 new MiniSlime */

View File

@ -547,7 +547,7 @@ void VaatiTransfiguredType0Action7(Entity* this) {
Entity* pEVar3;
u32 uVar4;
sub_08078B48();
PausePlayer();
if (this->timer) {
if (--this->timer == 0) {
SetRoomFlag(2);

View File

@ -99,8 +99,8 @@ void VaatiTransfiguredEyeFunction0Action0(Entity* this) {
Entity* child;
u8 bVar2;
bVar2 = gMessage.doTextBox & 0x7f;
if ((gMessage.doTextBox & 0x7f) == 0) {
bVar2 = gMessage.state & MESSAGE_ACTIVE;
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->spriteSettings.draw = 0;
this->field_0x80.HALF.LO = bVar2;

View File

@ -634,7 +634,7 @@ void sub_08041D14(Entity* this) {
Entity* pEVar1;
GetNextFrame(((VaatiWrathHeapStruct*)this->myHeap)->type2);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
if (this->timer != 0) {
this->timer--;
} else {

View File

@ -189,7 +189,7 @@ void Subtask_PortalCutscene_0(void) {
gUsedPalettes |= 0x200000;
EraseAllEntities();
LoadRoomEntityList(gUnk_080D4110[portalId]);
ResetSystemPriority();
ClearEventPriority();
gArea.filler3[0]++;
SetFade(FADE_INSTANT, 8);
}

View File

@ -6,6 +6,12 @@
#include "npc.h"
#include "manager/diggingCaveEntranceManager.h"
typedef struct Temp {
void* prev;
void* next;
u8 _0[0x38];
} Temp;
extern u8 gUpdateVisibleTiles;
extern Manager gUnk_02033290;
void UpdatePlayerInput(void);
@ -89,7 +95,7 @@ void SetEntityPriority(Entity* ent, u32 prio) {
ent->updatePriority = prio;
}
bool32 EntityIsDeleted(Entity* this) {
bool32 EntityDisabled(Entity* this) {
u32 value;
if (this->flags & ENT_DELETED)
@ -98,19 +104,19 @@ bool32 EntityIsDeleted(Entity* this) {
return FALSE;
// pick highest
if (gPriorityHandler.sys_priority > gPriorityHandler.ent_priority)
value = gPriorityHandler.sys_priority;
if (gPriorityHandler.event_priority > gPriorityHandler.ent_priority)
value = gPriorityHandler.event_priority;
else
value = gPriorityHandler.ent_priority;
if (gMessage.doTextBox & 0x7F)
if (gMessage.state & MESSAGE_ACTIVE)
value = max(value, PRIO_MESSAGE);
return value > this->updatePriority;
}
bool32 AnyPrioritySet(void) {
u32 prio = gPriorityHandler.sys_priority;
if (gPriorityHandler.sys_priority <= gPriorityHandler.ent_priority)
u32 prio = gPriorityHandler.event_priority;
if (gPriorityHandler.event_priority <= gPriorityHandler.ent_priority)
prio = gPriorityHandler.ent_priority;
return prio != PRIO_MIN;
}
@ -180,12 +186,12 @@ static void UpdatePriorityTimer(void) {
}
void SetPlayerEventPriority(void) {
gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT;
gPriorityHandler.event_priority = PRIO_PLAYER_EVENT;
gPlayerEntity.updatePriority = PRIO_PLAYER_EVENT;
}
void ResetPlayerEventPriority(void) {
gPriorityHandler.sys_priority = PRIO_MIN;
gPriorityHandler.event_priority = PRIO_MIN;
gPlayerEntity.updatePriority = PRIO_PLAYER;
}
@ -195,15 +201,15 @@ void RevokePriority(Entity* e) {
}
void SetRoomReloadPriority(void) {
gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT;
gPriorityHandler.event_priority = PRIO_PLAYER_EVENT;
}
void SetInitializationPriority(void) {
gPriorityHandler.sys_priority = PRIO_HIGHEST;
gPriorityHandler.event_priority = PRIO_HIGHEST;
}
void ResetSystemPriority(void) {
gPriorityHandler.sys_priority = PRIO_MIN;
void ClearEventPriority(void) {
gPriorityHandler.event_priority = PRIO_MIN;
}
void UpdateEntities(void) {
@ -241,8 +247,6 @@ void EraseAllEntities(void) {
gOAMControls.unk[1].unk6 = 1;
}
extern Entity gUnk_030015A0[0x48];
Entity* GetEmptyEntity() {
u8 flags_ip;
Entity* end;
@ -253,9 +257,9 @@ Entity* GetEmptyEntity() {
LinkedList* listPtr;
LinkedList* endListPtr;
if (gEntCount <= 0x46) {
currentEnt = gUnk_030015A0;
end = currentEnt + ARRAY_COUNT(gUnk_030015A0);
if (gEntCount < MAX_ENTITIES - 1) {
currentEnt = gEntities;
end = currentEnt + ARRAY_COUNT(gEntities);
do {
if (currentEnt->prev == 0) {
@ -267,7 +271,8 @@ Entity* GetEmptyEntity() {
currentEnt = &gPlayerEntity;
do {
if ((s32)currentEnt->prev < 0 && (currentEnt->flags & 0xc) && currentEnt != gUpdateContext.current_entity) {
if ((s32)currentEnt->prev < 0 && (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2)) &&
currentEnt != gUpdateContext.current_entity) {
ClearDeletedEntity(currentEnt);
return currentEnt;
}
@ -282,9 +287,10 @@ Entity* GetEmptyEntity() {
currentEnt = listPtr->first;
nextList = listPtr + 1;
while ((u32)currentEnt != (u32)listPtr) {
if (currentEnt->kind != MANAGER && flags_ip < (currentEnt->flags & 0x1c) &&
if (currentEnt->kind != MANAGER &&
flags_ip < (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED)) &&
gUpdateContext.current_entity != currentEnt) {
flags_ip = currentEnt->flags & 0x1c;
flags_ip = currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED);
rv = currentEnt;
}
currentEnt = currentEnt->next;
@ -301,16 +307,16 @@ Entity* GetEmptyEntity() {
return rv;
}
extern Entity gItemGetEntities[7];
extern Entity gAuxPlayerEntities[7];
Entity* CreateItemGetEntity(void) {
Entity* ent = gItemGetEntities;
Entity* CreateAuxPlayerEntity(void) {
Entity* ent = gAuxPlayerEntities;
do {
if (ent->prev == NULL) {
return ent;
}
} while (++ent < &gItemGetEntities[7]);
} while (++ent < &gAuxPlayerEntities[7]);
return NULL;
}
@ -407,12 +413,6 @@ void DeleteAllEntities(void) {
}
}
typedef struct Temp {
void* prev;
void* next;
u8 _0[0x38];
} Temp;
// fix this
Manager* GetEmptyManager(void) {
Temp* it;

View File

@ -208,7 +208,7 @@ static void GameMain_ChangeRoom(void) {
return;
UpdatePlayerMapCoords();
ResetSystemPriority();
ClearEventPriority();
UpdateWindcrests();
sub_080300C4();
gMain.substate = GAMEMAIN_UPDATE;
@ -252,8 +252,8 @@ static void GameMain_Update(void) {
return;
}
if ((gMessage.doTextBox & 0x7f) || gPriorityHandler.priority_timer != 0)
sub_08078B48();
if ((gMessage.state & MESSAGE_ACTIVE) || gPriorityHandler.priority_timer != 0)
PausePlayer();
FlushSprites();
UpdateEntities();
@ -305,7 +305,7 @@ static void GameMain_BarrelUpdate(void) {
CheckGameOver();
CopyOAM();
if (!gFadeControl.active)
ResetSystemPriority();
ClearEventPriority();
}
static void GameMain_ChangeArea(void) {

View File

@ -204,7 +204,7 @@ void PlayerUpdate(Entity* this) {
else
gPlayerState.flags &= ~PL_DRUGGED;
if (!EntityIsDeleted(this)) {
if (!EntityDisabled(this)) {
if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) {
PutAwayItems();
if (gPlayerState.flags & PL_MOLDWORM_RELEASED) {
@ -258,7 +258,7 @@ static void HandlePlayerLife(Entity* this) {
return;
}
if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.doTextBox & 0x7f))
if ((gPlayerState.controlMode != CONTROL_ENABLED) || (gMessage.state & 0x7f))
return;
#ifdef EU
@ -274,7 +274,7 @@ static void HandlePlayerLife(Entity* this) {
}
}
#else
gRoomVars.unk2 = gMessage.doTextBox & 0x7f;
gRoomVars.unk2 = gMessage.state & MESSAGE_ACTIVE;
temp = gSave.stats.maxHealth / 4;
if (temp > 24)
temp = 24;

View File

@ -403,8 +403,8 @@ void EnableRandomDrops(void) {
gRoomVars.randomDropsDisabled = FALSE;
}
extern void sub_08000F14(s16*, const s16*, const s16*, const s16*);
extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*);
extern void SumDropProbabilities(s16*, const s16*, const s16*, const s16*);
extern u32 SumDropProbabilities2(s16*, const s16*, const s16*, const s16*);
u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter);
u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
extern const u8 gUnk_080FE1B4[] /* = {
@ -459,7 +459,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
#endif
}
// vector addition, s0 = ptr4 + ptr2 + ptr3
sub_08000F14(droptable.a, ptr4->a, ptr2->a, ptr3->a);
SumDropProbabilities(droptable.a, ptr4->a, ptr2->a, ptr3->a);
if (gSave.stats.health <= 8) {
droptable.s.hearts += 5;
}
@ -486,7 +486,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
// vector addition, s0 = s0 + ptr2 + ptr3
// resulting values are clamped to be >= 0
// returns sum over s0
summOdds = sub_08000F2C(droptable.a, droptable.a, ptr2->a, ptr3->a);
summOdds = SumDropProbabilities2(droptable.a, droptable.a, ptr2->a, ptr3->a);
rand = Random();
item = (rand >> 0x18);
item &= 0xF;

View File

@ -61,6 +61,6 @@ void (*const gMiscManagerunctions[])() = { NULL,
EnterRoomTextboxManager_Main };
void ManagerUpdate(Entity* this) {
if (!EntityIsDeleted(this))
if (!EntityDisabled(this))
gMiscManagerunctions[this->id](this);
}

View File

@ -34,7 +34,7 @@ void sub_0805E1F8(u32, bool32);
void EnterRoomTextboxManager_Main(EnterRoomTextboxManager* this) {
EnterRoomTextboxManager_Actions[super->action](this);
if ((gRoomControls.room != this->unk_20) || (gMessage.doTextBox & 0x7F)) {
if ((gRoomControls.room != this->unk_20) || (gMessage.state & MESSAGE_ACTIVE)) {
sub_0805E1D8(this);
}
}
@ -56,7 +56,7 @@ void sub_0805E18C(EnterRoomTextboxManager* this) {
if (--super->subtimer == 0) {
super->type2 = 0;
gPlayerState.controlMode = CONTROL_1;
ResetSystemPriority();
ClearEventPriority();
}
}
if (--super->timer == 0) {

View File

@ -26,7 +26,7 @@ void EntitySpawnManager_Main(EntitySpawnManager* this) {
if (super->type2 != 0) {
super->type2 = 0;
SetPlayerControl(0xff);
sub_08078B48();
PausePlayer();
}
if (this->spawnTimer == 0) {
if (this->sound != 0) {

View File

@ -69,7 +69,7 @@ static void EzloHintManager_Action2(EzloHintManager* this) {
if (!PlayerStateValid(this))
return;
SetPlayerControl(3);
sub_08078B48();
PausePlayer();
SetPlayerEventPriority();
super->action = 3;
super->subAction = 0;

View File

@ -20,8 +20,8 @@ extern void sub_0801E120(void);
extern void sub_0801E154(u32);
extern void sub_0801E160(u32, u32, u32);
bool32 sub_0805BA78();
void sub_0805BAD4();
bool32 LerpLightLevel();
void UpdateLightAlpha();
void LightManager_Main(LightManager* this) {
s32 sVar1;
@ -43,8 +43,8 @@ void LightManager_Main(LightManager* this) {
}
if (gMain.substate == GAMEMAIN_UPDATE) {
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
sub_0805BA78();
sub_0805BAD4();
LerpLightLevel();
UpdateLightAlpha();
}
if (gArea.lightType == 2) {
gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON;
@ -87,44 +87,33 @@ void LightManager_Main(LightManager* this) {
#define ABS(x) ((unsigned)(x < 0 ? -(x) : x))
bool32 sub_0805BA78() {
u32 uVar1;
s32 iVar1;
s32 iVar2;
bool32 LerpLightLevel() {
s32 tgt;
s32 cur;
iVar2 = (short)gArea.lightLevel;
iVar1 = gRoomVars.lightLevel;
cur = (short)gArea.lightLevel;
tgt = gRoomVars.lightLevel;
if (iVar1 < 0) {
iVar1 = 0;
}
tgt = max(tgt, 0);
tgt = min(tgt, 0x100);
if (0x100 < iVar1) {
iVar1 = 0x100;
}
if (iVar2 != iVar1) {
if (ABS(iVar1 - iVar2) <= 4) {
iVar2 = iVar1;
} else {
if (iVar1 < iVar2) {
iVar2 = iVar2 - 4;
} else {
if (iVar1 > iVar2) {
iVar2 = iVar2 + 4;
}
}
}
gArea.lightLevel = iVar2;
} else {
return FALSE;
if (cur != tgt) {
if (ABS(tgt - cur) <= 4) {
cur = tgt;
} else if (tgt < cur) {
cur -= 4;
} else if (tgt > cur) {
cur += 4;
}
gArea.lightLevel = cur;
return TRUE;
}
return FALSE;
}
extern u16 gUnk_08108CA8[];
void sub_0805BAD4() {
void UpdateLightAlpha() {
static const u16 gUnk_08108CA8[] = { 0x10, 0x10f, 0x20e, 0x30d, 0x40c, 0x50b, 0x60a, 0x709, 0x808,
0x907, 0xa06, 0xb05, 0xc04, 0xd03, 0xe02, 0xf01, 0x1000, 0x00 };
if (gArea.lightType != 0) {
@ -164,8 +153,8 @@ void sub_0805BB74(s32 lightLevel) {
if (manager) {
LightManager_Main(manager);
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
sub_0805BA78();
sub_0805BAD4();
LerpLightLevel();
UpdateLightAlpha();
}
}
@ -175,9 +164,9 @@ bool32 UpdateLightLevel() {
iVar1 = FALSE;
if (gArea.lightType && gRoomVars.lightLevel < (s16)gArea.lightLevel) {
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
iVar1 = sub_0805BA78();
iVar1 = LerpLightLevel();
if (iVar1) {
sub_0805BAD4();
UpdateLightAlpha();
}
}
return iVar1;
@ -189,9 +178,9 @@ s32 sub_0805BC04(void) {
iVar1 = 0;
if (gArea.lightType && gRoomVars.lightLevel > (short)gArea.lightLevel) {
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
iVar1 = sub_0805BA78();
iVar1 = LerpLightLevel();
if (iVar1) {
sub_0805BAD4();
UpdateLightAlpha();
}
}
return iVar1;

View File

@ -70,7 +70,7 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) {
super->subAction = 0;
super->timer = 120;
SetPlayerControl(2);
sub_08078B48();
PausePlayer();
object = CreateObject(THUNDERBOLT, 0, 0);
if (object != NULL) {
object->x.HALF.HI = gRoomControls.origin_x + 0x88;
@ -100,7 +100,7 @@ void Vaati3StartManager_Type0_Action2(Vaati3StartManager* this) {
}
void Vaati3StartManager_Type0_Action3(Vaati3StartManager* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
if (super->timer != 0) {
super->timer--;
} else {

View File

@ -331,7 +331,7 @@ void KinstoneMenu_Type5_Overlay0(void) {
}
void KinstoneMenu_Type5_Overlay1(void) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
gMenu.overlayType = 2;
SoundReq(SFX_147);
}

View File

@ -49,7 +49,7 @@ static void StatusUpdate(u32 status);
static void SwitchChoice(u32 to, u32 from);
static void MsgChangeLine(u32 lineNo);
static void SetDoTextBox(u32 doTextbox);
static void SetState(u32 status);
static void DeleteWindow(void);
static u32 ChangeWindowSize(u32 delta);
@ -122,14 +122,14 @@ s32 sub_08056338(void) {
s32 result;
result = -1;
if (((gMessage.doTextBox & 0x7f) == 0) && (gUnk_02000040.unk_00 == 3))
if (((gMessage.state & MESSAGE_ACTIVE) == 0) && (gUnk_02000040.unk_00 == 3))
result = gUnk_02000040.unk_01;
return result;
}
void MessageClose(void) {
if ((gMessage.doTextBox & 0x7f) != 0) {
gMessage.doTextBox = 0x88;
if (gMessage.state & MESSAGE_ACTIVE) {
gMessage.state = 0x88;
}
}
@ -173,7 +173,7 @@ void MessageRequest(u32 index) {
gMessage.textWindowHeight = 4;
gMessage.textWindowPosX = 1;
gMessage.textWindowPosY = 12;
gMessage.doTextBox = 1;
gMessage.state = 1;
}
void MessageInitialize(void) {
@ -190,7 +190,7 @@ void MessageMain(void) {
[MSG_OPEN] = MsgOpen, [MSG_CLOSE] = MsgClose, [MSG_DIE] = MsgDie,
};
if (gMessage.doTextBox == 1) {
if (gMessage.state == 1) {
MemClear((u32*)&gTextRender, sizeof(gTextRender));
StatusUpdate(MSG_INIT);
}
@ -258,7 +258,7 @@ u32 MsgInit(void) {
gTextRender.curToken._c = &gUnk_08107BE0;
gTextRender._50.unk8 = gTextGfxBuffer;
gTextRender._50.unk4 = 0xd0;
SetDoTextBox(2);
SetState(2);
MsgChangeLine(0);
StatusUpdate(MSG_UPDATE);
return 1;
@ -295,7 +295,7 @@ static u32 MsgClose(void) {
}
static u32 MsgDie(void) {
SetDoTextBox(0);
SetState(0);
StatusUpdate(MSG_IDLE);
return 0;
}
@ -306,7 +306,7 @@ static u32 MsgUpdate(void) {
[RENDER_WAIT] = TextDispWait, [RENDER_ROLL] = TextDispRoll, [RENDER_ENQUIRY] = TextDispEnquiry,
};
SetDoTextBox(4);
SetState(4);
gTextDispFunctions[gTextRender.renderStatus](&gTextRender);
ChangeWindowSize(0);
return 0;
@ -604,7 +604,7 @@ static void TextDispRoll(TextRender* this) {
static void TextDispDie(TextRender* this) {
gMessage.unk = 0;
SetDoTextBox(7);
SetState(7);
if ((this->_8e != 1) && (this->_8e == 2 || MESSAGE_PRESS_ANY_ADVANCE_KEYS)) {
StatusUpdate(MSG_CLOSE);
}
@ -628,8 +628,8 @@ static void MsgChangeLine(u32 lineNo) {
PaletteChange(&gTextRender, gTextRender._8f | 0x40);
}
static void SetDoTextBox(u32 doTextbox) {
gMessage.doTextBox = gTextRender.message.doTextBox = doTextbox;
static void SetState(u32 status) {
gMessage.state = gTextRender.message.state = status;
}
static void DeleteWindow(void) {

View File

@ -14,7 +14,7 @@ void NPCUpdate(Entity* this) {
DeleteThisEntity();
if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
NPCInit(this);
if (!EntityIsDeleted(this))
if (!EntityDisabled(this))
gNPCFunctions[this->id][0](this);
if (this->next != NULL) {
if (gNPCFunctions[this->id][1] != NULL)

View File

@ -94,7 +94,7 @@ void Beedle_Action1(Entity* this) {
}
void Beedle_Action2(Entity* this) {
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action++;
InitializeAnimation(this, 8);
}

View File

@ -266,7 +266,7 @@ void sub_0806D274(BigGoronEntity* this) {
case 0:
case 1:
default:
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->frameIndex = 2;
break;
}

View File

@ -72,7 +72,7 @@ void sub_08063584(Entity* this) {
}
void sub_08063608(Entity* this) {
u8 tmp = gMessage.doTextBox & 0x7f;
u8 tmp = gMessage.state & MESSAGE_ACTIVE;
if (tmp == 0) {
this->action = 1;
this->subtimer = tmp;

View File

@ -99,7 +99,7 @@ void sub_08064570(CastleMaidEntity* this) {
}
break;
case 2:
if ((gMessage.doTextBox & 0x7f) != 0) {
if ((gMessage.state & MESSAGE_ACTIVE) != 0) {
return;
}
super->action = 1;

View File

@ -219,7 +219,7 @@ void sub_0806797C(CatEntity* this) {
void sub_0806799C(CatEntity* this) {
UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
sub_08067B08(this);
SetEntityPriority(super, PRIO_PLAYER);
}

View File

@ -54,7 +54,7 @@ void sub_08065A00(EponaEntity* this) {
}
void sub_08065A10(EponaEntity* this) {
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = 1;
InitAnimationForceUpdate(super, super->animationState / 2);
}

View File

@ -162,7 +162,7 @@ void sub_08065D74(GhostBrothersEntity* this) {
void sub_08065DB8(GhostBrothersEntity* this) {
switch (super->subAction) {
case 0: {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->subAction++;
super->timer = 60;
InitAnimationForceUpdate(super, 4);
@ -188,7 +188,7 @@ void sub_08065DB8(GhostBrothersEntity* this) {
break;
}
case 4: {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->subAction++;
super->timer = 30;
this->unk_6c = gUnk_0811022E;

View File

@ -72,7 +72,7 @@ void sub_08069328(Entity* this) {
void sub_08069390(Entity* this) {
UpdateAnimationSingleFrame(this);
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->interactType = INTERACTION_NONE;
RevokePriority(this);

View File

@ -57,9 +57,9 @@ void sub_080695AC(Entity* this) {
void sub_080695E8(Entity* this) {
UpdateAnimationSingleFrame(this);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->interactType = gMessage.doTextBox & 0x7f;
this->interactType = gMessage.state & MESSAGE_ACTIVE;
RevokePriority(this);
InitAnimationForceUpdate(this, this->animationState);
}

View File

@ -346,7 +346,7 @@ void sub_08063E54(Entity* this) {
}
void sub_08063E6C(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
InitializeAnimation(this, this->animationState + 4);
}
@ -397,7 +397,7 @@ void sub_08063F20(GuardEntity* this) {
}
void sub_08063F78(GuardEntity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = super->action - 1;
InitializeAnimation(super, (super->animationState >> 1) + 4 + this->unk_70);
}

View File

@ -319,7 +319,7 @@ void sub_080621AC(KidEntity* this) {
break;
case 2:
GetNextFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = 1;
}
break;

View File

@ -150,7 +150,7 @@ void sub_08067EF0(MountainMinishEntity* this) {
}
break;
case 2:
if ((gMessage.doTextBox & 0x7f) != 0)
if ((gMessage.state & MESSAGE_ACTIVE) != 0)
break;
super->action = 1;
InitializeAnimation(super, (super->animationState >> 1) + 4);

View File

@ -101,7 +101,7 @@ void sub_080663D4(NPC23Entity* this) {
}
ProcessMovement0(super);
}
sub_08078B48();
PausePlayer();
GetNextFrame(super);
}

View File

@ -51,7 +51,7 @@ void sub_08062B48(Entity* this) {
}
void sub_08062B70(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
InitializeAnimation(this, 2);
this->action = 1;
RevokePriority(this);

View File

@ -149,13 +149,13 @@ void sub_0806B540(Entity* this) {
SetLocalFlag(0x3f);
break;
case 1:
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
context->unk_18 = 2;
MessageNoOverlap(TEXT_INDEX(TEXT_PERCY, 0x15), this);
}
break;
case 2:
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
context->unk_18 = 3;
if (gSave.stats.hasAllFigurines != 0) {
InitItemGetSequence(ITEM_RUPEE100, 0, 0);

View File

@ -74,7 +74,7 @@ void sub_08063AC0(Entity* this) {
}
void sub_08063B44(Entity* this) {
u8 tmp = gMessage.doTextBox & 0x7f;
u8 tmp = gMessage.state & MESSAGE_ACTIVE;
if (tmp == 0) {
this->action = 1;
this->subtimer = tmp;

View File

@ -273,7 +273,7 @@ void sub_08060528(PostmanEntity* this) {
break;
case 2:
UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) != 0) {
if ((gMessage.state & MESSAGE_ACTIVE) != 0) {
break;
}
super->action = 1;

View File

@ -64,7 +64,7 @@ void sub_08062C24(Entity* this) {
}
void sub_08062C54(Entity* this) {
if ((gMessage.doTextBox & 127) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
InitializeAnimation(this, 0);
RevokePriority(this);

View File

@ -108,8 +108,8 @@ void sub_080650CC(StockwellEntity* this) {
void sub_080651AC(StockwellEntity* this) {
GetNextFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
super->interactType = gMessage.doTextBox & 0x7f;
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->interactType = gMessage.state & MESSAGE_ACTIVE;
super->action = 1;
InitializeAnimation(super, 4);
}
@ -164,7 +164,7 @@ void sub_0806528C(Entity* this) {
}
void sub_080652B0(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->subAction++;
this->timer = 10;
gRoomVars.animFlags = this->subtimer;
@ -184,16 +184,16 @@ void sub_080652E4(Entity* this) {
}
void sub_08065314(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->subAction++;
MenuFadeIn(3, 3);
}
}
void sub_08065338(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->subAction = gMessage.doTextBox & 0x7f;
this->subAction = gMessage.state & MESSAGE_ACTIVE;
gRoomVars.animFlags = this->subtimer;
InitializeAnimation(this, 4);
}

View File

@ -127,7 +127,7 @@ void sub_08064B88(SturgeonEntity* this) {
}
void sub_08064C2C(SturgeonEntity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = 1;
InitializeAnimation(super, (u32)super->subtimer);
}

View File

@ -119,7 +119,7 @@ void sub_08065680(TalonEntity* this) {
}
void sub_080656A4(TalonEntity* this) {
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = this->unk_69;
InitAnimationForceUpdate(super, this->unk_6a);
}

View File

@ -250,7 +250,7 @@ void sub_0806ACC4(TownMinishEntity* this) {
}
break;
case 2:
if (gMessage.doTextBox & 0x7f)
if (gMessage.state & MESSAGE_ACTIVE)
break;
super->action = 1;

View File

@ -153,7 +153,7 @@ void sub_08061D64(TownspersonEntity* this) {
void sub_08061E24(TownspersonEntity* this) {
GetNextFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
super->action = 1;
InitializeAnimation(super, this->unk_69);
}

View File

@ -78,7 +78,7 @@ void sub_0806C7D4(Entity* this) {
}
void sub_0806C834(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
--this->action;
InitializeAnimation(this, (this->animationState / 2) + 4);
}

View File

@ -205,7 +205,7 @@ void ObjectUpdate(Entity* this) {
ObjectInit(this);
if (this->iframes != 0)
this->iframes++;
if (!EntityIsDeleted(this)) {
if (!EntityDisabled(this)) {
gObjectFunctions[this->id](this);
this->contactFlags &= ~0x80;
}

View File

@ -225,7 +225,7 @@ void Bird_Type8(BirdEntity* this) {
super->speed = 0x300;
}
if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.doTextBox & 0x7f) == 0 &&
if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.state & MESSAGE_ACTIVE) == 0 &&
gPlayerEntity.action != PLAYER_SLEEP && gPlayerEntity.action != PLAYER_BOUNCE &&
gPlayerEntity.action != PLAYER_MINISH && gPlayerState.framestate != PL_STATE_CLIMB &&
gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_PARACHUTE &&
@ -240,21 +240,21 @@ void Bird_Type8(BirdEntity* this) {
super->speed = 0x300;
this->gravity = Q_8_8(-32.0);
PlayerDropHeldObject();
sub_08078B48();
PausePlayer();
ResetPlayerAnimationAndAction();
PutAwayItems();
gPlayerState.swim_state = 0;
gPlayerState.jump_status = 0;
gPlayerEntity.flags &= ~0x80;
gPlayerEntity.spriteSettings.draw = 0;
gPriorityHandler.sys_priority = 6;
gPriorityHandler.event_priority = 6;
gPauseMenuOptions.disabled = 1;
}
}
}
break;
default:
sub_08078B48();
PausePlayer();
gPlayerEntity.spriteSettings.draw = 0;
break;
}
@ -313,7 +313,7 @@ void Bird_Type9(BirdEntity* this) {
SoundReq(SFX_123);
super->spritePriority.b1 = 2;
InitAnimationForceUpdate(super, 0);
sub_08078B48();
PausePlayer();
} else if (super->action == 1) {
gPlayerEntity.spriteSettings.draw = 0;
child = super->child;
@ -324,7 +324,7 @@ void Bird_Type9(BirdEntity* this) {
child->spriteRendering.b3 = super->spriteRendering.b3;
child->spriteOrientation.flipY = super->spriteOrientation.flipY;
}
sub_08078B48();
PausePlayer();
if (gRoomControls.scroll_x + 0x78 < super->x.HALF.HI) {
super->action++;
super->spritePriority.b1 = 1;

View File

@ -208,10 +208,10 @@ void Book_Action5(BookEntity* this) {
break;
}
case 1: {
u8 doTextBox = gMessage.doTextBox & 0x7f;
if (!doTextBox) {
u8 status = gMessage.state & MESSAGE_ACTIVE;
if (!status) {
super->spriteSettings.draw = 1;
super->subAction = doTextBox;
super->subAction = status;
}
break;
}

View File

@ -38,7 +38,7 @@ void Bush(BushEntity* this) {
Bush_Action1,
Bush_Action2,
};
if (!EntityIsDeleted(super)) {
if (!EntityDisabled(super)) {
Bush_Actions[super->action](this);
}
}

View File

@ -53,7 +53,7 @@ void CameraTarget(Entity* this) {
case FUSION_STATE_0:
case FUSION_STATE_1:
case FUSION_STATE_2:
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
break;
}
default:

View File

@ -104,7 +104,7 @@ void sub_0809F5F0(CloudEntity* this) {
super->action = 2;
super->timer = 120;
SetPlayerControl(3);
sub_08078B48();
PausePlayer();
gRoomControls.camera_target = super;
}
}

View File

@ -266,7 +266,7 @@ void CrenelBeanSprout_Action6(CrenelBeanSproutEntity* this) {
CrenelBeanSprout_Action6SubAction2,
};
if (super->subAction != 2) {
sub_08078B48();
PausePlayer();
}
CrenelBeanSprout_Action6SubActions[super->subAction](this);
}

View File

@ -457,7 +457,7 @@ void CutsceneMiscObject_Type7(CutsceneMiscObjectEntity* this) {
}
break;
case 2:
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
CreateItemEntity(ITEM_JABBERNUT, 0, 0);
DeleteThisEntity();
}

View File

@ -81,11 +81,11 @@ void EzloCap_Type0Action1(EzloCapEntity* this) {
static const u8 gUnk_0811F16C[] = { 4, 0, 2, 6, 10, 8, 9, 5, 1, 0, 0, 0 };
u32 tmp = gPlayerEntity.palette.b.b0;
super->palette.b.b0 = tmp;
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
DeleteEntity(super);
return;
}
if ((gMessage.doTextBox & 0x7f) != 5) {
if ((gMessage.state & MESSAGE_ACTIVE) != 5) {
if (((gMessage.unk == 0xa) || (gMessage.unk == 0)) || ((gMessage.unk & 0xf) > 9)) {
if (super->animIndex != (super->subtimer | 3)) {
InitAnimationForceUpdate(super, super->subtimer | 3);

View File

@ -138,7 +138,7 @@ void FourElements_Action5(FourElementsEntity* this) {
void FourElements_Action6(FourElementsEntity* this) {
RequestPriorityDuration(NULL, 10);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
SetPriorityTimer(90);
gPlayerState.controlMode = 1;
EnablePauseMenu();

View File

@ -267,7 +267,7 @@ void FrozenOctorok_Action1SubAction0(FrozenOctorokEntity* this) {
void FrozenOctorok_Action1SubAction1(FrozenOctorokEntity* this) {
Entity* obj;
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
if (this->unk_79-- == 0) {
obj = CreateObjectWithParent(super, FROZEN_OCTOROK, 7, 0);
if (obj != NULL) {

View File

@ -96,7 +96,7 @@ void sub_080921BC(GentariCurtainEntity* this) {
GenericEntity* pEVar1;
GenericEntity* end;
pEVar1 = (GenericEntity*)gItemGetEntities;
pEVar1 = (GenericEntity*)gAuxPlayerEntities;
end = pEVar1 + 0x4f;
do {

View File

@ -82,7 +82,7 @@ void GleerokParticle_Init(GleerokParticleEntity* this) {
DeleteThisEntity();
}
}
sub_08078B48();
PausePlayer();
return;
case 0:
super->direction = gUnk_081229D0[super->type2].direction;

View File

@ -96,7 +96,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
if (super->interactType != INTERACTION_NONE) {
super->interactType = INTERACTION_NONE;
super->subAction = 1;
sub_08078B48();
PausePlayer();
ResetActiveItems();
gPlayerState.heldObject = 4;
gNewPlayerEntity.unk_74 = super;

View File

@ -325,7 +325,7 @@ void LilypadLarge_Action2(LilypadLargeEntity* this) {
};
subActionFuncs[super->subAction](this);
gPlayerState.flags |= PL_FLAGS2;
sub_08078B48();
PausePlayer();
}
void sub_08085A44(LilypadLargeEntity* this) {
@ -460,7 +460,7 @@ void sub_08085D28(LilypadLargeEntity* this) {
(GetRelativeCollisionTile(super, 0, 0x18) == 0x11)) {
super->action = 2;
super->subAction = 0;
sub_08078B48();
PausePlayer();
}
}

View File

@ -93,7 +93,7 @@ void LinkAnimation_ItemGet(LinkAnimationEntity* this) {
break;
case ITEMGET_WAIT:
UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) != 0) {
if ((gMessage.state & MESSAGE_ACTIVE) != 0) {
return;
}
if (super->frame & ANIM_DONE) {

View File

@ -18,7 +18,7 @@ void MoleMittsParticle(Entity* this) {
MoleMittsParticle_Init,
MoleMittsParticle_Action1,
};
if (!EntityIsDeleted(this)) {
if (!EntityDisabled(this)) {
MoleMittsParticle_Actions[this->action](this);
}
}

View File

@ -316,7 +316,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) {
}
break;
case 9:
sub_08078B48();
PausePlayer();
if ((this->unk_78.WORD_U)-- == 0) {
gRoomControls.camera_target = &gPlayerEntity;
DeleteThisEntity();

View File

@ -40,7 +40,7 @@ void Well_Init(WellEntity* this) {
void Well_Action1(WellEntity* this) {
u32 tileIndex = GetTileType(this->unk_80, 1);
if (tileIndex != 0x407D) {
sub_08078B48();
PausePlayer();
gPlayerEntity.x.WORD = super->x.WORD;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI + 4;
DeleteThisEntity();

View File

@ -21,7 +21,7 @@ void WindTribeTeleporter_Action1(WindTribeTeleporterEntity*);
void WindTribeTeleporter_Action2(WindTribeTeleporterEntity*);
void WindTribeTeleporter_Action3(WindTribeTeleporterEntity*);
void sub_080A11E0(WindTribeTeleporterEntity*);
bool32 sub_080A11C0(WindTribeTeleporterEntity*);
static bool32 PlayerCollidingTeleporter(WindTribeTeleporterEntity*);
void WindTribeTeleporter(WindTribeTeleporterEntity* this) {
static void (*const WindTribeTeleporter_Actions[])(WindTribeTeleporterEntity*) = {
@ -40,11 +40,11 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) {
super->spritePriority.b0 = 7;
super->hitbox = (Hitbox*)&gHitbox_22;
SetEntityPriority(super, 6);
if (sub_080A11C0(this)) {
if (PlayerCollidingTeleporter(this)) {
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
SetPlayerControl(CONTROL_DISABLED);
sub_08078B48();
PausePlayer();
SetPlayerEventPriority();
SoundReq(SFX_112);
super->action = 3;
@ -54,12 +54,12 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) {
}
void WindTribeTeleporter_Action1(WindTribeTeleporterEntity* this) {
if (sub_080A11C0(this)) {
if (PlayerCollidingTeleporter(this)) {
if (this->unk_68 == 0) {
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
SetPlayerControl(CONTROL_DISABLED);
sub_08078B48();
PausePlayer();
SetPlayerEventPriority();
SoundReq(SFX_112);
super->action = 2;
@ -177,7 +177,7 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) {
}
}
bool32 sub_080A11C0(WindTribeTeleporterEntity* this) {
static bool32 PlayerCollidingTeleporter(WindTribeTeleporterEntity* this) {
if (gPlayerEntity.z.HALF.HI != 0) {
return FALSE;
} else {

View File

@ -31,7 +31,7 @@ const s8 gUnk_08126EEC[] = {
};
Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) {
Entity* e = CreateItemGetEntity();
Entity* e = CreateAuxPlayerEntity();
if (e != NULL) {
LinkAnimationEntity* this = (LinkAnimationEntity*)e;
e->id = LINK_ANIMATION;
@ -42,7 +42,7 @@ Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) {
AppendEntityToList(e, 6);
PrependEntityToList(e, 6);
CopyPosition(&gPlayerEntity, e);
gPriorityHandler.sys_priority = 6;
gPriorityHandler.event_priority = 6;
gPauseMenuOptions.disabled = 1;
// store player state

View File

@ -280,7 +280,7 @@ extern ScriptExecutionContext gPlayerScriptExecutionContext;
bool32 CheckInitPauseMenu(void) {
u32 framestate;
if (((gInput.newKeys & START_BUTTON) == 0 || gFadeControl.active || gPauseMenuOptions.disabled ||
(gMessage.doTextBox & 0x7F) || gSave.stats.health == 0 || !gSave.inventory[0] ||
(gMessage.state & MESSAGE_ACTIVE) || gSave.stats.health == 0 || !gSave.inventory[0] ||
gPlayerState.controlMode != 0 || gPriorityHandler.priority_timer != 0)) {
return FALSE;
}
@ -728,7 +728,7 @@ static void sub_08070E9C(Entity* this) {
static void sub_08070EDC(Entity* this) {
this->updatePriority = PRIO_MESSAGE;
if ((gMessage.doTextBox & 0x7f) != 0)
if (gMessage.state & MESSAGE_ACTIVE)
this->subAction = 1;
if ((gPlayerState.flags & PL_MINISH) == 0)
@ -739,7 +739,7 @@ static void sub_08070EDC(Entity* this) {
static void sub_08070f24(Entity* this) {
UpdateAnimationSingleFrame(this);
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->updatePriority = this->updatePriorityPrev;
ResetPlayerAnimationAndAction();
}
@ -808,7 +808,7 @@ static void sub_08071038(Entity* this) {
UpdateAnimationSingleFrame(this);
// player is still reading message
if (CheckQueuedAction() || (gMessage.doTextBox & 0x7f))
if (CheckQueuedAction() || (gMessage.state & MESSAGE_ACTIVE))
return;
if (this->frame & ANIM_DONE) {
@ -1286,7 +1286,7 @@ static void PlayerTalkEzlo_Init(Entity* this) {
ResetActiveItems();
gActiveItems[ACTIVE_ITEM_LANTERN].animPriority = 0;
this->iframes = 0;
gPriorityHandler.sys_priority = PRIO_PLAYER_EVENT;
gPriorityHandler.event_priority = PRIO_PLAYER_EVENT;
this->updatePriority = PRIO_PLAYER_EVENT;
if (gPlayerState.flags & PL_MINISH) {
@ -1335,7 +1335,7 @@ static void PlayerTalkEzlo_CreateMessage(Entity* this) {
static void PlayerTalkEzlo_MessageIdle(Entity* this) {
u32 rightOrLeft;
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->subAction++;
if ((gPlayerState.flags & PL_MINISH) == 0) {
if (this->animationState == IdleEast)
@ -1380,7 +1380,7 @@ static void PlayerTalkEzlo_Leave(Entity* this) {
}
static void reset_priority(void) {
gPriorityHandler.sys_priority = PRIO_MIN;
gPriorityHandler.event_priority = PRIO_MIN;
gPlayerEntity.updatePriority = gPlayerEntity.updatePriorityPrev;
}

View File

@ -72,7 +72,7 @@ void ItemUpdate(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0 && this->subAction == 0)
ItemInit(this);
if (!EntityIsDeleted(this)) {
if (!EntityDisabled(this)) {
gPlayerItemFunctions[this->id](this);
this->contactFlags &= ~0x80;
if (this->iframes != 0) {

View File

@ -36,7 +36,7 @@ static Entity* GiveItemWithCutscene(u32 item, u32 type2, u32 delay) {
item = ITEM_RUPEE50;
type2 = 0;
}
e = CreateItemGetEntity();
e = CreateAuxPlayerEntity();
if (e != NULL) {
e->type = item;
e->type2 = type2;

View File

@ -462,7 +462,7 @@ Entity* CreatePlayerItemWithParent(ItemBehavior* this, u32 id) {
}
void* CreateItemGetPlayerItemWithParent(ItemBehavior* this) {
GenericEntity* playerItem = (GenericEntity*)CreateItemGetEntity();
GenericEntity* playerItem = (GenericEntity*)CreateAuxPlayerEntity();
if (playerItem != NULL) {
playerItem->base.id = gItemDefinitions[this->behaviorId].playerItemId;
playerItem->base.kind = PLAYER_ITEM;
@ -501,7 +501,7 @@ Entity* CreatePlayerItem(u32 id, u32 type, u32 type2, u32 unk) {
Entity* sub_08077CF8(u32 id, u32 type, u32 type2, u32 unk) {
GenericEntity* ent;
ent = (GenericEntity*)CreateItemGetEntity();
ent = (GenericEntity*)CreateAuxPlayerEntity();
if (ent != NULL) {
ent->base.flags = ENT_COLLIDE;
ent->base.kind = PLAYER_ITEM;
@ -988,7 +988,7 @@ bool32 sub_08078140(ChargeState* info) {
void ForceSetPlayerState(u32 framestate) {
gPlayerState.framestate = framestate;
gPlayerEntity.flags &= ~ENT_COLLIDE;
sub_08078B48();
PausePlayer();
}
void DetermineRButtonInteraction(void) {
@ -1504,7 +1504,7 @@ void SetPlayerItemGetState(Entity* item, u8 param_2, u8 param_3) {
DeleteClones();
}
void sub_08078B48(void) {
void PausePlayer(void) {
gPlayerState.field_0x7 |= 0x80;
gPlayerState.keepFacing |= 0x80;
gPlayerState.field_0xa |= 0x80;
@ -2494,7 +2494,7 @@ u32 sub_08079FD4(Entity* this, u32 param_2) {
void UpdatePlayerPalette(void) {
u32 palette;
if ((gPlayerState.hurtBlinkSpeed != 0) && ((gMessage.doTextBox & 0x7f) == 0)) {
if ((gPlayerState.hurtBlinkSpeed != 0) && ((gMessage.state & MESSAGE_ACTIVE) == 0)) {
gPlayerState.hurtBlinkSpeed--;
}
palette = GetPlayerPalette(FALSE);

View File

@ -1054,7 +1054,7 @@ void ScriptCommand_0807E858(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_SetPlayerIdle(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.controlMode = CONTROL_DISABLED;
sub_08078B48();
PausePlayer();
}
void ScriptCommand_EnablePlayerControl(Entity* entity, ScriptExecutionContext* context) {
@ -1129,7 +1129,7 @@ void ScriptCommand_0807E974(Entity* entity, ScriptExecutionContext* context) {
MessageFromTarget(context->scriptInstructionPointer[1]);
break;
case 1:
if (gMessage.doTextBox & 0x7F)
if (gMessage.state & MESSAGE_ACTIVE)
break;
context->unk_18 = 2;
context->unk_19 = 0xF;
@ -1191,7 +1191,7 @@ void ScriptCommand_AddInteractableFuser(Entity* entity, ScriptExecutionContext*
}
void ScriptCommand_WaitUntilTextboxCloses(Entity* entity, ScriptExecutionContext* context) {
if (gMessage.doTextBox & 0x7F) {
if (gMessage.state & MESSAGE_ACTIVE) {
gActiveScriptInfo.commandSize = 0;
}
}

View File

@ -268,7 +268,7 @@ void sub_0807FF1C(RoomControls* controls) {
gUpdateVisibleTiles = 3;
if (++controls->unk_18 > 0x13) {
controls->scrollAction = 0;
ResetSystemPriority();
ClearEventPriority();
}
}
}
@ -408,7 +408,7 @@ void sub_080801BC(RoomControls* controls) {
if (controls->unk_1c == 0) {
controls->scrollAction = 0;
controls->reload_flags = 0;
ResetSystemPriority();
ClearEventPriority();
gScreen.lcd.displayControl &= ~DISPCNT_WIN1_ON;
gScreen.controls.windowInsideControl &= 0xff;
gScreen.controls.windowOutsideControl &= 0xff00;

View File

@ -93,7 +93,7 @@ void StaffrollTask_State0(void) {
gScreen.bg1.control = 0x1e4d;
gScreen.bg2.control = 0x1dc3;
InitSoundPlayingInfo();
ResetSystemPriority();
ClearEventPriority();
SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100);
}

View File

@ -278,7 +278,7 @@ void Subtask_Die(void) {
gMain.substate = gUI.pauseFadeIn;
gUI.nextToLoad = gFadeControl.active;
gUI.lastState = gFadeControl.active;
ResetSystemPriority();
ClearEventPriority();
}
}

View File

@ -626,7 +626,8 @@ void ButtonUIElement_Action1(UIElement* element) {
MAX_MOVEMENT = (!element->type2) ? 4 : 8;
if (element->type2 == 0 && (((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.doTextBox & 0x7f) != 0)) {
if (element->type2 == 0 &&
(((gUnk_0200AF00.unk_1 >> element->type) & 1) || (gMessage.state & MESSAGE_ACTIVE) != 0)) {
y = (s16)gUnk_0200AF00.buttonY[element->type] - 0x28;
} else {
y = (s16)gUnk_0200AF00.buttonY[element->type];
@ -792,7 +793,7 @@ void HeartUIElement(UIElement* element) {
u32 health;
u32 frameIndex;
element->unk_0_1 = 0;
if (((gUnk_0200AF00.unk_1 & 0x10) == 0) && ((gMessage.doTextBox & 0x7f) == 0)) {
if (((gUnk_0200AF00.unk_1 & 0x10) == 0) && ((gMessage.state & MESSAGE_ACTIVE) == 0)) {
health = gUnk_0200AF00.health;
if (health != 0) {
element->unk_0_1 = 1;
@ -845,7 +846,7 @@ void EzloNagUIElement_Action1(UIElement* element) {
}
void EzloNagUIElement_Action2(UIElement* element) {
if (gUnk_0200AF00.ezloNagFuncIndex >= 5 || (gMessage.doTextBox & 0x7f)) {
if (gUnk_0200AF00.ezloNagFuncIndex >= 5 || (gMessage.state & MESSAGE_ACTIVE)) {
element->action = 0;
element->unk_0_1 = 0;
return;