PlayState rename (#835)

* PlayState rename

* Make this work with the latest master and run format

* Respond to hensldm's review

* Respond to Elliptic's review

* Add Effect_GetPlayState to namefixer.py

* Add missed comma
This commit is contained in:
Tom Overton 2022-06-26 08:57:37 -07:00 committed by GitHub
parent f77c4770f7
commit 158d1b26b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1175 changed files with 36240 additions and 36688 deletions

View File

@ -74,11 +74,11 @@ If you make significant progress on decompiling a function, but can't get it to
```c
#ifdef NON_MATCHING
void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) {
void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) {
// ...
}
#else
void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v);
void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s")
#endif
```

View File

@ -139,18 +139,18 @@ All compound flag lists (e.g. `ACTOR_FLAG_4 | ACTOR_FLAG_8`) should be listed in
- Use `sizeof` or `ARRAY_COUNT`/`ARRAY_COUNTU` where it makes sense, e.g. in loops that are using an array.
- clang-format sometimes does weird things to array formatting. Experiment with and without a comma after the last element and see which looks better.
## GlobalCtx2
## Play2
In some particular instances, IDO requires the function argument `globalCtx` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `globalCtx2` and than this `globalCtx2` just assigned to a stack variable called `globalCtx`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c`
In some particular instances, IDO requires the function argument `play` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `play2` and than this `play2` just assigned to a stack variable called `play`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c`
```c
void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
void EnFirefly_Update(Actor* thisx, PlayState* play2) {
PlayState* play = play2;
EnFirefly* this = THIS;
```
In other places the cast is actually not explictly needed, but a stack `pad` variable is still needed. For this there should just be a stack variable called `pad` of type `s32` before the actor `THIS` cast. For example in `z_bg_goron_oyu`
```c
void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) {
void BgGoronOyu_Init(Actor* thisx, PlayState* play) {
s32 pad;
BgGoronOyu* this = THIS;
CollisionHeader* colHeader = NULL;

View File

@ -16,15 +16,15 @@ Again our example will be taken from a small NPC: this time, `EnMs` (Bean Seller
#define THIS ((EnMs*)thisx)
void EnMs_Init(Actor* thisx, GlobalContext* globalCtx);
void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnMs_Update(Actor* thisx, GlobalContext* globalCtx);
void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnMs_Init(Actor* thisx, PlayState* play);
void EnMs_Destroy(Actor* thisx, PlayState* play);
void EnMs_Update(Actor* thisx, PlayState* play);
void EnMs_Draw(Actor* thisx, PlayState* play);
void func_80952734(EnMs* this, GlobalContext* globalCtx);
void func_809527F8(EnMs* this, GlobalContext* globalCtx);
void func_809529AC(EnMs* this, GlobalContext* globalCtx);
void func_80952A1C(EnMs *this, GlobalContext *globalCtx);
void func_80952734(EnMs* this, PlayState* play);
void func_809527F8(EnMs* this, PlayState* play);
void func_809529AC(EnMs* this, PlayState* play);
void func_80952A1C(EnMs* this, PlayState* play);
const ActorInit En_Ms_InitVars = {
ACTOR_EN_MS,
@ -56,13 +56,13 @@ extern InitChainEntry D_80952BCC[];
extern AnimationHeader D_060005EC;
extern FlexSkeletonHeader D_06003DC0;
void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) {
void EnMs_Init(Actor* thisx, PlayState* play) {
EnMs* this = THIS;
Actor_ProcessInitChain(thisx, D_80952BCC);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &D_80952BA0);
SkelAnime_InitFlex(play, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9);
Collider_InitCylinder(play, &this->collider);
Collider_SetCylinderType1(play, &this->collider, &this->actor, &D_80952BA0);
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f);
Actor_SetScale(&this->actor, 0.015f);
this->actor.colChkInfo.mass = 0xFF;
@ -72,13 +72,13 @@ void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) {
this->actor.gravity = -1.0f;
}
void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EnMs_Destroy(Actor* thisx, PlayState* play) {
EnMs* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->collider);
Collider_DestroyCylinder(play, &this->collider);
}
void func_80952734(EnMs* this, GlobalContext* globalCtx) {
void func_80952734(EnMs* this, PlayState* play) {
s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if (gSaveContext.save.inventory.items[10] == ITEM_NONE) {
@ -87,40 +87,40 @@ void func_80952734(EnMs* this, GlobalContext* globalCtx) {
this->actor.textId = 0x932;
}
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) {
this->actionFunc = func_809527F8;
return;
}
if (this->actor.xzDistToPlayer < 90.0f) {
if (ABS_ALT(temp_v1) < 0x2000) {
func_800B8614(&this->actor, globalCtx, 90.0f);
func_800B8614(&this->actor, play, 90.0f);
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_809527F8.s")
void func_809529AC(EnMs *this, GlobalContext *globalCtx) {
if (Actor_HasParent(&this->actor, globalCtx)) {
void func_809529AC(EnMs* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) {
this->actor.textId = 0;
func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0);
func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0);
this->actionFunc = func_80952A1C;
} else {
Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
}
}
void func_80952A1C(EnMs *this, GlobalContext *globalCtx) {
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) {
func_80151938(globalCtx, 0x936U);
void func_80952A1C(EnMs* this, PlayState* play) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
func_80151938(play, 0x936U);
this->actionFunc = func_809527F8;
} else {
func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1);
func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1);
}
}
void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) {
void EnMs_Update(Actor* thisx, PlayState* play) {
s32 pad;
EnMs* this = THIS;
@ -128,16 +128,16 @@ void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actor.targetArrowOffset = 500.0f;
Actor_SetScale(&this->actor, 0.015f);
SkelAnime_Update(&this->skelAnime);
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
}
void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) {
void EnMs_Draw(Actor* thisx, PlayState* play) {
EnMs* this = THIS;
func_8012C28C(globalCtx->state.gfxCtx);
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL,
func_8012C28C(play->state.gfxCtx);
SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL,
NULL, &this->actor);
}
@ -152,53 +152,53 @@ $ ../mips_to_c/mips_to_c.py asm/non_matchings/overlays/ovl_En_Ms/func_809527F8.s
```
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
void func_809527F8(EnMs* this, PlayState* play) {
u8 temp_v0;
u8 temp_v0_2;
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 != 4) {
if (temp_v0 != 5) {
if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) {
if ((temp_v0 == 6) && (Message_ShouldAdvance(play) != 0)) {
this->actionFunc = func_80952734;
return;
}
// Duplicate return node #17. Try simplifying control flow for better match
return;
}
if (Message_ShouldAdvance(globalCtx) != 0) {
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
if (Message_ShouldAdvance(play) != 0) {
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
return;
}
// Duplicate return node #17. Try simplifying control flow for better match
return;
}
if (Message_ShouldAdvance(globalCtx) != 0) {
temp_v0_2 = globalCtx->msgCtx.choiceIndex;
if (Message_ShouldAdvance(play) != 0) {
temp_v0_2 = play->msgCtx.choiceIndex;
if (temp_v0_2 != 0) {
if (temp_v0_2 != 1) {
}
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
// Duplicate return node #17. Try simplifying control flow for better match
return;
}
func_801477B4(globalCtx);
func_801477B4(play);
if ((s32) gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
}
if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
return;
}
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
}
@ -208,10 +208,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
which is long, messy, and contains some rather nasty-looking control flow, including horrors like
```C
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 != 4) {
if (temp_v0 != 5) {
if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) {
if ((temp_v0 == 6) && (Message_ShouldAdvance(play) != 0)) {
this->actionFunc = func_80952734;
return;
}
@ -234,11 +234,11 @@ For didactic purposes, we'll use a feature of mips2c called goto-only mode to ex
instead will produce
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
void func_809527F8(EnMs* this, PlayState* play) {
u8 temp_v0;
u8 temp_v0_2;
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 == 4) {
goto block_7;
}
@ -248,24 +248,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
if (temp_v0 != 6) {
goto block_17;
}
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
this->actionFunc = func_80952734;
return;
block_5:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
return;
block_7:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
temp_v0_2 = globalCtx->msgCtx.choiceIndex;
temp_v0_2 = play->msgCtx.choiceIndex;
if (temp_v0_2 == 0) {
goto block_11;
}
@ -274,29 +274,29 @@ block_7:
}
goto block_16;
block_11:
func_801477B4(globalCtx);
func_801477B4(play);
if ((s32) gSaveContext.save.playerData.rupees >= 0xA) {
goto block_13;
}
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
block_13:
if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) {
goto block_15;
}
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
return;
block_15:
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
return;
block_16:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
block_17:
return;
}
@ -316,7 +316,7 @@ The simplest sort of block label to eliminate is one that is only used once, and
goto block_13;
}
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
block_13:
```
@ -326,7 +326,7 @@ Currently, this says to jump over the code block `play_sound...` if the conditio
```C
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
}
```
@ -336,11 +336,11 @@ Likewise, one can do this with `block_15`.
If you examine appropriate part of the diff, you will usually find that such eliminations make no, or very little, difference to the compiled code.
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
void func_809527F8(EnMs* this, PlayState* play) {
u8 temp_v0;
u8 temp_v0_2;
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 == 4) {
goto block_7;
}
@ -350,24 +350,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
if (temp_v0 != 6) {
goto block_17;
}
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
this->actionFunc = func_80952734;
return;
block_5:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
return;
block_7:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
goto block_17;
}
temp_v0_2 = globalCtx->msgCtx.choiceIndex;
temp_v0_2 = play->msgCtx.choiceIndex;
if (temp_v0_2 == 0) {
goto block_11;
}
@ -376,27 +376,27 @@ block_7:
}
goto block_16;
block_11:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
}
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
return;
}
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
return;
block_16:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
block_17:
return;
}
@ -406,11 +406,11 @@ We can't apply this rule any more, so we need to move on to the next: `block_17`
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
void func_809527F8(EnMs* this, PlayState* play) {
u8 temp_v0;
u8 temp_v0_2;
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 == 4) {
goto block_7;
}
@ -420,24 +420,24 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
if (temp_v0 != 6) {
return;
}
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
this->actionFunc = func_80952734;
return;
block_5:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
return;
block_7:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
temp_v0_2 = globalCtx->msgCtx.choiceIndex;
temp_v0_2 = play->msgCtx.choiceIndex;
if (temp_v0_2 == 0) {
goto block_11;
}
@ -446,27 +446,27 @@ block_7:
}
goto block_16;
block_11:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
}
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
return;
}
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
return;
block_16:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
}
```
@ -475,7 +475,7 @@ Our next rule is about non-crossing blocks. If two code blocks do not contain an
Now let's start thinking about switches. A good indicator of a switch in goto-only mode is something like
```C
temp_v0_2 = globalCtx->msgCtx.choiceIndex;
temp_v0_2 = play->msgCtx.choiceIndex;
if (temp_v0_2 == 0) {
goto block_11;
}
@ -493,23 +493,23 @@ because
So let us rewrite the entire second half as a switch:
```C
switch (globalCtx->msgCtx.choiceIndex) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
return;
}
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
return;
}
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
return;
@ -518,7 +518,7 @@ So let us rewrite the entire second half as a switch:
case 1:
default:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
break;
}
```
@ -528,19 +528,19 @@ There's a couple of other obvious things here:
- a common pattern everywhere, a sequence of ifs with returns as the last thing inside is the same as an if-else chain, so we can rewrite these as
```C
switch (globalCtx->msgCtx.choiceIndex) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
} else {
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
}
@ -549,7 +549,7 @@ There's a couple of other obvious things here:
case 1:
default:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
break;
}
```
@ -557,7 +557,7 @@ There's a couple of other obvious things here:
Well, at least the bottom half looks respectable now. Again, there is no code after the switch, so the next thing up, namely
```C
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
```
@ -565,10 +565,10 @@ Well, at least the bottom half looks respectable now. Again, there is no code af
can be swapped round and made to wrap the switch. This leaves us with
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
void func_809527F8(EnMs* this, PlayState* play) {
u8 temp_v0;
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 == 4) {
goto block_7;
}
@ -578,34 +578,34 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
if (temp_v0 != 6) {
return;
}
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
this->actionFunc = func_80952734;
return;
block_5:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
return;
block_7:
if (Message_ShouldAdvance(globalCtx) != 0) {
switch (globalCtx->msgCtx.choiceIndex) {
if (Message_ShouldAdvance(play) != 0) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
} else {
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
}
@ -614,7 +614,7 @@ block_7:
case 1:
default:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
break;
}
}
@ -623,7 +623,7 @@ block_7:
Now, the top of the function also looks like a switch:
```C
temp_v0 = Message_GetState(&globalCtx->msgCtx);
temp_v0 = Message_GetState(&play->msgCtx);
if (temp_v0 == 4) {
goto block_7;
}
@ -640,36 +640,36 @@ Interestingly, this time the blocks are the other way round. Also, the last stat
Putting all this together, we write down a function with no gotos in it:
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
switch (Message_GetState(&globalCtx->msgCtx)) {
void func_809527F8(EnMs* this, PlayState* play) {
switch (Message_GetState(&play->msgCtx)) {
case 6:
this->actionFunc = func_80952734;
break;
case 5:
if (Message_ShouldAdvance(globalCtx) == 0) {
if (Message_ShouldAdvance(play) == 0) {
return;
}
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
break;
case 4:
if (Message_ShouldAdvance(globalCtx) != 0) {
switch (globalCtx->msgCtx.choiceIndex) {
if (Message_ShouldAdvance(play) != 0) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
} else {
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
}
@ -678,7 +678,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
case 1:
default:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
break;
}
}
@ -693,35 +693,35 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
Lastly, we can simplify `case 5` to replace the return in the if by the rest of the code, and we end up with
```C
void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
switch (Message_GetState(&globalCtx->msgCtx)) {
void func_809527F8(EnMs* this, PlayState* play) {
switch (Message_GetState(&play->msgCtx)) {
case 6:
this->actionFunc = func_80952734;
break;
case 5:
if (Message_ShouldAdvance(globalCtx) != 0) {
func_801477B4(globalCtx);
Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
if (Message_ShouldAdvance(play) != 0) {
func_801477B4(play);
Actor_PickUp((Actor *) this, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
this->actionFunc = func_809529AC;
}
break;
case 4:
if (Message_ShouldAdvance(globalCtx) != 0) {
switch (globalCtx->msgCtx.choiceIndex) {
if (Message_ShouldAdvance(play) != 0) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_801477B4(globalCtx);
func_801477B4(play);
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
func_80151938(play, 0x935U);
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
func_80151938(play, 0x937U);
} else {
func_8019F208();
Actor_PickUp((Actor *) this, globalCtx, 0x35, 90.0f, 10.0f);
Actor_PickUp((Actor *) this, play, 0x35, 90.0f, 10.0f);
func_801159EC(-0xA);
this->actionFunc = func_809529AC;
}
@ -730,7 +730,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
case 1:
default:
func_8019F230();
func_80151938(globalCtx, 0x934U);
func_80151938(play, 0x934U);
break;
}
}

View File

@ -21,10 +21,10 @@ The actor file starts off looking like:
#define THIS ((EnRecepgirl*)thisx)
// --------------- 3 ---------------
void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Init(Actor* thisx, PlayState* play);
void EnRecepgirl_Destroy(Actor* thisx, PlayState* play);
void EnRecepgirl_Update(Actor* thisx, PlayState* play);
void EnRecepgirl_Draw(Actor* thisx, PlayState* play);
// --------------- 4 ---------------
#if 0
@ -115,7 +115,7 @@ The header file looks like this at the moment:
struct EnRecepgirl;
typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*);
typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*);
typedef struct EnRecepgirl {
/* 0x0000 */ Actor actor;
@ -141,7 +141,7 @@ The general rule for order of decompilation is
- Next, decompile any other functions from the actor you have found in `Init`. You generally start with the action functions, because they return nothing and all take the same arguments,
```C
void func_80whatever(EnRecepgirl* this, GlobalContext* globalCtx);
void func_80whatever(EnRecepgirl* this, PlayState* play);
```
- Decompile each action function in turn until you run out. Along the way, do any other functions in the actor for which you have discovered the argument types. (You are probably better doing depth-first on action functions than breadth-first: it's normally easier to follow along one branch of the actions than be thinking about several at once.)
@ -207,14 +207,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60
static s32 D_80C106C8 = 0;
InitChainEntry D_80C106C0[2]; // unable to generate initializer
void EnRecepgirl_Init(EnRecepgirl *this, GlobalContext *globalCtx) {
void EnRecepgirl_Init(EnRecepgirl* this, PlayState* play) {
EnRecepgirl* this = (EnRecepgirl *) thisx;
void **temp_s0;
void **phi_s0;
Actor_ProcessInitChain((Actor *) this, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
phi_s0 = D_80C106B0;
if (D_80C106C8 == 0) {
do {
@ -225,7 +225,7 @@ void EnRecepgirl_Init(EnRecepgirl *this, GlobalContext *globalCtx) {
D_80C106C8 = 1;
}
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) {
if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -244,14 +244,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60
static s32 D_80C106C8 = 0;
InitChainEntry D_80C106C0[2]; // unable to generate initializer
void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Init(Actor* thisx, PlayState* play) {
EnRecepgirl* this = (EnRecepgirl *) thisx;
void **temp_s0;
void **phi_s0;
Actor_ProcessInitChain((Actor *) this, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
phi_s0 = D_80C106B0;
if (D_80C106C8 == 0) {
do {
@ -262,7 +262,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
D_80C106C8 = 1;
}
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) {
if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -300,14 +300,14 @@ static void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60
static s32 D_80C106C8 = 0;
InitChainEntry D_80C106C0[2]; // unable to generate initializer
void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Init(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
void **temp_s0;
void **phi_s0;
Actor_ProcessInitChain(&this->actor, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
phi_s0 = D_80C106B0;
if (D_80C106C8 == 0) {
do {
@ -318,7 +318,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
D_80C106C8 = 1;
}
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) {
if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -388,7 +388,7 @@ This is the combined system that handles actors' skeletons and their animations.
```C
Actor_ProcessInitChain(&this->actor, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
SkelAnime_InitFlex(play, (SkelAnime *) this->unk_144, &D_06011B60, (AnimationHeader *) &D_06009890, this + 0x188, this + 0x218, 0x18);
phi_s0 = D_80C106B0;
```
@ -396,7 +396,7 @@ An actor with SkelAnime has three structs in the Actor struct that handle it: on
There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`),
```C
void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount);
```
we can read off the types of the various arguments:
@ -432,7 +432,7 @@ As with the data, these externed symbols should be kept in increasing address or
They are both passed to the function as pointers, so need `&` to pass the address instead of the actual data. Hence we end up with
```C
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
SkelAnime_InitFlex(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
```
note that `this->jointTable` and `this->morphTable` are arrays, so are already effectively pointers and don't need a `&`.
@ -487,14 +487,14 @@ Removing some of the declarations for data that we have accounted for, the funct
```C
? func_80C10148(EnRecepgirl *); // extern
void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Init(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
void **temp_s0;
void **phi_s0;
Actor_ProcessInitChain(&this->actor, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
SkelAnime_InitFlex(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
phi_s0 = D_80C106B0;
if (D_80C106C8 == 0) {
@ -507,7 +507,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
}
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) {
if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -520,7 +520,7 @@ We have one significant problem and a few minor ones left.
### Casts and boolean functions
mips2c likes casting a lot: this is useful for getting types, less so when the type is changed automatically, such as in `Flags_GetSwitch(globalCtx, (s32) this->actor.params)`. Also, if we look at this function's definition, we discover it will only return `true` or `false`, so we can remove the `!= 0`.
mips2c likes casting a lot: this is useful for getting types, less so when the type is changed automatically, such as in `Flags_GetSwitch(play, (s32) this->actor.params)`. Also, if we look at this function's definition, we discover it will only return `true` or `false`, so we can remove the `!= 0`.
### Functions called
@ -529,14 +529,14 @@ One minor problem is what `func_80C10148` is: C needs a prototype to compile it
2. It's not used to assign a value
To this experience will add a third reason:
3. This is probably a setup function for an actionFunc, which are usually either `void (*)(ActorType*)` or `void (*)(ActorType*, GlobalContext*)`.
3. This is probably a setup function for an actionFunc, which are usually either `void (*)(ActorType*)` or `void (*)(ActorType*, PlayState*)`.
The upshot of all this is to remove mips2c's `? func_80C10148(EnRecepgirl *); // extern`, and add a `void func_80C10148(EnRecepgirl* this);` underneath the declarations for the main four functions:
```C
void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Init(Actor* thisx, PlayState* play);
void EnRecepgirl_Destroy(Actor* thisx, PlayState* play);
void EnRecepgirl_Update(Actor* thisx, PlayState* play);
void EnRecepgirl_Draw(Actor* thisx, PlayState* play);
void func_80C10148(EnRecepgirl* this);
```
@ -625,12 +625,12 @@ Hence we end up with
void func_80C10148(EnRecepgirl* this);
[...]
void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Init(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
Actor_ProcessInitChain(&this->actor, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
SkelAnime_InitFlex(play, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24);
if (D_80C106C8 == 0) {
for (i = 0; i < 4; i++) {
@ -641,7 +641,7 @@ void EnRecepgirl_Init(Actor *thisx, GlobalContext *globalCtx) {
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, this->actor.params)) {
if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;

View File

@ -51,7 +51,7 @@ You can keep the diff open in the terminal, and it will refresh when the C file
In this case, we see that various branches are happening in the wrong place. Here I fear experience is necessary: notice that the function has three blocks that look quite similar, and three separate conditionals that depend on the same variable. This is a good indicator of a switch. Changing the function to use a switch,
```C
void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) {
void EnJj_Init(Actor* thisx, PlayState* play) {
EnJj* this = THIS;
s32 sp4C;
@ -64,7 +64,7 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) {
switch (temp_v0) {
case -1:
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600B9A8, &D_06001F4C, this->jointTable,
SkelAnime_InitFlex(play, &this->skelAnime, &D_0600B9A8, &D_06001F4C, this->jointTable,
this->morphTable, 22);
Animation_PlayLoop(&this->skelAnime, &D_06001F4C);
this->unk_30A = 0;
@ -78,24 +78,24 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) {
func_80A87800(this, func_80A87C30);
}
this->childActor = Actor_SpawnAsChild(
&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_JJ, this->dyna.actor.world.pos.x - 10.0f,
&play->actorCtx, &this->dyna.actor, play, ACTOR_EN_JJ, this->dyna.actor.world.pos.x - 10.0f,
this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, this->dyna.actor.world.rot.y, 0, 0);
DynaPolyActor_Init(&this->dyna, 0);
CollisionHeader_GetVirtual(&D_06000A1C, &sp4C);
this->dyna.bgId =
DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &D_80A88CB4);
DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C);
Collider_InitCylinder(play, &this->collider);
Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &D_80A88CB4);
this->dyna.actor.colChkInfo.mass = 0xFF;
break;
case 0:
DynaPolyActor_Init(&this->dyna, 0);
CollisionHeader_GetVirtual(&D_06001830, &sp4C);
// temp_a1_2 = &globalCtx->colCtx.dyna;
// temp_a1_2 = &play->colCtx.dyna;
// sp44 = temp_a1_2;
this->dyna.bgId =
DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C);
func_8003ECA8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C);
func_8003ECA8(play, &play->colCtx.dyna, this->dyna.bgId);
this->dyna.actor.update = func_80A87F44;
this->dyna.actor.draw = NULL;
Actor_SetScale(&this->dyna.actor, 0.087f);
@ -104,7 +104,7 @@ void EnJj_Init(Actor* thisx, GlobalContext* globalCtx) {
DynaPolyActor_Init(&this->dyna, 0);
CollisionHeader_GetVirtual(&D_0600BA8C, &sp4C);
this->dyna.bgId =
DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp4C);
DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, sp4C);
this->dyna.actor.update = func_80A87F44;
this->dyna.actor.draw = NULL;
Actor_SetScale(&this->dyna.actor, 0.087f);
@ -123,10 +123,10 @@ we see that the diff is nearly correct (note that `-3` lets you compare current
![Init diff 2](images/init_diff2.png)
</details>
except we still have some stack issues. Now that `temp_v0` is only used once, it looks fake. Eliminating it actually seems to make the stack worse. To fix this, we employ something that we have evidence that the developers did: namely, we make a copy of `globalCtx` (the theory is that they actually used `gameState` as an argument of the main 4 functions, just like we used `Actor* thisx` as the first argument.) The quick way to do this is to change the top of the function to
except we still have some stack issues. Now that `temp_v0` is only used once, it looks fake. Eliminating it actually seems to make the stack worse. To fix this, we employ something that we have evidence that the developers did: namely, we make a copy of `play` (the theory is that they actually used `gameState` as an argument of the main 4 functions, just like we used `Actor* thisx` as the first argument.) The quick way to do this is to change the top of the function to
```C
void EnJj_Init(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
void EnJj_Init(Actor* thisx, PlayState* play2) {
PlayState* play = play2;
EnJj* this = THIS;
...
```

View File

@ -40,15 +40,15 @@ Large code block, click to show
#define THIS ((EnRecepgirl*)thisx)
void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Init(Actor* thisx, PlayState* play);
void EnRecepgirl_Destroy(Actor* thisx, PlayState* play);
void EnRecepgirl_Update(Actor* thisx, PlayState* play);
void EnRecepgirl_Draw(Actor* thisx, PlayState* play);
void func_80C10148(EnRecepgirl* this);
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx);
void func_80C1019C(EnRecepgirl* this, PlayState* play);
void func_80C10290(EnRecepgirl* this);
void func_80C102D4(EnRecepgirl * this, GlobalContext * globalCtx);
void func_80C102D4(EnRecepgirl* this, PlayState* play);
const ActorInit En_Recepgirl_InitVars = {
ACTOR_EN_RECEPGIRL,
@ -73,13 +73,13 @@ static InitChainEntry D_80C106C0[] = {
static s32 D_80C106C8 = 0;
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s")
void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) {
void EnRecepgirl_Init(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
s32 i;
Actor_ProcessInitChain(&this->actor, D_80C106C0);
ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24);
SkelAnime_InitFlex(play, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24);
if (D_80C106C8 == 0) {
for (i = 0; i < 4; i++) {
@ -90,7 +90,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) {
this->unk_2AC = 2;
if (Flags_GetSwitch(globalCtx, this->actor.params)) {
if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -100,7 +100,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) {
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Destroy.s")
void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) {
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s")
@ -127,7 +127,7 @@ void func_80C10148(EnRecepgirl *this) {
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C1019C.s")
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
void func_80C1019C(EnRecepgirl* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) {
if (this->skelAnime.animation == &object_bg_Anim_00A280) {
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f);
@ -136,13 +136,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
}
}
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) {
func_80C10290(this);
} else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) {
func_800B8614(&this->actor, globalCtx, 60.0f);
if (Player_GetMask(globalCtx) == 2) {
func_800B8614(&this->actor, play, 60.0f);
if (Player_GetMask(play) == 2) {
this->actor.textId = 0x2367;
} else if (Flags_GetSwitch(globalCtx, this->actor.params)) {
} else if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -157,7 +157,7 @@ void func_80C10290(EnRecepgirl *this) {
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C102D4.s")
void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
void func_80C102D4(EnRecepgirl* this, PlayState* play) {
u8 temp_v0_2;
if (SkelAnime_Update(&this->skelAnime) != 0) {
@ -176,16 +176,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
}
}
temp_v0_2 = Message_GetState(&globalCtx->msgCtx);
temp_v0_2 = Message_GetState(&play->msgCtx);
if (temp_v0_2 == 2) {
this->actor.textId = 0x2ADC;
func_80C10148(this);
return;
}
if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
if ((temp_v0_2 == 5) && (Message_ShouldAdvance(play) != 0)) {
if (this->actor.textId == 0x2AD9) {
Flags_SetSwitch(globalCtx, this->actor.params);
Flags_SetSwitch(play, this->actor.params);
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f);
if ((gSaveContext.save.weekEventReg[63] & 0x80)) {
this->actor.textId = 0x2ADF;
@ -205,23 +205,23 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
this->actor.textId = 0x2AE0;
}
}
func_80151938(globalCtx, this->actor.textId);
func_80151938(play, this->actor.textId);
}
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Update.s")
void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Update(Actor* thisx, PlayState* play) {
s32 pad;
EnRecepgirl* this = THIS;
Vec3s sp30;
this->actionFunc(this, globalCtx);
Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
this->actionFunc(this, play);
Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
func_80C100DC(this);
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s")
s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) {
s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
@ -231,7 +231,7 @@ s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *p
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s")
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
void func_80C10590(PlayState* play, s32 limbIndex, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
@ -241,18 +241,18 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
}
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s")
void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Draw(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
func_8012C28C(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]);
SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor);
SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
```
@ -412,7 +412,7 @@ Finally, clearly `4` is linked to the data over which we're iterating: namely it
We've got one struct variable left. To find out what it does, we can look at a function that uses it, for example
```C
s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
s32 EnRecepgirl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
Actor* thisx) {
EnRecepgirl* this = THIS;
@ -422,7 +422,7 @@ s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx**
return false;
}
void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) {
void EnRecepgirl_UnkLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
@ -449,7 +449,7 @@ void func_80C10148(EnRecepgirl* this) {
this->actionFunc = func_80C1019C;
}
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
void func_80C1019C(EnRecepgirl* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) {
if (this->skelAnime.animation == &object_bg_Anim_00A280) {
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f);
@ -458,13 +458,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
}
}
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) {
func_80C10290(this);
} else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) {
func_800B8614(&this->actor, globalCtx, 60.0f);
if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) {
func_800B8614(&this->actor, play, 60.0f);
if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) {
this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?"
} else if (Flags_GetSwitch(globalCtx, this->actor.params)) {
} else if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC; // hear directions again?
} else {
this->actor.textId = 0x2AD9; // "Welcome..."
@ -477,7 +477,7 @@ void func_80C10290(EnRecepgirl* this) {
this->actionFunc = func_80C102D4;
}
void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) {
void func_80C102D4(EnRecepgirl* this, PlayState* play) {
u8 temp_v0_2;
if (SkelAnime_Update(&this->skelAnime)) {
@ -496,13 +496,13 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) {
}
}
temp_v0_2 = Message_GetState(&globalCtx->msgCtx);
temp_v0_2 = Message_GetState(&play->msgCtx);
if (temp_v0_2 == 2) {
this->actor.textId = 0x2ADC; // hear directions again?
func_80C10148(this);
} else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
} else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(play) != 0)) {
if (this->actor.textId == 0x2AD9) { // "Welcome..."
Flags_SetSwitch(globalCtx, this->actor.params);
Flags_SetSwitch(play, this->actor.params);
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f);
if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting
this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended)
@ -524,11 +524,11 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) {
this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment
}
}
func_80151938(globalCtx, this->actor.textId);
func_80151938(play, this->actor.textId);
}
}
```
All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&globalCtx->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`.
All this branching is to make the conversation look more diverse and interesting. Notably, though, `func_80C1019C` is set to start with, and is only changed when `Actor_ProcessTalkRequest(&this->actor, &play->state) != 0`. This is something to do with talking. The other function handles the rest of the conversation, and hands back to the first if `Message_GetState(&play->msgCtx) == 2`. This function is *something* to do with the text state, which will require `z_message` to be decomped. However, observation in-game will reveal this is something to do with ending dialogue. So we can conclude that the action functions are `EnRecepgirl_Wait` and `EnRecepgirl_Talk`. The setup functions are thus `EnRecepgirl_SetupWait` and `EnRecepgirl_SetupTalk`.
For more complex actors, we have a tool called `graphovl.py` that can produce function flow graphs for actors: running
```
@ -551,7 +551,7 @@ We like to make macros for reading an actor's `params` (indeed, this is required
Actor_SetScale(&this->dyna.actor, 0.1f);
DynaPolyActor_Init(&this->dyna, 1);
CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
}
```
@ -571,7 +571,7 @@ Notice that we use `thisx`: this makes the form of every one of these macros the
Actor_SetScale(&this->dyna.actor, 0.1f);
DynaPolyActor_Init(&this->dyna, 1);
CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
}
```

View File

@ -12,29 +12,29 @@ This document will be a bit different: we will look at the draw functions in EnR
Unless it is completely invisible, an actor usually has a draw function as one of the main four actor functions. Hence its prototype looks like
```C
void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnRecepgirl_Draw(Actor* thisx, PlayState* play);
```
From now on, the process is rather different from the decompilation process used for the other functions. Here is the output of mips2c after sorting out the actor struct from Init, and with the arguments set back to `Actor* thisx`:
```C
s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); // extern
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor); // extern
s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor); // extern
void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor); // extern
void *D_80C106B0[4] = {(void *)0x600F8F0, (void *)0x600FCF0, (void *)0x60100F0, (void *)0x600FCF0};
void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Draw(Actor* thisx, PlayState* play) {
EnRecepgirl* this = (EnRecepgirl *) thisx;
GraphicsContext *sp30;
Gfx *temp_v1;
GraphicsContext *temp_a0;
temp_a0 = globalCtx->state.gfxCtx;
temp_a0 = play->state.gfxCtx;
sp30 = temp_a0;
func_8012C28C(temp_a0);
temp_v1 = sp30->polyOpa.p;
sp30->polyOpa.p = temp_v1 + 8;
temp_v1->words.w0 = 0xDB060020;
temp_v1->words.w1 = (u32) D_80C106B0[this->unk_2AC];
SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, (s32) this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, (Actor *) this);
SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, (s32) this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, (Actor *) this);
}
```
@ -91,25 +91,25 @@ If you have worked on OoT, you will be aware of the functions `Graph_OpenDisps`
It's sensible to eliminate all the `gfxCtx` temps and reintroduce as needed. Also remember to change the prototype and function definition back!
```C
s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor);
s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s")
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor);
void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s")
// #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s")
void EnRecepgirl_Draw(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Draw(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
func_8012C28C(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, D_80C106B0[this->unk_2AC]);
SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor);
SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80C10558, NULL, func_80C10590, &this->actor);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
```
@ -117,20 +117,20 @@ And this matches.
The last two functions in the actor are used as arguments in `SkelAnime_DrawTransformFlexOpa`. This is a `SkelAnime` function, except unlike the OoT ones, it has three function callback arguments instead of two: in `functions.h` or `z_skelanime.c`, we find
```C
void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount,
void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount,
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor)
```
The typedefs of the callbacks it uses are in `z64animation.h`:
```C
typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
typedef s32 (*OverrideLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
struct Actor* thisx);
typedef void (*PostLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot,
typedef void (*PostLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot,
struct Actor* thisx);
[...]
typedef void (*TransformLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx);
typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, struct Actor* thisx);
```
which is where mips2c got them from.
@ -140,7 +140,7 @@ In this case, only two of them are used, and it is these that are the last funct
Well, we don't have a PostLimbDraw here, but as we see from the prototype, it's much the same as the OverrideLimbDraw but without the `pos` argument and no return value.
```C
s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor) {
s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *actor) {
if (limbIndex == 5) {
rot->x += actor->unk2B0;
}
@ -149,7 +149,7 @@ s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *p
```
Only two things to do here: we need to use `EnRecepgirl` to get to `actor + 0x2B0`, and the return value is used as a boolean, so we replace `0` by `false` (`true` means "don't draw the limb", and is hardly ever used).
```C
s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) {
s32 func_80C10558(PlayState* play, s32 limbIndex, Gfx **dList, Vec3f *pos, Vec3s *rot, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
@ -161,7 +161,7 @@ s32 func_80C10558(GlobalContext *globalCtx, s32 limbIndex, Gfx **dList, Vec3f *p
As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives
```C
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) {
void func_80C10590(PlayState* play, s32 limbIndex, Actor *actor) {
if (limbIndex == 5) {
Matrix_RotateYS((s16) (0x400 - actor->unk2AE), 1);
Matrix_MultVecX(500.0f, (Vec3f *) &actor->focus);
@ -173,7 +173,7 @@ There is only minor cleanup needed here:
- replacing the last argument of `Matrix_RotateYS` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`.
- `(Vec3f *) &actor->focus` to `&actor->focus.pos` (this is the same issue as `(Actor*)this`, where mips2c doesn't climb deep enough into the struct).
```C
void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
void func_80C10590(PlayState* play, s32 limbIndex, Actor *thisx) {
EnRecepgirl* this = THIS;
if (limbIndex == 5) {
@ -187,7 +187,7 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) {
Since EnRecepgirl was a bit light on graphics macros, we will look at an example that has a few more. A nice simple one is `ObjTree_Draw`: the original mips2c output is
```C
void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) {
void ObjTree_Draw(Actor* thisx, PlayState* play) {
s16 sp36;
s16 sp34;
Gfx *sp28;
@ -201,14 +201,14 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) {
sp36 = (s16) (s32) (f32) thisx->shape.rot.x;
sp34 = (s16) (s32) (f32) thisx->shape.rot.z;
temp_a0 = globalCtx->state.gfxCtx;
temp_a0 = play->state.gfxCtx;
temp_s0 = temp_a0;
func_8012C28C(temp_a0);
temp_v0 = temp_s0->polyOpa.p;
temp_s0->polyOpa.p = temp_v0 + 8;
temp_v0->words.w0 = 0xDA380003;
sp28 = temp_v0;
sp28->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx);
sp28->words.w1 = Matrix_NewMtx(play->state.gfxCtx);
temp_v0_2 = temp_s0->polyOpa.p;
temp_s0->polyOpa.p = temp_v0_2 + 8;
temp_v0_2->words.w1 = (u32) &D_06000680;
@ -218,7 +218,7 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) {
temp_s0->polyOpa.p = temp_v0_3 + 8;
temp_v0_3->words.w0 = 0xDA380003;
sp20 = temp_v0_3;
sp20->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx);
sp20->words.w1 = Matrix_NewMtx(play->state.gfxCtx);
temp_v0_4 = temp_s0->polyOpa.p;
temp_s0->polyOpa.p = temp_v0_4 + 8;
temp_v0_4->words.w1 = (u32) &D_060007C8;
@ -231,7 +231,7 @@ We can see there are four blocks here, although only two different macros:
temp_s0->polyOpa.p = temp_v0 + 8;
temp_v0->words.w0 = 0xDA380003;
sp28 = temp_v0;
sp28->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx);
sp28->words.w1 = Matrix_NewMtx(play->state.gfxCtx);
```
gfxdis gives
```
@ -240,7 +240,7 @@ gSPMatrix(POLY_OPA_DISP++, 0x12345678, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVI
```
so it becomes
```C
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
```
```C
@ -263,7 +263,7 @@ gSPDisplayList(POLY_OPA_DISP++, D_06000680);
temp_s0->polyOpa.p = temp_v0_3 + 8;
temp_v0_3->words.w0 = 0xDA380003;
sp20 = temp_v0_3;
sp20->words.w1 = Matrix_NewMtx(globalCtx->state.gfxCtx);
sp20->words.w1 = Matrix_NewMtx(play->state.gfxCtx);
```
This is the same as the first one. Indeed, it's identical.
```C
@ -276,21 +276,21 @@ This is the same as the second one, but with a different second word.
Tidying up and inserting `OPEN_DISPS` and `CLOSE_DISPS`, we end up with
```C
void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ObjTree_Draw(Actor* thisx, PlayState* play) {
s16 sp36 = (f32) thisx->shape.rot.x;
s16 sp34 = (f32) thisx->shape.rot.z;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_8012C28C(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_06000680);
Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_060007C8);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
```

View File

@ -40,13 +40,13 @@ glabel func_809529AC
and turn it into compilable C code:
```C
void func_809529AC(EnMs *this, GlobalContext *globalCtx) {
if (Actor_HasParent(&this->actor, globalCtx)) {
void func_809529AC(EnMs* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) {
this->actor.textId = 0;
func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0);
func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0);
this->actionFunc = func_80952A1C;
} else {
Actor_PickUp(&this->actor, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
Actor_PickUp(&this->actor, play, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel);
}
}
```

View File

@ -61,7 +61,7 @@ Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum
We can also use our new skeleton name and limb enum when initialization the skeleton like so:
```c
SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX);
SkelAnime_Init(play, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX);
```
Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had:

View File

@ -26,7 +26,7 @@ void EnRecepgirl_Destroy(s32 arg0, ? arg1) {
```
so it really does do nothing. It is worth staying on this briefly to understand what is is doing, though. Even with no context, mips2c knows it takes two arguments because it does two saves onto the stack: the calling convention the N64 uses requires the first four arguments be saved from the registers onto the stack, since the registers are expected to be cleared when a function call happens. It's done a bad job of guessing what they are, but that's to be expected: the assembly only tells us they're words. Thankfully we already know in this case, so we can just replace the `GLOBAL_ASM` by
```C
void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EnRecepgirl_Destroy(Actor* thisx, PlayState* play) {
}
```
@ -54,11 +54,11 @@ void func_80C10148(EnRecepgirl *this) {
This gives us some information immediately: `D_0600AD98` is an `AnimationHeader`, and `func_80C1019C` is set as the action function. This means that we know its type, even though mips2c does not: looking in the header, we see the typedef is
```C
typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*);
typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, PlayState*);
```
and so we prototype `func_80C1019C` as
```C
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx);
void func_80C1019C(EnRecepgirl* this, PlayState* play);
```
at the top (were it above the function we're currently working on, the prototype could eventually be replaced by the function definition itself, but since it isn't, it goes at the top with the others).
@ -73,7 +73,7 @@ If we tackle these, we end up with
```C
void func_80C10148(EnRecepgirl* this);
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx);
void func_80C1019C(EnRecepgirl* this, PlayState* play);
[...]
@ -103,7 +103,7 @@ Remake the context and run mips2c on this function's assembly file. We get
```C
? func_80C10290(EnRecepgirl *); // extern
void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) {
void func_80C1019C(EnRecepgirl* this, PlayState* play) {
SkelAnime *sp24;
SkelAnime *temp_a0;
@ -116,17 +116,17 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) {
Animation_ChangeTransitionRepeat(temp_a0, &D_06009890, -4.0f);
}
}
if (Actor_ProcessTalkRequest((Actor *) this, globalCtx) != 0) {
if (Actor_ProcessTalkRequest((Actor *) this, play) != 0) {
func_80C10290(this);
return;
}
if (Actor_IsFacingPlayer((Actor *) this, 0x2000) != 0) {
func_800B8614((Actor *) this, globalCtx, 60.0f);
if (Player_GetMask(globalCtx) == 2) {
func_800B8614((Actor *) this, play, 60.0f);
if (Player_GetMask(play) == 2) {
this->actor.textId = 0x2367;
return;
}
if (Flags_GetSwitch(globalCtx, (s32) this->actor.params) != 0) {
if (Flags_GetSwitch(play, (s32) this->actor.params) != 0) {
this->actor.textId = 0x2ADC;
return;
}
@ -147,7 +147,7 @@ This is a bit juicier! We can do some preliminary cleanup, then worry about the
Changing all these, we end up with
```C
void func_80C10148(EnRecepgirl* this);
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx);
void func_80C1019C(EnRecepgirl* this, PlayState* play);
void func_80C10290(EnRecepgirl* this);
[...]
@ -160,7 +160,7 @@ extern FlexSkeletonHeader D_06011B60;
[...]
void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) {
void func_80C1019C(EnRecepgirl* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) {
if (&D_0600A280 == this->skelAnime.animation) {
Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f);
@ -168,17 +168,17 @@ void func_80C1019C(EnRecepgirl *this, GlobalContext *globalCtx) {
Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f);
}
}
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) {
func_80C10290(this);
return;
}
if (Actor_IsFacingPlayer(&this->actor, 0x2000) != 0) {
func_800B8614(&this->actor, globalCtx, 60.0f);
if (Player_GetMask(globalCtx) == 2) {
func_800B8614(&this->actor, play, 60.0f);
if (Player_GetMask(play) == 2) {
this->actor.textId = 0x2367;
return;
}
if (Flags_GetSwitch(globalCtx, this->actor.params)) {
if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC;
return;
}
@ -194,7 +194,7 @@ If we look with diff.py, we find this matches. But we can replace some of the `r
Here, it's debatable whether to keep the first, since `func_80C10290` is likely a setup function. The latter two should be changed to elses, though. For now, let's replace all of them. This leaves us with
```C
void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
void func_80C1019C(EnRecepgirl* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) {
if (this->skelAnime.animation == &D_0600A280) {
Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f);
@ -203,13 +203,13 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) {
}
}
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) {
func_80C10290(this);
} else if (Actor_IsFacingPlayer(&this->actor, 0x2000)) {
func_800B8614(&this->actor, globalCtx, 60.0f);
if (Player_GetMask(globalCtx) == 2) {
func_800B8614(&this->actor, play, 60.0f);
if (Player_GetMask(play) == 2) {
this->actor.textId = 0x2367;
} else if (Flags_GetSwitch(globalCtx, this->actor.params)) {
} else if (Flags_GetSwitch(play, this->actor.params)) {
this->actor.textId = 0x2ADC;
} else {
this->actor.textId = 0x2AD9;
@ -227,7 +227,7 @@ typedef enum {
/* 0x19 */ PLAYER_MASK_MAX
} PlayerMask;
```
and so we can write the last if as `Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK`.
and so we can write the last if as `Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK`.
Again, we have no choice in what to do next.
@ -236,7 +236,7 @@ Again, we have no choice in what to do next.
Remaking the context and running mips2c gives
```C
void func_80C102D4(EnRecepgirl *, GlobalContext *); // extern
void func_80C102D4(EnRecepgirl*, PlayState*); // extern
void func_80C10290(EnRecepgirl *this) {
Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f);
@ -256,7 +256,7 @@ Large code block, click to show
```C
extern AnimationHeader D_06000968;
void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
void func_80C102D4(EnRecepgirl* this, PlayState* play) {
SkelAnime *sp20;
AnimationHeader *temp_v0;
SkelAnime *temp_a0;
@ -282,16 +282,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
Animation_MorphToPlayOnce(sp20, &D_0600A280, -4.0f);
}
}
temp_v0_2 = Message_GetState(&globalCtx->msgCtx);
temp_v0_2 = Message_GetState(&play->msgCtx);
if (temp_v0_2 == 2) {
this->actor.textId = 0x2ADC;
func_80C10148(this);
return;
}
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 0)) {
temp_v0_3 = this->actor.textId;
if (temp_v0_3 == 0x2AD9) {
Flags_SetSwitch(globalCtx, (s32) this->actor.params);
Flags_SetSwitch(play, (s32) this->actor.params);
Animation_MorphToPlayOnce(sp20, &D_0600AD98, 10.0f);
if ((*(&gSaveContext + 0xF37) & 0x80) != 0) {
this->actor.textId = 0x2ADF;
@ -312,7 +312,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
this->actor.textId = 0x2AE0;
}
}
func_80151938(globalCtx, this->actor.textId);
func_80151938(play, this->actor.textId);
}
}
```
@ -321,7 +321,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
Well, this is a big one! We get one more extern, for `D_06000968`. A lot of the temps used in the conditionals look fake, with the exception of `temp_v0_2`: because the function is only called once but the temp is used twice, the temp must be real. Removing the others and switching the `animation` conditionals,
```C
void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
void func_80C102D4(EnRecepgirl* this, PlayState* play) {
u8 temp_v0_2;
if (SkelAnime_Update(&this->skelAnime) != 0) {
@ -340,16 +340,16 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
}
}
temp_v0_2 = Message_GetState(&globalCtx->msgCtx);
temp_v0_2 = Message_GetState(&play->msgCtx);
if (temp_v0_2 == 2) {
this->actor.textId = 0x2ADC;
func_80C10148(this);
return;
}
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 0)) {
if (this->actor.textId == 0x2AD9) {
Flags_SetSwitch(globalCtx, this->actor.params);
Flags_SetSwitch(play, this->actor.params);
Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f);
if ((*(&gSaveContext + 0xF37) & 0x80) != 0) {
this->actor.textId = 0x2ADF;
@ -369,7 +369,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
this->actor.textId = 0x2AE0;
}
}
func_80151938(globalCtx, this->actor.textId);
func_80151938(play, this->actor.textId);
}
}
```
@ -390,14 +390,14 @@ The yellow shows registers that don't match, the different colours on the regist
```
somehow we skipped over `t0`. Where is this in the code? The `153` in the middle is the line number in the C file (the `3f0`s are the offsets into the assembly file), we have `--source` if you want to see the code explicitly, or you can do it the old-fashioned way, and work it out from nearby function calls. In this case, `func_80C10148` is run straight after, and the only place that is called is
```C
temp_v0_2 = Message_GetState(&globalCtx->msgCtx);
temp_v0_2 = Message_GetState(&play->msgCtx);
if (temp_v0_2 == 2) {
this->actor.textId = 0x2ADC;
func_80C10148(this);
return;
}
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(play) != 0)) {
```
If you look at the conditionals and the declaration of `temp_v0_2`, you may notice something odd: `temp_v0_2` is a `u8`. Therefore the `& 0xFF` does nothing! It's surprisingly common for this to happen, be it leaving out a `& 0xFF` or adding an extraneous one. If we remove it, we get a match:
@ -417,12 +417,12 @@ Remake the context and run mips2c:
```C
? func_80C100DC(EnRecepgirl *); // extern
void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Update(Actor* thisx, PlayState* play) {
EnRecepgirl* this = (EnRecepgirl *) thisx;
? sp30;
this->actionFunc(this, globalCtx);
Actor_TrackPlayer(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z);
this->actionFunc(this, play);
Actor_TrackPlayer(play, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z);
func_80C100DC(this);
}
```
@ -435,18 +435,18 @@ void func_80C100DC(EnRecepgirl *);
[...]
void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Update(Actor* thisx, PlayState* play) {
EnRecepgirl* this = THIS;
? sp30;
this->actionFunc(this, globalCtx);
Actor_TrackPlayer(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z);
this->actionFunc(this, play);
Actor_TrackPlayer(play, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z);
func_80C100DC(this);
}
```
Now, our problem is `Actor_TrackPlayer`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be
```C
s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos)
s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos)
```
So mips2c has made a bit of a mess here:
- the third argument should be a `Vec3s`. Hence `this + 0x2AE` is a `Vec3s*`, and so `this->unk_2AE` is a `Vec3s`
@ -455,12 +455,12 @@ So mips2c has made a bit of a mess here:
Fixing all of this, we end up with
```C
void EnRecepgirl_Update(EnRecepgirl *this, GlobalContext *globalCtx) {
void EnRecepgirl_Update(EnRecepgirl* this, PlayState* play) {
EnRecepgirl* this = THIS;
Vec3s sp30;
this->actionFunc(this, globalCtx);
Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
this->actionFunc(this, play);
Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
func_80C100DC(this);
}
```
@ -482,21 +482,21 @@ It's entirely possible that `unk_2AD` is not real, and is just padding: see [Typ
![EnRecepgirl_Update's stack difference](images/EnRecepgirl_stack_diff.png)
So `sp30` is in the wrong place: it's `4` too high on the stack in ours. This is because the main four functions do not actually take `GlobalContext`: they really take `Gamestate` and recast it with a temp, just like `EnRecepgirl* this = THIS;`. We haven't implemented this in the repo yet, though, so for now, it suffices to put a pad on the stack where it would go instead: experience has shown when it matters, it goes above the actor recast, so we end up with
So `sp30` is in the wrong place: it's `4` too high on the stack in ours. This is because the main four functions do not actually take `PlayState`: they really take `Gamestate` and recast it with a temp, just like `EnRecepgirl* this = THIS;`. We haven't implemented this in the repo yet, though, so for now, it suffices to put a pad on the stack where it would go instead: experience has shown when it matters, it goes above the actor recast, so we end up with
```C
void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) {
void EnRecepgirl_Update(Actor* thisx, PlayState* play) {
s32 pad;
EnRecepgirl* this = THIS;
Vec3s sp30;
this->actionFunc(this, globalCtx);
Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
this->actionFunc(this, play);
Actor_TrackPlayer(play, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos);
func_80C100DC(this);
}
```
and this now matches.
**N.B.** sometimes using an actual `GlobalContext* globalCtx` temp is required for matching: add it to your bag o' matching memes.
**N.B.** sometimes using an actual `PlayState* play` temp is required for matching: add it to your bag o' matching memes.
### *Some remarks about the function stack

View File

@ -33,7 +33,7 @@ Useful data for guessing types:
Another useful thing to put here: the typedef for an action function is
```C
typedef void (*ActorNameActionFunc)(struct ActorName*, GlobalContext*);
typedef void (*ActorNameActionFunc)(struct ActorName*, PlayState*);
```
where you replace `ActorName` by the actual actor name as used elsewhere in the actor, e.g. `EnRecepgirl`. In MM these typedefs have been automatically generated, so you don't need to constantly copy from here or another actor any more.

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED)
#define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr))
#define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera])
#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamera])
#define CAM_ID_MAIN 0
#define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \
@ -38,9 +38,9 @@
} \
(void)0
#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorLists[ACTORCAT_PLAYER].first)
#define GET_PLAYER(play) ((Player*)(play)->actorCtx.actorLists[ACTORCAT_PLAYER].first)
#define GET_FIRST_ENEMY(globalCtx) ((Actor*)(globalCtx)->actorCtx.actorLists[ACTORCAT_ENEMY].first)
#define GET_FIRST_ENEMY(play) ((Actor*)(play)->actorCtx.actorLists[ACTORCAT_ENEMY].first)
// linkAge still exists in MM, but is always set to 0 (always adult)
// There are remnants of these macros from OOT, but they are essentially useless

View File

@ -882,7 +882,7 @@ extern s16 actorCutsceneEnding;
extern s16 actorCutsceneCurrentCamera;
extern Actor* actorCutsceneCurrentCutsceneActor;
// extern UNK_TYPE4 actorCutsceneStartMethod;
extern GlobalContext* actorCutscenesGlobalCtxt;
extern PlayState* actorCutscenesPlayState;
extern s16 actorCutsceneReturnCamera;
extern s16 D_801BD8C6;
extern GameStateOverlay gGameStateOverlayTable[];
@ -3243,8 +3243,8 @@ extern ShrinkWindowContext gShrinkWindowContext;
extern ShrinkWindowContext* gShrinkWindowContextPtr;
// extern UNK_TYPE4 D_801F6B50;
// extern UNK_TYPE1 D_801F6B58;
extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx);
extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx);
extern void (*sKaleidoScopeUpdateFunc)(PlayState* play);
extern void (*sKaleidoScopeDrawFunc)(PlayState* play);
extern FaultAddrConvClient sKaleidoAreaFaultClient;
// extern UNK_TYPE1 D_801F6C10;
extern Input D_801F6C18;

View File

@ -979,17 +979,17 @@ typedef struct {
/* 0x10 */ OSTime resetTime;
} PreNmiBuff; // size = 0x18 (actually osAppNmiBuffer is 0x40 bytes large but the rest is unused)
typedef struct GlobalContext GlobalContext;
typedef struct PlayState PlayState;
typedef s32 (*ColChkResetFunc)(GlobalContext*, Collider*);
typedef void (*ColChkBloodFunc)(GlobalContext*, Collider*, Vec3f*);
typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider*);
typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*);
typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
typedef s32 (*ColChkResetFunc)(PlayState*, Collider*);
typedef void (*ColChkBloodFunc)(PlayState*, Collider*, Vec3f*);
typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*);
typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*);
typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
typedef void(*draw_func)(GlobalContext* globalCtx, s16 index);
typedef void(*draw_func)(PlayState* play, s16 index);
typedef void(*room_draw_func)(GlobalContext* globalCtx, Room* room, u32 flags);
typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags);
typedef struct {
/* 0x00 */ draw_func unk0;
@ -1010,7 +1010,7 @@ typedef struct Camera {
/* 0x068 */ Vec3f up;
/* 0x074 */ Vec3f eyeNext;
/* 0x080 */ Vec3f skyboxOffset;
/* 0x08C */ struct GlobalContext* globalCtx;
/* 0x08C */ struct PlayState* play;
/* 0x090 */ struct Player* player;
/* 0x094 */ PosRot playerPosRot;
/* 0x0A8 */ struct Actor* target;
@ -1115,7 +1115,7 @@ typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*);
#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9)
typedef struct {
/* 0x0 */ GlobalContext* globalCtx;
/* 0x0 */ PlayState* play;
/* 0x4 */ s32 type; // bitfield, highest set bit determines type
/* 0x8 */ s16 countdown;
/* 0xA */ s16 state;
@ -1256,7 +1256,7 @@ typedef struct {
/* 0x00 */ u16 state;
} GameOverContext; // size = 0x02
struct GlobalContext {
struct PlayState {
/* 0x00000 */ GameState state;
/* 0x000A4 */ s16 sceneNum;
/* 0x000A6 */ u8 sceneConfig;
@ -1288,19 +1288,19 @@ struct GlobalContext {
/* 0x17D88 */ ObjectContext objectCtx;
/* 0x186E0 */ RoomContext roomCtx;
/* 0x18760 */ DoorContext doorCtx;
/* 0x18768 */ void (*playerInit)(Player* player, struct GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader);
/* 0x1876C */ void (*playerUpdate)(Player* player, struct GlobalContext* globalCtx, Input* input);
/* 0x18770 */ void (*unk_18770)(struct GlobalContext* globalCtx, Player* player);
/* 0x18774 */ s32 (*startPlayerFishing)(struct GlobalContext* globalCtx);
/* 0x18778 */ s32 (*grabPlayer)(struct GlobalContext* globalCtx, Player* player);
/* 0x1877C */ s32 (*startPlayerCutscene)(struct GlobalContext* globalCtx, Player* player, s32 mode);
/* 0x18780 */ void (*func_18780)(Player* player, struct GlobalContext* globalCtx);
/* 0x18784 */ s32 (*damagePlayer)(struct GlobalContext* globalCtx, s32 damage);
/* 0x18788 */ void (*talkWithPlayer)(struct GlobalContext* globalCtx, Actor* actor);
/* 0x1878C */ void (*unk_1878C)(struct GlobalContext* globalCtx);
/* 0x18790 */ void (*unk_18790)(struct GlobalContext* globalCtx, s16 arg1, Actor* actor);
/* 0x18768 */ void (*playerInit)(Player* player, struct PlayState* play, FlexSkeletonHeader* skelHeader);
/* 0x1876C */ void (*playerUpdate)(Player* player, struct PlayState* play, Input* input);
/* 0x18770 */ void (*unk_18770)(struct PlayState* play, Player* player);
/* 0x18774 */ s32 (*startPlayerFishing)(struct PlayState* play);
/* 0x18778 */ s32 (*grabPlayer)(struct PlayState* play, Player* player);
/* 0x1877C */ s32 (*startPlayerCutscene)(struct PlayState* play, Player* player, s32 mode);
/* 0x18780 */ void (*func_18780)(Player* player, struct PlayState* play);
/* 0x18784 */ s32 (*damagePlayer)(struct PlayState* play, s32 damage);
/* 0x18788 */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor);
/* 0x1878C */ void (*unk_1878C)(struct PlayState* play);
/* 0x18790 */ void (*unk_18790)(struct PlayState* play, s16 arg1, Actor* actor);
/* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype
/* 0x18798 */ s32 (*setPlayerTalkAnim)(struct GlobalContext* globalCtx, void* talkAnim, s32 arg2);
/* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, void* talkAnim, s32 arg2);
/* 0x1879C */ s16 playerActorCsIds[10];
/* 0x187B0 */ MtxF viewProjectionMtxF;
/* 0x187F0 */ Vec3f unk_187F0;

View File

@ -13,13 +13,13 @@
#define MASS_HEAVY 0xFE // Can only be pushed by OC collisions with IMMOVABLE and HEAVY objects.
struct Actor;
struct GlobalContext;
struct PlayState;
struct Lights;
struct CollisionPoly;
struct EnBox;
typedef void(*ActorFunc)(struct Actor* this, struct GlobalContext* globalCtx);
typedef void(*ActorFunc)(struct Actor* this, struct PlayState* play);
typedef struct {
/* 0x00 */ Vec3f pos;
@ -110,7 +110,7 @@ typedef struct {
/* 0x1E */ s8 numLoaded; // original name: "clients"
} ActorOverlay; // size = 0x20
typedef void(*ActorShadowFunc)(struct Actor* actor, struct Lights* mapper, struct GlobalContext* globalCtx);
typedef void(*ActorShadowFunc)(struct Actor* actor, struct Lights* mapper, struct PlayState* play);
typedef struct {
/* 0x00 */ Vec3s rot; // Current actor shape rotation
@ -254,7 +254,7 @@ typedef enum {
struct EnItem00;
typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*);
typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct PlayState*);
#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000)
#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8)
@ -275,7 +275,7 @@ typedef struct EnItem00 {
struct EnAObj;
typedef void (*EnAObjActionFunc)(struct EnAObj*, struct GlobalContext*);
typedef void (*EnAObjActionFunc)(struct EnAObj*, struct PlayState*);
typedef struct EnAObj {
/* 0x000 */ Actor actor;

View File

@ -6,7 +6,7 @@
#include "z64dma.h"
#include "z64math.h"
struct GlobalContext;
struct PlayState;
struct Actor;
struct SkelAnime;
@ -189,7 +189,7 @@ typedef struct SkelAnime {
/* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph
/* 0x30 */ union {
s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph
s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph
s32 (*link)(struct PlayState*, struct SkelAnime*); // Loop, Play once, and Morph
} update;
/* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton
/* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace.
@ -198,29 +198,29 @@ typedef struct SkelAnime {
/* 0x3E */ Vec3s baseTransl; // Base modelspace translation.
} SkelAnime; // size = 0x44
typedef s32 (*OverrideLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
typedef s32 (*OverrideLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
struct Actor* thisx);
typedef void (*PostLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot,
typedef void (*PostLimbDrawOpa)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot,
struct Actor* thisx);
typedef s32 (*OverrideLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
typedef s32 (*OverrideLimbDraw)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
struct Actor* thisx, Gfx** gfx);
typedef void (*PostLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot,
typedef void (*PostLimbDraw)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot,
struct Actor* thisx, Gfx** gfx);
typedef s32 (*OverrideLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
typedef s32 (*OverrideLimbDrawFlex)(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
struct Actor* thisx);
typedef void (*PostLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot,
typedef void (*PostLimbDrawFlex)(struct PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot,
struct Actor* thisx);
typedef void (*TransformLimbDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx);
typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, struct Actor* thisx);
typedef void (*TransformLimbDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* thisx, Gfx** gfx);
typedef void (*TransformLimbDraw)(struct PlayState* play, s32 limbIndex, struct Actor* thisx, Gfx** gfx);
typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData*);
typedef void (*AnimationEntryCallback)(struct PlayState*, AnimationEntryData*);
extern u32 link_animetion_segment;
@ -251,7 +251,7 @@ typedef struct AnimationSpeedInfo {
struct SkeletonInfo;
typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList,
typedef s32 (*UnkKeyframeCallback)(struct PlayState* play, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList,
u8* arg4, void* arg5);
// Keyframe limb?
@ -312,10 +312,10 @@ typedef struct SkeletonInfo {
/* 0x2C */ s16* unk_2C;
} SkeletonInfo;
typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList,
typedef s32 (*OverrideKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList,
u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos);
typedef void (*PostKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList,
typedef void (*PostKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList,
u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos);
#endif

View File

@ -1,7 +1,7 @@
#ifndef Z64_BGCHECK_H
#define Z64_BGCHECK_H
struct GlobalContext;
struct PlayState;
struct Actor;
struct DynaPolyActor;
@ -223,7 +223,7 @@ typedef struct {
} CollisionContext; // size = 0x1470
typedef struct {
/* 0x00 */ struct GlobalContext* globalCtx;
/* 0x00 */ struct PlayState* play;
/* 0x04 */ CollisionContext* colCtx;
/* 0x08 */ u16 xpFlags;
/* 0x0C */ CollisionPoly** resultPoly;

View File

@ -4,7 +4,7 @@
#include "PR/ultratypes.h"
#include "z64math.h"
struct GlobalContext;
struct PlayState;
typedef struct {
/* 0x0 */ u16 flags; // Only the bottom two bits are used, although others are set in objects
@ -44,19 +44,19 @@ typedef struct {
/* 0x1C */ s16 (*jointTable)[9];
} SkelCurve; // size = 0x20
typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor);
typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor);
typedef s32 (*OverrideCurveLimbDraw)(struct PlayState* play, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor);
typedef void (*PostCurveLimbDraw)(struct PlayState* play, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor);
f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount);
void SkelCurve_Clear(SkelCurve* skelCurve);
s32 SkelCurve_Init(struct GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation);
void SkelCurve_Destroy(struct GlobalContext* globalCtx, SkelCurve* skelCurve);
s32 SkelCurve_Init(struct PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation);
void SkelCurve_Destroy(struct PlayState* play, SkelCurve* skelCurve);
void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed);
s32 SkelCurve_Update(struct GlobalContext* globalCtx, SkelCurve* skelCurve);
void SkelCurve_Draw(Actor* actor, struct GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx);
s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve);
void SkelCurve_Draw(Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx);
// ZAPD compatibility typedefs

View File

@ -8,7 +8,7 @@
#include "unk.h"
struct GraphicsContext;
struct GlobalContext;
struct PlayState;
#define SPARK_COUNT 3
#define BLURE_COUNT 25
@ -199,7 +199,7 @@ typedef struct {
} EffectTireMark; // size = 0x60C
typedef struct {
/* 0x0000 */ struct GlobalContext* globalCtx;
/* 0x0000 */ struct PlayState* play;
struct {
EffectStatus status;
EffectSpark effect;
@ -238,9 +238,9 @@ typedef enum {
struct EffectSs;
typedef u32 (*EffectSsInitFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* effectSs, void* initParams);
typedef void(*EffectSsUpdateFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* particle);
typedef void(*EffectSsDrawFunc)(struct GlobalContext* globalCtx, u32 index, struct EffectSs* particle);
typedef u32 (*EffectSsInitFunc)(struct PlayState* play, u32 index, struct EffectSs* effectSs, void* initParams);
typedef void(*EffectSsUpdateFunc)(struct PlayState* play, u32 index, struct EffectSs* particle);
typedef void(*EffectSsDrawFunc)(struct PlayState* play, u32 index, struct EffectSs* particle);
typedef struct {
/* 0x00 */ u32 type;

View File

@ -88,6 +88,6 @@ typedef enum LightType {
} LightType;
typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec);
typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct GlobalContext* globalCtx);
typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play);
#endif

View File

@ -186,7 +186,7 @@ typedef struct {
} WeaponInfo; // size = 0x1C
typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*);
typedef void (*PlayerFuncD58)(struct PlayState*, struct Player*);
typedef struct Player {
/* 0x000 */ Actor actor;

View File

@ -6,7 +6,7 @@
#include "os.h"
struct GameState;
struct GlobalContext;
struct PlayState;
struct FileChooseContext;
// TODO: properly name DOWN, RETURN and TOP
@ -275,7 +275,7 @@ typedef enum SunsSongState {
void Sram_ActivateOwl(u8 owlId);
void Sram_ClearFlagsAtDawnOfTheFirstDay(void);
void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx);
void Sram_SaveEndOfCycle(struct PlayState* play);
void Sram_IncrementDay(void);
u16 Sram_CalcChecksum(void* data, size_t count);
void Sram_InitNewSave(void);
@ -290,8 +290,8 @@ void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx
void func_80146DF8(SramContext* sramCtx);
void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx);
void Sram_Alloc(struct GameState* gamestate, SramContext* sramCtx);
void Sram_SaveSpecialEnterClockTown(struct GlobalContext* globalCtx);
void Sram_SaveSpecialNewDay(struct GlobalContext* globalCtx);
void Sram_SaveSpecialEnterClockTown(struct PlayState* play);
void Sram_SaveSpecialNewDay(struct PlayState* play);
void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages);
void func_80147020(SramContext* sramCtx);
void func_80147068(SramContext* sramCtx);

View File

@ -5,7 +5,7 @@
struct GraphicsContext;
struct GameState;
struct GlobalContext;
struct PlayState;
/**
* Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member)
@ -78,8 +78,8 @@ typedef struct {
/* 0x04C */ SkelAnime skelAnime;
} Skin; // size = 0x90
typedef void (*SkinPostDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, Skin* skin);
typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, s32 limbIndex, Skin* skin);
typedef void (*SkinPostDraw)(struct Actor* thisx, struct PlayState* play, Skin* skin);
typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct PlayState* play, s32 limbIndex, Skin* skin);
#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0)
#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1)
@ -89,10 +89,10 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod
void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3);
void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags);
void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags);
void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation);
void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation);
void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6);
void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags);
void func_80138228(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation);
void func_80138258(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation);
void func_8013828C(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6);
void func_801382C4(Actor* actor, struct PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags);
void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst);
void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst);

View File

@ -17,9 +17,9 @@ typedef enum {
} SubSCutsceneType;
//! @TODO: rename based on func_8013E748 and func_800B8500
typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*);
typedef s32 (*func_8013E748_VerifyFunc)(struct PlayState*, Actor*, void*);
typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*);
typedef s32 (*VerifyActor)(struct PlayState*, Actor*, Actor*, void*);
#define SUBS_SHADOW_TEX_WIDTH 64
#define SUBS_SHADOW_TEX_HEIGHT 64
@ -55,8 +55,8 @@ typedef struct TrackOptionsSet {
(ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY)
struct ActorPathing;
typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*);
typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*);
typedef void (*ActorPathingComputeFunc)(struct PlayState*, struct ActorPathing*);
typedef s32 (*ActorPathingUpdateFunc)(struct PlayState*, struct ActorPathing*);
typedef struct ActorPathing {
/* 0x00 */ Path* setupPathList;
@ -82,12 +82,12 @@ typedef struct ActorPathing {
/* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again
} ActorPathing; // size = 0x6C
struct EnDoor* SubS_FindDoor(struct GlobalContext* globalCtx, s32 switchFlag);
struct EnDoor* SubS_FindDoor(struct PlayState* play, s32 switchFlag);
Gfx* SubS_DrawTransformFlexLimb(struct GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx);
Gfx* SubS_DrawTransformFlex(struct GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx);
Gfx* SubS_DrawTransformFlexLimb(struct PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx);
Gfx* SubS_DrawTransformFlex(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx);
s32 SubS_InCsMode(struct GlobalContext* globalCtx);
s32 SubS_InCsMode(struct PlayState* play);
s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot);
@ -98,24 +98,24 @@ s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypoin
void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]);
void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], f32 knots[]);
s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed);
void SubS_TimePathing_ComputeInitialY(struct GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos);
void SubS_TimePathing_ComputeInitialY(struct PlayState* play, Path* path, s32 waypoint, Vec3f* targetPos);
Path* SubS_GetAdditionalPath(struct GlobalContext* globalCtx, u8 pathIndex, s32 max);
Path* SubS_GetAdditionalPath(struct PlayState* play, u8 pathIndex, s32 max);
Actor* SubS_FindNearestActor(Actor* actor, struct GlobalContext* globalCtx, u8 actorCategory, s16 actorId);
Actor* SubS_FindNearestActor(Actor* actor, struct PlayState* play, u8 actorCategory, s16 actorId);
s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index);
s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex);
Path* SubS_GetDayDependentPath(struct GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex);
Path* SubS_GetDayDependentPath(struct PlayState* play, u8 pathIndex, u8 max, s32* startPointIndex);
s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction);
s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart);
s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst);
s32 func_8013C964(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type);
s32 func_8013C964(Actor* actor, struct PlayState* play, f32 xzRange, f32 yRange, s32 itemId, s32 type);
void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size);
void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]);
@ -126,30 +126,30 @@ s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnT
s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB);
Path* SubS_GetPathByIndex(struct GlobalContext* globalCtx, s16 pathIndex, s16 max);
Path* SubS_GetPathByIndex(struct PlayState* play, s16 pathIndex, s16 max);
s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst);
s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq);
s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep);
s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq);
s8 SubS_IsObjectLoaded(s8 index, struct GlobalContext* globalCtx);
s8 SubS_GetObjectIndex(s16 id, struct GlobalContext* globalCtx);
s8 SubS_IsObjectLoaded(s8 index, struct PlayState* play);
s8 SubS_GetObjectIndex(s16 id, struct PlayState* play);
Actor* SubS_FindActor(struct GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId);
Actor* SubS_FindActor(struct PlayState* play, Actor* actorListStart, u8 actorCategory, s16 actorId);
s32 SubS_FillLimbRotTables(struct GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs);
s32 SubS_FillLimbRotTables(struct PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs);
s32 SubS_IsFloorAbove(struct GlobalContext* globalCtx, Vec3f* pos, f32 distAbove);
s32 SubS_IsFloorAbove(struct PlayState* play, Vec3f* pos, f32 distAbove);
s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst);
u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex);
void SubS_ActorPathing_Init(struct GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags);
s32 SubS_ActorPathing_Update(struct GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc);
void SubS_ActorPathing_ComputePointInfo(struct GlobalContext* globalCtx, ActorPathing* actorPath);
s32 SubS_ActorPathing_MoveWithGravity(struct GlobalContext* globalCtx, ActorPathing* actorPath);
s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct GlobalContext* globalCtx, ActorPathing* actorPath);
s32 SubS_ActorPathing_SetNextPoint(struct GlobalContext* globalCtx, ActorPathing* actorPath);
void SubS_ActorPathing_Init(struct PlayState* play, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags);
s32 SubS_ActorPathing_Update(struct PlayState* play, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc);
void SubS_ActorPathing_ComputePointInfo(struct PlayState* play, ActorPathing* actorPath);
s32 SubS_ActorPathing_MoveWithGravity(struct PlayState* play, ActorPathing* actorPath);
s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct PlayState* play, ActorPathing* actorPath);
s32 SubS_ActorPathing_SetNextPoint(struct PlayState* play, ActorPathing* actorPath);
void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex);
@ -159,11 +159,11 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes);
void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane);
s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect);
Actor* SubS_FindActorCustom(struct GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor);
Actor* SubS_FindActorCustom(struct PlayState* play, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor);
s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc);
s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data);
s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol);
s32 func_8013E748(Actor* actor, struct PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc);
s32 SubS_ActorAndPlayerFaceEachOther(struct PlayState* play, Actor* actor, void* data);
s32 func_8013E8F8(Actor* actor, struct PlayState* play, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol);
s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax);

View File

@ -34,7 +34,7 @@ typedef enum {
/* 21 */ ENHY_ANIMATION_MAX
} EnHyAnimation;
typedef void (*EnHyActionFunc)(struct EnHy*, GlobalContext*);
typedef void (*EnHyActionFunc)(struct EnHy*, PlayState*);
typedef struct EnHy {
/* 0x000 */ Actor actor;
@ -76,19 +76,19 @@ extern s8 gEnHyParentBodyParts[];
extern u8 gEnHyShadowSizes[];
s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex);
EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx);
void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex);
s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx);
EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play);
void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex);
s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play);
void EnHy_Blink(EnHy* enHy, s32 arg1);
s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex);
void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4);
s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5);
s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3);
s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex);
s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex);
s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex);
void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4);
s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5);
s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3);
s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex);
s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, s16 animIndex);
s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget);
s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget);
void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx);
s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold);
void EnHy_UpdateCollider(EnHy* enHy, PlayState* play);
s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold);
#endif // Z_EN_HY_CODE_H

View File

@ -1,7 +1,7 @@
#include "global.h"
void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId) {
func_80151938(globalCtx, textId);
void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId) {
func_80151938(play, textId);
actor->textId = textId;
}
@ -77,16 +77,15 @@ s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRo
*
* @note same note as Actor_TrackPlayer
*/
s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot,
f32 focusHeight) {
Player* player = GET_PLAYER(globalCtx);
s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight) {
Player* player = GET_PLAYER(play);
s16 yaw;
Vec3f target;
actor->focus.pos = actor->world.pos;
actor->focus.pos.y += focusHeight;
if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) {
if (!((play->csCtx.state != 0) || gDbgCamEnabled)) {
yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
if (yaw >= 0x4300) {
Actor_TrackNone(headRot, torsoRot);
@ -94,8 +93,8 @@ s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3
}
}
if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) {
target = globalCtx->view.eye;
if ((play->csCtx.state != 0) || gDbgCamEnabled) {
target = play->view.eye;
} else {
target = player->actor.focus.pos;
}
@ -121,14 +120,14 @@ s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3
* @note if in a cutscene or debug camera is enabled, the computed rotation will instead turn towards the view eye no
* matter the yaw.
*/
s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) {
Player* player = GET_PLAYER(globalCtx);
s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) {
Player* player = GET_PLAYER(play);
s16 yaw;
Vec3f target;
actor->focus.pos = focusPos;
if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) {
if (!((play->csCtx.state != 0) || gDbgCamEnabled)) {
yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
if (yaw >= 0x4300) {
Actor_TrackNone(headRot, torsoRot);
@ -136,8 +135,8 @@ s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Ve
}
}
if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) {
target = globalCtx->view.eye;
if ((play->csCtx.state != 0) || gDbgCamEnabled) {
target = play->view.eye;
} else {
target = player->actor.focus.pos;
}

View File

@ -474,15 +474,15 @@ u16 gScenesPerRegion[11][27] = {
},
};
s32 Inventory_GetBtnBItem(GlobalContext* globalCtx) {
s32 Inventory_GetBtnBItem(PlayState* play) {
if (gSaveContext.buttonStatus[0] == BTN_DISABLED) {
return ITEM_NONE;
} else if (gSaveContext.unk_1015 == ITEM_NONE) {
return ITEM_NONE;
} else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) {
if (globalCtx->interfaceCtx.unk_21C != 0) {
if (globalCtx->interfaceCtx.unk_21E != 0) {
return globalCtx->interfaceCtx.unk_21E;
if (play->interfaceCtx.unk_21C != 0) {
if (play->interfaceCtx.unk_21E != 0) {
return play->interfaceCtx.unk_21E;
}
}
return ITEM_NONE;
@ -501,12 +501,12 @@ void Inventory_ChangeEquipment(s16 value) {
/**
* Only deletes shield, equipment argument unused and is a remnant of OoT
*/
u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) {
Player* player = GET_PLAYER(globalCtx);
u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) {
Player* player = GET_PLAYER(play);
if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) {
SET_EQUIP_VALUE(EQUIP_SHIELD, 0);
Player_SetEquipmentData(globalCtx, player);
Player_SetEquipmentData(play, player);
return true;
}
@ -719,12 +719,12 @@ s16 Inventory_GetSkullTokenCount(s16 sceneIndex) {
}
}
void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) {
void Inventory_SaveLotteryCodeGuess(PlayState* play) {
u16 lotteryCodeGuess;
lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit
lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit
lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit
lotteryCodeGuess = ((play->msgCtx.unk12054[0] & 0xF) << 8); // First Digit
lotteryCodeGuess |= ((play->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit
lotteryCodeGuess |= (play->msgCtx.unk12054[2] & 0xF); // Third Digit
gSaveContext.save.lotteryCodeGuess =
(gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF);
}

View File

@ -134,8 +134,8 @@ static u32 sCurrentBit = 0;
static s32 sTimer = 0;
void FlagSet_Update(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
Input* input = CONTROLLER1(&globalCtx->state);
PlayState* play = (PlayState*)gameState;
Input* input = CONTROLLER1(&play->state);
/* Intra-byte navigation */
@ -255,7 +255,7 @@ void FlagSet_Update(GameState* gameState) {
// Pressing B will exit
} else if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
globalCtx->pauseCtx.debugState = 0;
play->pauseCtx.debugState = 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,11 @@ void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) {
dynaActor->stateFlags = DYNAPOLY_STATE_NONE;
}
void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) {
void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) {
CollisionHeader* header = NULL;
CollisionHeader_GetVirtual(meshHeader, &header);
dynaActor->bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &dynaActor->actor, header);
dynaActor->bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &dynaActor->actor, header);
}
void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) {
@ -102,7 +102,7 @@ s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) {
}
}
s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius,
s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius,
s16 startHeight) {
Vec3f startPos;
Vec3f endPos;
@ -125,16 +125,16 @@ s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActo
endPos.y = startPos.y;
endPos.z = sign * adjustedEndRadius * cos + startPos.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false,
true, &bgId, &dynaActor->actor, 0.0f)) {
if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true,
&bgId, &dynaActor->actor, 0.0f)) {
return false;
}
startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x;
startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z;
endPos.x = sign * adjustedEndRadius * sin + startPos.x;
endPos.z = sign * adjustedEndRadius * cos + startPos.z;
if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false,
true, &bgId, &dynaActor->actor, 0.0f)) {
if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true,
&bgId, &dynaActor->actor, 0.0f)) {
return false;
}
return true;

View File

@ -124,13 +124,13 @@ void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* pol
ssList->head = index;
}
void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list) {
void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list) {
list->tbl = NULL;
list->count = 0;
}
void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes) {
list->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.heap, numNodes * sizeof(SSNode), -2);
void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes) {
list->tbl = (SSNode*)THA_AllocEndAlign(&play->state.heap, numNodes * sizeof(SSNode), -2);
list->maxNodes = numNodes;
list->count = 0;
}
@ -1376,7 +1376,7 @@ s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* pol
* Initialize StaticLookup Table
* returns size of table, in bytes
*/
u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) {
u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLookup* lookupTbl) {
Vec3s* vtxList;
CollisionPoly* polyList;
s32 polyMax;
@ -1460,11 +1460,11 @@ u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx,
/**
* Returns whether the current scene should reserve less memory for it's collision lookup
*/
s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx) {
s32 BgCheck_IsSmallMemScene(PlayState* play) {
s16* i;
for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) {
if (globalCtx->sceneNum == *i) {
if (play->sceneNum == *i) {
return true;
}
}
@ -1499,11 +1499,11 @@ void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* s
*max = *subdivLength * subdivAmount + min;
}
s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices) {
s32 BgCheck_GetSpecialSceneMaxObjects(PlayState* play, s32* maxNodes, s32* maxPolygons, s32* maxVertices) {
s32 i;
for (i = 0; i < ARRAY_COUNT(sCustomDynapolyMem); i++) {
if (globalCtx->sceneNum == sCustomDynapolyMem[i].sceneId) {
if (play->sceneNum == sCustomDynapolyMem[i].sceneId) {
*maxNodes = sCustomDynapolyMem[i].maxNodes;
*maxPolygons = sCustomDynapolyMem[i].maxPolygons;
*maxVertices = sCustomDynapolyMem[i].maxVertices;
@ -1516,7 +1516,7 @@ s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s
/**
* Allocate CollisionContext
*/
void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) {
void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader) {
u32 tblMax;
u32 memSize;
u32 lookupTblMemSize;
@ -1527,7 +1527,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->colHeader = colHeader;
colCtx->flags = 0;
if (BgCheck_IsSmallMemScene(globalCtx)) {
if (BgCheck_IsSmallMemScene(play)) {
colCtx->memSize = 0xF000;
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 512;
@ -1540,7 +1540,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
s32 useCustomSubdivisions;
s32 i;
if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) {
if (BgCheck_TryGetCustomMemsize(play->sceneNum, &customMemSize)) {
colCtx->memSize = customMemSize;
} else {
colCtx->memSize = 0x23000;
@ -1548,12 +1548,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 544;
colCtx->dyna.vtxListMax = 512;
BgCheck_GetSpecialSceneMaxObjects(globalCtx, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax,
BgCheck_GetSpecialSceneMaxObjects(play, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax,
&colCtx->dyna.vtxListMax);
useCustomSubdivisions = false;
for (i = 0; i < ARRAY_COUNT(sSceneSubdivisionList); i++) {
if (globalCtx->sceneNum == sSceneSubdivisionList[i].sceneId) {
if (play->sceneNum == sSceneSubdivisionList[i].sceneId) {
colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x;
colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y;
colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z;
@ -1568,7 +1568,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
}
}
colCtx->lookupTbl = THA_AllocEndAlign(
&globalCtx->state.heap,
&play->state.heap,
colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1);
if (colCtx->lookupTbl == NULL) {
Fault_AddHungupAndCrash("../z_bgcheck.c", 3955);
@ -1601,12 +1601,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
}
SSNodeList_Init(&colCtx->polyNodes);
SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons);
SSNodeList_Alloc(play, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons);
lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, globalCtx, colCtx->lookupTbl);
lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, play, colCtx->lookupTbl);
DynaPoly_Init(globalCtx, &colCtx->dyna);
DynaPoly_Alloc(globalCtx, &colCtx->dyna);
DynaPoly_Init(play, &colCtx->dyna);
DynaPoly_Alloc(play, &colCtx->dyna);
}
/**
@ -1661,7 +1661,7 @@ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) {
* returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected
* returns the poly found in `outPoly`, and the bgId of the entity in `outBgId`
*/
f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly,
s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 checkDist, s32 arg9) {
f32 yIntersectDyna;
f32 yIntersect;
@ -1693,7 +1693,7 @@ f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
checkPos.y -= colCtx->subdivLength.y;
}
if (!(arg9 & 1)) {
dynaRaycast.globalCtx = globalCtx;
dynaRaycast.play = play;
dynaRaycast.colCtx = colCtx;
dynaRaycast.xpFlags = xpFlags;
dynaRaycast.resultPoly = outPoly;
@ -1741,22 +1741,20 @@ f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPol
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
Vec3f* pos) {
f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
s32 bgId;
return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0);
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0);
}
/**
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
Vec3f* pos) {
f32 BgCheck_EntityRaycastFloor2_1(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) {
s32 bgId;
return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1);
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1);
}
/**
@ -1780,18 +1778,18 @@ f32 BgCheck_EntityRaycastFloor5(CollisionContext* colCtx, CollisionPoly** outPol
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor5_2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
s32* bgId, Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0);
f32 BgCheck_EntityRaycastFloor5_2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0);
}
/**
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
s32* bgId, Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0);
f32 BgCheck_EntityRaycastFloor5_3(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
Actor* actor, Vec3f* pos) {
return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0);
}
/**
@ -2453,11 +2451,11 @@ void SSNodeList_Init(SSNodeList* this) {
* tblMax is the number of SSNode records to allocate
* numPolys is the number of polygons defined within the CollisionHeader
*/
void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys) {
void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) {
this->max = tblMax;
this->count = 0;
this->tbl = THA_AllocEndAlign(&globalCtx->state.heap, tblMax * sizeof(SSNode), -2);
this->polyCheckTbl = THA_AllocEndAlign16(&globalCtx->state.heap, numPolys * sizeof(u8));
this->tbl = THA_AllocEndAlign(&play->state.heap, tblMax * sizeof(SSNode), -2);
this->polyCheckTbl = THA_AllocEndAlign16(&play->state.heap, numPolys * sizeof(u8));
if (this->polyCheckTbl == NULL) {
sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n");
@ -2554,7 +2552,7 @@ void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex) {
/**
* Initialize BgActor
*/
void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor) {
void BgActor_Init(PlayState* play, BgActor* bgActor) {
bgActor->actor = NULL;
bgActor->colHeader = NULL;
ScaleRotPos_Init(&bgActor->prevTransform);
@ -2598,8 +2596,8 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) {
/**
* Allocate dyna.polyList
*/
void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) {
*polyList = THA_AllocEndAlign(&globalCtx->state.heap, numPolys * sizeof(CollisionPoly), -2);
void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) {
*polyList = THA_AllocEndAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2);
}
/**
@ -2612,8 +2610,8 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) {
/**
* Allocate dyna.vtxList
*/
void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) {
*vtxList = THA_AllocEndAlign(&globalCtx->state.heap, numVtx * sizeof(Vec3s), -2);
void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) {
*vtxList = THA_AllocEndAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2);
}
/**
@ -2627,14 +2625,14 @@ void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) {
/**
* Allocate dyna.waterBoxList
*/
void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) {
waterBoxList->boxes = THA_AllocEndAlign(&globalCtx->state.heap, numWaterBoxes * sizeof(WaterBox), -2);
void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) {
waterBoxList->boxes = THA_AllocEndAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2);
}
/**
* Update BgActor's prevTransform
*/
void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) {
void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) {
bgActor->prevTransform = bgActor->curTransform;
}
@ -2651,43 +2649,42 @@ s32 DynaPoly_IsBgIdBgActor(s32 bgId) {
/**
* Init DynaCollisionContext
*/
void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna) {
dyna->bitFlag = DYNAPOLY_INVALIDATE_LOOKUP;
DynaPoly_NullPolyList(&dyna->polyList);
DynaPoly_NullVtxList(&dyna->vtxList);
DynaPoly_InitWaterBoxList(&dyna->waterBoxList);
DynaSSNodeList_Init(globalCtx, &dyna->polyNodes);
DynaSSNodeList_Init(play, &dyna->polyNodes);
}
/**
* Set DynaCollisionContext
*/
void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna) {
s32 i;
for (i = 0; i < BG_ACTOR_MAX; i++) {
BgActor_Init(globalCtx, &dyna->bgActors[i]);
BgActor_Init(play, &dyna->bgActors[i]);
dyna->bgActorFlags[i] = 0;
}
DynaPoly_NullPolyList(&dyna->polyList);
DynaPoly_AllocPolyList(globalCtx, &dyna->polyList, dyna->polyListMax);
DynaPoly_AllocPolyList(play, &dyna->polyList, dyna->polyListMax);
DynaPoly_NullVtxList(&dyna->vtxList);
DynaPoly_AllocVtxList(globalCtx, &dyna->vtxList, dyna->vtxListMax);
DynaPoly_AllocVtxList(play, &dyna->vtxList, dyna->vtxListMax);
DynaPoly_InitWaterBoxList(&dyna->waterBoxList);
DynaPoly_AllocWaterBoxList(globalCtx, &dyna->waterBoxList, DYNA_WATERBOX_MAX);
DynaPoly_AllocWaterBoxList(play, &dyna->waterBoxList, DYNA_WATERBOX_MAX);
DynaSSNodeList_Init(globalCtx, &dyna->polyNodes);
DynaSSNodeList_Alloc(globalCtx, &dyna->polyNodes, dyna->polyNodesMax);
DynaSSNodeList_Init(play, &dyna->polyNodes);
DynaSSNodeList_Alloc(play, &dyna->polyNodes, dyna->polyNodesMax);
}
/**
* Set BgActor
* original name: DynaPolyInfo_setActor
*/
s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor,
CollisionHeader* colHeader) {
s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader) {
s32 bgId;
s32 foundSlot = false;
@ -2721,42 +2718,42 @@ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) {
return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor;
}
void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C62BC(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 4;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C6314(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~4;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C636C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 8;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C63C4(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~8;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C641C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 0x20;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void func_800C6474(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~0x20;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
@ -2766,13 +2763,13 @@ void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgI
/**
* original name: DynaPolyInfo_delReserve
*/
void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
DynaPolyActor* actor;
if (DynaPoly_IsBgIdBgActor(bgId) == false) {
return;
}
actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId);
actor = DynaPoly_GetActor(&play->colCtx, bgId);
if (actor != NULL) {
actor->bgId = BGACTOR_NEG_ONE;
@ -2781,7 +2778,7 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna
}
}
void func_800C6554(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
void func_800C6554(PlayState* play, DynaCollisionContext* dyna) {
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
@ -2839,8 +2836,8 @@ void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPo
/**
* original name: DynaPolyInfo_expandSRT
*/
void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex,
s32* polyStartIndex, s32* waterBoxStartIndex) {
void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex,
s32* waterBoxStartIndex) {
Actor* actor;
s32 pad;
s32 pad2;
@ -3064,13 +3061,13 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/DynaPoly_ExpandSRT.s")
#endif
void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) {
void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor) {
DynaPolyActor* dynaActor;
s32 i;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if ((dyna->bgActorFlags[i] & 1)) {
dynaActor = DynaPoly_GetActor(&globalCtx->colCtx, i);
dynaActor = DynaPoly_GetActor(&play->colCtx, i);
if (dynaActor != NULL && &dynaActor->actor == actor) {
DynaPolyActor_ResetState((DynaPolyActor*)actor);
return;
@ -3082,7 +3079,7 @@ void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionCont
/**
* original name: DynaPolyInfo_setup
*/
void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) {
DynaPolyActor* actor;
s32 vtxStartIndex;
s32 polyStartIndex;
@ -3099,19 +3096,19 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
if (dyna->bgActorFlags[i] & 2) {
// Initialize BgActor
dyna->bgActorFlags[i] = 0;
BgActor_Init(globalCtx, &dyna->bgActors[i]);
BgActor_Init(play, &dyna->bgActors[i]);
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) {
// Delete BgActor
actor = DynaPoly_GetActor(&globalCtx->colCtx, i);
actor = DynaPoly_GetActor(&play->colCtx, i);
if (actor == NULL) {
return;
}
actor->bgId = BGACTOR_NEG_ONE;
dyna->bgActorFlags[i] = 0;
BgActor_Init(globalCtx, &dyna->bgActors[i]);
BgActor_Init(play, &dyna->bgActors[i]);
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
@ -3120,7 +3117,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
waterBoxStartIndex = 0;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2)) {
DynaPoly_ExpandSRT(globalCtx, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex);
DynaPoly_ExpandSRT(play, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex);
}
}
dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP;
@ -3150,12 +3147,12 @@ void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertice
/**
* Update all BgActor's previous ScaleRotPos
*/
void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna) {
s32 i;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if (dyna->bgActorFlags[i] & 1) {
DynaPoly_SetBgActorPrevTransform(globalCtx, &dyna->bgActors[i]);
DynaPoly_SetBgActorPrevTransform(play, &dyna->bgActors[i]);
}
}
}
@ -3295,10 +3292,10 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) {
}
dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId);
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) {
pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0;
if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) {
pauseState = dynaRaycast->play->pauseCtx.state != 0;
if (!pauseState) {
pauseState = dynaRaycast->globalCtx->pauseCtx.debugState != 0;
pauseState = dynaRaycast->play->pauseCtx.debugState != 0;
}
if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) {
curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform;
@ -3983,7 +3980,7 @@ void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** de
/**
* SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders
*/
void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx) {
void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play) {
DynaCollisionContext* dyna = &colCtx->dyna;
s32 i;
u16 flag;
@ -3991,7 +3988,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globa
for (i = 0; i < BG_ACTOR_MAX; i++) {
flag = dyna->bgActorFlags[i];
if ((flag & 1) && !(flag & 2)) {
Actor_SetObjectDependency(globalCtx, dyna->bgActors[i].actor);
Actor_SetObjectDependency(play, dyna->bgActors[i].actor);
CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader);
}
}
@ -4378,7 +4375,7 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32
* returns true if point is within the xz boundaries of an active water box, else false
* `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox
*/
s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox, s32* bgId) {
CollisionHeader* colHeader;
u32 room;
@ -4392,7 +4389,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = 0x3F & (curWaterBox->properties >> 13);
if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) {
if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) {
if (curWaterBox->properties & 0x80000) {
continue;
}
@ -4438,16 +4435,16 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
}
// boolean
s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox);
return WaterBox_GetSurface1_2(play, colCtx, x, z, ySurface, outWaterBox);
}
// boolean
s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
s32 bgId;
return WaterBox_GetSurfaceImpl(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId);
return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId);
}
#ifdef NON_MATCHING
@ -4457,7 +4454,7 @@ s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f
* returns the index of the waterbox found, or -1 if no waterbox is found
* `outWaterBox` returns the pointer to the waterbox found, or NULL if none is found
*/
s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist,
s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist,
WaterBox** outWaterBox, s32* bgId) {
CollisionHeader* colHeader;
s32 room;
@ -4477,7 +4474,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec
waterBox = &colHeader->waterBoxes[i];
room = WATERBOX_ROOM(waterBox->properties);
if (!(room == globalCtx->roomCtx.currRoom.num || room == 0x3F)) {
if (!(room == play->roomCtx.currRoom.num || room == 0x3F)) {
continue;
}
if ((waterBox->properties & 0x80000)) {
@ -4596,8 +4593,8 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox)
* returns true if point is within the xz boundaries of an active water box, else false
* `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox
*/
s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox, s32* bgId) {
s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox,
s32* bgId) {
CollisionHeader* colHeader;
u32 room;
WaterBox* curWaterBox;
@ -4614,7 +4611,7 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = WATERBOX_ROOM(curWaterBox->properties);
if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) {
if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) {
if ((curWaterBox->properties & 0x80000) != 0) {
if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) {
if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) {
@ -4656,11 +4653,10 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32
#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s")
#endif
s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) {
s32 bgId;
return func_800CA6F0(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId);
return func_800CA6F0(play, colCtx, x, z, ySurface, outWaterBox, &bgId);
}
/**

View File

@ -3,37 +3,37 @@
/**
* Draws a display list to the opaque display buffer
*/
void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) {
void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) {
Gfx* dl;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
dl = POLY_OPA_DISP;
gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]);
gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(&dl[2], dlist);
POLY_OPA_DISP = &dl[3];
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Draws a display list to the translucent display buffer
*/
void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) {
void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) {
Gfx* dl;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
dl = POLY_XLU_DISP;
gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]);
gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(&dl[2], dlist);
POLY_XLU_DISP = &dl[3];
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#include "global.h"
void func_801AAAA0(GlobalContext* globalCtx) {
void func_801AAAA0(PlayState* play) {
}

View File

@ -7,10 +7,10 @@ typedef struct {
/* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called
} DebugDispObjectInfo; // size = 0x8
typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*);
typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*);
void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, GlobalContext*);
void DebugDisplay_DrawPolygon(DebugDispObject*, void*, GlobalContext*);
void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*);
void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*);
DebugDispObject* DebugDisplay_Init(void) {
sDebugObjectListHead = NULL;
@ -51,44 +51,44 @@ DebugDispObjectInfo sDebugObjectInfoTable[] = {
{ 1, &sDebugDisplay2DL },
};
void DebugDisplay_DrawObjects(GlobalContext* globalCtx) {
void DebugDisplay_DrawObjects(PlayState* play) {
DebugDispObject* dispObj = sDebugObjectListHead;
DebugDispObjectInfo* objInfo;
while (dispObj != NULL) {
objInfo = &sDebugObjectInfoTable[dispObj->type];
sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx);
sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, play);
dispObj = dispObj->next;
}
}
void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
func_8012C6FC(globalCtx->state.gfxCtx);
func_8012C6FC(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY);
Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY);
Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73);
void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
func_8012C588(globalCtx->state.gfxCtx);
func_8012C588(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
@ -96,10 +96,10 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex
Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, arg1);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
s32 D_801BB068[] = {
@ -110,16 +110,16 @@ s32 D_801BB08C = 0;
Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1);
void func_800E992C(GlobalContext* globalCtx, s32 arg1) {
void func_800E992C(PlayState* play, s32 arg1) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C560(globalCtx->state.gfxCtx);
func_8012C560(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1));
gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(play->state.gfxCtx, arg1));
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s")

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
#include "global.h"
void EffFootmark_Init(GlobalContext* globalCtx) {
void EffFootmark_Init(PlayState* play) {
EffFootmark* footmark;
s32 i;
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
footmark->actor = NULL;
footmark->location.x = 0;
footmark->location.y = 0;
@ -16,15 +16,15 @@ void EffFootmark_Init(GlobalContext* globalCtx) {
}
}
void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size,
u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) {
void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red,
u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) {
s32 i;
EffFootmark* footmark;
EffFootmark* destination = NULL;
EffFootmark* oldest = NULL;
s32 isNew = 1;
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (((actor == footmark->actor) && (footmark->id == id)) && ((footmark->flags & 1) == 0)) {
if (fabsf((footmark->location).x - location->x) <= 1) {
if (fabsf((footmark->location).z - location->z) <= 1) {
@ -70,11 +70,11 @@ void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor
}
}
void EffFootmark_Update(GlobalContext* globalCtx) {
void EffFootmark_Update(PlayState* play) {
EffFootmark* footmark;
s32 i;
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
if ((footmark->flags & 1) == 1) {
if (footmark->age < 0xFFFFu) { // TODO replace with MAX_U16 or something
@ -95,21 +95,21 @@ void EffFootmark_Update(GlobalContext* globalCtx) {
}
}
void EffFootmark_Draw(GlobalContext* globalCtx) {
void EffFootmark_Draw(PlayState* play) {
EffFootmark* footmark;
s32 i;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
GraphicsContext* gfxCtx = play->state.gfxCtx;
func_8012C448(globalCtx->state.gfxCtx);
func_8012C448(play->state.gfxCtx);
gSPDisplayList(gfxCtx->polyXlu.p++, D_801BC240);
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
Matrix_Put(&footmark->displayMatrix);
Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, footmark->red, footmark->green, footmark->blue,
footmark->alpha >> 8);

View File

@ -43,7 +43,7 @@ void EffectShieldParticle_Init(void* thisx, void* initParamsx) {
this->lightInfo.type = LIGHT_POINT_NOGLOW;
this->lightInfo.params.point = initParams->lightPoint;
this->lightNode =
LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo);
LightContext_InsertLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, &this->lightInfo);
} else {
this->lightNode = NULL;
}
@ -54,10 +54,10 @@ void EffectShieldParticle_Destroy(void* thisx) {
EffectShieldParticle* this = (EffectShieldParticle*)thisx;
if ((this != NULL) && (this->lightDecay == true)) {
if (this->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) {
Effect_GetGlobalCtx()->lightCtx.listHead = this->lightNode->next;
if (this->lightNode == Effect_GetPlayState()->lightCtx.listHead) {
Effect_GetPlayState()->lightCtx.listHead = this->lightNode->next;
}
LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->lightNode);
LightContext_RemoveLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, this->lightNode);
}
}

View File

@ -122,7 +122,7 @@ s32 EffectSpark_Update(void* thisx) {
void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
Vtx* vertices;
EffectSpark* this = (EffectSpark*)thisx;
GlobalContext* globalCtx = Effect_GetGlobalCtx();
PlayState* play = Effect_GetPlayState();
s32 i;
s32 j;
u8 sp1D3;
@ -199,7 +199,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z);
temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) / 64.0f;
SkinMatrix_SetScale(&spAC, temp, temp, 1.0f);
SkinMatrix_MtxFMtxFMult(&spEC, &globalCtx->billboardMtxF, &sp6C);
SkinMatrix_MtxFMtxFMult(&spEC, &play->billboardMtxF, &sp6C);
SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C);
vertices[j].v.ob[0] = -32;

View File

@ -1,11 +1,11 @@
#include "global.h"
void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_OPA_DISP;
cos = Math_CosS((0x8000 / arg3) * arg2);
@ -23,14 +23,14 @@ void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_OPA_DISP = displayListHead;
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
Gfx* displayListHead;
f32 cos;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
cos = Math_CosS((0x4000 / arg3) * arg2);
displayListHead = POLY_OPA_DISP;
@ -41,26 +41,26 @@ void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_OPA_DISP = displayListHead;
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_800AE5A0(GlobalContext* globalCtx) {
void func_800AE5A0(PlayState* play) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
gDPPipeSync(POLY_OPA_DISP++);
POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP);
POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_XLU_DISP;
cos = Math_CosS((0x8000 / arg3) * arg2);
@ -78,14 +78,14 @@ void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_XLU_DISP = displayListHead;
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_XLU_DISP;
cos = Math_CosS((0x4000 / arg3) * arg2);
@ -96,16 +96,16 @@ void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_XLU_DISP = displayListHead;
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_800AE8EC(GlobalContext* globalCtx) {
void func_800AE8EC(PlayState* play) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
gDPPipeSync(POLY_XLU_DISP++);
POLY_XLU_DISP = func_801660B8(globalCtx, POLY_XLU_DISP);
POLY_XLU_DISP = func_801660B8(play, POLY_XLU_DISP);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -40,8 +40,8 @@ EffectInfo sEffectInfoTable[] = {
},
};
GlobalContext* Effect_GetGlobalCtx(void) {
return sEffectContext.globalCtx;
PlayState* Effect_GetPlayState(void) {
return sEffectContext.play;
}
void* Effect_GetByIndex(s32 index) {
@ -93,7 +93,7 @@ void Effect_InitStatus(EffectStatus* status) {
status->unk2 = 0;
}
void Effect_Init(GlobalContext* globalCtx) {
void Effect_Init(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
@ -113,10 +113,10 @@ void Effect_Init(GlobalContext* globalCtx) {
Effect_InitStatus(&sEffectContext.tireMarks[i].status);
}
sEffectContext.globalCtx = globalCtx;
sEffectContext.play = play;
}
void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) {
void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) {
u32 slotFound;
s32 i;
void* effect = NULL;
@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg
*pIndex = TOTAL_EFFECT_COUNT;
if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
if (FrameAdvance_IsEnabled(&play->state) != true) {
slotFound = false;
switch (type) {
case EFFECT_SPARK:
@ -217,14 +217,14 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) {
}
}
void Effect_UpdateAll(GlobalContext* globalCtx) {
void Effect_UpdateAll(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
if (1) {} // necessary to match
if (sEffectContext.sparks[i].status.active) {
if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) {
Effect_Destroy(globalCtx, i);
Effect_Destroy(play, i);
}
}
}
@ -233,7 +233,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.blures[i].status.active) {
if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) {
Effect_Destroy(globalCtx, i + SPARK_COUNT);
Effect_Destroy(play, i + SPARK_COUNT);
}
}
}
@ -242,7 +242,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.shieldParticles[i].status.active) {
if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) {
Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT);
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT);
}
}
}
@ -251,13 +251,13 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.tireMarks[i].status.active) {
if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) {
Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
}
}
}
}
void Effect_Destroy(GlobalContext* globalCtx, s32 index) {
void Effect_Destroy(PlayState* play, s32 index) {
if (index == TOTAL_EFFECT_COUNT) {
return;
}
@ -290,7 +290,7 @@ void Effect_Destroy(GlobalContext* globalCtx, s32 index) {
}
}
void Effect_DestroyAll(GlobalContext* globalCtx) {
void Effect_DestroyAll(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {

View File

@ -3,12 +3,12 @@
EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) {
void EffectSS_Init(PlayState* play, s32 numEntries) {
u32 i;
EffectSs* effectsSs;
EffectSsOverlay* overlay;
sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs));
sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&play->state.heap, numEntries * sizeof(EffectSs));
sEffectSsInfo.searchIndex = 0;
sEffectSsInfo.size = numEntries;
@ -24,7 +24,7 @@ void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) {
}
}
void EffectSS_Clear(GlobalContext* globalCtx) {
void EffectSS_Clear(PlayState* play) {
u32 i;
EffectSs* effectsSs;
EffectSsOverlay* overlay;
@ -150,10 +150,10 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
return false;
}
void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
void EffectSS_Copy(PlayState* play, EffectSs* effectsSs) {
s32 index;
if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
if (FrameAdvance_IsEnabled(&play->state) != true) {
if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) {
sEffectSsInfo.searchIndex = index + 1;
sEffectSsInfo.data_table[index] = *effectsSs;
@ -161,7 +161,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
}
}
void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) {
void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) {
s32 index;
u32 overlaySize;
EffectSsOverlay* entry = &gParticleOverlayTable[type];
@ -199,13 +199,13 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init
sEffectSsInfo.data_table[index].type = type;
sEffectSsInfo.data_table[index].priority = priority;
if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) {
if (initInfo->init(play, index, &sEffectSsInfo.data_table[index], initData) == 0) {
EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]);
}
}
}
void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
void EffectSS_UpdateParticle(PlayState* play, s32 index) {
EffectSs* particle = &sEffectSsInfo.data_table[index];
if (particle->update != NULL) {
@ -217,11 +217,11 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
particle->pos.y += particle->velocity.y;
particle->pos.z += particle->velocity.z;
particle->update(globalCtx, index, particle);
particle->update(play, index, particle);
}
}
void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) {
void EffectSS_UpdateAllParticles(PlayState* play) {
s32 i;
for (i = 0; i < sEffectSsInfo.size; i++) {
@ -234,25 +234,25 @@ void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) {
}
if (sEffectSsInfo.data_table[i].life > -1) {
EffectSS_UpdateParticle(globalCtx, i);
EffectSS_UpdateParticle(play, i);
}
}
}
void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) {
void EffectSS_DrawParticle(PlayState* play, s32 index) {
EffectSs* entry = &sEffectSsInfo.data_table[index];
if (entry->draw != NULL) {
entry->draw(globalCtx, index, entry);
entry->draw(play, index, entry);
}
}
void EffectSS_DrawAllParticles(GlobalContext* globalCtx) {
Lights* lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
void EffectSS_DrawAllParticles(PlayState* play) {
Lights* lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx);
s32 i;
Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx);
Lights_Draw(lights, globalCtx->state.gfxCtx);
Lights_BindAll(lights, play->lightCtx.listHead, NULL, play);
Lights_Draw(lights, play->state.gfxCtx);
for (i = 0; i < sEffectSsInfo.size; i++) {
if (sEffectSsInfo.data_table[i].life > -1) {
@ -264,7 +264,7 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) {
(sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) {
EffectSS_Delete(&sEffectSsInfo.data_table[i]);
} else {
EffectSS_DrawParticle(globalCtx, i);
EffectSS_DrawParticle(play, i);
}
}
}

View File

@ -32,8 +32,8 @@
#include "overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h"
#include "overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h"
void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture) {
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) {
GraphicsContext* gfxCtx = play->state.gfxCtx;
f32 scale;
MtxF mfTrans;
MtxF mfScale;
@ -41,14 +41,14 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur
MtxF mfTrans11DA0;
s32 pad1;
Mtx* mtx;
void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment;
void* object = play->objectCtx.status[this->rgObjBankIdx].segment;
OPEN_DISPS(gfxCtx);
scale = this->rgScale * 0.0025f;
SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z);
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0);
SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0);
SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult);
gSegments[0x06] = PHYSICAL_TO_VIRTUAL(object);
gSPSegment(POLY_XLU_DISP++, 0x06, object);
@ -70,7 +70,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur
// EffectSsDust Spawn Functions
void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life,
u8 updateMode) {
EffectSsDustInitParams initParams;
@ -86,80 +86,78 @@ void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec
initParams.life = life;
initParams.updateMode = updateMode;
EffectSs_Spawn(globalCtx, EFFECT_SS_DUST, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DUST, 128, &initParams);
}
void func_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0DE0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0);
EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0);
}
void func_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0E48(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0);
EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0);
}
void func_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0EB0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) {
EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
}
void func_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0F18(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) {
EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
}
void func_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0F80(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) {
EffectSsDust_Spawn(globalCtx, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
EffectSsDust_Spawn(play, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0);
}
void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B0FE8(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1);
EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1);
}
void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B1054(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1);
EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1);
}
static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 };
static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 };
void func_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
void func_800B10C0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
void func_800B1130(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
void func_800B11A0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
void func_800B11A0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
}
void func_800B1210(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
void func_800B1210(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0);
}
void func_800B1280(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 life) {
EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
void func_800B1280(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) {
EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
}
void func_800B12F0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 life) {
EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
void func_800B12F0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) {
EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0);
}
void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B1360(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor) {
func_800B0DE0(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5);
func_800B0DE0(play, pos, velocity, accel, primColor, envColor, 100, 5);
}
void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void func_800B139C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor) {
func_800B0E48(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5);
func_800B0E48(play, pos, velocity, accel, primColor, envColor, 100, 5);
}
void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel) {
@ -182,7 +180,7 @@ void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity,
accel->z = 0.0f;
}
void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
void func_800B14D4(PlayState* play, f32 randScale, Vec3f* srcPos) {
s32 i;
Vec3f pos;
Vec3f velocity;
@ -190,11 +188,11 @@ void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
for (i = 0; i < 20; i++) {
func_800B13D8(srcPos, randScale, &pos, &velocity, &accel);
func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 7);
func_800B1280(play, &pos, &velocity, &accel, 100, 30, 7);
}
}
void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
void func_800B1598(PlayState* play, f32 randScale, Vec3f* srcPos) {
s32 i;
Vec3f pos;
Vec3f velocity;
@ -202,24 +200,24 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
for (i = 0; i < 20; i++) {
func_800B13D8(srcPos, randScale, &pos, &velocity, &accel);
func_800B12F0(globalCtx, &pos, &velocity, &accel, 100, 30, 7);
func_800B12F0(play, &pos, &velocity, &accel, 100, 30, 7);
}
}
void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
void EffectSsKirakira_SpawnSmallYellow(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
Color_RGBA8 primColor = { 255, 255, 200, 255 };
Color_RGBA8 envColor = { 255, 200, 0, 0 };
EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16);
EffectSsKirakira_SpawnDispersed(play, pos, velocity, accel, &primColor, &envColor, 1000, 16);
}
void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor) {
EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16);
void EffectSsKirakira_SpawnSmall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor) {
EffectSsKirakira_SpawnDispersed(play, pos, velocity, accel, primColor, envColor, 1000, 16);
}
void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) {
void EffectSsKirakira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s32 life) {
EffectSsKirakiraInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -236,11 +234,11 @@ void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f
initParams.envColor = *envColor;
initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life));
EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams);
}
void EffectSsKirakira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) {
void EffectSsKirakira_SpawnFocused(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s32 life) {
EffectSsKirakiraInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -255,10 +253,10 @@ void EffectSsKirakira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f*
Color_RGBA8_Copy(&initParams.envColor, envColor);
initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life));
EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams);
}
void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
void EffectSsBomb2_SpawnFade(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
EffectSsBomb2InitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -268,11 +266,10 @@ void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloci
initParams.scaleStep = 0;
initParams.drawMode = 0;
EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams);
EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams);
}
void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
s16 scaleStep) {
void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) {
EffectSsBomb2InitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -282,12 +279,12 @@ void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* vel
initParams.scaleStep = scaleStep;
initParams.drawMode = 1;
EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams);
EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams);
}
// EffectSsBlast Spawn Functions
void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life) {
EffectSsBlastInitParams initParams;
@ -301,32 +298,32 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.sclaeStepDecay = sclaeStepDecay;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams);
}
void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
s16 scaleStep, s16 life) {
static Color_RGBA8 primColor = { 255, 255, 255, 255 };
static Color_RGBA8 envColor = { 200, 200, 200, 0 };
EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life);
EffectSsBlast_Spawn(play, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life);
}
void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life) {
EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life);
void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s16 life) {
EffectSsBlast_Spawn(play, pos, velocity, accel, primColor, envColor, 100, 375, 35, life);
}
void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
static Color_RGBA8 primColor = { 255, 255, 255, 255 };
static Color_RGBA8 envColor = { 200, 200, 200, 0 };
EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10);
EffectSsBlast_SpawnShockwave(play, pos, velocity, accel, &primColor, &envColor, 10);
}
// EffectSsGSpk Spawn Functions
void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
void EffectSsGSpk_SpawnAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsGSpkInitParams initParams;
@ -340,11 +337,11 @@ void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos,
initParams.scaleStep = scaleStep;
initParams.updateMode = 0;
EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams);
}
// unused
void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
void EffectSsGSpk_SpawnNoAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) {
EffectSsGSpkInitParams initParams;
@ -358,19 +355,19 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po
initParams.scaleStep = scaleStep;
initParams.updateMode = 1;
EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams);
}
void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
Color_RGBA8 primColor = { 255, 255, 150, 255 };
Color_RGBA8 envColor = { 255, 0, 0, 0 };
EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor);
EffectSsGSpk_SpawnSmall(play, actor, pos, velocity, accel, &primColor, &envColor);
}
// unused
void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
s16 scale, s16 scaleStep) {
void EffectSsGSpk_SpawnRandColor(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
s16 scaleStep) {
Color_RGBA8 primColor = { 255, 255, 150, 255 };
Color_RGBA8 envColor = { 255, 0, 0, 0 };
s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f;
@ -384,16 +381,16 @@ void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f*
envColor.b += randOffset;
envColor.a += randOffset;
EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep);
EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep);
}
void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
void EffectSsGSpk_SpawnSmall(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor) {
EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, primColor, envColor, 100, 5);
EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, primColor, envColor, 100, 5);
}
// EffectSsDFire Spawn Functions
void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 alpha, s16 fadeDelay, s16 arg8, s32 life) {
EffectSsDFireInitParams initParams;
@ -407,12 +404,12 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.unk_2C = arg8;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_D_FIRE, 128, &initParams);
}
// EffectSsBubble Spawn Functions
void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale,
void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale,
f32 scale) {
EffectSsBubbleInitParams initParams;
@ -422,12 +419,12 @@ void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset,
initParams.xzPosRandScale = xzPosRandScale;
initParams.scale = scale;
EffectSs_Spawn(globalCtx, EFFECT_SS_BUBBLE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_BUBBLE, 128, &initParams);
}
// EffectSsGRipple Spawn Functions
void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) {
void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) {
EffectSsGRippleInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -435,13 +432,13 @@ void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16
initParams.radiusMax = radiusMax;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_G_RIPPLE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_G_RIPPLE, 128, &initParams);
}
// EffectSsGSplash Spawn Functions
void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor,
s16 type, s16 scale) {
void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type,
s16 scale) {
EffectSsGSplashInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -456,23 +453,23 @@ void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* pr
initParams.customColor = 0;
}
EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPLASH, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_G_SPLASH, 128, &initParams);
}
// EffectSsGFire Spawn Functions
void EffectSsGFire_Spawn(GlobalContext* globalCtx, Vec3f* pos) {
void EffectSsGFire_Spawn(PlayState* play, Vec3f* pos) {
EffectSsGFireInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
EffectSs_Spawn(globalCtx, EFFECT_SS_G_FIRE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_G_FIRE, 128, &initParams);
}
// EffectSsLightning Spawn Functions
void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor,
s16 scale, s16 yaw, s16 life, s16 numBolts) {
void EffectSsLightning_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale,
s16 yaw, s16 life, s16 numBolts) {
EffectSsLightningInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -483,13 +480,13 @@ void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8*
initParams.life = life;
initParams.numBolts = numBolts;
EffectSs_Spawn(globalCtx, EFFECT_SS_LIGHTNING, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_LIGHTNING, 128, &initParams);
}
// EffectSsDtBubble Spawn Functions
void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale,
s16 life, s16 colorProfile, s16 randXZ) {
void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life,
s16 colorProfile, s16 randXZ) {
EffectSsDtBubbleInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -501,10 +498,10 @@ void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Ve
initParams.life = life;
initParams.randXZ = randXZ;
EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams);
}
void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ) {
EffectSsDtBubbleInitParams initParams;
@ -518,7 +515,7 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec
initParams.randXZ = randXZ;
initParams.customColor = 1;
EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams);
}
// EffectSsHahen Spawn Functions
@ -532,8 +529,8 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec
* - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will
* only live for 200 frames
*/
void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale,
s16 objId, s16 life, Gfx* dList) {
void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId,
s16 life, Gfx* dList) {
EffectSsHahenInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -545,7 +542,7 @@ void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.objId = objId;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_HAHEN, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_HAHEN, 128, &initParams);
}
/**
@ -557,8 +554,8 @@ void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
* - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will
* only live for 200 frames
*/
void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale,
s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList) {
void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange,
s16 count, s16 objId, s16 life, Gfx* dList) {
s32 i;
Vec3f velocity;
Vec3f accel;
@ -571,15 +568,15 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca
velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale;
velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale;
EffectSsHahen_Spawn(globalCtx, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId,
life, dList);
EffectSsHahen_Spawn(play, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, life,
dList);
}
}
void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) {
void func_800B2364(PlayState* play, Vec3f* pos, Gfx* dList) {
Vec3f accel = { 0.0f, -2.0f, 0.0f };
EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList);
EffectSsHahen_Spawn(play, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList);
}
// EffectSsStick Spawn Functions
@ -588,19 +585,19 @@ void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) {
* As child, spawn a broken stick fragment
* As adult, spawn a broken sword fragment
*/
void EffectSsStick_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 yaw) {
void EffectSsStick_Spawn(PlayState* play, Vec3f* pos, s16 yaw) {
EffectSsStickInitParams initParams;
initParams.pos = *pos;
initParams.yaw = yaw;
EffectSs_Spawn(globalCtx, EFFECT_SS_STICK, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_STICK, 128, &initParams);
}
// EffectSsSibuki Spawn Functions
void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay,
s16 direction, s16 scale) {
void EffectSsSibuki_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, s16 direction,
s16 scale) {
EffectSsSibukiInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -610,48 +607,48 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.direction = direction;
initParams.scale = scale;
EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_SIBUKI, 128, &initParams);
}
void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) {
void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos) {
s16 i;
Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
s16 randDirection = Rand_ZeroOne() * 1.99f;
for (i = 0; i < KREG(19) + 30; i++) {
EffectSsSibuki_Spawn(globalCtx, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40);
EffectSsSibuki_Spawn(play, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40);
}
}
// EffectSsStone1 Spawn Functions
void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0) {
void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0) {
EffectSsStone1InitParams initParams;
initParams.pos = *pos;
initParams.reg0 = reg0;
EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_STONE1, 128, &initParams);
}
// EffectSsHitMark Spawn Functions
void EffectSsHitMark_Spawn(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) {
void EffectSsHitMark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) {
EffectSsHitMarkInitParams initParams;
initParams.type = type;
initParams.scale = scale;
Math_Vec3f_Copy(&initParams.pos, pos);
EffectSs_Spawn(globalCtx, EFFECT_SS_HITMARK, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_HITMARK, 128, &initParams);
}
void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos) {
EffectSsHitMark_Spawn(globalCtx, type, 300, pos);
void EffectSsHitMark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos) {
EffectSsHitMark_Spawn(play, type, 300, pos);
}
void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) {
EffectSsHitMark_Spawn(globalCtx, type, scale, pos);
void EffectSsHitMark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos) {
EffectSsHitMark_Spawn(play, type, scale, pos);
}
// EffectSsFhgFlash Spawn Functions
@ -664,7 +661,7 @@ void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 sc
* 1: spawn at one of Player's body parts, chosen at random
* 2: spawn at one of Phantom Ganon's body parts, chosen at random
*/
void EffectSsFhgFlash_SpawnShock(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, u8 param) {
void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 param) {
EffectSsFhgFlashInitParams initParams;
initParams.actor = actor;
@ -673,12 +670,12 @@ void EffectSsFhgFlash_SpawnShock(GlobalContext* globalCtx, Actor* actor, Vec3f*
initParams.param = param;
initParams.type = FHGFLASH_SHOCK;
EffectSs_Spawn(globalCtx, EFFECT_SS_FHG_FLASH, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_FHG_FLASH, 128, &initParams);
}
// EffectSsKFire Spawn Functions
void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) {
void EffectSsKFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) {
EffectSsKFireInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -687,12 +684,12 @@ void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.scaleMax = scaleMax;
initParams.type = type;
EffectSs_Spawn(globalCtx, EFFECT_SS_K_FIRE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_K_FIRE, 128, &initParams);
}
// EffectSsSolderSrchBall Spawn Functions
void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused,
void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused,
s16* linkDetected, s16 drawFlag) {
EffectSsSolderSrchBallInitParams initParams;
@ -703,14 +700,14 @@ void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v
initParams.linkDetected = linkDetected;
initParams.drawFlag = drawFlag;
EffectSs_Spawn(globalCtx, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams);
}
// EffectSsKakera Spawn Functions
void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5,
s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx,
s16 objId, Gfx* dList) {
void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6,
s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId,
Gfx* dList) {
EffectSsKakeraInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -729,12 +726,12 @@ void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.objId = objId;
initParams.dList = dList;
EffectSs_Spawn(globalCtx, EFFECT_SS_KAKERA, 101, &initParams);
EffectSs_Spawn(play, EFFECT_SS_KAKERA, 101, &initParams);
}
// EffectSsIcePiece Spawn Functions
void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) {
void EffectSsIcePiece_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) {
EffectSsIcePieceInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -742,10 +739,10 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec
Math_Vec3f_Copy(&initParams.accel, accel);
initParams.scale = scale;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_ICE_PIECE, 128, &initParams);
}
void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) {
void EffectSsIcePiece_SpawnBurst(PlayState* play, Vec3f* refPos, f32 scale) {
static Vec3f accel = { 0.0f, 0.0f, 0.0f };
static Vec3f vecScales[] = {
{ 0.0f, 70.0f, 0.0f },
@ -776,15 +773,15 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc
pos.y += vecScales[i].y;
pos.z += vecScales[i].z;
EffectSsIcePiece_Spawn(globalCtx, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity,
&accel, 25);
EffectSsIcePiece_Spawn(play, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity, &accel,
25);
}
}
// EffectSsEnIce Spawn Functions
void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Color_RGBA8* prim,
Color_RGBA8* env, f32 scale) {
void EffectSsEnIce_SpawnFlyingVec3f(PlayState* play, Actor* actor, Vec3f* pos, Color_RGBA8* prim, Color_RGBA8* env,
f32 scale) {
EffectSsEnIceInitParams initParams;
initParams.actor = actor;
@ -798,25 +795,25 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3
Actor_PlaySfxAtPos(actor, NA_SE_PL_FREEZE_S);
}
EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams);
EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 80, &initParams);
}
void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) {
void func_800B2B44(PlayState* play, Actor* actor, Vec3f* pos, f32 scale) {
static Color_RGBA8 primColor = { 150, 150, 150, 250 };
static Color_RGBA8 envColor = { 235, 245, 255, 255 };
EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale);
EffectSsEnIce_SpawnFlyingVec3f(play, actor, pos, &primColor, &envColor, scale);
}
void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) {
void func_800B2B7C(PlayState* play, Actor* actor, Vec3s* arg2, f32 scale) {
Vec3f dest;
Math_Vec3s_ToVec3f(&dest, arg2);
func_800B2B44(globalCtx, actor, &dest, scale);
func_800B2B44(play, actor, &dest, scale);
}
void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel,
Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life) {
void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor, s32 life) {
EffectSsEnIceInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -828,12 +825,12 @@ void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f*
initParams.life = life;
initParams.type = 1;
EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 128, &initParams);
}
// EffectSsFireTail Spawn Functions
void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5,
void EffectSsFireTail_Spawn(PlayState* play, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5,
Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 bodyPart, s32 life) {
EffectSsFireTailInitParams initParams;
@ -848,10 +845,10 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos,
initParams.bodyPart = bodyPart;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_FIRE_TAIL, 128, &initParams);
}
void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart,
void EffectSsFireTail_SpawnFlame(PlayState* play, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart,
f32 colorIntensity) {
static Color_RGBA8 primColor = { 255, 255, 0, 255 };
static Color_RGBA8 envColor = { 255, 0, 0, 255 };
@ -863,20 +860,19 @@ void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f*
envColor.b = 0;
primColor.r = envColor.r = (s32)(255.0f * colorIntensity);
EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor,
EffectSsFireTail_Spawn(play, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor,
(colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1);
}
void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) {
Player* player = GET_PLAYER(globalCtx);
void EffectSsFireTail_SpawnFlameOnPlayer(PlayState* play, f32 scale, s16 bodyPart, f32 colorIntensity) {
Player* player = GET_PLAYER(play);
EffectSsFireTail_SpawnFlame(globalCtx, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart,
colorIntensity);
EffectSsFireTail_SpawnFlame(play, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, colorIntensity);
}
// EffectSsEnFire Spawn Functions
void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags,
void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags,
s16 bodyPart) {
EffectSsEnFireInitParams initParams;
@ -891,10 +887,10 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po
Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION);
}
EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams);
}
void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* pos, s16 scale, s16 arg4, s16 flags,
void EffectSsEnFire_SpawnVec3s(PlayState* play, Actor* actor, Vec3s* pos, s16 scale, s16 arg4, s16 flags,
s16 bodyPart) {
EffectSsEnFireInitParams initParams;
@ -911,12 +907,12 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po
Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION);
}
EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams);
}
// EffectSsExtra Spawn Functions
void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) {
void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) {
EffectSsExtraInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -925,12 +921,12 @@ void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.scale = scale;
initParams.scoreIdx = scoreIdx;
EffectSs_Spawn(globalCtx, EFFECT_SS_EXTRA, 100, &initParams);
EffectSs_Spawn(play, EFFECT_SS_EXTRA, 100, &initParams);
}
// EffectSsDeadDb Spawn Functions
void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) {
EffectSsDeadDbInitParams initParams;
@ -948,10 +944,10 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.envColor.b = env->b;
initParams.unk_30 = unk;
EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams);
}
void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
void func_800B3030(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s32 colorIndex) {
static Color_RGBA8 primColor = { 255, 255, 255, 255 };
static Color_RGBA8 envColors[] = {
@ -961,12 +957,12 @@ void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f*
{ 150, 150, 150, 255 },
};
EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9);
EffectSsDeadDb_Spawn(play, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9);
}
// EffectSsDeadDd Spawn Functions
void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life) {
EffectSsDeadDdInitParams initParams;
@ -986,12 +982,12 @@ void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.alphaStep = alphaStep;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DD, 120, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DEAD_DD, 120, &initParams);
}
// EffectSsDeadDs Spawn Functions
void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
void EffectSsDeadDs_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 alpha, s32 life) {
EffectSsDeadDsInitParams initParams;
@ -1002,16 +998,16 @@ void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.scaleStep = scaleStep;
initParams.alpha = alpha;
initParams.life = life;
EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DS, 100, &initParams);
EffectSs_Spawn(play, EFFECT_SS_DEAD_DS, 100, &initParams);
}
void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) {
EffectSsDeadDs_Spawn(globalCtx, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life);
void func_800B31BC(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) {
EffectSsDeadDs_Spawn(play, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life);
}
// EffectSsIceSmoke Spawn Functions
void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
void EffectSsIceSmoke_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
EffectSsIceSmokeInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -1019,12 +1015,12 @@ void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit
Math_Vec3f_Copy(&initParams.accel, accel);
initParams.scale = scale;
EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_SMOKE, 128, &initParams);
EffectSs_Spawn(play, EFFECT_SS_ICE_SMOKE, 128, &initParams);
}
// EffectSsIceBlock Spawn Functions
void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
void EffectSsIceBlock_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
EffectEnIceBlockInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@ -1032,5 +1028,5 @@ void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit
Math_Vec3f_Copy(&initParams.accel, accel);
initParams.scale = scale;
EffectSs_Spawn(globalCtx, EFFECT_EN_ICE_BLOCK, 128, &initParams);
EffectSs_Spawn(play, EFFECT_EN_ICE_BLOCK, 128, &initParams);
}

View File

@ -1,6 +1,6 @@
#include "global.h"
u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
u16 ElfMessage_GetFirstCycleHint(PlayState* play) {
if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) {
return 0;
}
@ -20,7 +20,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
if (gSaveContext.save.weekEventReg[9] & 1) {
return 0x21E;
}
if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) {
if (play->sceneNum == SCENE_YOUSEI_IZUMI) {
return 0;
}
return 0x21D;
@ -29,7 +29,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
return 0x21F;
}
if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) {
if (globalCtx->sceneNum != SCENE_OKUJOU) {
if (play->sceneNum != SCENE_OKUJOU) {
return 0x244;
}
return 0;

View File

@ -2,56 +2,56 @@
#define THIS ((EnAObj*)thisx)
void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx);
void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx);
void EnAObj_Update1(EnAObj* this, PlayState* play);
void EnAObj_Update2(EnAObj* this, PlayState* play);
void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
void EnAObj_Init(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300;
this->actor.params = (this->actor.params & 0xFF) - 9;
Actor_ProcessInitChain(&this->actor, &enAObjInitVar);
ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12);
Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit);
Collider_InitAndSetCylinder(play, &this->collision, &this->actor, &enAObjCylinderInit);
Collider_UpdateCylinder(&this->actor, &this->collision);
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
this->actionFunc = EnAObj_Update1;
}
void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EnAObj_Destroy(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->collision);
Collider_DestroyCylinder(play, &this->collision);
}
void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) {
void EnAObj_Update1(EnAObj* this, PlayState* play) {
s32 yawDiff;
if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
this->actionFunc = EnAObj_Update2;
} else {
yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y));
if ((yawDiff < 0x2800) || ((this->actor.params == 1) && (yawDiff > 0x5800))) {
func_800B863C(&this->actor, globalCtx);
func_800B863C(&this->actor, play);
}
}
}
void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) {
if (Actor_TextboxIsClosing(&this->actor, globalCtx)) {
void EnAObj_Update2(EnAObj* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
this->actionFunc = EnAObj_Update1;
}
}
void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) {
void EnAObj_Update(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
Actor_SetFocus(&this->actor, 45.0f);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collision.base);
}
void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) {
Gfx_DrawDListOpa(globalCtx, enAObjDisplayLists[thisx->params]);
void EnAObj_Draw(Actor* thisx, PlayState* play) {
Gfx_DrawDListOpa(play, enAObjDisplayLists[thisx->params]);
}

View File

@ -58,7 +58,7 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) {
return isChanged;
}
EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) {
EnDoor* nearestDoor = NULL;
Actor* doorIter = NULL;
f32 dist;
@ -67,7 +67,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
f32 minDist = 0.0f;
do {
doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
door = (EnDoor*)doorIter;
dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor);
if (!isSetup || (dist < minDist)) {
@ -83,16 +83,16 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
return nearestDoor;
}
void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) {
gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment);
void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) {
gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment);
EnHy_ChangeAnim(&enHy->skelAnime, animIndex);
}
s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx) {
s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) {
s32 isUpdated = false;
if (enHy->actor.draw != NULL) {
gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment);
gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment);
SkelAnime_Update(&enHy->skelAnime);
isUpdated = true;
}
@ -109,26 +109,26 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) {
}
}
s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
s32 isInitialized = false;
if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) &&
(SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) &&
(SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) &&
(SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) {
if ((SubS_IsObjectLoaded(enHy->animObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->headObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelUpperObjIndex, play) == true) &&
(SubS_IsObjectLoaded(enHy->skelLowerObjIndex, play) == true)) {
enHy->actor.objBankIndex = enHy->skelLowerObjIndex;
isInitialized = true;
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->actor.objBankIndex].segment);
SkelAnime_InitFlex(globalCtx, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->actor.objBankIndex].segment);
SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
ENHY_LIMB_MAX);
EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
}
return isInitialized;
}
void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) {
void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4) {
s32 pad;
s8 animIndex;
Vec3f offset;
@ -137,26 +137,26 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3,
Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos);
phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f;
animIndex = ((s8)phi_f0 < 0) ? 0 : 2;
EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4);
EnHy_ChangeObjectAndAnim(enHy, play, (animIndex == 0) ? arg3 : arg4);
enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.moveFlags |= 3;
AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f);
AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f);
door->unk_1A1 = 1;
door->animIndex = animIndex;
}
s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) {
s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) {
s32 ret = false;
s16 yaw;
EnDoor* door;
s32 pad;
if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) {
door = EnHy_FindNearestDoor(&enHy->actor, globalCtx);
door = EnHy_FindNearestDoor(&enHy->actor, play);
if (door != NULL) {
ret = true;
func_800F0BB4(enHy, globalCtx, door, arg3, arg4);
func_800F0BB4(enHy, play, door, arg3, arg4);
yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos);
enHy->actor.world.pos.x += arg5 * Math_SinS(yaw);
enHy->actor.world.pos.z += arg5 * Math_CosS(yaw);
@ -168,17 +168,17 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3
return ret;
}
s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) {
s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3) {
s32 ret = false;
s32 pad;
EnDoor* door;
enHy->curPoint = 0;
if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) {
door = EnHy_FindNearestDoor(&enHy->actor, globalCtx);
door = EnHy_FindNearestDoor(&enHy->actor, play);
if (door != NULL) {
ret = true;
func_800F0BB4(enHy, globalCtx, door, arg2, arg3);
func_800F0BB4(enHy, play, door, arg2, arg3);
enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos);
enHy->actor.world.rot.y = enHy->actor.shape.rot.y;
enHy->actor.gravity = 0.0f;
@ -188,16 +188,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) {
return ret;
}
s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) {
s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex) {
enHy->actor.gravity = gravity;
enHy->actor.flags |= ACTOR_FLAG_1;
EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
enHy->curPoint++;
return false;
}
s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) {
EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, s16 animIndex) {
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
enHy->curPoint--;
return false;
}
@ -238,16 +238,16 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) {
return reachedEnd;
}
void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx) {
void EnHy_UpdateCollider(EnHy* enHy, PlayState* play) {
enHy->collider.dim.pos.x = enHy->actor.world.pos.x;
enHy->collider.dim.pos.y = enHy->actor.world.pos.y;
enHy->collider.dim.pos.z = enHy->actor.world.pos.z;
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base);
CollisionCheck_SetAC(play, &play->colChkCtx, &enHy->collider.base);
CollisionCheck_SetOC(play, &play->colChkCtx, &enHy->collider.base);
}
s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold) {
s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold) {
u8 wasLeftFootOnGround = enHy->isLeftFootOnGround;
u8 wasRightFootOnGround = enHy->isRightFootOnGround;
s32 waterSfxId;
@ -262,15 +262,15 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr
}
sfxId = waterSfxId + SFX_FLAG;
} else {
sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG;
sfxId = SurfaceType_GetSfx(&play->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG;
}
enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold);
enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->leftFootPos, distAboveThreshold);
if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) {
Actor_PlaySfxAtPos(&enHy->actor, sfxId);
}
enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold);
enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->rightFootPos, distAboveThreshold);
if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) {
Actor_PlaySfxAtPos(&enHy->actor, sfxId);
}

View File

@ -6,16 +6,16 @@
#define THIS ((EnItem00*)thisx)
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx);
void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx);
void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx);
void EnItem00_Init(Actor* thisx, PlayState* play);
void EnItem00_Destroy(Actor* thisx, PlayState* play);
void EnItem00_Update(Actor* thisx, PlayState* play);
void EnItem00_Draw(Actor* thisx, PlayState* play);
void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx);
void func_800A640C(EnItem00* this, GlobalContext* globalCtx);
void func_800A6650(EnItem00* this, GlobalContext* globalCtx);
void func_800A6780(EnItem00* this, GlobalContext* globalCtx);
void func_800A6A40(EnItem00* this, GlobalContext* globalCtx);
void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play);
void func_800A640C(EnItem00* this, PlayState* play);
void func_800A6650(EnItem00* this, PlayState* play);
void func_800A6780(EnItem00* this, PlayState* play);
void func_800A6A40(EnItem00* this, PlayState* play);
const ActorInit En_Item00_InitVars = {
ACTOR_EN_ITEM00,
@ -53,8 +53,8 @@ static InitChainEntry sInitChain[] = {
ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP),
};
void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale) {
Actor_SetObjectDependency(globalCtx, &this->actor);
void EnItem00_SetObject(EnItem00* this, PlayState* play, f32* shadowOffset, f32* shadowScale) {
Actor_SetObjectDependency(play, &this->actor);
Actor_SetScale(&this->actor, 0.5f);
this->unk154 = 0.5f;
*shadowOffset = 0.0f;
@ -62,7 +62,7 @@ void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOff
this->actor.world.rot.x = 0x4000;
}
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
void EnItem00_Init(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
s32 pad;
f32 shadowOffset = 980.0f;
@ -74,7 +74,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
thisx->params &= 0xFF; // Has to be thisx to match
if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) {
if (Flags_GetCollectible(play, this->collectibleFlag)) {
if (this->actor.params == ITEM00_HEART_PIECE) {
sp30 = 0;
this->collectibleFlag = 0;
@ -89,7 +89,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
}
Actor_ProcessInitChain(&this->actor, sInitChain);
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
this->unk150 = 1;
@ -164,16 +164,16 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
this->unk154 = 0.01f;
break;
case ITEM00_SHIELD_HERO:
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2);
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_MAP:
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MAP);
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_MAP);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_COMPASS:
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_COMPASS);
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_COMPASS);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
default:
break;
@ -205,51 +205,51 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
switch (this->actor.params) {
case ITEM00_RUPEE_GREEN:
Item_Give(globalCtx, ITEM_RUPEE_GREEN);
Item_Give(play, ITEM_RUPEE_GREEN);
break;
case ITEM00_RUPEE_BLUE:
Item_Give(globalCtx, ITEM_RUPEE_BLUE);
Item_Give(play, ITEM_RUPEE_BLUE);
break;
case ITEM00_RUPEE_RED:
Item_Give(globalCtx, ITEM_RUPEE_RED);
Item_Give(play, ITEM_RUPEE_RED);
break;
case ITEM00_RUPEE_PURPLE:
Item_Give(globalCtx, ITEM_RUPEE_PURPLE);
Item_Give(play, ITEM_RUPEE_PURPLE);
break;
case ITEM00_RUPEE_HUGE:
Item_Give(globalCtx, ITEM_RUPEE_HUGE);
Item_Give(play, ITEM_RUPEE_HUGE);
break;
case ITEM00_HEART:
Item_Give(globalCtx, ITEM_HEART);
Item_Give(play, ITEM_HEART);
break;
case ITEM00_FLEXIBLE:
case ITEM00_BIG_FAIRY:
func_80115908(globalCtx, 0x70);
func_80115908(play, 0x70);
break;
case ITEM00_BOMBS_A:
case ITEM00_BOMBS_B:
Item_Give(globalCtx, ITEM_BOMBS_5);
Item_Give(play, ITEM_BOMBS_5);
break;
case ITEM00_ARROWS_10:
Item_Give(globalCtx, ITEM_ARROWS_10);
Item_Give(play, ITEM_ARROWS_10);
break;
case ITEM00_ARROWS_30:
Item_Give(globalCtx, ITEM_ARROWS_30);
Item_Give(play, ITEM_ARROWS_30);
break;
case ITEM00_ARROWS_40:
Item_Give(globalCtx, ITEM_ARROWS_40);
Item_Give(play, ITEM_ARROWS_40);
break;
case ITEM00_ARROWS_50:
Item_Give(globalCtx, ITEM_ARROWS_50);
Item_Give(play, ITEM_ARROWS_50);
break;
case ITEM00_MAGIC_LARGE:
Item_Give(globalCtx, ITEM_MAGIC_LARGE);
Item_Give(play, ITEM_MAGIC_LARGE);
break;
case ITEM00_MAGIC_SMALL:
Item_Give(globalCtx, ITEM_MAGIC_SMALL);
Item_Give(play, ITEM_MAGIC_SMALL);
break;
case ITEM00_SMALL_KEY:
Item_Give(globalCtx, ITEM_KEY_SMALL);
Item_Give(play, ITEM_KEY_SMALL);
break;
case ITEM00_NUTS_1:
getItemId = GI_NUTS_1;
@ -261,31 +261,31 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
break;
}
if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, globalCtx) == 0)) {
Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f);
if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, play) == 0)) {
Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f);
}
this->actionFunc = func_800A6A40;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EnItem00_Destroy(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->collider);
Collider_DestroyCylinder(play, &this->collider);
}
void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx) {
void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) {
s32 sp1C;
sp1C = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS);
if (Object_IsLoaded(&globalCtx->objectCtx, sp1C)) {
sp1C = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS);
if (Object_IsLoaded(&play->objectCtx, sp1C)) {
this->actor.objBankIndex = sp1C;
this->actionFunc = func_800A640C;
}
}
void func_800A640C(EnItem00* this, GlobalContext* globalCtx) {
void func_800A640C(EnItem00* this, PlayState* play) {
if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk152 < 0)) ||
(this->actor.params == ITEM00_HEART_PIECE) || (this->actor.params == ITEM00_HEART_CONTAINER)) {
this->actor.shape.rot.y = this->actor.shape.rot.y + 960;
@ -335,18 +335,18 @@ static Color_RGBA8 D_801ADF14 = { 255, 255, 255, 0 };
static Vec3f D_801ADF18 = { 0.0f, 0.1f, 0.0f };
static Vec3f D_801ADF24 = { 0.0f, 0.01f, 0.0f };
void func_800A6650(EnItem00* this, GlobalContext* globalCtx) {
void func_800A6650(EnItem00* this, PlayState* play) {
u32 pad;
Vec3f pos;
if (this->actor.params <= ITEM00_RUPEE_RED) {
this->actor.shape.rot.y = this->actor.shape.rot.y + 960;
}
if ((globalCtx->gameplayFrames & 1) != 0) {
if ((play->gameplayFrames & 1) != 0) {
pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f);
pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f);
pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f);
EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
EffectSsKirakira_SpawnSmall(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
}
if ((this->actor.bgCheckFlags & 3) != 0) {
if (this->actor.velocity.y > -2.0f) {
@ -359,7 +359,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) {
}
}
void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
void func_800A6780(EnItem00* this, PlayState* play) {
s32 pad;
Vec3f pos;
s32 var1;
@ -399,11 +399,11 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
}
}
if ((globalCtx->gameplayFrames & 1) == 0) {
if ((play->gameplayFrames & 1) == 0) {
pos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 10.0f);
pos.y = this->actor.world.pos.y + ((Rand_ZeroOne() - 0.5f) * 10.0f);
pos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 10.0f);
EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
EffectSsKirakira_SpawnSmall(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
}
if (this->actor.bgCheckFlags & 0x0003) {
@ -413,12 +413,12 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
}
}
void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
void func_800A6A40(EnItem00* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if (this->unk14A != GI_NONE) {
if (Actor_HasParent(&this->actor, globalCtx) == 0) {
Actor_PickUp(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f);
if (Actor_HasParent(&this->actor, play) == 0) {
Actor_PickUp(&this->actor, play, this->unk14A, 50.0f, 80.0f);
this->unk152++;
} else {
this->unk14A = GI_NONE;
@ -445,10 +445,10 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) {
}
}
void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
void EnItem00_Update(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
s32 pad;
Player* player = GET_PLAYER(globalCtx);
Player* player = GET_PLAYER(play);
s32 sp38 = player->stateFlags3 & 0x1000;
s32 getItemId = GI_NONE;
s32 params;
@ -461,7 +461,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->unk14E = this->unk152;
}
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
Math_SmoothStepToF(&this->actor.scale.x, this->unk154, 0.1f, this->unk154 * 0.1f, 0.0f);
this->actor.scale.z = this->actor.scale.x;
@ -469,7 +469,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if (this->actor.gravity != 0.0f) {
Actor_MoveWithGravity(&this->actor);
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D);
Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D);
if (this->actor.floorHeight <= BGCHECK_Y_MIN) {
Actor_MarkForDeath(&this->actor);
@ -478,7 +478,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
}
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
params = this->actor.params;
if ((params == ITEM00_SHIELD_HERO) || (params == ITEM00_MAP) || (params == ITEM00_COMPASS)) {
@ -493,35 +493,35 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
(this->actor.playerHeightRel <= 100.0f)) &&
!((sp38 == 0) && (this->actor.xzDistToPlayer <= 30.0f) && (this->actor.playerHeightRel >= -50.0f) &&
(this->actor.playerHeightRel <= 50.0f))) {
if (!Actor_HasParent(&this->actor, globalCtx)) {
if (!Actor_HasParent(&this->actor, play)) {
return;
}
}
if (globalCtx->gameOverCtx.state != 0) {
if (play->gameOverCtx.state != 0) {
return;
}
switch (this->actor.params) {
case ITEM00_RUPEE_GREEN:
this->unk1A4 = 1;
Item_Give(globalCtx, ITEM_RUPEE_GREEN);
Item_Give(play, ITEM_RUPEE_GREEN);
break;
case ITEM00_RUPEE_BLUE:
this->unk1A4 = 1;
Item_Give(globalCtx, ITEM_RUPEE_BLUE);
Item_Give(play, ITEM_RUPEE_BLUE);
break;
case ITEM00_RUPEE_RED:
this->unk1A4 = 1;
Item_Give(globalCtx, ITEM_RUPEE_RED);
Item_Give(play, ITEM_RUPEE_RED);
break;
case ITEM00_RUPEE_PURPLE:
this->unk1A4 = 1;
Item_Give(globalCtx, ITEM_RUPEE_PURPLE);
Item_Give(play, ITEM_RUPEE_PURPLE);
break;
case ITEM00_RUPEE_HUGE:
this->unk1A4 = 1;
Item_Give(globalCtx, ITEM_RUPEE_HUGE);
Item_Give(play, ITEM_RUPEE_HUGE);
break;
case ITEM00_STICK:
getItemId = GI_STICKS_1;
@ -533,27 +533,27 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
getItemId = GI_NUTS_10;
break;
case ITEM00_HEART:
Item_Give(globalCtx, ITEM_HEART);
Item_Give(play, ITEM_HEART);
break;
case ITEM00_FLEXIBLE:
case ITEM00_BIG_FAIRY:
func_80115908(globalCtx, 0x70);
func_80115908(play, 0x70);
break;
case ITEM00_BOMBS_A:
case ITEM00_BOMBS_B:
Item_Give(globalCtx, ITEM_BOMBS_5);
Item_Give(play, ITEM_BOMBS_5);
break;
case ITEM00_ARROWS_10:
Item_Give(globalCtx, ITEM_ARROWS_10);
Item_Give(play, ITEM_ARROWS_10);
break;
case ITEM00_ARROWS_30:
Item_Give(globalCtx, ITEM_ARROWS_30);
Item_Give(play, ITEM_ARROWS_30);
break;
case ITEM00_ARROWS_40:
Item_Give(globalCtx, ITEM_ARROWS_40);
Item_Give(play, ITEM_ARROWS_40);
break;
case ITEM00_ARROWS_50:
Item_Give(globalCtx, ITEM_ARROWS_50);
Item_Give(play, ITEM_ARROWS_50);
break;
case ITEM00_SMALL_KEY:
getItemId = GI_KEY_SMALL;
@ -565,10 +565,10 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
getItemId = GI_HEART_CONTAINER;
break;
case ITEM00_MAGIC_LARGE:
Item_Give(globalCtx, ITEM_MAGIC_LARGE);
Item_Give(play, ITEM_MAGIC_LARGE);
break;
case ITEM00_MAGIC_SMALL:
Item_Give(globalCtx, ITEM_MAGIC_SMALL);
Item_Give(play, ITEM_MAGIC_SMALL);
break;
case ITEM00_SHIELD_HERO:
getItemId = GI_SHIELD_HERO;
@ -584,8 +584,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
}
if (getItemId != GI_NONE) {
if (!Actor_HasParent(&this->actor, globalCtx)) {
Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f);
if (!Actor_HasParent(&this->actor, play)) {
Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f);
}
}
@ -596,8 +596,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_SHIELD_HERO:
case ITEM00_MAP:
case ITEM00_COMPASS:
if (Actor_HasParent(&this->actor, globalCtx)) {
Flags_SetCollectible(globalCtx, this->collectibleFlag);
if (Actor_HasParent(&this->actor, play)) {
Flags_SetCollectible(play, this->collectibleFlag);
Actor_MarkForDeath(&this->actor);
}
return;
@ -608,8 +608,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if ((this->actor.params <= ITEM00_RUPEE_RED) || (this->actor.params == ITEM00_RUPEE_HUGE)) {
play_sound(NA_SE_SY_GET_RUPY);
} else if (getItemId != GI_NONE) {
if (Actor_HasParent(&this->actor, globalCtx)) {
Flags_SetCollectible(globalCtx, this->collectibleFlag);
if (Actor_HasParent(&this->actor, play)) {
Flags_SetCollectible(play, this->collectibleFlag);
Actor_MarkForDeath(&this->actor);
}
return;
@ -617,7 +617,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
play_sound(NA_SE_SY_GET_ITEM);
}
Flags_SetCollectible(globalCtx, this->collectibleFlag);
Flags_SetCollectible(play, this->collectibleFlag);
this->unk152 = 15;
this->unk14C = 35;
@ -632,12 +632,12 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actionFunc = func_800A6A40;
}
void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx);
void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx);
void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx);
void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx);
void EnItem00_DrawRupee(EnItem00* this, PlayState* play);
void EnItem00_DrawSprite(EnItem00* this, PlayState* play);
void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play);
void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play);
void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
void EnItem00_Draw(Actor* thisx, PlayState* play) {
s32 pad;
EnItem00* this = THIS;
@ -648,26 +648,26 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_RUPEE_RED:
case ITEM00_RUPEE_HUGE:
case ITEM00_RUPEE_PURPLE:
EnItem00_DrawRupee(this, globalCtx);
EnItem00_DrawRupee(this, play);
break;
case ITEM00_HEART_PIECE:
EnItem00_DrawHeartPiece(this, globalCtx);
EnItem00_DrawHeartPiece(this, play);
break;
case ITEM00_HEART_CONTAINER:
EnItem00_DrawHeartContainer(this, globalCtx);
EnItem00_DrawHeartContainer(this, play);
break;
case ITEM00_HEART:
if (this->unk152 < 0) {
if (this->unk152 == -1) {
s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART);
if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) {
s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART);
if (Object_IsLoaded(&play->objectCtx, bankIndex)) {
this->actor.objBankIndex = bankIndex;
Actor_SetObjectDependency(globalCtx, &this->actor);
Actor_SetObjectDependency(play, &this->actor);
this->unk152 = -2;
}
} else {
Matrix_Scale(16.0f, 16.0f, 16.0f, MTXMODE_APPLY);
GetItem_Draw(globalCtx, 8);
GetItem_Draw(play, 8);
}
break;
}
@ -684,16 +684,16 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_SMALL_KEY:
case ITEM00_NUTS_10:
case ITEM00_BOMBS_0:
EnItem00_DrawSprite(this, globalCtx);
EnItem00_DrawSprite(this, play);
break;
case ITEM00_SHIELD_HERO:
GetItem_Draw(globalCtx, GID_SHIELD_HERO);
GetItem_Draw(play, GID_SHIELD_HERO);
break;
case ITEM00_MAP:
GetItem_Draw(globalCtx, GID_DUNGEON_MAP);
GetItem_Draw(play, GID_DUNGEON_MAP);
break;
case ITEM00_COMPASS:
GetItem_Draw(globalCtx, GID_COMPASS);
GetItem_Draw(play, GID_COMPASS);
case ITEM00_MASK:
case ITEM00_FLEXIBLE:
case ITEM00_3_HEARTS:
@ -712,14 +712,14 @@ TexturePtr D_801ADF30[] = {
gameplay_keep_Tex_062020 // Purple rupee
};
void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) {
void EnItem00_DrawRupee(EnItem00* this, PlayState* play) {
s32 pad;
s32 iconNb;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
func_800B8050(&this->actor, globalCtx, 0);
func_8012C28C(play->state.gfxCtx);
func_800B8050(&this->actor, play, 0);
if (this->actor.params <= ITEM00_RUPEE_RED) {
iconNb = this->actor.params;
@ -727,13 +727,13 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) {
iconNb = this->actor.params - 0x10;
}
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF30[iconNb]));
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); // TODO symbol
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
TexturePtr D_801ADF44[12] = {
@ -751,12 +751,12 @@ TexturePtr D_801ADF44[12] = {
gameplay_keep_Tex_05F7C0 // Small Key
};
void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) {
void EnItem00_DrawSprite(EnItem00* this, PlayState* play) {
s32 iconNb = this->actor.params - 3;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP);
POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP);
if (this->actor.params == ITEM00_NUTS_10) {
iconNb = 6;
@ -773,45 +773,45 @@ void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) {
gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF44[iconNb]));
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) {
void EnItem00_DrawHeartContainer(EnItem00* actor, PlayState* play) {
s32 pad;
s32 pad2;
if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
OPEN_DISPS(globalCtx->state.gfxCtx);
if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
OPEN_DISPS(play->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001290);
gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001470);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}
void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) {
void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
func_800B8118(&this->actor, globalCtx, 0);
func_8012C2DC(play->state.gfxCtx);
func_800B8118(&this->actor, play, 0);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
s16 func_800A7650(s16 dropId) {
@ -834,7 +834,7 @@ s16 func_800A7650(s16 dropId) {
return dropId;
}
Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) {
Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) {
s32 pad;
Actor* spawnedActor = NULL;
s32 newParamFF;
@ -850,29 +850,28 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
if (paramFF == ITEM00_3_HEARTS) {
for (i = 0; i < 3; i++) {
spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000);
spawnedActor = Item_DropCollectible(play, spawnPos, param7F00 | ITEM00_HEART | param8000);
}
} else if (paramFF == ITEM00_MUSHROOM_CLOUD) {
param7F00 >>= 8;
if (!Flags_GetCollectible(globalCtx, param7F00)) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0,
0, param7F00);
if (!Flags_GetCollectible(play, param7F00)) {
Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0,
param7F00);
}
} else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
newParamFF = params & 0xFF;
if (newParamFF == ITEM00_FLEXIBLE) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) {
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) {
SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
spawnedActor =
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
if (param20000 == 0) {
if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) {
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) {
SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
}
}
@ -881,8 +880,8 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
params = func_800A7650(newParamFF);
}
if ((s32)params != ITEM00_NO_DROP) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0,
0, 0, (s32)params | param8000 | param7F00);
if ((spawnedActor != NULL) && (param8000 == 0)) {
if (param10000 == 0) {
spawnedActor->velocity.y = 8.0f;
@ -907,7 +906,7 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
return spawnedActor;
}
Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) {
Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) {
Actor* spawnedActor = NULL;
s32 pad;
s32 param10000 = params & 0x10000;
@ -922,21 +921,20 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para
if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
if ((params & 0xFF) == ITEM00_FLEXIBLE) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
} else {
spawnedActor =
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
}
if (Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F) == 0) {
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
if (Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F) == 0) {
SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
params = func_800A7650(params & 0xFF);
if (params != ITEM00_NO_DROP) {
spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0,
0, 0, (s32)params | param8000 | param7F00);
if (spawnedActor != NULL) {
if (param8000 == 0) {
spawnedActor->velocity.y = 0.0f;
@ -1032,7 +1030,7 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
};
void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) {
void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params) {
EnItem00* spawnedActor;
u8 dropId;
s32 dropQuantity;
@ -1084,9 +1082,9 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
if (dropId == ITEM00_FLEXIBLE) {
if (gSaveContext.save.playerData.health <= 0x10) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, 2);
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0,
2);
SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
return;
}
@ -1129,8 +1127,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
if (param8000 == 0) {
dropId = func_800A7650(dropId);
if (dropId != (u8)ITEM00_NO_DROP) {
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00,
spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, dropId);
spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x,
spawnPos->y, spawnPos->z, 0, 0, 0, dropId);
if ((spawnedActor != 0) && (dropId != (u8)ITEM00_NO_DROP)) {
spawnedActor->actor.velocity.y = 8.0f;
spawnedActor->actor.speedXZ = 2.0f;
@ -1148,7 +1146,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
}
}
} else {
Item_DropCollectible(globalCtx, spawnPos, params | 0x8000);
Item_DropCollectible(play, spawnPos, params | 0x8000);
}
dropQuantity--;
@ -1185,6 +1183,6 @@ s32 func_800A817C(s32 index) {
return D_801AE214[index];
}
s32 Item_CanDropBigFairy(GlobalContext* globalCtx, s32 index, s32 collectibleFlag) {
return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, collectibleFlag));
s32 Item_CanDropBigFairy(PlayState* play, s32 index, s32 collectibleFlag) {
return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(play, collectibleFlag));
}

View File

@ -1,33 +1,33 @@
#include "global.h"
void EnvFlags_UnsetAll(GlobalContext* globalCtx) {
void EnvFlags_UnsetAll(PlayState* play) {
u8 i;
for (i = 0; i < ARRAY_COUNT(globalCtx->envFlags); i++) {
globalCtx->envFlags[i] = 0;
for (i = 0; i < ARRAY_COUNT(play->envFlags); i++) {
play->envFlags[i] = 0;
}
}
void EnvFlags_Set(GlobalContext* globalCtx, s16 flag) {
void EnvFlags_Set(PlayState* play, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = 1 << bit;
globalCtx->envFlags[index] |= mask;
play->envFlags[index] |= mask;
}
void EnvFlags_Unset(GlobalContext* globalCtx, s16 flag) {
void EnvFlags_Unset(PlayState* play, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = (1 << bit) ^ 0xFFFF;
globalCtx->envFlags[index] &= mask;
play->envFlags[index] &= mask;
}
s32 EnvFlags_Get(GlobalContext* globalCtx, s16 flag) {
s32 EnvFlags_Get(PlayState* play, s16 flag) {
s16 index = flag / 16;
s16 bit = flag % 16;
s16 mask = 1 << bit;
return globalCtx->envFlags[index] & mask;
return play->envFlags[index] & mask;
}

View File

@ -178,9 +178,9 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = {
};
// clang-format on
u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet) {
if ((Player_GetMask(globalCtx) > PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) {
return sReactionTextIds[reactionSet][Player_GetMask(globalCtx) - 1];
u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet) {
if ((Player_GetMask(play) > PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) {
return sReactionTextIds[reactionSet][Player_GetMask(play) - 1];
}
return 0;
}

View File

@ -44,7 +44,7 @@ void SkelCurve_Clear(SkelCurve* skelCurve) {
*
* @return bool always true
*/
s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg,
s32 SkelCurve_Init(PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg,
CurveAnimationHeader* animation) {
SkelCurveLimb** limbs;
CurveSkeletonHeader* skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg);
@ -61,7 +61,7 @@ s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeleton
/**
* Frees the joint table.
*/
void SkelCurve_Destroy(GlobalContext* globalCtx, SkelCurve* skelCurve) {
void SkelCurve_Destroy(PlayState* play, SkelCurve* skelCurve) {
if (skelCurve->jointTable != NULL) {
ZeldaArena_Free(skelCurve->jointTable);
}
@ -91,7 +91,7 @@ typedef enum {
*
* @return bool true when the animation has finished.
*/
s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) {
s32 SkelCurve_Update(PlayState* play, SkelCurve* skelCurve) {
s16* jointData;
u8* knotCounts;
CurveAnimationHeader* animation;
@ -108,7 +108,7 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) {
constantData = Lib_SegmentedToVirtual(animation->constantData);
jointData = *skelCurve->jointTable;
skelCurve->curFrame += skelCurve->playSpeed * ((s32)globalCtx->state.framerateDivisor * 0.5f);
skelCurve->curFrame += skelCurve->playSpeed * ((s32)play->state.framerateDivisor * 0.5f);
if (((skelCurve->playSpeed >= 0.0f) && (skelCurve->curFrame > skelCurve->endFrame)) ||
((skelCurve->playSpeed < 0.0f) && (skelCurve->curFrame < skelCurve->endFrame))) {
@ -155,16 +155,16 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) {
/**
* Recursively draws limbs with appropriate properties.
*/
void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skelCurve,
OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
if ((overrideLimbDraw == NULL) ||
((overrideLimbDraw != NULL) && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) {
((overrideLimbDraw != NULL) && overrideLimbDraw(play, skelCurve, limbIndex, thisx))) {
Vec3f scale;
Vec3s rot;
Vec3f pos;
@ -191,7 +191,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel
dList = limb->dList[0];
if (dList != NULL) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
@ -200,13 +200,13 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel
dList = limb->dList[0];
if (dList != NULL) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
dList = limb->dList[1];
if (dList != NULL) {
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, dList);
}
@ -214,25 +214,25 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel
}
if (postLimbDraw != NULL) {
postLimbDraw(globalCtx, skelCurve, limbIndex, thisx);
postLimbDraw(play, skelCurve, limbIndex, thisx);
}
if (limb->child != LIMB_DONE) {
SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
SkelCurve_DrawLimb(play, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
SkelCurve_DrawLimb(play, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve,
OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
void SkelCurve_Draw(Actor* actor, PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
if (skelCurve->jointTable != NULL) {
SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
}

View File

@ -37,7 +37,7 @@ FireObjLightParams sFireObjLightParams[] = {
{ 200, { 128, 128, 0 }, { 127, 127, 0 } },
};
void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) {
void FireObj_InitWithParams(PlayState* play, FireObj* fire, FireObjInitParams* init) {
fire->size = init->size;
fire->sizeInv = 1.0f / init->size;
fire->dynamicSizeStep = init->dynamicSizeStep;
@ -92,8 +92,8 @@ void FireObj_StepSize(FireObj* fire) {
fire->xScale = fire->dynamicSize * fire->size;
}
void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
Player* player = GET_PLAYER(globalCtx);
void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) {
Player* player = GET_PLAYER(play);
WaterBox* waterBox;
f32 waterY;
s32 sp40 = false;
@ -114,7 +114,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
FireObj_SetState(fire, fire->dynamicSizeStep, nextState);
}
if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) &&
WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) &&
WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) &&
(waterY - fire->position.y > 6500.0f * fire->yScale)) {
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3);
}
@ -131,25 +131,24 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
}
} else if (player->unk_B28 == 0) {
player->unk_B28 = 0xD2;
SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION);
SoundSource_PlaySfxAtFixedWorldPos(play, &fire->position, 20, NA_SE_EV_FLAME_IGNITION);
} else if (player->unk_B28 < 0xC8) {
player->unk_B28 = 0xC8;
}
}
}
void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) {
void FireObj_Draw(PlayState* play, FireObj* fire) {
s32 pad;
FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex];
if (fire->state != FIRE_STATE_3) {
Vec3s vec;
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
gSPSegment(
POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128));
OPEN_DISPS(play->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128));
gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g,
fireColors->primColor.b, fireColors->primColor.a);
@ -157,31 +156,31 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) {
gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0);
vec.x = 0;
vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000;
vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000;
vec.z = 0;
Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec);
Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}
void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) {
void FireObj_InitLight(PlayState* play, FireObjLight* light, u8* paramsIndex, Vec3f* pos) {
FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex];
Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g,
objectParams->color.b, objectParams->radius);
light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo);
light->light = LightContext_InsertLight(play, &play->lightCtx, &light->lightInfo);
light->lightParamsIndex = *paramsIndex;
}
void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) {
LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light);
void FireObj_DestroyLight(PlayState* play, FireObjLight* light) {
LightContext_RemoveLight(play, &play->lightCtx, light->light);
}
void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) {
void FireObj_UpdateLight(PlayState* play, FireObjLight* light, FireObj* fire) {
FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex];
s16 radius;
@ -198,33 +197,33 @@ void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj*
}
}
void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) {
void FireObj_Init(PlayState* play, FireObj* fire, FireObjInitParams* init, Actor* actor) {
FireObj* fire2 = fire;
FireObj_InitWithParams(globalCtx, fire, init);
Collider_InitCylinder(globalCtx, &fire->collision);
Collider_SetCylinder(globalCtx, &fire->collision, actor, &sFireObjCollisionInit);
FireObj_InitWithParams(play, fire, init);
Collider_InitCylinder(play, &fire->collision);
Collider_SetCylinder(play, &fire->collision, actor, &sFireObjCollisionInit);
fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f;
fire2->collision.dim.height = fire->size * 16000.0f;
fire->collision.dim.yShift = fire->size * -1728.0f;
FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position);
FireObj_InitLight(play, &fire->light, &init->lightParamsIndex, &fire->position);
}
void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) {
Collider_DestroyCylinder(globalCtx, &fire->collision);
FireObj_DestroyLight(globalCtx, &fire->light);
void FireObj_Destroy(PlayState* play, FireObj* fire) {
Collider_DestroyCylinder(play, &fire->collision);
FireObj_DestroyLight(play, &fire->light);
}
void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState) {
FireObj_SetState(fire, dynamicSizeStep, newState);
}
void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) {
void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor) {
s32 pad; // Gamestate cast?
EnArrow* arrow = (EnArrow*)fire->collision.base.ac;
FireObj_UpdateStateTransitions(globalCtx, fire);
FireObj_UpdateStateTransitions(play, fire);
if (fire->state == FIRE_STATE_3) {
if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) {
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0);
@ -237,6 +236,6 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) {
fire->collision.dim.pos.x = fire->position.x;
fire->collision.dim.pos.y = fire->position.y;
fire->collision.dim.pos.z = fire->position.z;
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &fire->collision.base);
FireObj_UpdateLight(globalCtx, &fire->light, fire);
CollisionCheck_SetAC(play, &play->colChkCtx, &fire->collision.base);
FireObj_UpdateLight(play, &fire->light, fire);
}

View File

@ -17,7 +17,7 @@ GameStateOverlay gGameStateOverlayTable[] = {
GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)),
GAMESTATE_OVERLAY(select, Select_Init, Select_Destroy, sizeof(SelectContext)),
GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)),
GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(GlobalContext)),
GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(PlayState)),
GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)),
GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)),
GAMESTATE_OVERLAY(daytelop, Daytelop_Init, Daytelop_Destroy, sizeof(DaytelopContext)),

View File

@ -1,27 +1,27 @@
#include "global.h"
void GameOver_Init(GlobalContext* globalCtx) {
globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE;
void GameOver_Init(PlayState* play) {
play->gameOverCtx.state = GAMEOVER_INACTIVE;
}
void GameOver_FadeLights(GlobalContext* globalCtx) {
GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
void GameOver_FadeLights(PlayState* play) {
GameOverContext* gameOverCtx = &play->gameOverCtx;
if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) ||
(gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) {
Kankyo_FadeInGameOverLights(globalCtx);
Kankyo_FadeInGameOverLights(play);
}
}
static s16 sGameOverTimer = 0;
void GameOver_Update(GlobalContext* globalCtx) {
GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
void GameOver_Update(PlayState* play) {
GameOverContext* gameOverCtx = &play->gameOverCtx;
s16 i;
switch (gameOverCtx->state) {
case GAMEOVER_DEATH_START:
func_801477B4(globalCtx);
func_801477B4(play);
for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) {
gSaveContext.unk_3DD0[i] = 0;
@ -60,14 +60,14 @@ void GameOver_Update(GlobalContext* globalCtx) {
gSaveContext.unk_3F20 = 0;
gSaveContext.unk_3F22 = 0;
gSaveContext.unk_3F24 = 0;
Kankyo_InitGameOverLights(globalCtx);
Kankyo_InitGameOverLights(play);
sGameOverTimer = 20;
func_8013ECE0(0.0f, 126, 124, 63);
gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
break;
case GAMEOVER_DEATH_FADE_OUT:
if (func_801A8A50(1) != NA_BGM_GAME_OVER) {
func_80169F78(&globalCtx->state);
func_80169F78(&play->state);
if (gSaveContext.respawnFlag != -7) {
gSaveContext.respawnFlag = -6;
}
@ -84,7 +84,7 @@ void GameOver_Update(GlobalContext* globalCtx) {
case GAMEOVER_REVIVE_START:
gameOverCtx->state++;
sGameOverTimer = 0;
Kankyo_InitGameOverLights(globalCtx);
Kankyo_InitGameOverLights(play);
ShrinkWindow_SetLetterboxTarget(32);
break;
case GAMEOVER_REVIVE_RUMBLE:
@ -107,7 +107,7 @@ void GameOver_Update(GlobalContext* globalCtx) {
}
break;
case GAMEOVER_REVIVE_FADE_OUT:
Kankyo_FadeOutGameOverLights(globalCtx);
Kankyo_FadeOutGameOverLights(play);
sGameOverTimer--;
if (sGameOverTimer == 0) {
gameOverCtx->state = GAMEOVER_INACTIVE;

View File

@ -54,7 +54,7 @@ void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) {
}
}
void KaleidoManager_Init(GlobalContext* globalCtx) {
void KaleidoManager_Init(PlayState* play) {
s32 largestSize = 0;
s32 size;
u32 i;
@ -66,7 +66,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) {
}
}
sKaleidoAreaPtr = THA_AllocEndAlign16(&globalCtx->state.heap, largestSize);
sKaleidoAreaPtr = THA_AllocEndAlign16(&play->state.heap, largestSize);
gKaleidoMgrCurOvl = NULL;
Fault_AddAddrConvClient(&sKaleidoAreaFaultClient, KaleidoManager_FaultAddrConvFunc, NULL);
}

View File

@ -1,11 +1,11 @@
#include "prevent_bss_reordering.h"
#include "global.h"
void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx);
void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx);
void (*sKaleidoScopeUpdateFunc)(PlayState* play);
void (*sKaleidoScopeDrawFunc)(PlayState* play);
extern void KaleidoScope_Update(GlobalContext* globalCtx);
extern void KaleidoScope_Draw(GlobalContext* globalCtx);
extern void KaleidoScope_Update(PlayState* play);
extern void KaleidoScope_Draw(PlayState* play);
void KaleidoScopeCall_LoadPlayer() {
KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR];
@ -19,21 +19,21 @@ void KaleidoScopeCall_LoadPlayer() {
}
}
void KaleidoScopeCall_Init(GlobalContext* globalCtx) {
void KaleidoScopeCall_Init(PlayState* play) {
sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update);
sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw);
KaleidoSetup_Init(globalCtx);
KaleidoSetup_Init(play);
}
void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) {
KaleidoSetup_Destroy(globalCtx);
void KaleidoScopeCall_Destroy(PlayState* play) {
KaleidoSetup_Destroy(play);
}
void KaleidoScopeCall_Update(GlobalContext* globalCtx) {
PauseContext* pauseCtx = &globalCtx->pauseCtx;
void KaleidoScopeCall_Update(PlayState* play) {
PauseContext* pauseCtx = &play->pauseCtx;
KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE];
if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) {
if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) {
if (pauseCtx->state == 1 || pauseCtx->state == 19) {
if (ShrinkWindow_GetLetterboxMagnitude() == 0) {
R_PAUSE_MENU_MODE = 1;
@ -60,9 +60,9 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) {
}
if (gKaleidoMgrCurOvl == kaleidoScopeOvl) {
sKaleidoScopeUpdateFunc(globalCtx);
sKaleidoScopeUpdateFunc(play);
if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) {
if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) {
KaleidoManager_ClearOvl(kaleidoScopeOvl);
KaleidoScopeCall_LoadPlayer();
}
@ -71,14 +71,14 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) {
}
}
void KaleidoScopeCall_Draw(GlobalContext* globalCtx) {
void KaleidoScopeCall_Draw(PlayState* play) {
KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE];
if (R_PAUSE_MENU_MODE == 3) {
if (((globalCtx->pauseCtx.state >= 4) && (globalCtx->pauseCtx.state <= 7)) ||
((globalCtx->pauseCtx.state >= 11) && (globalCtx->pauseCtx.state <= 26))) {
if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) ||
((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 26))) {
if (gKaleidoMgrCurOvl == kaleidoScopeOvl) {
sKaleidoScopeDrawFunc(globalCtx);
sKaleidoScopeDrawFunc(play);
}
}
}

View File

@ -5,8 +5,8 @@ s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 };
f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f };
f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f };
void func_800F4A10(GlobalContext* globalCtx) {
PauseContext* pauseCtx = &globalCtx->pauseCtx;
void func_800F4A10(PlayState* play) {
PauseContext* pauseCtx = &play->pauseCtx;
s16 i;
func_8013EE24();
@ -59,35 +59,34 @@ void func_800F4A10(GlobalContext* globalCtx) {
YREG(26) = -0x3840;
}
void KaleidoSetup_Update(GlobalContext* globalCtx) {
Input* input = CONTROLLER1(&globalCtx->state);
MessageContext* msgCtx = &globalCtx->msgCtx;
Player* player = GET_PLAYER(globalCtx);
PauseContext* pauseCtx = &globalCtx->pauseCtx;
void KaleidoSetup_Update(PlayState* play) {
Input* input = CONTROLLER1(&play->state);
MessageContext* msgCtx = &play->msgCtx;
Player* player = GET_PLAYER(play);
PauseContext* pauseCtx = &play->pauseCtx;
if (CHECK_BTN_ALL(input->cur.button, BTN_R)) {
if (msgCtx && msgCtx) {}
}
if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) {
if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) {
if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) {
if ((play->sceneLoadFlag == 0) && (play->unk_18B4A == 0)) {
if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) {
if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) {
if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) {
if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) {
if ((play->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) {
if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) {
if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) {
if ((globalCtx->actorCtx.unk268 == 0) &&
CHECK_BTN_ALL(input->press.button, BTN_START)) {
if (!(play->actorCtx.unk5 & 2) && !(play->actorCtx.unk5 & 4)) {
if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) {
gSaveContext.unk_3F26 = gSaveContext.unk_3F22;
pauseCtx->unk_2B9 = 0;
pauseCtx->state = 1;
func_800F4A10(globalCtx);
func_800F4A10(play);
pauseCtx->mode = pauseCtx->pageIndex * 2 + 1;
func_801A3A7C(1);
}
if (pauseCtx->state == 1) {
Game_SetFramerateDivisor(&globalCtx->state, 2);
Game_SetFramerateDivisor(&play->state, 2);
if (ShrinkWindow_GetLetterboxTarget() != 0) {
ShrinkWindow_SetLetterboxTarget(0);
}
@ -102,8 +101,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) {
}
}
void KaleidoSetup_Init(GlobalContext* globalCtx) {
PauseContext* pauseCtx = &globalCtx->pauseCtx;
void KaleidoSetup_Init(PlayState* play) {
PauseContext* pauseCtx = &play->pauseCtx;
s32 pad[2];
bzero(pauseCtx, sizeof(PauseContext));
@ -138,8 +137,8 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) {
pauseCtx->unk_2BC = 40;
pauseCtx->unk_29E = 100;
View_Init(&pauseCtx->view, globalCtx->state.gfxCtx);
View_Init(&pauseCtx->view, play->state.gfxCtx);
}
void KaleidoSetup_Destroy(GlobalContext* globalCtx) {
void KaleidoSetup_Destroy(PlayState* play) {
}

View File

@ -1,11 +1,11 @@
#include "global.h"
// stubbed in NTSC-U
void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset) {
void Font_LoadChar(PlayState* play, u16 codePointIndex, s32 offset) {
}
void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset) {
MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
DmaMgr_SendRequest0(&font->charBuf[font->unk_11D88][offset],

View File

@ -33,8 +33,8 @@ TexturePtr HeartDDTextures[] = {
gDefenseHeartThreeQuarterTex,
};
void LifeMeter_Init(GlobalContext* globalCtx) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
void LifeMeter_Init(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
interfaceCtx->unkTimer = 320;
@ -71,8 +71,8 @@ void LifeMeter_Init(GlobalContext* globalCtx) {
sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = 0;
}
void LifeMeter_UpdateColors(GlobalContext* globalCtx) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
void LifeMeter_UpdateColors(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
f32 factorBeating = interfaceCtx->lifeColorChange * 0.1f;
f32 ddFactor;
s32 type = 0;
@ -167,26 +167,26 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) {
sBeatingHeartsDDEnv[2] = (u8)(bFactor + 0) & 0xFF;
}
s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) {
gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health;
s32 LifeMeter_SaveInterfaceHealth(PlayState* play) {
gSaveContext.save.playerData.health = play->interfaceCtx.health;
return 1;
}
s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
interfaceCtx->unkTimer = 320;
interfaceCtx->health += 0x10;
if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) {
globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health;
if (play->interfaceCtx.health >= gSaveContext.save.playerData.health) {
play->interfaceCtx.health = gSaveContext.save.playerData.health;
return 1;
}
return 0;
}
s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
if (interfaceCtx->unkTimer != 0) {
interfaceCtx->unkTimer--;
@ -195,14 +195,14 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) {
interfaceCtx->health -= 0x10;
if (interfaceCtx->health <= 0) {
interfaceCtx->health = 0;
globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1));
play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 1));
return 1;
}
}
return 0;
}
void LifeMeter_Draw(GlobalContext* globalCtx) {
void LifeMeter_Draw(PlayState* play) {
s32 pad[5];
TexturePtr heartTex;
s32 curColorSet;
@ -213,8 +213,8 @@ void LifeMeter_Draw(GlobalContext* globalCtx) {
f32 posX;
f32 halfTexSize;
f32 temp_f4;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
GraphicsContext* gfxCtx = play->state.gfxCtx;
InterfaceContext* interfaceCtx = &play->interfaceCtx;
Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx;
s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10;
s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10;
@ -391,16 +391,16 @@ void LifeMeter_Draw(GlobalContext* globalCtx) {
CLOSE_DISPS(gfxCtx);
}
void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) {
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
void LifeMeter_UpdateSizeAndBeep(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
if (interfaceCtx->lifeSizeChangeDirection != 0) {
interfaceCtx->lifeSizeChange--;
if (interfaceCtx->lifeSizeChange <= 0) {
interfaceCtx->lifeSizeChange = 0;
interfaceCtx->lifeSizeChangeDirection = 0;
if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) &&
(globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) {
if (!Player_InCsMode(&play->state) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) &&
LifeMeter_IsCritical() && !Play_InCsMode(play)) {
play_sound(NA_SE_SY_HITPOINT_ALARM);
}
}

View File

@ -124,7 +124,7 @@ void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* p
}
}
void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* globalCtx) {
void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play) {
Light* light;
f32 radiusF = params->point.radius;
Vec3f posF;
@ -135,7 +135,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global
posF.x = params->point.x;
posF.y = params->point.y;
posF.z = params->point.z;
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &posF, &adjustedPos);
SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &posF, &adjustedPos);
if ((adjustedPos.z > -radiusF) && (600 + radiusF > adjustedPos.z) && (400 > fabsf(adjustedPos.x) - radiusF) &&
(400 > fabsf(adjustedPos.y) - radiusF)) {
light = Lights_FindSlot(lights);
@ -189,7 +189,7 @@ void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) {
* Note: Lights in a given list can only be binded to however many free slots are
* available in the Lights group. This is at most 7 slots for a new group, but could be less.
*/
void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx) {
void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play) {
static LightsPosBindFunc posBindFuncs[] = {
Lights_BindPoint,
(LightsPosBindFunc)Lights_BindDirectional,
@ -204,7 +204,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo
if (listHead != NULL) {
if ((refPos == NULL) && (lights->enablePosLights == 1)) {
do {
posBindFuncs[listHead->info->type](lights, &listHead->info->params, globalCtx);
posBindFuncs[listHead->info->type](lights, &listHead->info->params, play);
listHead = listHead->next;
} while (listHead != NULL);
} else {
@ -248,8 +248,8 @@ void Lights_FreeNode(LightNode* light) {
}
}
void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx) {
LightContext_InitList(globalCtx, lightCtx);
void LightContext_Init(PlayState* play, LightContext* lightCtx) {
LightContext_InitList(play, lightCtx);
LightContext_SetAmbientColor(lightCtx, 80, 80, 80);
func_80102544(lightCtx, 0, 0, 0, 0x3E4, 0x3200);
bzero(&sLightsBuffer, sizeof(LightsBuffer));
@ -276,13 +276,13 @@ Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx)
return Lights_New(gfxCtx, lightCtx->ambient.r, lightCtx->ambient.g, lightCtx->ambient.b);
}
void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx) {
void LightContext_InitList(PlayState* play, LightContext* lightCtx) {
lightCtx->listHead = NULL;
}
void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) {
void LightContext_DestroyList(PlayState* play, LightContext* lightCtx) {
while (lightCtx->listHead != NULL) {
LightContext_RemoveLight(globalCtx, lightCtx, lightCtx->listHead);
LightContext_RemoveLight(play, lightCtx, lightCtx->listHead);
lightCtx->listHead = lightCtx->listHead->next;
}
}
@ -293,7 +293,7 @@ void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx)
* Note: Due to the limited number of slots in a Lights group, inserting too many lights in the
* list may result in older entries not being bound to a Light when calling Lights_BindAll
*/
LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info) {
LightNode* LightContext_InsertLight(PlayState* play, LightContext* lightCtx, LightInfo* info) {
LightNode* light;
light = Lights_FindBufSlot();
@ -312,7 +312,7 @@ LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* ligh
return light;
}
void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* light) {
void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* light) {
if (light != NULL) {
if (light->prev != NULL) {
light->prev->next = light->next;
@ -372,8 +372,8 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient
return lights;
}
void Lights_GlowCheck(GlobalContext* globalCtx) {
LightNode* light = globalCtx->lightCtx.listHead;
void Lights_GlowCheck(PlayState* play) {
LightNode* light = play->lightCtx.listHead;
while (light != NULL) {
LightPoint* params = &light->info->params.point;
@ -386,7 +386,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
pos.x = params->x;
pos.y = params->y;
pos.z = params->z;
Actor_GetProjectedPos(globalCtx, &pos, &multDest, &wDest);
Actor_GetProjectedPos(play, &pos, &multDest, &wDest);
params->drawGlow = 0;
@ -406,13 +406,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
}
}
void Lights_DrawGlow(GlobalContext* globalCtx) {
void Lights_DrawGlow(PlayState* play) {
Gfx* dl;
LightPoint* params;
LightNode* light = globalCtx->lightCtx.listHead;
LightNode* light = play->lightCtx.listHead;
if (light != NULL) {
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
dl = func_8012C7FC(POLY_XLU_DISP);
@ -434,8 +434,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) {
Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW);
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(dl++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(dl++, gameplay_keep_DL_029CF0);
}
@ -446,6 +445,6 @@ void Lights_DrawGlow(GlobalContext* globalCtx) {
POLY_XLU_DISP = dl;
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -42,8 +42,8 @@ void func_80147520(void) {
D_801CFCA4[7] = D_801CFCA4[8] = 0;
}
void func_80147564(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_80147564(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk1204A[0] = 0xBD;
msgCtx->unk1204A[1] = 0xB8;
@ -65,9 +65,9 @@ void func_80147564(GlobalContext* globalCtx) {
D_801F6B20 = 0xA;
}
s32 Message_ShouldAdvance(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
Input* controller = CONTROLLER1(&globalCtx->state);
s32 Message_ShouldAdvance(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
Input* controller = CONTROLLER1(&play->state);
if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) {
if (CHECK_BTN_ALL(controller->press.button, BTN_A)) {
@ -84,9 +84,9 @@ s32 Message_ShouldAdvance(GlobalContext* globalCtx) {
}
}
s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
Input* controller = CONTROLLER1(&globalCtx->state);
s32 Message_ShouldAdvanceSilent(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
Input* controller = CONTROLLER1(&play->state);
if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) {
return CHECK_BTN_ALL(controller->press.button, BTN_A);
@ -96,10 +96,10 @@ s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) {
}
}
void func_801477B4(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_801477B4(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
if (globalCtx->msgCtx.unk11F10 != 0) {
if (play->msgCtx.unk11F10 != 0) {
msgCtx->unk12023 = 2;
msgCtx->msgMode = 0x43;
msgCtx->unk12020 = 0;
@ -114,10 +114,10 @@ void func_801477B4(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s")
#ifdef NON_MATCHING
void func_80148B98(GlobalContext* globalCtx, u8 arg1) {
void func_80148B98(PlayState* play, u8 arg1) {
static s16 held = 0;
MessageContext* msgCtx = &globalCtx->msgCtx;
Input* curInput = CONTROLLER1(&globalCtx->state);
MessageContext* msgCtx = &play->msgCtx;
Input* curInput = CONTROLLER1(&play->state);
if ((curInput->rel.stick_y > 29) && held == 0) {
held = 1;
@ -147,8 +147,8 @@ void func_80148B98(GlobalContext* globalCtx, u8 arg1) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s")
#endif
void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_80148CBC(PlayState* play, UNK_PTR puParm2, u8 arg2) {
MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk11FF4 = 0x30;
if (arg2 == 1) {
@ -156,7 +156,7 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
} else {
msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex];
}
func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6);
func_80147818(play, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s")
@ -173,8 +173,8 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s")
void Message_FindMessage(GlobalContext* globalCtx, u16 textId) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_FindMessage(PlayState* play, u16 textId) {
MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageEntryTable;
const char* segment = msgEntry->segment;
@ -209,12 +209,12 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s")
void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
MessageContext* msgCtx = &play->msgCtx;
s32 temp1 = *offset;
f32 temp2 = *arg3;
Font_LoadChar(globalCtx, codePointIndex, temp1);
Font_LoadChar(play, codePointIndex, temp1);
msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex;
temp1 += FONT_CHAR_TEX_SIZE;
temp2 += (16.0f * msgCtx->unk12098);
@ -223,21 +223,21 @@ void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset,
}
// Message_LoadRupees JPN ?
void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &play->msgCtx;
s16 t = *decodedBufPos;
s32 k = *offset;
f32 f = *arg3;
Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213
Font_LoadChar(play, 0x838B, k); // 0x838b = ル in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x838B;
t += 1;
Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213
Font_LoadChar(play, 0x8373, k); // 0x8373 = ピ in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x8373;
t += 1;
Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213
Font_LoadChar(play, 0x815C, k); // Ox815C = ― in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x815C;
@ -257,7 +257,7 @@ void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f3
extern u16* D_801D0188;
extern s16* D_801D0250;
void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) {
f32 sp3C;
s16 temp_s0;
s16 temp_s1;
@ -276,10 +276,10 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
temp_s1 = *arg3;
temp_s2 = *arg1;
sp3C = *arg2;
if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) {
if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) {
phi_v0 = 0xA;
} else {
phi_v0 = arg0->pauseCtx.unk_238[4];
phi_v0 = play->pauseCtx.unk_238[4];
}
temp_s6 = *(&D_801D0250 + (phi_v0 * 2));
phi_s0 = 0;
@ -290,8 +290,8 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
phi_s2 = temp_s2;
do {
temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2);
(arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0;
Font_LoadChar(arg0, *temp_v0, phi_s2);
(play + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0;
Font_LoadChar(play, *temp_v0, phi_s2);
temp_s0 = phi_s0 + 1;
temp_s1_2 = phi_s1 + 1;
temp_s2_2 = phi_s2 + 0x80;
@ -304,7 +304,7 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
}
*arg3 = phi_s1_2 - 1;
*arg1 = phi_s2_2;
*arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098));
*arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * play->msgCtx.unk12098));
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s")
@ -318,53 +318,53 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s")
void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_StartTextbox(PlayState* play, u16 textId, Actor* Actor) {
MessageContext* msgCtx = &play->msgCtx;
msgCtx->ocarinaAction = 0xFFFF;
func_80150D08(globalCtx, textId);
func_80150D08(play, textId);
msgCtx->unkActor = Actor;
msgCtx->msgMode = 1;
msgCtx->unk12023 = 0;
msgCtx->unk12024 = 0;
globalCtx->msgCtx.ocarinaMode = 0;
play->msgCtx.ocarinaMode = 0;
}
void func_80151938(GlobalContext* globalCtx, u16 textId) {
MessageContext* msgCtx = &globalCtx->msgCtx;
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
void func_80151938(PlayState* play, u16 textId) {
MessageContext* msgCtx = &play->msgCtx;
InterfaceContext* interfaceCtx = &play->interfaceCtx;
msgCtx->unk11F10 = 0;
func_80150D08(globalCtx, textId);
func_80150A84(globalCtx);
func_80150D08(play, textId);
func_80150A84(play);
msgCtx->msgMode = 5;
msgCtx->unk12023 = 8;
msgCtx->unk12024 = 0;
if (interfaceCtx->unk_222 == 0) {
if (textId != 0x1B93) {
func_8011552C(globalCtx, 0x10);
func_8011552C(play, 0x10);
} else if (textId != 0xF8) {
func_8011552C(globalCtx, 6);
func_8011552C(play, 6);
}
}
msgCtx->unk1203C = msgCtx->unk1203A;
if (globalCtx->pauseCtx.unk_1F0 != 0) {
if (play->pauseCtx.unk_1F0 != 0) {
msgCtx->unk12004 = 0x22;
msgCtx->unk12006 = 0x15E;
func_80149C18(globalCtx);
func_80149C18(play);
msgCtx->unk12023 = 1;
}
}
void func_80151A68(GlobalContext* globalCtx, u16 textId) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_80151A68(PlayState* play, u16 textId) {
MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk11F10 = 0;
func_80150D08(globalCtx, textId);
func_80150A84(globalCtx);
func_8015B198(globalCtx);
func_80150D08(play, textId);
func_80150A84(play);
func_8015B198(play);
msgCtx->msgMode = 0x45;
msgCtx->unk12024 = 0;
msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0;
@ -386,8 +386,8 @@ void func_80151A68(GlobalContext* globalCtx, u16 textId) {
}
}
void func_80151BB4(GlobalContext* globalCtx, u8 arg1) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void func_80151BB4(PlayState* play, u8 arg1) {
MessageContext* msgCtx = &play->msgCtx;
u8 temp = arg1;
if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
@ -403,8 +403,8 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) {
}
}
u32 func_80151C9C(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
u32 func_80151C9C(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
while (true) {
if (msgCtx->unk120B1 == 0) {
@ -419,7 +419,7 @@ u32 func_80151C9C(GlobalContext* globalCtx) {
(u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]];
if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]);
func_80151938(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]);
play_sound(NA_SE_SY_SCHEDULE_WRITE);
return true;
}
@ -429,14 +429,14 @@ u32 func_80151C9C(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s")
void func_80152434(GlobalContext* globalCtx, u16 arg2) {
globalCtx->msgCtx.unk12046 = 0;
func_80151DA4(globalCtx, arg2);
void func_80152434(PlayState* play, u16 arg2) {
play->msgCtx.unk12046 = 0;
func_80151DA4(play, arg2);
}
void func_80152464(GlobalContext* globalCtx, u16 arg1) {
globalCtx->msgCtx.unk12046 = 1;
func_80151DA4(globalCtx, arg1);
void func_80152464(PlayState* play, u16 arg1) {
play->msgCtx.unk12046 = 1;
func_80151DA4(play, arg1);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s")
@ -451,21 +451,21 @@ void func_80152C64(View* view) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s")
// Spawn song effect?
void func_80152EC0(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
Player* player = GET_PLAYER(globalCtx);
void func_80152EC0(PlayState* play) {
MessageContext* msgCtx = &play->msgCtx;
Player* player = GET_PLAYER(play);
if (1) {}
if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) &&
((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) {
msgCtx->unk120B0 = 1;
if (msgCtx->songPlayed != 0x16) {
Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x,
Actor_Spawn(&play->actorCtx, play, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x,
player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]);
return;
}
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x,
player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0);
Actor_Spawn(&play->actorCtx, play, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, player->actor.world.pos.y,
player->actor.world.pos.z, 0, 0, 0, 0);
}
}
@ -473,34 +473,34 @@ void func_80152EC0(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s")
void func_80153E7C(GlobalContext* globalCtx, void* arg1) {
if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) {
func_8014ADBC(globalCtx, arg1);
void func_80153E7C(PlayState* play, void* arg1) {
if ((gSaveContext.options.language == 0) && (play->msgCtx.unk12090 == 0)) {
func_8014ADBC(play, arg1);
return;
}
if (globalCtx->msgCtx.unk12090 != 0) {
func_8015E7EC(globalCtx, arg1);
if (play->msgCtx.unk12090 != 0) {
func_8015E7EC(play, arg1);
return;
}
func_8015966C(globalCtx, arg1, 0);
func_8015966C(play, arg1, 0);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s")
void func_80156758(GlobalContext* globalCtx) {
void func_80156758(PlayState* play) {
Gfx* nextDisplayList;
Gfx* polyOpa;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
GraphicsContext* gfxCtx = play->state.gfxCtx;
OPEN_DISPS(gfxCtx);
polyOpa = POLY_OPA_DISP;
nextDisplayList = Graph_GfxPlusOne(polyOpa);
gSPDisplayList(OVERLAY_DISP++, nextDisplayList);
if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) {
func_801541D4(globalCtx, &nextDisplayList);
if ((play->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(play)) {
func_801541D4(play, &nextDisplayList);
}
gSPEndDisplayList(nextDisplayList++);
@ -511,17 +511,17 @@ void func_80156758(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s")
void func_801586A4(GlobalContext* globalCtx) {
globalCtx->msgCtx.messageEntryTableNes = D_801C6B98;
globalCtx->msgCtx.messageTableStaff = D_801CFB08;
void func_801586A4(PlayState* play) {
play->msgCtx.messageEntryTableNes = D_801C6B98;
play->msgCtx.messageTableStaff = D_801CFB08;
}
void Message_Init(GlobalContext* globalCtx) {
void Message_Init(PlayState* play) {
Font* font;
MessageContext* messageCtx = &globalCtx->msgCtx;
MessageContext* messageCtx = &play->msgCtx;
func_801586A4(globalCtx);
globalCtx->msgCtx.ocarinaMode = 0;
func_801586A4(play);
play->msgCtx.ocarinaMode = 0;
messageCtx->msgMode = 0;
messageCtx->unk11F10 = 0;
messageCtx->currentTextId = 0;
@ -529,10 +529,10 @@ void Message_Init(GlobalContext* globalCtx) {
messageCtx->choiceIndex = 0;
messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0;
messageCtx->unk1201E = 0xFF;
View_Init(&messageCtx->view, globalCtx->state.gfxCtx);
messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00);
font = &globalCtx->msgCtx.font;
Font_LoadOrderedFont(&globalCtx->msgCtx.font);
View_Init(&messageCtx->view, play->state.gfxCtx);
messageCtx->unk11EF8 = THA_AllocEndAlign16(&play->state.heap, 0x13C00);
font = &play->msgCtx.font;
Font_LoadOrderedFont(&play->msgCtx.font);
font->unk_11D88 = 0;
messageCtx->unk12090 = messageCtx->unk12092 = 0;
messageCtx->unk12094 = 0;

View File

@ -42,8 +42,8 @@ extern u8 D_801D0710[4];
extern u8 D_801D0714[11][16];
extern s16 D_801D07C4[11];
void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_FindMessageNES(PlayState* play, u16 textId) {
MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes;
const char* segment = msgEntry->segment;
@ -70,12 +70,12 @@ void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) {
font->messageEnd = nextSegment - foundSegment;
}
void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadCharNES(PlayState* play, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
MessageContext* msgCtx = &play->msgCtx;
s32 temp1 = *offset;
f32 temp2 = *arg3;
Font_LoadCharNES(globalCtx, codePointIndex, temp1);
Font_LoadCharNES(play, codePointIndex, temp1);
msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex;
temp1 += FONT_CHAR_TEX_SIZE;
temp2 += (16.0f * msgCtx->unk12098);
@ -83,35 +83,35 @@ void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offse
*arg3 = temp2;
}
void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
msgCtx->decodedBuffer.schar[p] = 0x20;
p++;
Font_LoadCharNES(globalCtx, 'R', o);
Font_LoadCharNES(play, 'R', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'R';
p++;
Font_LoadCharNES(globalCtx, 'u', o);
Font_LoadCharNES(play, 'u', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'u';
p++;
Font_LoadCharNES(globalCtx, 'p', o);
Font_LoadCharNES(play, 'p', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'p';
p++;
Font_LoadCharNES(globalCtx, 'e', o);
Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
Font_LoadCharNES(globalCtx, 'e', o);
Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
Font_LoadCharNES(globalCtx, 's', o);
Font_LoadCharNES(play, 's', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 's';
@ -121,8 +121,8 @@ void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s
*arg3 = f;
}
void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
@ -132,7 +132,7 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos
p++;
for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) {
Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o);
Font_LoadCharNES(play, D_801D06F0[gSaveContext.options.language - 1][j], o);
msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j];
o += FONT_CHAR_TEX_SIZE;
p++;
@ -145,37 +145,37 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos
*arg3 = f;
}
void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) {
MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
msgCtx->decodedBuffer.schar[p] = ' ';
p++;
Font_LoadCharNES(globalCtx, 'R', o);
Font_LoadCharNES(play, 'R', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'R';
p++;
Font_LoadCharNES(globalCtx, 'u', o);
Font_LoadCharNES(play, 'u', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'u';
p++;
Font_LoadCharNES(globalCtx, 'p', o);
Font_LoadCharNES(play, 'p', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'p';
p++;
Font_LoadCharNES(globalCtx, 'e', o);
Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
Font_LoadCharNES(globalCtx, 'e', o);
Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
if (singular != 1) {
p++;
Font_LoadCharNES(globalCtx, 's', o);
Font_LoadCharNES(play, 's', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 's';
f += 16.0f * msgCtx->unk12098 * 6.0f;
@ -188,8 +188,8 @@ void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* of
*arg3 = f;
}
void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) {
MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
@ -225,12 +225,12 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar
}
for (i = 0; i < 4; i++) {
Font_LoadCharNES(globalCtx, digits[i] + '0', o);
Font_LoadCharNES(play, digits[i] + '0', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = digits[i] + '0';
p++;
if (i == 1) {
Font_LoadCharNES(globalCtx, ':', o);
Font_LoadCharNES(play, ':', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = ':';
p++;
@ -243,8 +243,8 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar
*arg3 = f;
}
void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decodedBufPos) {
MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg2;
@ -253,10 +253,10 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s
s16 currentArea;
s16 stringLimit;
if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) {
if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) {
currentArea = 10;
} else {
currentArea = globalCtx->pauseCtx.unk_238[4];
currentArea = play->pauseCtx.unk_238[4];
}
stringLimit = D_801D07C4[currentArea];
@ -264,7 +264,7 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s
msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i];
currentChar = msgCtx->decodedBuffer.schar[p];
if (currentChar != ' ') {
Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o);
Font_LoadCharNES(play, D_801D0714[currentArea][i], o);
o += FONT_CHAR_TEX_SIZE;
}
currentChar = msgCtx->decodedBuffer.schar[p];

View File

@ -1,8 +1,8 @@
#include "global.h"
#include "message_data_static.h"
void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) {
MessageContext* msgCtx = &globalCtx->msgCtx;
void Message_FindCreditsMessage(PlayState* play, u16 textId) {
MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageTableStaff;
const char* segment = msgEntry->segment;

View File

@ -1,10 +1,10 @@
#include "global.h"
Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) {
Path* Path_GetByIndex(PlayState* play, s16 index, s16 max) {
Path* path;
if (index != max) {
path = &globalCtx->setupPathList[index];
path = &play->setupPathList[index];
} else {
path = NULL;
}

View File

@ -58,8 +58,8 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s")
s32 Play_InCsMode(GlobalContext* globalCtx) {
return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state);
s32 Play_InCsMode(PlayState* this) {
return (this->csCtx.state != 0) || Player_InCsMode(&this->state);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s")
@ -154,113 +154,113 @@ s16 Play_GetOriginalSceneNumber(s16 sceneNum) {
* Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene
* number. Exception for Inverted Stone Tower Temple, which uses its own.
*/
void Play_SaveCycleSceneFlags(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
void Play_SaveCycleSceneFlags(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
CycleSceneFlags* cycleSceneFlags;
cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)];
cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest;
cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0];
cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1];
cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(this->sceneNum)];
cycleSceneFlags->chest = this->actorCtx.flags.chest;
cycleSceneFlags->switch0 = this->actorCtx.flags.switches[0];
cycleSceneFlags->switch1 = this->actorCtx.flags.switches[1];
if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple
cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum];
if (this->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple
cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneNum];
}
cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0];
cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom;
cycleSceneFlags->collectible = this->actorCtx.flags.collectible[0];
cycleSceneFlags->clearedRoom = this->actorCtx.flags.clearedRoom;
}
void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
Vec3f* pos, s16 yaw) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
PlayState* this = (PlayState*)thisx;
gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF);
gSaveContext.respawn[respawnMode].roomIndex = roomIndex;
gSaveContext.respawn[respawnMode].pos = *pos;
gSaveContext.respawn[respawnMode].yaw = yaw;
gSaveContext.respawn[respawnMode].playerParams = playerParams;
gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2];
gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1];
gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
gSaveContext.respawn[respawnMode].tempSwitchFlags = this->actorCtx.flags.switches[2];
gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.flags.collectible[1];
gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.flags.collectible[2];
}
void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
Player* player = GET_PLAYER(globalCtx);
void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) {
PlayState* this = (PlayState*)thisx;
Player* player = GET_PLAYER(this);
if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos
Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex),
globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos
Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex),
this->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
player->actor.shape.rot.y);
}
}
// Override respawn data in Sakon's Hideout
void func_80169ECC(GlobalContext* globalCtx) {
if (globalCtx->sceneNum == SCENE_SECOM) {
globalCtx->nextEntranceIndex = 0x2060;
void func_80169ECC(PlayState* this) {
if (this->sceneNum == SCENE_SECOM) {
this->nextEntranceIndex = 0x2060;
gSaveContext.respawnFlag = -7;
}
}
// Gameplay_TriggerVoidOut ?
// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer
void func_80169EFC(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
void func_80169EFC(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2];
gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1];
gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex;
gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2];
gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1];
gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2];
this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex;
gSaveContext.respawnFlag = 1;
func_80169ECC(globalCtx);
globalCtx->sceneLoadFlag = 0x14;
globalCtx->unk_1887F = 2;
func_80169ECC(this);
this->sceneLoadFlag = 0x14;
this->unk_1887F = 2;
}
// Gameplay_LoadToLastEntrance ?
// Used by game_over and Test7
void func_80169F78(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
void func_80169F78(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex;
this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex;
gSaveContext.respawnFlag = -1;
func_80169ECC(globalCtx);
globalCtx->sceneLoadFlag = 0x14;
globalCtx->unk_1887F = 2;
func_80169ECC(this);
this->sceneLoadFlag = 0x14;
this->unk_1887F = 2;
}
// Gameplay_TriggerRespawn ?
// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1
void func_80169FDC(GameState* gameState) {
func_80169F78(gameState);
void func_80169FDC(GameState* thisx) {
func_80169F78(thisx);
}
// Used by Kankyo to determine how to change the lighting, e.g. for game over.
s32 func_80169FFC(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
s32 func_80169FFC(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
return globalCtx->roomCtx.currRoom.mesh->type0.type != 1;
return this->roomCtx.currRoom.mesh->type0.type != 1;
}
s32 FrameAdvance_IsEnabled(GameState* gameState) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
s32 FrameAdvance_IsEnabled(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
return globalCtx->frameAdvCtx.enabled != 0;
return this->frameAdvCtx.enabled != 0;
}
// Unused, unchanged from OoT, which uses it only in one Camera function.
/**
* @brief Tests if \p actor is a door and the sides are different rooms.
*
* @param[in] gameState GameState, promoted to globalCtx inside.
* @param[in] thisx GameState, promoted to play inside.
* @param[in] actor Actor to test.
* @param[out] yaw Facing angle of the actor, or reverse if in the back room.
* @return true if \p actor is a door and the sides are in different rooms, false otherwise
*/
s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw) {
PlayState* this = (PlayState*)thisx;
TransitionActorEntry* transitionActor;
s8 frontRoom;
@ -268,7 +268,7 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
return false;
}
transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10];
transitionActor = &this->doorCtx.transitionActorList[(u16)actor->params >> 10];
frontRoom = transitionActor->sides[0].room;
if (frontRoom == transitionActor->sides[1].room) {
return false;
@ -287,11 +287,11 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
/**
* @brief Tests if \p pos is underwater.
*
* @param[in] globalCtx GlobalContext
* @param[in] play PlayState
* @param[in] pos position to test
* @return true if inside a waterbox and not above a void.
*/
s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) {
s32 Play_IsUnderwater(PlayState* this, Vec3f* pos) {
WaterBox* waterBox;
CollisionPoly* poly;
Vec3f waterSurfacePos;
@ -299,10 +299,10 @@ s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) {
waterSurfacePos = *pos;
if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
if ((WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
&waterBox) == true) &&
(pos->y < waterSurfacePos.y) &&
(BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) {
(BgCheck_EntityRaycastFloor3(&this->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) {
return true;
} else {
return false;
@ -320,17 +320,17 @@ extern s16 D_801D0D64[];
// Used by Player
/**
* Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in
* globalCtx->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set
* this->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set
* to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64,
* set the corresponding playerActorCsId (and possibly change its priority for the zeroth one)
*/
void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId) {
PlayState* this = (PlayState*)thisx;
s32 i;
s16* curPlayerActorCsId = globalCtx->playerActorCsIds;
s16* curPlayerActorCsId = this->playerActorCsIds;
s16* phi_s1 = D_801D0D64;
for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) {
for (i = 0; i < ARRAY_COUNT(this->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) {
ActorCutscene* actorCutscene;
s32 curActorCsId;
@ -352,7 +352,7 @@ void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCs
}
// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear.
void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) {
void func_8016A268(GameState* thisx, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) {
MREG(64) = arg1;
MREG(65) = arg2;
MREG(66) = arg3;

View File

@ -9,10 +9,10 @@ ActorFunc sPlayerCallDestroyFunc;
ActorFunc sPlayerCallUpdateFunc;
ActorFunc sPlayerCallDrawFunc;
void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx);
void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx);
void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx);
void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx);
void PlayerCall_Init(Actor* thisx, PlayState* play);
void PlayerCall_Destroy(Actor* thisx, PlayState* play);
void PlayerCall_Update(Actor* thisx, PlayState* play);
void PlayerCall_Draw(Actor* thisx, PlayState* play);
const ActorInit Player_InitVars = {
ACTOR_PLAYER,
@ -26,10 +26,10 @@ const ActorInit Player_InitVars = {
(ActorFunc)PlayerCall_Draw,
};
void Player_Init(Actor* thisx, GlobalContext* globalCtx);
void Player_Destroy(Actor* thisx, GlobalContext* globalCtx);
void Player_Update(Actor* thisx, GlobalContext* globalCtx);
void Player_Draw(Actor* thisx, GlobalContext* globalCtx);
void Player_Init(Actor* thisx, PlayState* play);
void Player_Destroy(Actor* thisx, PlayState* play);
void Player_Update(Actor* thisx, PlayState* play);
void Player_Draw(Actor* thisx, PlayState* play);
void PlayerCall_InitFuncPtrs(void) {
sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init);
@ -38,23 +38,23 @@ void PlayerCall_InitFuncPtrs(void) {
sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw);
}
void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) {
void PlayerCall_Init(Actor* thisx, PlayState* play) {
KaleidoScopeCall_LoadPlayer();
PlayerCall_InitFuncPtrs();
sPlayerCallInitFunc(thisx, globalCtx);
sPlayerCallInitFunc(thisx, play);
}
void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void PlayerCall_Destroy(Actor* thisx, PlayState* play) {
KaleidoScopeCall_LoadPlayer();
sPlayerCallDestroyFunc(thisx, globalCtx);
sPlayerCallDestroyFunc(thisx, play);
}
void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) {
void PlayerCall_Update(Actor* thisx, PlayState* play) {
KaleidoScopeCall_LoadPlayer();
sPlayerCallUpdateFunc(thisx, globalCtx);
sPlayerCallUpdateFunc(thisx, play);
}
void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) {
void PlayerCall_Draw(Actor* thisx, PlayState* play) {
KaleidoScopeCall_LoadPlayer();
sPlayerCallDrawFunc(thisx, globalCtx);
sPlayerCallDrawFunc(thisx, play);
}

View File

@ -303,7 +303,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
s32 ret;
u32 eq;
Vec3f originVec;
GlobalContext* globalCtx = camera->globalCtx;
PlayState* play = camera->play;
originVec.x = 0.0f;
originVec.y = 0.0f;
@ -326,7 +326,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) {
req = &sQuakeRequest[idx];
if (req->callbackIdx != 0) {
if (globalCtx->cameraPtrs[req->camId] == NULL) {
if (play->cameraPtrs[req->camId] == NULL) {
Quake_Remove(req);
} else {
eq = (camera->camId != req->camera->camId);
@ -382,9 +382,9 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
return ret;
}
void Distortion_Init(GlobalContext* globalCtx) {
sDistortionContext.globalCtx = globalCtx;
View_ClearDistortion(&globalCtx->view);
void Distortion_Init(PlayState* play) {
sDistortionContext.play = play;
View_ClearDistortion(&play->view);
sDistortionContext.type = 0;
sDistortionContext.countdown = 0;
sDistortionContext.state = DISTORTION_INACTIVE;
@ -419,9 +419,9 @@ void Distortion_ClearType(s32 type) {
* Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed
*/
s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) {
if (SurfaceType_GetConveyorType(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly,
if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly,
player->actor.floorBgId) == CONVEYOR_WATER) {
return SurfaceType_GetConveyorSpeed(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly,
return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly,
player->actor.floorBgId);
}
return 0;
@ -446,9 +446,9 @@ void Distortion_Update(void) {
f32 zScale;
f32 speed;
Player* player;
GlobalContext* globalCtx = sDistortionContext.globalCtx;
PlayState* play = sDistortionContext.play;
PosRot playerPosRot;
Camera* camera = GET_ACTIVE_CAM(globalCtx);
Camera* camera = GET_ACTIVE_CAM(play);
f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f);
if (sDistortionContext.type != 0) {
@ -636,7 +636,7 @@ void Distortion_Update(void) {
screenPlanePhase = 0x156;
sDistortionContext.countdown = 2;
player = GET_PLAYER(globalCtx);
player = GET_PLAYER(play);
if (player != NULL) {
Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor);
@ -688,7 +688,7 @@ void Distortion_Update(void) {
screenPlanePhase = 0x156;
sDistortionContext.countdown = 2;
player = GET_PLAYER(globalCtx);
player = GET_PLAYER(play);
depthPhaseStep = 359.2f;
screenPlanePhaseStep = -18.5f;
@ -759,20 +759,20 @@ void Distortion_Update(void) {
depthPhase += DEGF_TO_BINANG(depthPhaseStep);
screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep);
View_SetDistortionDirRot(&sDistortionContext.globalCtx->view,
View_SetDistortionDirRot(&sDistortionContext.play->view,
Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor),
Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor),
Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor));
View_SetDistortionScale(&sDistortionContext.globalCtx->view,
View_SetDistortionScale(&sDistortionContext.play->view,
(Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f,
(Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f,
(Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f);
View_SetDistortionSpeed(&sDistortionContext.globalCtx->view, speed * speedScaleFactor);
View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor);
sDistortionContext.state = DISTORTION_ACTIVE;
} else if (sDistortionContext.state != DISTORTION_INACTIVE) {
View_ClearDistortion(&globalCtx->view);
View_ClearDistortion(&play->view);
sDistortionContext.state = DISTORTION_INACTIVE;
sDistortionContext.countdown = 0;

View File

@ -896,8 +896,8 @@ void func_8012C240(GraphicsContext* gfxCtx) {
gSPDisplayList(gfxCtx->polyXlu.p++, &sSetupDL[6 * 0x19]);
}
void func_8012C268(GlobalContext* globalCtx) {
func_8012C28C(globalCtx->state.gfxCtx);
void func_8012C268(PlayState* play) {
func_8012C28C(play->state.gfxCtx);
}
void func_8012C28C(GraphicsContext* gfxCtx) {

View File

@ -1,30 +1,30 @@
#include "global.h"
void Room_nop8012D510(GlobalContext* globalCtx, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) {
void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) {
}
void Room_DrawType3Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags) {
}
void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags) {
RoomMeshType0* mesh;
s32 i;
RoomMeshType0Params* meshParams;
GraphicsContext* gfxCtx;
UNK_TYPE4 pad;
gfxCtx = globalCtx->state.gfxCtx;
gfxCtx = play->state.gfxCtx;
if (flags & 1) {
func_800BCBF4(&D_801C1D10, globalCtx);
func_800BCBF4(&D_801C1D10, play);
gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment);
func_8012C268(globalCtx);
func_8012C268(play);
gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD);
}
if (flags & 2) {
func_800BCC68(&D_801C1D10, globalCtx);
func_800BCC68(&D_801C1D10, play);
gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment);
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD);
}
@ -51,18 +51,18 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E32C.s")
void Room_DrawType1Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) {
RoomMeshType1* mesh = &room->mesh->type1;
if (mesh->format == 1) {
func_8012DEE8(globalCtx, room, flags);
func_8012DEE8(play, room, flags);
} else if (mesh->format == 2) {
func_8012E32C(globalCtx, room, flags);
func_8012E32C(play, room, flags);
} else {
__assert("../z_room.c", 0x3c5);
}
}
void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) {
void Room_Init(PlayState* play, RoomContext* roomCtx) {
s32 i;
roomCtx->currRoom.num = -1;
roomCtx->currRoom.segment = NULL;
@ -75,7 +75,7 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s")
s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) {
s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) {
if (roomCtx->unk31 == 0) {
s32 size;
@ -84,14 +84,14 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32
roomCtx->currRoom.segment = NULL;
roomCtx->unk31 = 1;
size = globalCtx->roomList[index].vromEnd - globalCtx->roomList[index].vromStart;
size = play->roomList[index].vromEnd - play->roomList[index].vromStart;
roomCtx->activeRoomVram =
(void*)(((s32)roomCtx->roomMemPages[roomCtx->activeMemPage] - (size + 8) * roomCtx->activeMemPage + 8) &
0xfffffff0);
osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, 1);
DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, globalCtx->roomList[index].vromStart,
size, 0, &roomCtx->loadQueue, NULL);
DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, play->roomList[index].vromStart, size, 0,
&roomCtx->loadQueue, NULL);
roomCtx->activeMemPage ^= 1;
return 1;
@ -100,7 +100,7 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32
return 0;
}
s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) {
s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) {
if (roomCtx->unk31 == 1) {
if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) {
roomCtx->unk31 = 0;
@ -108,18 +108,18 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) {
// TODO: Segment number enum
gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram);
Scene_ProcessHeader(globalCtx, (SceneCmd*)roomCtx->currRoom.segment);
func_80123140(globalCtx, GET_PLAYER(globalCtx));
Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
Scene_ProcessHeader(play, (SceneCmd*)roomCtx->currRoom.segment);
func_80123140(play, GET_PLAYER(play));
Actor_SpawnTransitionActors(play, &play->actorCtx);
if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) &&
(globalCtx->sceneNum != SCENE_IKNINSIDE)) {
globalCtx->envCtx.lightSettingOverride = 0xff;
globalCtx->envCtx.unk_E0 = 0;
if (((play->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) &&
(play->sceneNum != SCENE_IKNINSIDE)) {
play->envCtx.lightSettingOverride = 0xff;
play->envCtx.unk_E0 = 0;
}
func_800FEAB0();
if (!func_800FE4B8(globalCtx)) {
func_800FD858(globalCtx);
if (!func_800FE4B8(play)) {
func_800FD858(play);
}
} else {
return 0;
@ -129,23 +129,23 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) {
return 1;
}
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) {
void Room_Draw(PlayState* play, Room* room, u32 flags) {
if (room->segment != NULL) {
// TODO: Segment number enum
gSegments[0x03] = PHYSICAL_TO_VIRTUAL(room->segment);
roomDrawFuncs[room->mesh->type0.type](globalCtx, room, flags);
roomDrawFuncs[room->mesh->type0.type](play, room, flags);
}
return;
}
void func_8012EBF8(GlobalContext* globalCtx, RoomContext* roomCtx) {
void func_8012EBF8(PlayState* play, RoomContext* roomCtx) {
roomCtx->prevRoom.num = -1;
roomCtx->prevRoom.segment = NULL;
func_800BA798(globalCtx, &globalCtx->actorCtx);
Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
func_800BA798(play, &play->actorCtx);
Actor_SpawnTransitionActors(play, &play->actorCtx);
if (-1 < roomCtx->currRoom.num) {
func_8010A33C(globalCtx, roomCtx->currRoom.num);
func_8010A2DC(globalCtx);
func_8010A33C(play, roomCtx->currRoom.num);
func_8010A2DC(play);
}
func_801A3CD8(globalCtx->roomCtx.currRoom.echo);
func_801A3CD8(play->roomCtx.currRoom.echo);
}

View File

@ -23,17 +23,17 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) {
}
void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
PlayState* play = (PlayState*)gameState;
s32 pad;
u32 spaceSize;
s32 i;
if (globalCtx->sceneNum == SCENE_CLOCKTOWER || globalCtx->sceneNum == SCENE_TOWN ||
globalCtx->sceneNum == SCENE_BACKTOWN || globalCtx->sceneNum == SCENE_ICHIBA) {
if (play->sceneNum == SCENE_CLOCKTOWER || play->sceneNum == SCENE_TOWN || play->sceneNum == SCENE_BACKTOWN ||
play->sceneNum == SCENE_ICHIBA) {
spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN;
} else if (globalCtx->sceneNum == SCENE_MILK_BAR) {
} else if (play->sceneNum == SCENE_MILK_BAR) {
spaceSize = OBJECT_SPACE_SIZE_MILK_BAR;
} else if (globalCtx->sceneNum == SCENE_00KEIKOKU) {
} else if (play->sceneNum == SCENE_00KEIKOKU) {
spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD;
} else {
spaceSize = OBJECT_SPACE_SIZE_DEFAULT;
@ -141,45 +141,45 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) {
}
// SceneTableEntry Header Command 0x00: Spawn List
void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) {
s32 loadedCount;
s16 playerObjectId;
void* nextObject;
globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) +
globalCtx->setupEntranceList[globalCtx->curSpawn].spawn;
if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
play->linkActorEntry =
(ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn;
if ((play->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
(gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) {
// Skull Kid Object
Object_Spawn(&globalCtx->objectCtx, OBJECT_STK);
Object_Spawn(&play->objectCtx, OBJECT_STK);
return;
}
loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD);
nextObject = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment;
globalCtx->objectCtx.num = loadedCount;
globalCtx->objectCtx.spawnedObjectCount = loadedCount;
loadedCount = Object_Spawn(&play->objectCtx, OBJECT_LINK_CHILD);
nextObject = play->objectCtx.status[play->objectCtx.num].segment;
play->objectCtx.num = loadedCount;
play->objectCtx.spawnedObjectCount = loadedCount;
playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm];
gActorOverlayTable[0].initInfo->objectId = playerObjectId;
Object_Spawn(&globalCtx->objectCtx, playerObjectId);
Object_Spawn(&play->objectCtx, playerObjectId);
globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment = nextObject;
play->objectCtx.status[play->objectCtx.num].segment = nextObject;
}
// SceneTableEntry Header Command 0x01: Actor List
void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->numSetupActors = cmd->actorList.num;
globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment);
globalCtx->actorCtx.unkC = 0;
void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) {
play->numSetupActors = cmd->actorList.num;
play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment);
play->actorCtx.unkC = 0;
}
// SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes
void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment);
void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd) {
play->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment);
}
// SceneTableEntry Header Command 0x03: Collision Header
void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) {
CollisionHeader* colHeaderTemp;
CollisionHeader* colHeader;
@ -200,55 +200,55 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) {
colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes);
}
BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader);
BgCheck_Allocate(&play->colCtx, play, colHeader);
}
// SceneTableEntry Header Command 0x04: Room List
void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->numRooms = cmd->roomList.num;
globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment);
void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd) {
play->numRooms = cmd->roomList.num;
play->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment);
}
// SceneTableEntry Header Command 0x06: Entrance List
void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment);
void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) {
play->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment);
}
// SceneTableEntry Header Command 0x07: Special Files
void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) {
static RomFile tatlMessageFiles[2] = {
{ SEGMENT_ROM_START(elf_message_field), SEGMENT_ROM_END(elf_message_field) },
{ SEGMENT_ROM_START(elf_message_ydan), SEGMENT_ROM_END(elf_message_ydan) },
};
if (cmd->specialFiles.subKeepIndex != 0) {
globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.subKeepIndex);
play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.subKeepIndex);
// TODO: Segment number enum?
gSegments[0x05] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
gSegments[0x05] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment);
}
if (cmd->specialFiles.cUpElfMsgNum != 0) {
globalCtx->unk_18868 = Play_LoadScene(globalCtx, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
play->unk_18868 = Play_LoadScene(play, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
}
}
// SceneTableEntry Header Command 0x08: Room Behavior
void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1;
globalCtx->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF;
globalCtx->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
globalCtx->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1;
globalCtx->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1;
globalCtx->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1;
void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) {
play->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1;
play->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF;
play->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1;
play->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1;
play->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1;
}
// SceneTableEntry Header Command 0x0A: Mesh Header
void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment);
void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) {
play->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment);
}
// SceneTableEntry Header Command 0x0B: Object List
void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) {
s32 i;
s32 j;
s32 k;
@ -260,21 +260,21 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment);
k = 0;
i = globalCtx->objectCtx.spawnedObjectCount;
status = &globalCtx->objectCtx.status[i];
firstObject = globalCtx->objectCtx.status;
i = play->objectCtx.spawnedObjectCount;
status = &play->objectCtx.status[i];
firstObject = play->objectCtx.status;
while (i < globalCtx->objectCtx.num) {
while (i < play->objectCtx.num) {
if (status->id != *objectEntry) {
status2 = &globalCtx->objectCtx.status[i];
status2 = &play->objectCtx.status[i];
for (j = i; j < globalCtx->objectCtx.num; j++) {
for (j = i; j < play->objectCtx.num; j++) {
status2->id = 0;
status2++;
}
globalCtx->objectCtx.num = i;
func_800BA6FC(globalCtx, &globalCtx->actorCtx);
play->objectCtx.num = i;
func_800BA6FC(play, &play->actorCtx);
continue;
}
@ -286,7 +286,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
}
while (k < cmd->objectList.num) {
nextPtr = func_8012F73C(&globalCtx->objectCtx, i, *objectEntry);
nextPtr = func_8012F73C(&play->objectCtx, i, *objectEntry);
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
firstObject[i + 1].segment = nextPtr;
@ -297,30 +297,30 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
objectEntry++;
}
globalCtx->objectCtx.num = i;
play->objectCtx.num = i;
}
// SceneTableEntry Header Command 0x0C: Light List
void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) {
s32 i;
LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment);
for (i = 0; i < cmd->lightList.num; i++) {
LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo);
LightContext_InsertLight(play, &play->lightCtx, lightInfo);
lightInfo++;
}
}
// SceneTableEntry Header Command 0x0D: Path List
void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment);
void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd) {
play->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment);
}
// SceneTableEntry Header Command 0x0E: Transition Actor List
void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->doorCtx.numTransitionActors = cmd->transiActorList.num;
globalCtx->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment);
func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList);
void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd) {
play->doorCtx.numTransitionActors = cmd->transiActorList.num;
play->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment);
func_80105818(play, play->doorCtx.numTransitionActors, play->doorCtx.transitionActorList);
}
// Init function for the transition system.
@ -329,16 +329,16 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) {
}
// SceneTableEntry Header Command 0x0F: Environment Light Settings List
void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num;
globalCtx->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment);
void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd) {
play->envCtx.numLightSettings = cmd->lightSettingList.num;
play->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment);
}
/**
* Loads different texture files for each region of the world.
* These later are stored in segment 0x06, and used in maps.
*/
void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) {
static RomFile sceneTextureFiles[9] = {
{ 0, 0 }, // Default
{ SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) },
@ -354,51 +354,51 @@ void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
if (size != 0) {
globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size);
DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size);
play->roomCtx.unk74 = THA_AllocEndAlign16(&play->state.heap, size);
DmaMgr_SendRequest0(play->roomCtx.unk74, vromStart, size);
}
}
// SceneTableEntry Header Command 0x11: Skybox Settings
void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->skyboxId = cmd->skyboxSettings.skyboxId & 3;
globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk5;
globalCtx->envCtx.unk_1E = cmd->skyboxSettings.unk6;
Scene_LoadAreaTextures(globalCtx, cmd->skyboxSettings.data1);
void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) {
play->skyboxId = cmd->skyboxSettings.skyboxId & 3;
play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk5;
play->envCtx.unk_1E = cmd->skyboxSettings.unk6;
Scene_LoadAreaTextures(play, cmd->skyboxSettings.data1);
}
// SceneTableEntry Header Command 0x12: Skybox Disables
void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4;
globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5;
void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd) {
play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4;
play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5;
}
// SceneTableEntry Header Command 0x10: Time Settings
void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) {
if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) {
gSaveContext.environmentTime = gSaveContext.save.time =
(u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f);
}
if (cmd->timeSettings.unk6 != 0xFF) {
globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk6;
play->envCtx.timeIncrement = cmd->timeSettings.unk6;
} else {
globalCtx->envCtx.timeIncrement = 0;
play->envCtx.timeIncrement = 0;
}
if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) {
globalCtx->envCtx.timeIncrement = 5;
if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.timeIncrement != 0)) {
play->envCtx.timeIncrement = 5;
}
if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) {
REG(15) = globalCtx->envCtx.timeIncrement;
REG(15) = play->envCtx.timeIncrement;
}
globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f;
play->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
play->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
play->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f;
if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) {
if (play->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) {
gSaveContext.environmentTime = gSaveContext.save.time;
if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) {
@ -417,30 +417,30 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x05: Wind Settings
void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) {
s8 temp1 = cmd->windSettings.west;
s8 temp2 = cmd->windSettings.vertical;
s8 temp3 = cmd->windSettings.south;
globalCtx->envCtx.windDir.x = temp1;
globalCtx->envCtx.windDir.y = temp2;
globalCtx->envCtx.windDir.z = temp3;
globalCtx->envCtx.windSpeed = cmd->windSettings.clothIntensity;
play->envCtx.windDir.x = temp1;
play->envCtx.windDir.y = temp2;
play->envCtx.windDir.z = temp3;
play->envCtx.windSpeed = cmd->windSettings.clothIntensity;
}
// SceneTableEntry Header Command 0x13: Exit List
void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment);
void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd) {
play->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment);
}
// SceneTableEntry Header Command 0x09: Undefined
void Scene_HeaderCmd09(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x15: Sound Settings=
void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq;
globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX;
void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) {
play->soundCtx.seqIndex = cmd->soundSettings.musicSeq;
play->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX;
if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) {
audio_setBGM(cmd->soundSettings.bgmId);
@ -448,12 +448,12 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x16: Echo Setting
void Scene_HeaderCmdEchoSetting(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->roomCtx.currRoom.echo = cmd->echoSettings.echo;
void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) {
play->roomCtx.currRoom.echo = cmd->echoSettings.echo;
}
// SceneTableEntry Header Command 0x18: Alternate Header List=
void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) {
SceneCmd** altHeaderList;
SceneCmd* altHeader;
@ -462,40 +462,40 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) {
altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1];
if (altHeader != NULL) {
Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader));
Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader));
(cmd + 1)->base.code = 0x14;
}
}
}
// SceneTableEntry Header Command 0x17: Cutscene List
void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->csCtx.sceneCsCount = cmd->base.data1;
globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2);
void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd) {
play->csCtx.sceneCsCount = cmd->base.data1;
play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2);
}
// SceneTableEntry Header Command 0x1B: Actor Cutscene List
void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num);
void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd) {
ActorCutscene_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num);
}
// SceneTableEntry Header Command 0x1C: Mini Maps
void Scene_HeaderCmdMiniMap(GlobalContext* globalCtx, SceneCmd* cmd) {
func_80104CF4(globalCtx);
func_8010549C(globalCtx, cmd->minimapSettings.segment);
void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd) {
func_80104CF4(play);
func_8010549C(play, cmd->minimapSettings.segment);
}
// SceneTableEntry Header Command 0x1D: Undefined
void Scene_HeaderCmd1D(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x1E: Minimap Compass Icon Info
void Scene_HeaderCmdMiniMapCompassInfo(GlobalContext* globalCtx, SceneCmd* cmd) {
func_8010565C(globalCtx, cmd->minimapChests.num, cmd->minimapChests.segment);
void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) {
func_8010565C(play, cmd->minimapChests.num, cmd->minimapChests.segment);
}
// SceneTableEntry Header Command 0x1A: Sets Area Visited Flag
void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) {
void Scene_HeaderCmdSetAreaVisitedFlag(PlayState* play, SceneCmd* cmd) {
s16 j = 0;
s16 i = 0;
@ -509,7 +509,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd)
}
}
if (globalCtx->sceneNum == gScenesPerRegion[i][j]) {
if (play->sceneNum == gScenesPerRegion[i][j]) {
break;
}
@ -522,22 +522,22 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd)
}
// SceneTableEntry Header Command 0x1A: Material Animations
void Scene_HeaderCmdAnimatedMaterials(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment);
void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) {
play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment);
}
/**
* Sets the exit fade from the next entrance index.
*/
void Scene_SetExitFade(GlobalContext* globalCtx) {
globalCtx->unk_1887F = Entrance_GetTransitionFlags(globalCtx->nextEntranceIndex) & 0x7F;
void Scene_SetExitFade(PlayState* play) {
play->unk_1887F = Entrance_GetTransitionFlags(play->nextEntranceIndex) & 0x7F;
}
/**
* Executes all of the commands in a scene or room header.
*/
s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) {
static void (*sceneCmdHandlers[])(GlobalContext*, SceneCmd*) = {
s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) {
static void (*sceneCmdHandlers[])(PlayState*, SceneCmd*) = {
Scene_HeaderCmdSpawnList,
Scene_HeaderCmdActorList,
Scene_HeaderCmdActorCutsceneCamList,
@ -580,7 +580,7 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) {
}
if (cmdId < SCENE_CMD_MAX) {
sceneCmdHandlers[cmdId](globalCtx, header);
sceneCmdHandlers[cmdId](play, header);
}
header++;

View File

@ -22,8 +22,8 @@ static Gfx sSceneDrawDefaultDL[] = {
/**
* Executes the current scene draw config handler.
*/
void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) {
static void (*sceneDrawConfigHandlers[])(GlobalContext*) = {
void Scene_ExecuteDrawConfig(PlayState* play) {
static void (*sceneDrawConfigHandlers[])(PlayState*) = {
Scene_DrawConfigDefault,
Scene_DrawConfigMatAnim,
Scene_DrawConfigDoNothing,
@ -34,27 +34,27 @@ void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) {
Scene_DrawConfigMatAnimManualStep,
};
sceneDrawConfigHandlers[globalCtx->sceneConfig](globalCtx);
sceneDrawConfigHandlers[play->sceneConfig](play);
}
/**
* SceneTableEntry Draw Config 0:
* Default scene draw config function. This just executes `sSceneDrawDefaultDL`.
*/
void Scene_DrawConfigDefault(GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
void Scene_DrawConfigDefault(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gSPDisplayList(POLY_OPA_DISP++, sSceneDrawDefaultDL);
gSPDisplayList(POLY_XLU_DISP++, sSceneDrawDefaultDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Returns a pointer to a single layer texture scroll displaylist.
*/
Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) {
return Gfx_TexScroll(globalCtx->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep),
Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params) {
return Gfx_TexScroll(play->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep),
params->width, params->height);
}
@ -62,11 +62,11 @@ Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams*
* Animated Material Type 0:
* Scrolls a single layer texture using the provided `AnimatedMatTexScrollParams`.
*/
void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params) {
AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params;
Gfx* texScrollDList = AnimatedMat_TexScroll(globalCtx, texScrollParams);
Gfx* texScrollDList = AnimatedMat_TexScroll(play, texScrollParams);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, texScrollDList);
@ -76,28 +76,27 @@ void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* para
gSPSegment(POLY_XLU_DISP++, segment, texScrollDList);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Returns a pointer to a two layer texture scroll displaylist.
*/
Gfx* AnimatedMat_TwoLayerTexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) {
return Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, params[0].xStep * sMatAnimStep,
-(params[0].yStep * sMatAnimStep), params[0].width, params[0].height, 1,
params[1].xStep * sMatAnimStep, -(params[1].yStep * sMatAnimStep), params[1].width,
params[1].height);
Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params) {
return Gfx_TwoTexScroll(play->state.gfxCtx, 0, params[0].xStep * sMatAnimStep, -(params[0].yStep * sMatAnimStep),
params[0].width, params[0].height, 1, params[1].xStep * sMatAnimStep,
-(params[1].yStep * sMatAnimStep), params[1].width, params[1].height);
}
/**
* Animated Material Type 1:
* Scrolls a two layer texture using the provided `AnimatedMatTexScrollParams`.
*/
void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params) {
AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params;
Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(globalCtx, texScrollParams);
Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(play, texScrollParams);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, texScrollDList);
@ -107,16 +106,16 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p
gSPSegment(POLY_XLU_DISP++, segment, texScrollDList);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID.
*/
void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) {
Gfx* colorDList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4);
void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) {
Gfx* colorDList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
// clang-format off
if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, colorDList); }
@ -132,14 +131,14 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p
gSPEndDisplayList(colorDList++);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Animated Material Type 2:
* Color key frame animation without linear interpolation.
*/
void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColor;
@ -150,7 +149,7 @@ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params)
? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame
: NULL;
AnimatedMat_SetColor(globalCtx, segment, primColor, envColor);
AnimatedMat_SetColor(play, segment, primColor, envColor);
}
/**
@ -164,7 +163,7 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) {
* Animated Material Type 3:
* Color key frame animation with linear interpolation.
*/
void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColorMax;
@ -216,7 +215,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para
envColorMax = NULL;
}
AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL);
AnimatedMat_SetColor(play, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL);
}
/**
@ -277,7 +276,7 @@ u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp) {
* Animated Material Type 4:
* Color key frame animation with non-linear interpolation.
*/
void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColorCur = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColorCur = Lib_SegmentedToVirtual(colorAnimParams->envColors);
@ -355,21 +354,21 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment,
envColorCur = NULL;
}
AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL);
AnimatedMat_SetColor(play, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL);
}
/**
* Animated Material Type 5:
* Cycles between a list of textures (imagine like a GIF)
*/
void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) {
void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params) {
AnimatedMatTexCycleParams* texAnimParams = params;
void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList);
u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList);
s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength;
void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, tex);
@ -379,15 +378,15 @@ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* param
gSPSegment(POLY_XLU_DISP++, segment, tex);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* This is the main function that handles the animated material system.
* There are six different animated material types, which should be set in the provided `AnimatedMaterial`.
*/
void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) {
static void (*matAnimDrawHandlers[])(GlobalContext*, s32 segment, void* params) = {
void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) {
static void (*matAnimDrawHandlers[])(PlayState*, s32 segment, void* params) = {
AnimatedMat_DrawTexScroll, AnimatedMat_DrawTwoTexScroll, AnimatedMat_DrawColor,
AnimatedMat_DrawColorLerp, AnimatedMat_DrawColorNonLinearInterp, AnimatedMat_DrawTexCycle,
};
@ -402,7 +401,7 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f
do {
segment = matAnim->segment;
segmentAbs = ((segment < 0) ? -segment : segment) + 7;
matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params));
matAnimDrawHandlers[matAnim->type](play, segmentAbs, Lib_SegmentedToVirtual(matAnim->params));
matAnim++;
} while (segment >= 0);
}
@ -411,123 +410,123 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f
/**
* Draws an animated material to both OPA and XLU buffers.
*/
void AnimatedMat_Draw(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 3);
void AnimatedMat_Draw(PlayState* play, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 3);
}
/**
* Draws an animated material to only the OPA buffer.
*/
void AnimatedMat_DrawOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 1);
void AnimatedMat_DrawOpa(PlayState* play, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 1);
}
/**
* Draws an animated material to only the XLU buffer.
*/
void AnimatedMat_DrawXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 2);
void AnimatedMat_DrawXlu(PlayState* play, AnimatedMaterial* matAnim) {
AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 2);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) both OPA and XLU buffers.
*/
void AnimatedMat_DrawAlpha(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 3);
void AnimatedMat_DrawAlpha(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 3);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) to only the OPA buffer.
*/
void AnimatedMat_DrawAlphaOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 1);
void AnimatedMat_DrawAlphaOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 1);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) to only the XLU buffer.
*/
void AnimatedMat_DrawAlphaXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 2);
void AnimatedMat_DrawAlphaXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 2);
}
/**
* Draws an animated material with a step to both the OPA and XLU buffers.
*/
void AnimatedMat_DrawStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) {
AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 3);
void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step) {
AnimatedMat_DrawMain(play, matAnim, 1, step, 3);
}
/**
* Draws an animated material with a step to only the OPA buffer.
*/
void AnimatedMat_DrawStepOpa(GlobalContext* globalCtx, AnimatedMaterial* textures, u32 step) {
AnimatedMat_DrawMain(globalCtx, textures, 1, step, 1);
void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* textures, u32 step) {
AnimatedMat_DrawMain(play, textures, 1, step, 1);
}
/**
* Draws an animated material with a step to only the XLU buffer.
*/
void AnimatedMat_DrawStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) {
AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 2);
void AnimatedMat_DrawStepXlu(PlayState* play, AnimatedMaterial* matAnim, u32 step) {
AnimatedMat_DrawMain(play, matAnim, 1, step, 2);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to both the OPA and XLU buffers.
*/
void AnimatedMat_DrawAlphaStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 3);
void AnimatedMat_DrawAlphaStep(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 3);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the OPA buffer.
*/
void AnimatedMat_DrawAlphaStepOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 1);
void AnimatedMat_DrawAlphaStepOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 1);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the XLU buffer.
*/
void AnimatedMat_DrawAlphaStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 2);
void AnimatedMat_DrawAlphaStepXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 2);
}
/**
* SceneTableEntry Draw Config 1:
* Allows the usage of the animated material system in scenes.
*/
void Scene_DrawConfigMatAnim(GlobalContext* globalCtx) {
AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
void Scene_DrawConfigMatAnim(PlayState* play) {
AnimatedMat_Draw(play, play->sceneMaterialAnims);
}
/**
* SceneTableEntry Draw Config 3:
* This config is unused, although it is identical to the grotto scene config from Ocarina of Time.
*/
void Scene_DrawConfig3(GlobalContext* globalCtx) {
void Scene_DrawConfig3(PlayState* play) {
u32 frames;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
frames = globalCtx->gameplayFrames;
frames = play->gameplayFrames;
gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 64, 256, 16));
gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 64, 256, 16));
gSPSegment(POLY_XLU_DISP++, 0x09,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1,
frames % 128, (frames * 1) % 128, 32, 32));
gSPSegment(POLY_OPA_DISP++, 0x0A,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32));
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32));
gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 128, 32, 32));
gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 128, 32, 32));
gSPSegment(POLY_XLU_DISP++, 0x0C,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048,
8, 512));
gSPSegment(
POLY_XLU_DISP++, 0x0C,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048, 8, 512));
gSPSegment(POLY_OPA_DISP++, 0x0D,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32));
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32));
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
@ -535,7 +534,7 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
@ -543,16 +542,16 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) {
* This config is unused and just has a single TwoTexScroll intended for two 32x32 textures (likely two water textures).
* It is identical to the Castle Courtyard and Sacred Forest Meadow scene config from Ocarina of Time.
*/
void Scene_DrawConfig4(GlobalContext* globalCtx) {
void Scene_DrawConfig4(PlayState* play) {
u32 frames;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
frames = globalCtx->gameplayFrames;
frames = play->gameplayFrames;
gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1,
frames % 128, (frames * 1) % 128, 32, 32));
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1, frames % 128,
(frames * 1) % 128, 32, 32));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
@ -560,20 +559,20 @@ void Scene_DrawConfig4(GlobalContext* globalCtx) {
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* SceneTableEntry Draw Config 2:
* Has no effect, and is only used in SPOT00 (cutscene scene).
*/
void Scene_DrawConfigDoNothing(GlobalContext* globalCtx) {
void Scene_DrawConfigDoNothing(PlayState* play) {
}
/**
* Stores a displaylist in the provided segment ID that sets a render mode from the index provided.
*/
void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
void Scene_SetRenderModeXlu(PlayState* play, s32 index, u32 flags) {
static Gfx renderModeSetNoneDL[] = {
gsSPEndDisplayList(),
// These instructions will never get executed
@ -612,7 +611,7 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
};
Gfx* dList = dLists[index];
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (flags & 1) {
gSPSegment(POLY_OPA_DISP++, 0x0C, dList);
@ -622,14 +621,14 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
gSPSegment(POLY_XLU_DISP++, 0x0C, dList);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Although this function is unused, it will store a displaylist in the provided segment ID that sets the culling mode
* from the index provided.
*/
void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
void Scene_SetCullFlag(PlayState* play, s32 index, u32 flags) {
static Gfx setBackCullDL[] = {
gsSPSetGeometryMode(G_CULL_BACK),
gsSPEndDisplayList(),
@ -644,7 +643,7 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
};
Gfx* dList = dLists[index];
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (flags & 1) {
gSPSegment(POLY_OPA_DISP++, 0x0C, dList);
@ -654,37 +653,37 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
gSPSegment(POLY_XLU_DISP++, 0x0C, dList);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
/**
* SceneTableEntry Draw Config 5:
* This config is unused, and its purpose is unknown.
*/
void Scene_DrawConfig5(GlobalContext* globalCtx) {
void Scene_DrawConfig5(PlayState* play) {
u32 dListIndex;
u32 alpha;
if (globalCtx->roomCtx.unk7A[0] != 0) {
if (play->roomCtx.unk7A[0] != 0) {
dListIndex = 1;
alpha = globalCtx->roomCtx.unk7A[1];
alpha = play->roomCtx.unk7A[1];
} else {
dListIndex = 0;
alpha = 255;
}
if (alpha == 0) {
globalCtx->roomCtx.unk78 = 0;
play->roomCtx.unk78 = 0;
} else {
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
globalCtx->roomCtx.unk78 = 1;
AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
Scene_SetRenderModeXlu(globalCtx, dListIndex, 3);
play->roomCtx.unk78 = 1;
AnimatedMat_Draw(play, play->sceneMaterialAnims);
Scene_SetRenderModeXlu(play, dListIndex, 3);
gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, alpha);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}
@ -693,8 +692,8 @@ void Scene_DrawConfig5(GlobalContext* globalCtx) {
* This is a special draw config for Sakon's Hideout, as well as the Music Box House. Its step value is set manually
* rather than always animating like `Scene_DrawConfigMatAnim`.
*/
void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) {
AnimatedMat_DrawStep(globalCtx, globalCtx->sceneMaterialAnims, globalCtx->roomCtx.unk7A[0]);
void Scene_DrawConfigMatAnimManualStep(PlayState* play) {
AnimatedMat_DrawStep(play, play->sceneMaterialAnims, play->roomCtx.unk7A[0]);
}
/**
@ -703,7 +702,7 @@ void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) {
* fraction to a certain value when certain flags are set, which are likely used for the pipes whenever they are
* activated.
*/
void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
void Scene_DrawConfigGreatBayTemple(PlayState* play) {
static Gfx greatBayTempleColorSetDL[] = {
gsDPSetPrimColor(0, 255, 255, 255, 255, 255),
gsSPEndDisplayList(),
@ -713,18 +712,18 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
Gfx* dListHead;
Gfx* dList;
if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) &&
Flags_GetSwitch(globalCtx, 0x36)) {
BgCheck_SetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) &&
Flags_GetSwitch(play, 0x36)) {
BgCheck_SetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
} else {
BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
BgCheck_UnsetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
}
dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18);
dList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 18);
AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
AnimatedMat_Draw(play, play->sceneMaterialAnims);
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
for (dListHead = dList, i = 0; i < 9; i++, dListHead += 2) {
lodFrac = 0;
@ -733,50 +732,48 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
switch (i) {
case 0:
if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) &&
Flags_GetSwitch(globalCtx, 0x35) && Flags_GetSwitch(globalCtx, 0x36)) {
if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) &&
Flags_GetSwitch(play, 0x36)) {
lodFrac = 255;
}
break;
case 1:
if (Flags_GetSwitch(globalCtx, 0x37)) {
if (Flags_GetSwitch(play, 0x37)) {
lodFrac = 68;
}
break;
case 2:
if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38)) {
if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38)) {
lodFrac = 68;
}
break;
case 3:
if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38) &&
Flags_GetSwitch(globalCtx, 0x39)) {
if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38) && Flags_GetSwitch(play, 0x39)) {
lodFrac = 68;
}
break;
case 4:
if (!(Flags_GetSwitch(globalCtx, 0x33))) {
if (!(Flags_GetSwitch(play, 0x33))) {
lodFrac = 68;
}
break;
case 5:
if (Flags_GetSwitch(globalCtx, 0x34)) {
if (Flags_GetSwitch(play, 0x34)) {
lodFrac = 68;
}
break;
case 6:
if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35)) {
if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35)) {
lodFrac = 68;
}
break;
case 7:
if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) &&
Flags_GetSwitch(globalCtx, 0x36)) {
if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && Flags_GetSwitch(play, 0x36)) {
lodFrac = 68;
}
break;
case 8:
if (Flags_GetSwitch(globalCtx, 0x3A)) {
if (Flags_GetSwitch(play, 0x3A)) {
lodFrac = 68;
}
break;
@ -788,5 +785,5 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
gSPSegment(POLY_OPA_DISP++, 0x06, dList);
gSPSegment(POLY_XLU_DISP++, 0x06, dList);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -6,7 +6,7 @@
(dest) = (temp) * (0x10000 / 60 / 24.0f); \
(dest) = SCHEDULE_CONVERT_TIME(dest);
s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script;
u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
@ -17,7 +17,7 @@ s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return false;
}
s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script;
u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
@ -28,7 +28,7 @@ s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return false;
}
s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleResult* result) {
s32 inRange = false;
ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script;
f32 f;
@ -54,7 +54,7 @@ s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResu
return false;
}
s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleResult* result) {
s32 inRange = false;
ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script;
f32 f;
@ -80,7 +80,7 @@ s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResu
return false;
}
s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_ReturnValueL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script;
//! @bug result is a u8, value is truncated
@ -90,36 +90,36 @@ s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult*
return true;
}
s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleResult* result) {
result->hasResult = false;
return true;
}
s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleResult* result) {
result->hasResult = true;
return true;
}
s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_Nop(PlayState* play, u8** script, ScheduleResult* result) {
return false;
}
s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script;
if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) ||
((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) &&
(INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) ||
((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) {
((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(play) == PLAYER_MASK_ROMANI))) {
*script += cmd->offset;
}
return false;
}
s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script;
result->result = cmd->result;
@ -128,29 +128,29 @@ s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult*
return true;
}
s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script;
s16 scene = (cmd->sceneH << 8) | cmd->sceneL;
if (scene != globalCtx->sceneNum) {
if (scene != play->sceneNum) {
*script += cmd->offset;
}
return false;
}
s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script;
s16 scene = (cmd->sceneH << 8) | cmd->sceneL;
if (scene != globalCtx->sceneNum) {
if (scene != play->sceneNum) {
*script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL);
}
return false;
}
s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script;
s16 day = (cmd->dayH << 8) | cmd->dayL;
@ -161,7 +161,7 @@ s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResul
return false;
}
s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script;
s16 day = (cmd->dayH << 8) | cmd->dayL;
@ -172,7 +172,7 @@ s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResul
return false;
}
s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script;
f32 f;
u16 time0;
@ -191,7 +191,7 @@ s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return true;
}
s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script;
f32 f;
u16 testTime;
@ -208,7 +208,7 @@ s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleRes
return false;
}
s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script;
f32 f;
u16 testTime;
@ -225,21 +225,21 @@ s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleRes
return false;
}
s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_BranchS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script;
*script += cmd->offset;
return false;
}
s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script;
*script += (s16)((cmd->offsetH << 8) | cmd->offsetL);
return false;
}
static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = {
static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleResult*) = {
Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL,
Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop,
Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL,
@ -269,13 +269,13 @@ static u8 sScheduleCmdSizes[] = {
sizeof(ScheduleCmdBranchL),
};
s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) {
s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleResult* result) {
u8 size;
s32 stop;
do {
size = sScheduleCmdSizes[*script];
stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result);
stop = (*sScheduleCmdFuncs[*script])(play, &script, result);
script += size;
} while (!stop);

File diff suppressed because it is too large Load Diff

View File

@ -182,11 +182,11 @@ void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dLis
CLOSE_DISPS(gfxCtx);
}
void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
void Skin_DrawImpl(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw,
SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) {
s32 i;
SkinLimb** skeleton;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
GraphicsContext* gfxCtx = play->state.gfxCtx;
OPEN_DISPS(gfxCtx);
@ -212,7 +212,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD
s32 segmentType;
if (overrideLimbDraw != NULL) {
shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin);
shouldDraw = overrideLimbDraw(actor, play, i, skin);
}
segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType;
@ -225,7 +225,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD
}
if (postDraw != NULL) {
postDraw(actor, globalCtx, skin);
postDraw(actor, play, skin);
}
close_disps:;
@ -233,26 +233,26 @@ close_disps:;
}
// allows specifying postDraw and setTranslation
void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) {
Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0);
void func_80138228(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) {
Skin_DrawImpl(actor, play, skin, postDraw, NULL, setTranslation, false, 0);
}
// allows specifying OverrideLimbDraw, postDraw and setTranslation
void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
void func_80138258(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw,
SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) {
Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0);
Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, false, 0);
}
// allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6
void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
void func_8013828C(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw,
SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) {
Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0);
Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0);
}
// allows specifying all variables
void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
void func_801382C4(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw,
SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) {
Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags);
Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags);
}
void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) {

View File

@ -105,7 +105,7 @@ void Skin_Free(GameState* gameState, Skin* skin) {
ZeldaArena_Free(skin->vtxTable);
}
SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState);
SkelAnime_Free(&skin->skelAnime, (PlayState*)gameState);
}
}

View File

@ -2,10 +2,10 @@
typedef struct {
Actor actor;
s32 (*pictoFunc)(GlobalContext* globalCtx, Actor* actor);
s32 (*pictoFunc)(PlayState* play, Actor* actor);
} PictoActor;
s32 func_8013A240(GlobalContext* globalCtx) {
s32 func_8013A240(PlayState* play) {
PictoActor* pictoActor;
Actor* actor;
s32 type = 0;
@ -15,15 +15,15 @@ s32 func_8013A240(GlobalContext* globalCtx) {
gSaveContext.save.pictoFlags0 = 0;
gSaveContext.save.pictoFlags1 = 0;
if (globalCtx->sceneNum == SCENE_20SICHITAI) {
if (play->sceneNum == SCENE_20SICHITAI) {
func_8013A41C(1);
}
for (; type < 12; type++) {
for (actor = globalCtx->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) {
for (actor = play->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) {
seen = 0;
switch (globalCtx->sceneNum) {
switch (play->sceneNum) {
case SCENE_20SICHITAI:
if ((actor->id == ACTOR_EN_MNK) || (actor->id == ACTOR_EN_BIGOKUTA)) {
seen = 1;
@ -63,7 +63,7 @@ s32 func_8013A240(GlobalContext* globalCtx) {
if (seen != 0) {
pictoActor = (PictoActor*)actor;
if (pictoActor->pictoFunc != NULL) {
if ((pictoActor->pictoFunc)(globalCtx, actor) == 0) {
if ((pictoActor->pictoFunc)(play, actor) == 0) {
count++;
}
}
@ -107,14 +107,14 @@ s16 func_8013A504(s16 val) {
return (val >= 0) ? val : -val;
}
s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin,
f32 distanceMax, s16 angleError) {
s32 func_8013A530(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax,
s16 angleError) {
Vec3f screenSpace;
s16 x;
s16 y;
f32 distance;
CollisionPoly* poly;
Camera* camera = GET_ACTIVE_CAM(globalCtx);
Camera* camera = GET_ACTIVE_CAM(play);
Actor* actors[2];
s32 ret = 0;
s32 bgId;
@ -132,7 +132,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos,
ret |= 0x3E;
}
Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance);
Actor_GetProjectedPos(play, pos, &screenSpace, &distance);
x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85;
y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67;
if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) {
@ -140,15 +140,15 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos,
ret |= 0x3D;
}
if (BgCheck_ProjectileLineTest(&globalCtx->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true,
if (BgCheck_ProjectileLineTest(&play->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true,
&bgId)) {
func_8013A41C(0x3C);
ret |= 0x3C;
}
actors[0] = actor;
actors[1] = &GET_PLAYER(globalCtx)->actor;
if (CollisionCheck_LineOCCheck(globalCtx, &globalCtx->colChkCtx, pos, &camera->eye, actors, 2)) {
actors[1] = &GET_PLAYER(play)->actor;
if (CollisionCheck_LineOCCheck(play, &play->colChkCtx, pos, &camera->eye, actors, 2)) {
func_8013A41C(0x3B);
ret |= 0x3B;
}

View File

@ -1,24 +1,24 @@
#include "global.h"
void SoundSource_InitAll(GlobalContext* globalCtx) {
SoundSource* sources = &globalCtx->soundSources[0];
void SoundSource_InitAll(PlayState* play) {
SoundSource* sources = &play->soundSources[0];
s32 i;
// clang-format off
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; }
for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { sources[i].countdown = 0; }
// clang-format on
}
void SoundSource_UpdateAll(GlobalContext* globalCtx) {
SoundSource* source = &globalCtx->soundSources[0];
void SoundSource_UpdateAll(PlayState* play) {
SoundSource* source = &play->soundSources[0];
s32 i;
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) {
if (source->countdown != 0) {
if (DECR(source->countdown) == 0) {
Audio_StopSfxByPos(&source->projectedPos);
} else {
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
if (source->playSfxEachFrame) {
Audio_PlaySfxAtPos(&source->projectedPos, source->sfxId);
}
@ -29,15 +29,15 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx) {
}
}
void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) {
void SoundSource_Add(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) {
s32 countdown;
SoundSource* source;
s32 smallestCountdown = 0xFFFF;
SoundSource* backupSource = NULL;
s32 i;
source = &globalCtx->soundSources[0];
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
source = &play->soundSources[0];
for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) {
if (source->countdown == 0) {
break;
}
@ -52,7 +52,7 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1
}
// If no sound source is available, replace the sound source with the smallest remaining countdown
if (i >= ARRAY_COUNT(globalCtx->soundSources)) {
if (i >= ARRAY_COUNT(play->soundSources)) {
source = backupSource;
Audio_StopSfxByPos(&source->projectedPos);
}
@ -62,14 +62,14 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1
source->playSfxEachFrame = playSfxEachFrame;
source->sfxId = sfxId;
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
Audio_PlaySfxAtPos(&source->projectedPos, sfxId);
}
void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) {
SoundSource_Add(globalCtx, worldPos, duration, sfxId, false);
void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) {
SoundSource_Add(play, worldPos, duration, sfxId, false);
}
void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) {
SoundSource_Add(globalCtx, worldPos, duration, sfxId, true);
void SoundSource_PlaySfxEachFrameAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) {
SoundSource_Add(play, worldPos, duration, sfxId, true);
}

View File

@ -226,7 +226,7 @@ void Sram_ClearFlagsAtDawnOfTheFirstDay(void) {
/**
* Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene
*/
void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
void Sram_SaveEndOfCycle(PlayState* play) {
s16 sceneNum;
s32 j;
s32 i;
@ -243,14 +243,14 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
gSaveContext.save.playerData.deaths = 999;
}
sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum);
Play_SaveCycleSceneFlags(&globalCtx->state);
sceneNum = Play_GetOriginalSceneNumber(play->sceneNum);
Play_SaveCycleSceneFlags(&play->state);
globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2];
globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0];
globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1];
globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3];
globalCtx->actorCtx.flags.clearedRoom = 0;
play->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2];
play->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0];
play->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1];
play->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3];
play->actorCtx.flags.clearedRoom = 0;
for (i = 0; i < SCENE_MAX; i++) {
gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0];
@ -346,7 +346,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
for (j = 1; j < 4; j++) {
if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) {
SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE);
func_80112B40(globalCtx, j);
func_80112B40(play, j);
}
}
gSaveContext.save.inventory.items[i] = ITEM_BOTTLE;
@ -415,7 +415,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
for (j = 1; j < 4; j++) {
if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) {
SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE);
func_80112B40(globalCtx, j);
func_80112B40(play, j);
}
}
@ -446,7 +446,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
gSaveContext.jinxTimer = 0;
gSaveContext.rupeeAccumulator = 0;
func_800F3B2C(globalCtx);
func_800F3B2C(play);
}
void Sram_IncrementDay(void) {
@ -1519,9 +1519,9 @@ void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) {
/**
* Saves the game on the very first time Player enters South Clock Town from the Clock Tower
*/
void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) {
void Sram_SaveSpecialEnterClockTown(PlayState* play) {
s32 pad[2];
SramContext* sramCtx = &globalCtx->sramCtx;
SramContext* sramCtx = &play->sramCtx;
gSaveContext.save.isFirstCycle = true;
gSaveContext.save.isOwlSave = false;
@ -1532,7 +1532,7 @@ void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) {
/**
* Saves when beating the game, after showing the "Dawn of the New Day" message
*/
void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) {
void Sram_SaveSpecialNewDay(PlayState* play) {
s32 cutscene = gSaveContext.save.cutscene;
s32 day;
u16 time = gSaveContext.save.time;
@ -1542,14 +1542,13 @@ void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) {
// Unconfirmed: "Obtained Fierce Deity Mask?"
gSaveContext.save.weekEventReg[84] &= (u8)~0x20;
Sram_SaveEndOfCycle(globalCtx);
func_8014546C(&globalCtx->sramCtx);
Sram_SaveEndOfCycle(play);
func_8014546C(&play->sramCtx);
gSaveContext.save.day = day;
gSaveContext.save.time = time;
gSaveContext.save.cutscene = cutscene;
func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2],
D_801C67F0[gSaveContext.fileNum * 2]);
func_80185F64(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]);
}
void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) {

View File

@ -17,12 +17,12 @@ s32 D_801C5DBC[] = { 0, 1 }; // Unused
/**
* Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag.
*/
EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) {
EnDoor* SubS_FindDoor(PlayState* play, s32 switchFlag) {
Actor* actor = NULL;
EnDoor* door;
while (true) {
actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
actor = SubS_FindActor(play, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
door = (EnDoor*)actor;
if (actor == NULL) {
@ -44,7 +44,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) {
return door;
}
Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable,
Gfx* SubS_DrawTransformFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable,
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx) {
StandardLimb* limb;
@ -62,11 +62,11 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
pos.z = limb->jointPos.z;
newDList = limbDList = limb->dList;
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
transformLimbDraw(globalCtx, limbIndex, actor, &gfx);
transformLimbDraw(play, limbIndex, actor, &gfx);
if (newDList != NULL) {
Matrix_ToMtx(*mtx);
@ -80,15 +80,15 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
Matrix_Pop();
}
if (postLimbDraw != NULL) {
postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx);
postLimbDraw(play, limbIndex, &limbDList, &rot, actor, &gfx);
}
if (limb->child != LIMB_DONE) {
gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
gfx = SubS_DrawTransformFlexLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, mtx, gfx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
gfx = SubS_DrawTransformFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, mtx, gfx);
}
return gfx;
@ -103,7 +103,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
* coordinates.
* Note that the `TransformLimbDraw` does not have a NULL check, so must be provided even if empty.
*/
Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount,
Gfx* SubS_DrawTransformFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount,
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx) {
StandardLimb* rootLimb;
@ -112,7 +112,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
Gfx* limbDList;
Vec3f pos;
Vec3s rot;
Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx)));
Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx)));
if (skeleton == NULL) {
return NULL;
@ -128,11 +128,11 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
newDlist = rootLimb->dList;
limbDList = rootLimb->dList;
if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) {
if (overrideLimbDraw == NULL || !overrideLimbDraw(play, 1, &newDlist, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
transformLimbDraw(globalCtx, 1, actor, &gfx);
transformLimbDraw(play, 1, actor, &gfx);
if (newDlist != NULL) {
Matrix_ToMtx(mtx);
@ -147,21 +147,21 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
}
if (postLimbDraw != NULL) {
postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx);
postLimbDraw(play, 1, &limbDList, &rot, actor, &gfx);
}
if (rootLimb->child != LIMB_DONE) {
gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw,
postLimbDraw, transformLimbDraw, actor, &mtx, gfx);
gfx = SubS_DrawTransformFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, &mtx, gfx);
}
Matrix_Pop();
return gfx;
}
s32 SubS_InCsMode(GlobalContext* globalCtx) {
s32 SubS_InCsMode(PlayState* play) {
s32 inCsMode = false;
if (Play_InCsMode(globalCtx)) {
if (Play_InCsMode(play)) {
inCsMode = true;
}
@ -434,14 +434,14 @@ s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 way
/**
* Computes the initial Y component of a time based path
*
* @param[in] globalCtx
* @param[in] play
* @param[in] path
* @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos
* @param[out] targetPos the computed position to move to, only the Y component has meaning
*
* @note Same note as SubS_TimePathing_Update()
*/
void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) {
void SubS_TimePathing_ComputeInitialY(PlayState* play, Path* path, s32 waypoint, Vec3f* targetPos) {
Vec3s* points = Lib_SegmentedToVirtual(path->points);
Vec3f posA;
Vec3f posB;
@ -475,18 +475,17 @@ void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32
posB = *targetPos;
posA.y = max;
posB.y = min;
if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true,
&bgId)) {
if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, &bgId)) {
targetPos->y = posResult.y;
}
}
Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) {
Path* SubS_GetAdditionalPath(PlayState* play, u8 pathIndex, s32 max) {
Path* path;
s32 i = 0;
do {
path = &globalCtx->setupPathList[pathIndex];
path = &play->setupPathList[pathIndex];
if (i >= max) {
break;
}
@ -500,7 +499,7 @@ Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) {
/**
* Finds the nearest actor instance of a specified Id and category to an actor.
*/
Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) {
Actor* SubS_FindNearestActor(Actor* actor, PlayState* play, u8 actorCategory, s16 actorId) {
Actor* actorIter = NULL;
Actor* actorTmp;
f32 dist;
@ -509,7 +508,7 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat
s32 isSetup = false;
do {
actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId);
actorIter = SubS_FindActor(play, actorIter, actorCategory, actorId);
actorTmp = actorIter;
if (actorTmp == NULL) {
@ -586,7 +585,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) {
return reached;
}
Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) {
Path* SubS_GetDayDependentPath(PlayState* play, u8 pathIndex, u8 max, s32* startPointIndex) {
Path* path = NULL;
s32 found = false;
s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) +
@ -599,7 +598,7 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s
}
while (pathIndex != 0xFF) {
path = &globalCtx->setupPathList[pathIndex];
path = &play->setupPathList[pathIndex];
if (sPathDayFlags[day] & path->unk2) {
found = true;
break;
@ -817,29 +816,29 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) {
}
//! TODO: Needs docs with func_800B8500
s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) {
s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 itemId, s32 type) {
s32 ret = false;
s16 x;
s16 y;
f32 xzDistToPlayerTemp;
Actor_GetScreenPos(globalCtx, actor, &x, &y);
Actor_GetScreenPos(play, actor, &x, &y);
switch (type) {
case 1:
yRange = fabsf(actor->playerHeightRel) + 1.0f;
xzRange = actor->xzDistToPlayer + 1.0f;
ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange);
ret = Actor_PickUp(actor, play, itemId, xzRange, yRange);
break;
case 2:
if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) {
ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 3:
//! @bug: Both x and y conditionals are always true, || should be an &&
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) {
ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 4:
@ -848,7 +847,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
xzDistToPlayerTemp = actor->xzDistToPlayer;
actor->xzDistToPlayer = 0.0f;
actor->flags |= 0x10000;
ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
ret = func_800B8500(actor, play, xzRange, yRange, itemId);
actor->xzDistToPlayer = xzDistToPlayerTemp;
break;
case 5:
@ -856,7 +855,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) &&
(fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) {
actor->flags |= 0x10000;
ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 6:
@ -864,7 +863,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) &&
(fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) {
actor->flags |= 0x10000;
ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
}
@ -1090,8 +1089,8 @@ s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) {
return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false;
}
Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) {
return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL;
Path* SubS_GetPathByIndex(PlayState* play, s16 pathIndex, s16 max) {
return (pathIndex != max) ? &play->setupPathList[pathIndex] : NULL;
}
s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) {
@ -1153,22 +1152,22 @@ s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* dis
return Math_Atan2S(diffX, diffZ);
}
s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) {
return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true;
s8 SubS_IsObjectLoaded(s8 index, PlayState* play) {
return !Object_IsLoaded(&play->objectCtx, index) ? false : true;
}
s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) {
return Object_GetIndex(&globalCtx->objectCtx, id);
s8 SubS_GetObjectIndex(s16 id, PlayState* play) {
return Object_GetIndex(&play->objectCtx, id);
}
/**
* Finds the first actor instance of a specified Id and category.
*/
Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) {
Actor* SubS_FindActor(PlayState* play, Actor* actorListStart, u8 actorCategory, s16 actorId) {
Actor* actor = actorListStart;
if (actor == NULL) {
actor = globalCtx->actorCtx.actorLists[actorCategory].first;
actor = play->actorCtx.actorLists[actorCategory].first;
}
while (actor != NULL && actorId != actor->id) {
@ -1178,9 +1177,9 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC
return actor;
}
s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
s32 SubS_FillLimbRotTables(PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
s32 i;
u32 frames = globalCtx->gameplayFrames;
u32 frames = play->gameplayFrames;
for (i = 0; i < numLimbs; i++) {
limbRotTableY[i] = (i * 50 + 0x814) * frames;
@ -1190,7 +1189,7 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li
return true;
}
s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) {
s32 SubS_IsFloorAbove(PlayState* play, Vec3f* pos, f32 distAbove) {
CollisionPoly* outPoly;
Vec3f posA;
Vec3f posB;
@ -1199,8 +1198,7 @@ s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) {
posA = posB = *pos;
posB.y += distAbove;
return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true,
&bgId);
return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, &bgId);
}
s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) {
@ -1220,12 +1218,11 @@ u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) {
return path->count;
}
void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath,
Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex,
u8 flags) {
void SubS_ActorPathing_Init(PlayState* play, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths,
s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags) {
Path* path;
actorPath->setupPathList = globalCtx->setupPathList;
actorPath->setupPathList = play->setupPathList;
actorPath->pathIndex = pathIndex;
path = &paths[pathIndex];
actorPath->points = Lib_SegmentedToVirtual(path->points);
@ -1250,9 +1247,9 @@ void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* ac
actorPath->prevFlags = flags;
}
s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath,
ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc,
ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) {
s32 SubS_ActorPathing_Update(PlayState* play, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc,
ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc,
ActorPathingUpdateFunc setNextPointFunc) {
s32 shouldSetNextPoint;
s32 reupdate;
@ -1272,24 +1269,24 @@ s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath,
do {
shouldSetNextPoint = false;
if (actorPath->computePointInfoFunc != NULL) {
actorPath->computePointInfoFunc(globalCtx, actorPath);
actorPath->computePointInfoFunc(play, actorPath);
}
if (actorPath->updateActorInfoFunc != NULL) {
shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath);
shouldSetNextPoint = actorPath->updateActorInfoFunc(play, actorPath);
}
if (shouldSetNextPoint) {
if (actorPath->setNextPointFunc != NULL) {
reupdate = actorPath->setNextPointFunc(globalCtx, actorPath);
reupdate = actorPath->setNextPointFunc(play, actorPath);
}
} else if (actorPath->moveFunc != NULL) {
reupdate = actorPath->moveFunc(globalCtx, actorPath);
reupdate = actorPath->moveFunc(play, actorPath);
}
} while (reupdate);
actorPath->prevFlags = actorPath->flags;
return false;
}
void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) {
void SubS_ActorPathing_ComputePointInfo(PlayState* play, ActorPathing* actorPath) {
Vec3f diff;
actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x;
@ -1305,17 +1302,17 @@ void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing*
actorPath->rotToCurPoint.z = 0;
}
s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) {
s32 SubS_ActorPathing_MoveWithGravity(PlayState* play, ActorPathing* actorPath) {
Actor_MoveWithGravity(actorPath->actor);
return false;
}
s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) {
s32 SubS_ActorPathing_MoveWithoutGravityReverse(PlayState* play, ActorPathing* actorPath) {
Actor_MoveWithoutGravityReverse(actorPath->actor);
return false;
}
s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) {
s32 SubS_ActorPathing_SetNextPoint(PlayState* play, ActorPathing* actorPath) {
s32 reupdate = true;
Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint);
@ -1484,18 +1481,18 @@ s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePoi
* Finds the first actor instance of a specified Id and category verified with a custom callback.
* The callback should return `true` when the actor is succesfully verified.
*/
Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory,
s16 actorId, void* verifyData, VerifyActor verifyActor) {
Actor* SubS_FindActorCustom(PlayState* play, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId,
void* verifyData, VerifyActor verifyActor) {
Actor* actorIter = actorListStart;
if (actorListStart == NULL) {
actorIter = globalCtx->actorCtx.actorLists[actorCategory].first;
actorIter = play->actorCtx.actorLists[actorCategory].first;
}
while (actorIter != NULL && (actorId != actorIter->id ||
(actorId == actorIter->id &&
(verifyActor == NULL ||
(verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) {
while (actorIter != NULL &&
(actorId != actorIter->id ||
(actorId == actorIter->id &&
(verifyActor == NULL || (verifyActor != NULL && !verifyActor(play, actor, actorIter, verifyData)))))) {
actorIter = actorIter->next;
}
@ -1503,18 +1500,18 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor
}
//! TODO: Needs docs with func_800B8500
s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data,
s32 func_8013E748(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data,
func_8013E748_VerifyFunc verifyFunc) {
s32 ret = false;
if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) {
ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId);
if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(play, actor, data))) {
ret = func_800B8500(actor, play, xzRange, yRange, exchangeItemId);
}
return ret;
}
s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) {
Player* player = GET_PLAYER(globalCtx);
s32 SubS_ActorAndPlayerFaceEachOther(PlayState* play, Actor* actor, void* data) {
Player* player = GET_PLAYER(play);
Vec3s* yawTols = (Vec3s*)data;
s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y));
s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
@ -1533,13 +1530,13 @@ s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, voi
}
//! TODO: Needs docs with func_800B8500
s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol,
s32 func_8013E8F8(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol,
s16 actorYawTol) {
Vec3s yawTols;
yawTols.x = playerYawTol;
yawTols.y = actorYawTol;
return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther);
return func_8013E748(actor, play, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther);
}
/**

View File

@ -36,7 +36,7 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) {
}
void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
PlayState* play = (PlayState*)gameState;
size_t size;
void* offset;
s32 pad;
@ -75,13 +75,13 @@ void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType)
skyboxCtx->envB = 40;
// Inverted Stone Tower Temple and Inverted Stone Tower
if ((globalCtx->sceneNum == SCENE_F41) || (globalCtx->sceneNum == SCENE_INISIE_R)) {
if ((play->sceneNum == SCENE_F41) || (play->sceneNum == SCENE_INISIE_R)) {
skyboxCtx->rotZ = 3.15000009537f;
}
}
}
void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) {
void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyType) {
size_t size;
if (1) {}
@ -89,7 +89,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
if (skyType == 1) {
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
if (globalCtx->envCtx.unk_10 == 0) {
if (play->envCtx.unk_10 == 0) {
// Send a DMA request for the clear sky texture
size = SEGMENT_ROM_SIZE(d2_fine_static);
@ -106,7 +106,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
if (globalCtx->envCtx.unk_11 == 0) {
if (play->envCtx.unk_11 == 0) {
// Send a DMA request for the clear sky texture
size = SEGMENT_ROM_SIZE(d2_fine_static);

View File

@ -12,13 +12,13 @@
#define THIS ((ArmsHook*)thisx)
void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Init(Actor* thisx, PlayState* play);
void ArmsHook_Destroy(Actor* thisx, PlayState* play);
void ArmsHook_Update(Actor* thisx, PlayState* play);
void ArmsHook_Draw(Actor* thisx, PlayState* play);
void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx);
void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx);
void ArmsHook_Wait(ArmsHook* this, PlayState* play);
void ArmsHook_Shoot(ArmsHook* this, PlayState* play);
const ActorInit Arms_Hook_InitVars = {
ACTOR_ARMS_HOOK,
@ -56,29 +56,29 @@ void ArmsHook_SetupAction(ArmsHook* this, ArmsHookActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx) {
void ArmsHook_Init(Actor* thisx, PlayState* play) {
ArmsHook* this = THIS;
Collider_InitQuad(globalCtx, &this->collider);
Collider_SetQuad(globalCtx, &this->collider, &this->actor, &D_808C1BC0);
Collider_InitQuad(play, &this->collider);
Collider_SetQuad(play, &this->collider, &this->actor, &D_808C1BC0);
ArmsHook_SetupAction(this, ArmsHook_Wait);
this->unk1E0 = this->actor.world.pos;
}
void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void ArmsHook_Destroy(Actor* thisx, PlayState* play) {
ArmsHook* this = THIS;
if (this->grabbed != NULL) {
this->grabbed->flags &= ~0x2000;
}
Collider_DestroyQuad(globalCtx, &this->collider);
Collider_DestroyQuad(play, &this->collider);
}
void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) {
void ArmsHook_Wait(ArmsHook* this, PlayState* play) {
if (this->actor.parent == NULL) {
ArmsHook_SetupAction(this, ArmsHook_Shoot);
Actor_SetSpeeds(&this->actor, 20.0f);
this->actor.parent = &GET_PLAYER(globalCtx)->actor;
this->actor.parent = &GET_PLAYER(play)->actor;
this->timer = 26;
}
}
@ -125,8 +125,8 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) {
Math_Vec3f_Diff(&actor->world.pos, &this->actor.world.pos, &this->unk1FC);
}
void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if ((this->actor.parent == NULL) || (!func_801240C8(player))) {
ArmsHook_DetachHookFromActor(this);
@ -244,11 +244,11 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
sp60.x = this->unk1EC.x - (this->unk1E0.x - this->unk1EC.x);
sp60.y = this->unk1EC.y - (this->unk1E0.y - this->unk1EC.y);
sp60.z = this->unk1EC.z - (this->unk1E0.z - this->unk1EC.z);
if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true,
if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true,
&bgId) &&
(func_800B90AC(globalCtx, &this->actor, poly, bgId, &posResult) == 0 ||
BgCheck_ProjectileLineTest(&globalCtx->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true,
true, &bgId))) {
(func_800B90AC(play, &this->actor, poly, bgId, &posResult) == 0 ||
BgCheck_ProjectileLineTest(&play->colCtx, &sp60, &this->unk1E0, &posResult, &poly, true, true, true, true,
&bgId))) {
f32 nx = COLPOLY_GET_NORMAL(poly->normal.x);
f32 nz = COLPOLY_GET_NORMAL(poly->normal.z);
@ -256,22 +256,21 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
this->actor.world.pos.x += 10.0f * nx;
this->actor.world.pos.z += 10.0f * nz;
this->timer = 1;
if (SurfaceType_IsHookshotSurface(&globalCtx->colCtx, poly, bgId)) {
if (SurfaceType_IsHookshotSurface(&play->colCtx, poly, bgId)) {
{
DynaPolyActor* dynaPolyActor;
if (bgId != BGCHECK_SCENE &&
(dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId)) != NULL) {
if (bgId != BGCHECK_SCENE && (dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId)) != NULL) {
ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor);
}
}
func_808C1154(this);
Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_STICK_OBJ);
} else {
CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &this->actor.world.pos);
CollisionCheck_SpawnShieldParticlesMetal(play, &this->actor.world.pos);
Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT);
}
} else {
if (CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button,
if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button,
BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) {
s32 pad;
this->timer = 1;
@ -280,10 +279,10 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
}
}
void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx) {
void ArmsHook_Update(Actor* thisx, PlayState* play) {
ArmsHook* this = THIS;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
this->unk1EC = this->unk1E0;
}
@ -294,10 +293,10 @@ static Vec3f D_808C1C34 = { 0.0f, -500.0f, -3000.0f };
static Vec3f D_808C1C40 = { 0.0f, 500.0f, 0.0f };
static Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f };
void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ArmsHook_Draw(Actor* thisx, PlayState* play) {
ArmsHook* this = THIS;
f32 f0;
Player* player = GET_PLAYER(globalCtx);
Player* player = GET_PLAYER(play);
if (player->actor.draw != NULL && player->rightHandType == 0xB) {
Vec3f sp68;
@ -306,7 +305,7 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) {
f32 sp4C;
f32 sp48;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) {
Matrix_MultVec3f(&D_808C1C10, &this->unk1E0);
@ -318,11 +317,11 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) {
Matrix_MultVec3f(&D_808C1C40, &sp5C);
Matrix_MultVec3f(&D_808C1C4C, &sp50);
}
func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50);
func_8012C28C(globalCtx->state.gfxCtx);
func_80122868(globalCtx, player);
func_80126440(play, &this->collider, &this->unk1C4, &sp5C, &sp50);
func_8012C28C(play->state.gfxCtx);
func_80122868(play, player);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, object_link_child_DL_01D960);
Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW);
Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68);
@ -332,10 +331,10 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) {
Matrix_RotateXS(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY);
f0 = sqrtf(SQ(sp68.y) + sp48);
Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0008D0);
func_801229A0(globalCtx, player);
func_801229A0(play, player);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -5,7 +5,7 @@
struct ArmsHook;
typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*);
typedef void (*ArmsHookActionFunc)(struct ArmsHook*, PlayState*);
typedef struct ArmsHook {
/* 0x000 */ Actor actor;

View File

@ -11,13 +11,13 @@
#define THIS ((ArrowFire*)thisx)
void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx);
void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx);
void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx);
void ArrowFire_Init(Actor* thisx, PlayState* play);
void ArrowFire_Destroy(Actor* thisx, PlayState* play);
void ArrowFire_Update(Actor* thisx, PlayState* play);
void ArrowFire_Draw(Actor* thisx, PlayState* play);
void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx);
void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx);
void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play);
void FireArrow_Fly(ArrowFire* this, PlayState* play);
#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c"
@ -63,7 +63,7 @@ void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) {
void ArrowFire_Init(Actor* thisx, PlayState* play) {
ArrowFire* this = THIS;
Actor_ProcessInitChain(&this->actor, sInitChain);
@ -74,19 +74,19 @@ void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) {
this->alpha = 160;
this->timer = 0;
this->screenFillIntensity = 0.0f;
Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit);
Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit);
Collider_InitAndSetQuad(play, &this->collider1, &this->actor, &sQuadInit);
Collider_InitAndSetQuad(play, &this->collider2, &this->actor, &sQuadInit);
}
void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void ArrowFire_Destroy(Actor* thisx, PlayState* play) {
ArrowFire* this = THIS;
func_80115D5C(&globalCtx->state);
Collider_DestroyQuad(globalCtx, &this->collider1);
Collider_DestroyQuad(globalCtx, &this->collider2);
func_80115D5C(&play->state);
Collider_DestroyQuad(play, &this->collider1);
Collider_DestroyQuad(play, &this->collider2);
}
void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) {
void FireArrow_ChargeAndWait(ArrowFire* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
@ -115,7 +115,7 @@ void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) {
VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale);
}
void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) {
void FireArrow_Hit(ArrowFire* this, PlayState* play) {
f32 offset;
f32 scale;
u16 timer;
@ -160,12 +160,12 @@ void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) {
return;
}
if (this->timer >= 13) {
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base);
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base);
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base);
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base);
}
}
void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) {
void FireArrow_Fly(ArrowFire* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
s32 pad;
s32 pad2;
@ -201,14 +201,14 @@ void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) {
}
}
void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) {
void ArrowFire_Update(Actor* thisx, PlayState* play) {
ArrowFire* this = (ArrowFire*)thisx;
if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) {
if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) {
Actor_MarkForDeath(&this->actor);
return;
}
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void FireArrow_SetQuadVerticies(ArrowFire* this) {
@ -237,10 +237,10 @@ void FireArrow_SetQuadVerticies(ArrowFire* this) {
Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20);
}
void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ArrowFire_Draw(Actor* thisx, PlayState* play) {
EnArrow* arrow;
ArrowFire* this = THIS;
u32 frames = globalCtx->state.frames;
u32 frames = play->state.frames;
s32 pad;
arrow = (EnArrow*)this->actor.parent;
@ -248,7 +248,7 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) {
if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) {
Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW);
Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY);
Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY);
@ -266,7 +266,7 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) {
gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect);
}
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128);
@ -282,15 +282,14 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) {
Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY);
Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
FireArrow_SetQuadVerticies(this);
gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL);
gSPDisplayList(POLY_XLU_DISP++,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1,
255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64));
gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32,
1, 255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64));
gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -5,7 +5,7 @@
struct ArrowFire;
typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*);
typedef void (*ArrowFireActionFunc)(struct ArrowFire*, PlayState*);
typedef struct ArrowFire {
/* 0x000 */ Actor actor;

View File

@ -11,13 +11,13 @@
#define THIS ((ArrowIce*)thisx)
void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx);
void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx);
void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx);
void ArrowIce_Init(Actor* thisx, PlayState* play);
void ArrowIce_Destroy(Actor* thisx, PlayState* play);
void ArrowIce_Update(Actor* thisx, PlayState* play);
void ArrowIce_Draw(Actor* thisx, PlayState* play);
void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx);
void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx);
void ArrowIce_Charge(ArrowIce* this, PlayState* play);
void ArrowIce_Fly(ArrowIce* this, PlayState* play);
#include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c"
@ -43,7 +43,7 @@ void ArrowIce_SetupAction(ArrowIce* this, ArrowIceActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) {
void ArrowIce_Init(Actor* thisx, PlayState* play) {
ArrowIce* this = THIS;
Actor_ProcessInitChain(&this->actor, sInitChain);
@ -56,12 +56,12 @@ void ArrowIce_Init(Actor* thisx, GlobalContext* globalCtx) {
this->blueingEffectMagnitude = 0.0f;
}
void ArrowIce_Destroy(Actor* thisx, GlobalContext* globalCtx) {
func_80115D5C(&globalCtx->state);
void ArrowIce_Destroy(Actor* thisx, PlayState* play) {
func_80115D5C(&play->state);
(void)"消滅"; // Unreferenced in retail, means "Disappearance"
}
void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx) {
void ArrowIce_Charge(ArrowIce* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
@ -91,7 +91,7 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) {
VEC3F_LERPIMPDST(firedPos, firedPos, icePos, scale);
}
void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) {
void ArrowIce_Hit(ArrowIce* this, PlayState* play) {
f32 scale;
u16 timer;
@ -140,7 +140,7 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) {
}
}
void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) {
void ArrowIce_Fly(ArrowIce* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
f32 distanceScaled;
s32 pad;
@ -173,28 +173,28 @@ void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) {
}
}
void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx) {
void ArrowIce_Update(Actor* thisx, PlayState* play) {
ArrowIce* this = THIS;
if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) {
if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) {
Actor_MarkForDeath(&this->actor);
return;
} else {
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
}
void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ArrowIce_Draw(Actor* thisx, PlayState* play) {
s32 pad;
ArrowIce* this = THIS;
Actor* transform;
u32 stateFrames = globalCtx->state.frames;
u32 stateFrames = play->state.frames;
EnArrow* arrow = (EnArrow*)this->actor.parent;
if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) {
transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW);
Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY);
@ -214,7 +214,7 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) {
}
// Draw ice on the arrow
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF);
gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128);
Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY);
@ -225,13 +225,13 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) {
}
Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY);
Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL);
gSPDisplayList(POLY_XLU_DISP++,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1,
511 - (stateFrames * 10) % 512, 511 - (stateFrames * 10) % 512, 4, 16));
gSPDisplayList(POLY_XLU_DISP++, gIceArrowModelDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -5,7 +5,7 @@
struct ArrowIce;
typedef void (*ArrowIceActionFunc)(struct ArrowIce*, GlobalContext*);
typedef void (*ArrowIceActionFunc)(struct ArrowIce*, PlayState*);
typedef struct ArrowIce {
/* 0x0000 */ Actor actor;

View File

@ -11,13 +11,13 @@
#define THIS ((ArrowLight*)thisx)
void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx);
void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx);
void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx);
void ArrowLight_Init(Actor* thisx, PlayState* play);
void ArrowLight_Destroy(Actor* thisx, PlayState* play);
void ArrowLight_Update(Actor* thisx, PlayState* play);
void ArrowLight_Draw(Actor* thisx, PlayState* play);
void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx);
void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx);
void ArrowLight_Charge(ArrowLight* this, PlayState* play);
void ArrowLight_Fly(ArrowLight* this, PlayState* play);
#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c"
@ -43,7 +43,7 @@ void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) {
void ArrowLight_Init(Actor* thisx, PlayState* play) {
ArrowLight* this = (ArrowLight*)thisx;
Actor_ProcessInitChain(&this->actor, sInitChain);
this->radius = 0;
@ -55,12 +55,12 @@ void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) {
this->screenFillIntensity = 0.0f;
}
void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) {
func_80115D5C(&globalCtx->state);
void ArrowLight_Destroy(Actor* thisx, PlayState* play) {
func_80115D5C(&play->state);
(void)"消滅"; // Unreferenced in retail, means "Disappearance"
}
void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) {
void ArrowLight_Charge(ArrowLight* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
if ((arrow == NULL) || (arrow->actor.update == NULL)) {
@ -88,7 +88,7 @@ void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) {
VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale);
}
void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) {
void ArrowLight_Hit(ArrowLight* this, PlayState* play) {
f32 scale;
u16 timer;
@ -134,7 +134,7 @@ void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) {
}
}
void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) {
void ArrowLight_Fly(ArrowLight* this, PlayState* play) {
EnArrow* arrow = (EnArrow*)this->actor.parent;
s32 pad[2];
@ -169,26 +169,26 @@ void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) {
}
}
void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) {
void ArrowLight_Update(Actor* thisx, PlayState* play) {
ArrowLight* this = THIS;
if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) {
if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) {
Actor_MarkForDeath(&this->actor);
return;
}
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) {
void ArrowLight_Draw(Actor* thisx, PlayState* play) {
s32 pad;
ArrowLight* this = (ArrowLight*)thisx;
u32 frames = globalCtx->state.frames;
u32 frames = play->state.frames;
EnArrow* arrow = (EnArrow*)this->actor.parent;
if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) {
Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW);
Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY);
@ -205,7 +205,7 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) {
gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect);
}
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128);
@ -219,12 +219,12 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) {
Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY);
Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL);
gSPDisplayList(POLY_XLU_DISP++,
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1,
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1,
511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16));
gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -5,7 +5,7 @@
struct ArrowLight;
typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*);
typedef void (*ArrowLightActionFunc)(struct ArrowLight*, PlayState*);
typedef struct ArrowLight {
/* 0x000 */ Actor actor;

View File

@ -11,17 +11,17 @@
#define THIS ((BgAstrBombwall*)thisx)
void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx);
void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx);
void BgAstrBombwall_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgAstrBombwall_Init(Actor* thisx, PlayState* play);
void BgAstrBombwall_Destroy(Actor* thisx, PlayState* play);
void BgAstrBombwall_Update(Actor* thisx, PlayState* play);
void BgAstrBombwall_Draw(Actor* thisx, PlayState* play);
void func_80C0A378(BgAstrBombwall* this);
void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx);
void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx);
void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx);
void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx);
void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx);
void func_80C0A38C(BgAstrBombwall* this, PlayState* play);
void func_80C0A400(BgAstrBombwall* this, PlayState* play);
void func_80C0A418(BgAstrBombwall* this, PlayState* play);
void func_80C0A458(BgAstrBombwall* this, PlayState* play);
void func_80C0A4BC(BgAstrBombwall* this, PlayState* play);
const ActorInit Bg_Astr_Bombwall_InitVars = {
ACTOR_BG_ASTR_BOMBWALL,
@ -95,20 +95,20 @@ void BgAstrBombwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot,
}
}
void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx) {
void BgAstrBombwall_Init(Actor* thisx, PlayState* play) {
s32 pad;
BgAstrBombwall* this = THIS;
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, 1);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_astr_obj_Colheader_002498);
Collider_InitTris(globalCtx, &this->collider);
if (Flags_GetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) {
DynaPolyActor_LoadMesh(play, &this->dyna, &object_astr_obj_Colheader_002498);
Collider_InitTris(play, &this->collider);
if (Flags_GetSwitch(play, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) {
Actor_MarkForDeath(&this->dyna.actor);
return;
}
this->dyna.actor.flags |= ACTOR_FLAG_10000000;
if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) {
if (!Collider_SetTris(play, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) {
Actor_MarkForDeath(&this->dyna.actor);
return;
}
@ -117,13 +117,13 @@ void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx) {
func_80C0A378(this);
}
void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void BgAstrBombwall_Destroy(Actor* thisx, PlayState* play) {
BgAstrBombwall* this = THIS;
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) {
void func_80C0A120(BgAstrBombwall* this, PlayState* play) {
s32 i;
Vec3f vec;
Vec3f pos;
@ -138,7 +138,7 @@ void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) {
vec.z = 0.0f;
Matrix_MultVec3f(&vec, &pos);
Math_Vec3f_Sum(&this->dyna.actor.world.pos, &pos, &pos);
func_800BBFB0(globalCtx, &pos, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, Rand_ZeroOne() * 240.0f + 20.0f, 0);
func_800BBFB0(play, &pos, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, Rand_ZeroOne() * 240.0f + 20.0f, 0);
velocity.x = Rand_ZeroOne() * 2.5f;
velocity.y = (Rand_ZeroOne() * 2.5f) + 1.0f;
velocity.z = Rand_ZeroOne() * 2.5f;
@ -151,8 +151,8 @@ void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) {
} else {
var_v0 = 0x20;
}
EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -260, var_v0, 20, 0, 0, 10, 0, 0, 50, -1,
OBJECT_ASTR_OBJ, object_astr_obj_DL_002178);
EffectSsKakera_Spawn(play, &pos, &velocity, &pos, -260, var_v0, 20, 0, 0, 10, 0, 0, 50, -1, OBJECT_ASTR_OBJ,
object_astr_obj_DL_002178);
}
}
@ -160,66 +160,66 @@ void func_80C0A378(BgAstrBombwall* this) {
this->actionFunc = func_80C0A38C;
}
void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx) {
void func_80C0A38C(BgAstrBombwall* this, PlayState* play) {
if (this->collider.base.acFlags & AC_HIT) {
this->collider.base.acFlags &= ~AC_HIT;
Flags_SetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor));
func_80C0A400(this, globalCtx);
Flags_SetSwitch(play, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor));
func_80C0A400(this, play);
} else {
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
}
}
void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx) {
void func_80C0A400(BgAstrBombwall* this, PlayState* play) {
this->actionFunc = func_80C0A418;
}
void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx) {
void func_80C0A418(BgAstrBombwall* this, PlayState* play) {
if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) {
func_80C0A458(this, globalCtx);
func_80C0A458(this, play);
}
}
void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx) {
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
void func_80C0A458(BgAstrBombwall* this, PlayState* play) {
func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId);
this->dyna.actor.draw = NULL;
func_80C0A120(this, globalCtx);
func_80C0A120(this, play);
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN);
this->actionFunc = func_80C0A4BC;
}
void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx) {
void func_80C0A4BC(BgAstrBombwall* this, PlayState* play) {
}
void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx) {
void BgAstrBombwall_Update(Actor* thisx, PlayState* play) {
BgAstrBombwall* this = THIS;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void BgAstrBombwall_Draw(Actor* thixs, GlobalContext* globalCtx) {
void BgAstrBombwall_Draw(Actor* thixs, PlayState* play) {
{
Gfx* opa;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
opa = POLY_OPA_DISP;
gSPDisplayList(&opa[0], &sSetupDL[25 * 6]);
gSPMatrix(&opa[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(&opa[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPSetGeometryMode(&opa[2], G_LIGHTING_POSITIONAL);
gSPDisplayList(&opa[3], object_astr_obj_DL_002380);
POLY_OPA_DISP = &opa[4];
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
{
Gfx* xlu;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
xlu = POLY_XLU_DISP;
gSPDisplayList(&xlu[0], &sSetupDL[25 * 6]);
gSPMatrix(&xlu[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(&xlu[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPSetGeometryMode(&xlu[2], G_LIGHTING_POSITIONAL);
gSPDisplayList(&xlu[3], object_astr_obj_DL_0022E0);
POLY_XLU_DISP = &xlu[4];
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -7,7 +7,7 @@ struct BgAstrBombwall;
#define BGASTRBOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F)
typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, GlobalContext*);
typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, PlayState*);
typedef struct BgAstrBombwall {
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ BgAstrBombwallActionFunc actionFunc;

View File

@ -10,10 +10,10 @@
#define THIS ((BgBotihasira*)thisx)
void BgBotihasira_Init(Actor* thisx, GlobalContext* globalCtx);
void BgBotihasira_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgBotihasira_Update(Actor* thisx, GlobalContext* globalCtx);
void BgBotihasira_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgBotihasira_Init(Actor* thisx, PlayState* play);
void BgBotihasira_Destroy(Actor* thisx, PlayState* play);
void BgBotihasira_Update(Actor* thisx, PlayState* play);
void BgBotihasira_Draw(Actor* thisx, PlayState* play);
#if 0
const ActorInit Bg_Botihasira_InitVars = {

View File

@ -5,7 +5,7 @@
struct BgBotihasira;
typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, GlobalContext*);
typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, PlayState*);
typedef struct BgBotihasira {
/* 0x0000 */ Actor actor;

View File

@ -19,31 +19,31 @@
#define THIS ((BgBreakwall*)thisx)
void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx);
void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx);
void BgBreakwall_Init(Actor* thisx, PlayState* play);
void BgBreakwall_Update(Actor* thisx, PlayState* play);
void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc);
s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx);
s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx);
void func_808B7A90(Actor* thisx, GlobalContext* globalCtx);
void func_808B7B54(Actor* thisx, GlobalContext* globalCtx);
void func_808B7D34(Actor* thisx, GlobalContext* globalCtx);
void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx);
s32 func_808B736C(BgBreakwall* this, PlayState* play);
s32 func_808B7380(BgBreakwall* this, PlayState* play);
s32 func_808B73C4(BgBreakwall* this, PlayState* play);
s32 func_808B73FC(BgBreakwall* this, PlayState* play);
s32 func_808B7410(BgBreakwall* this, PlayState* play);
s32 func_808B7460(BgBreakwall* this, PlayState* play);
s32 func_808B74A8(BgBreakwall* this, PlayState* play);
s32 func_808B74D8(BgBreakwall* this, PlayState* play);
s32 func_808B751C(BgBreakwall* this, PlayState* play);
void func_808B76CC(BgBreakwall* this, PlayState* play);
void func_808B77D0(BgBreakwall* this, PlayState* play);
void func_808B77E0(BgBreakwall* this, PlayState* play);
void func_808B782C(BgBreakwall* this, PlayState* play);
void func_808B78A4(BgBreakwall* this, PlayState* play);
void func_808B78DC(BgBreakwall* this, PlayState* play);
void func_808B7914(BgBreakwall* this, PlayState* play);
void func_808B7A10(BgBreakwall* this, PlayState* play);
void func_808B7A90(Actor* thisx, PlayState* play);
void func_808B7B54(Actor* thisx, PlayState* play);
void func_808B7D34(Actor* thisx, PlayState* play);
void BgBreakwall_Draw(Actor* thisx, PlayState* play);
const ActorInit Bg_Breakwall_InitVars = {
ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS,
@ -141,63 +141,63 @@ void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc
this->actionFunc = actionFunc;
}
s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B736C(BgBreakwall* this, PlayState* play) {
return true;
}
s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B7380(BgBreakwall* this, PlayState* play) {
if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) {
return false;
}
return true;
}
s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B73C4(BgBreakwall* this, PlayState* play) {
return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1);
}
s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B73FC(BgBreakwall* this, PlayState* play) {
return true;
}
s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) {
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
s32 func_808B7410(BgBreakwall* this, PlayState* play) {
if (Flags_GetSwitch(play, this->switchFlag)) {
this->dyna.actor.draw = NULL;
}
Actor_SetScale(&this->dyna.actor, 0.1f);
return true;
}
s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) {
if (!Flags_GetSwitch(globalCtx, this->switchFlag)) {
s32 func_808B7460(BgBreakwall* this, PlayState* play) {
if (!Flags_GetSwitch(play, this->switchFlag)) {
this->dyna.actor.scale.x = 0.1f;
}
return true;
}
s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B74A8(BgBreakwall* this, PlayState* play) {
if (gSaveContext.save.weekEventReg[55] & 0x80) {
return false;
}
return true;
}
s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B74D8(BgBreakwall* this, PlayState* play) {
if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) {
return false;
}
return true;
}
s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) {
s32 func_808B751C(BgBreakwall* this, PlayState* play) {
Actor_SetScale(&this->dyna.actor, 0.1f);
if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) &&
!Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) {
!Flags_GetSwitch(play, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) {
return false;
}
func_800FEA50(globalCtx);
func_800FEA50(play);
if (gSaveContext.save.isNight) {
this->unk_15E = 0;
@ -207,15 +207,15 @@ s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) {
return true;
}
void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
void BgBreakwall_Init(Actor* thisx, PlayState* play) {
s32 pad;
BgBreakwall* this = THIS;
BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)];
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00);
this->unk_15C = Object_GetIndex(&play->objectCtx, sp24->unk_00);
if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) {
if ((this->unk_15C < 0) || !sp24->unk_14(this, play)) {
Actor_MarkForDeath(&this->dyna.actor);
return;
}
@ -224,17 +224,17 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) {
this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor);
}
void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void BgBreakwall_Destroy(Actor* thisx, PlayState* play) {
BgBreakwall* this = THIS;
BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)];
if (temp_s1->unk_10 != NULL) {
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
}
void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) {
if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) {
void func_808B76CC(BgBreakwall* this, PlayState* play) {
if (Object_IsLoaded(&play->objectCtx, this->unk_15C)) {
BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)];
this->dyna.actor.objBankIndex = this->unk_15C;
@ -246,7 +246,7 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) {
this->dyna.actor.flags &= ~ACTOR_FLAG_10;
}
Actor_SetObjectDependency(globalCtx, &this->dyna.actor);
Actor_SetObjectDependency(play, &this->dyna.actor);
if (temp_s1->unk_0C != NULL) {
temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C);
@ -254,7 +254,7 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) {
if (temp_s1->unk_10 != NULL) {
DynaPolyActor_Init(&this->dyna, 0);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10);
DynaPolyActor_LoadMesh(play, &this->dyna, temp_s1->unk_10);
}
BgBreakwall_SetupAction(this, temp_s1->unk_18);
@ -262,21 +262,21 @@ void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) {
}
}
void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B77D0(BgBreakwall* this, PlayState* play) {
}
void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) {
if (!Flags_GetSwitch(globalCtx, this->switchFlag)) {
void func_808B77E0(BgBreakwall* this, PlayState* play) {
if (!Flags_GetSwitch(play, this->switchFlag)) {
this->dyna.actor.draw = BgBreakwall_Draw;
} else {
this->dyna.actor.draw = NULL;
}
}
void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B782C(BgBreakwall* this, PlayState* play) {
f32 phi_f0;
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
if (Flags_GetSwitch(play, this->switchFlag)) {
phi_f0 = 1.0f;
} else {
phi_f0 = 0.1f;
@ -284,23 +284,23 @@ void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) {
Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f);
}
void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B78A4(BgBreakwall* this, PlayState* play) {
if (gSaveContext.save.weekEventReg[55] & 0x80) {
Actor_MarkForDeath(&this->dyna.actor);
}
}
void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B78DC(BgBreakwall* this, PlayState* play) {
Actor_SetScale(&this->dyna.actor, 3.5f);
func_800B9010(&this->dyna.actor, NA_SE_EV_TORNADE - SFX_FLAG);
}
void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B7914(BgBreakwall* this, PlayState* play) {
s32 pad;
Vec3f sp30;
Vec3f sp24;
if ((globalCtx->gameplayFrames % 8) == 0) {
if ((play->gameplayFrames % 8) == 0) {
sp30.x = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.x - 55.0f);
sp30.y = this->dyna.actor.world.pos.y + 70.0f;
sp30.z = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.z - 130.0f);
@ -309,11 +309,11 @@ void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) {
sp24.y = 0.5f;
sp24.z = 0.0f;
EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f));
EffectSsIceSmoke_Spawn(play, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f));
}
}
void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) {
void func_808B7A10(BgBreakwall* this, PlayState* play) {
if (gSaveContext.save.isNight) {
if (this->unk_15E < 245) {
this->unk_15E += 10;
@ -327,17 +327,17 @@ void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) {
}
}
void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) {
void BgBreakwall_Update(Actor* thisx, PlayState* play) {
BgBreakwall* this = THIS;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) {
void func_808B7A90(Actor* thisx, PlayState* play) {
Color_RGBA8 sp2C;
Color_RGBA8 sp28;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_800FE7A8(D_808B82F0, &sp2C);
func_800FE7A8(D_808B8300, &sp28);
@ -345,19 +345,19 @@ void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255);
gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) {
void func_808B7B54(Actor* thisx, PlayState* play) {
s32 pad;
Color_RGBA8 sp50;
Color_RGBA8 sp4C;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_800FE7A8(D_808B8310, &sp50);
func_800FE7A8(D_808B8330, &sp4C);
@ -373,17 +373,17 @@ void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) {
gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255);
gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) {
void func_808B7D34(Actor* thisx, PlayState* play) {
BgBreakwall* this = THIS;
s32 sp48;
s32 tempA;
s32 tempB;
s32 tempC;
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
sp48 = 255 - this->unk_15E;
@ -391,50 +391,50 @@ void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) {
tempB = (((sp48 * 145) + (this->unk_15E * 85)) & 0xFF00) >> 8;
tempC = (((sp48 * 135) + (this->unk_15E * 55)) & 0xFF00) >> 8;
gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, tempA, tempB, tempC));
gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(play->state.gfxCtx, 255, 255, tempA, tempB, tempC));
tempA = (((sp48 * 255) + (this->unk_15E * 150)) & 0xFF00) >> 8;
tempB = (((sp48 * 255) + (this->unk_15E * 100)) & 0xFF00) >> 8;
tempC = (((sp48 * 255) + (this->unk_15E * 75)) & 0xFF00) >> 8;
gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, tempA, tempA, tempB, tempC));
gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(play->state.gfxCtx, 255, tempA, tempA, tempB, tempC));
tempA = (((sp48 * 185) + (this->unk_15E * 140)) & 0xFF00) >> 8;
tempB = (((sp48 * 235) + (this->unk_15E * 45)) & 0xFF00) >> 8;
gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, 255, tempA, tempB));
gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(play->state.gfxCtx, 255, 255, 255, tempA, tempB));
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}
void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) {
void BgBreakwall_Draw(Actor* thisx, PlayState* play) {
s32 pad;
BgBreakwall* this = THIS;
BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)];
OPEN_DISPS(globalCtx->state.gfxCtx);
OPEN_DISPS(play->state.gfxCtx);
if (temp_s2->unk_0C != NULL) {
AnimatedMat_Draw(globalCtx, temp_s2->unk_0C);
AnimatedMat_Draw(play, temp_s2->unk_0C);
}
if (temp_s2->unk_1C != NULL) {
temp_s2->unk_1C(&this->dyna.actor, globalCtx);
temp_s2->unk_1C(&this->dyna.actor, play);
}
if (temp_s2->unk_04 != NULL) {
func_8012C28C(globalCtx->state.gfxCtx);
func_8012C28C(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, temp_s2->unk_04);
}
if (temp_s2->unk_08 != NULL) {
func_8012C2DC(globalCtx->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -5,9 +5,9 @@
struct BgBreakwall;
typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*);
typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*);
typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*);
typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, PlayState*);
typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, PlayState*);
typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, PlayState*);
#define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF)
#define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9)

View File

@ -10,10 +10,10 @@
#define THIS ((BgCraceMovebg*)thisx)
void BgCraceMovebg_Init(Actor* thisx, GlobalContext* globalCtx);
void BgCraceMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgCraceMovebg_Update(Actor* thisx, GlobalContext* globalCtx);
void BgCraceMovebg_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgCraceMovebg_Init(Actor* thisx, PlayState* play);
void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play);
void BgCraceMovebg_Update(Actor* thisx, PlayState* play);
void BgCraceMovebg_Draw(Actor* thisx, PlayState* play);
#if 0
const ActorInit Bg_Crace_Movebg_InitVars = {

View File

@ -5,7 +5,7 @@
struct BgCraceMovebg;
typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, GlobalContext*);
typedef void (*BgCraceMovebgActionFunc)(struct BgCraceMovebg*, PlayState*);
typedef struct BgCraceMovebg {
/* 0x0000 */ Actor actor;

View File

@ -11,13 +11,13 @@
#define THIS ((BgCtowerGear*)thisx)
void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_Init(Actor* thisx, PlayState* play);
void BgCtowerGear_Destroy(Actor* thisx, PlayState* play);
void BgCtowerGear_Update(Actor* thisx, PlayState* play);
void BgCtowerGear_Draw(Actor* thisx, PlayState* play);
void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerGear_UpdateOrgan(Actor* thisx, PlayState* play);
void BgCtowerGear_DrawOrgan(Actor* thisx, PlayState* play);
const ActorInit Bg_Ctower_Gear_InitVars = {
ACTOR_BG_CTOWER_GEAR,
@ -64,7 +64,7 @@ static InitChainEntry sInitChainOrgan[] = {
static Gfx* sDLists[] = { gClockTowerCeilingCogDL, gClockTowerCenterCogDL, gClockTowerWaterWheelDL };
void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
void BgCtowerGear_Splash(BgCtowerGear* this, PlayState* play) {
s32 i;
s32 flag40 = this->dyna.actor.flags & 0x40;
Vec3f splashSpawnPos;
@ -86,7 +86,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f);
splashSpawnPos.y += this->dyna.actor.world.pos.y;
splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f);
EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340);
EffectSsGSplash_Spawn(play, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340);
}
}
}
@ -104,7 +104,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f);
splashSpawnPos.y += this->dyna.actor.world.pos.y;
splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f);
EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280);
EffectSsGSplash_Spawn(play, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280);
}
}
}
@ -112,7 +112,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
}
}
void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerGear_Init(Actor* thisx, PlayState* play) {
BgCtowerGear* this = THIS;
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
@ -128,24 +128,24 @@ void BgCtowerGear_Init(Actor* thisx, GlobalContext* globalCtx) {
}
if (type == BGCTOWERGEAR_WATER_WHEEL) {
DynaPolyActor_Init(&this->dyna, 3);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerWaterWheelCol);
DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerWaterWheelCol);
} else if (type == BGCTOWERGEAR_ORGAN) {
DynaPolyActor_Init(&this->dyna, 0);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerOrganCol);
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerOrganCol);
func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId);
}
}
void BgCtowerGear_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerGear_Destroy(Actor* thisx, PlayState* play) {
BgCtowerGear* this = THIS;
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
if ((type == BGCTOWERGEAR_WATER_WHEEL) || (type == BGCTOWERGEAR_ORGAN)) {
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
}
void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerGear_Update(Actor* thisx, PlayState* play) {
BgCtowerGear* this = THIS;
s32 type = BGCTOWERGEAR_GET_TYPE(&this->dyna.actor);
@ -156,22 +156,22 @@ void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) {
func_800B9010(&this->dyna.actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG);
} else if (type == BGCTOWERGEAR_WATER_WHEEL) {
this->dyna.actor.shape.rot.z -= 0x1F4;
BgCtowerGear_Splash(this, globalCtx);
BgCtowerGear_Splash(this, play);
}
}
void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerGear_UpdateOrgan(Actor* thisx, PlayState* play) {
BgCtowerGear* this = THIS;
if (Cutscene_CheckActorAction(globalCtx, 104)) {
switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 104)]->action) {
if (Cutscene_CheckActorAction(play, 104)) {
switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 104)]->action) {
case 1:
this->dyna.actor.draw = NULL;
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId);
break;
case 2:
this->dyna.actor.draw = BgCtowerGear_DrawOrgan;
func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId);
break;
case 3:
Actor_MarkForDeath(&this->dyna.actor);
@ -180,17 +180,17 @@ void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) {
}
}
void BgCtowerGear_Draw(Actor* thisx, GlobalContext* globalCtx) {
Gfx_DrawDListOpa(globalCtx, sDLists[BGCTOWERGEAR_GET_TYPE(thisx)]);
void BgCtowerGear_Draw(Actor* thisx, PlayState* play) {
Gfx_DrawDListOpa(play, sDLists[BGCTOWERGEAR_GET_TYPE(thisx)]);
}
void BgCtowerGear_DrawOrgan(Actor* thisx, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
void BgCtowerGear_DrawOrgan(Actor* thisx, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, gClockTowerOrganDL);
func_8012C2DC(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_8012C2DC(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gClockTowerOrganPipesDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -11,15 +11,15 @@
#define THIS ((BgCtowerRot*)thisx)
void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgCtowerRot_Init(Actor* thisx, PlayState* play);
void BgCtowerRot_Destroy(Actor* thisx, PlayState* play);
void BgCtowerRot_Update(Actor* thisx, PlayState* play);
void BgCtowerRot_Draw(Actor* thisx, PlayState* play);
void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx);
void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx);
void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx);
void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx);
void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play);
void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, PlayState* play);
void BgCtowerRot_DoorIdle(BgCtowerRot* this, PlayState* play);
void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, PlayState* play);
const ActorInit Bg_Ctower_Rot_InitVars = {
ACTOR_BG_CTOWER_ROT,
@ -39,7 +39,7 @@ static InitChainEntry sInitChain[] = {
static Gfx* sDLists[] = { gClockTowerCorridorDL, gClockTowerStoneDoorMainDL, gClockTowerStoneDoorDL };
void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerRot_Init(Actor* thisx, PlayState* play) {
s32 pad;
BgCtowerRot* this = THIS;
Player* player;
@ -48,17 +48,17 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) {
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, 1);
if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) {
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerCorridorCol);
DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerCorridorCol);
this->actionFunc = BgCtowerRot_CorridorRotate;
return;
}
player = GET_PLAYER(globalCtx);
player = GET_PLAYER(play);
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorMainCol);
DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerStoneDoorMainCol);
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x4000;
} else {
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTowerStoneDoorCol);
DynaPolyActor_LoadMesh(play, &this->dyna, &gClockTowerStoneDoorCol);
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000;
}
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos);
@ -72,31 +72,31 @@ void BgCtowerRot_Init(Actor* thisx, GlobalContext* globalCtx) {
}
}
void BgCtowerRot_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerRot_Destroy(Actor* thisx, PlayState* play) {
BgCtowerRot* this = THIS;
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
void BgCtowerRot_CorridorRotate(BgCtowerRot* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Vec3f offset;
f32 rotZ;
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos);
rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f);
func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17);
func_800DFAC8(play->cameraPtrs[CAM_ID_MAIN], 17);
this->dyna.actor.shape.rot.z = rotZ * 16.384f;
if (globalCtx->csCtx.frames == 132) {
if (play->csCtx.frames == 132) {
play_sound(NA_SE_SY_SPIRAL_DASH);
}
}
void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, GlobalContext* globalCtx) {
void BgCtowerRot_DoorDoNothing(BgCtowerRot* this, PlayState* play) {
}
void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
void BgCtowerRot_DoorClose(BgCtowerRot* this, PlayState* play) {
if (!Math_SmoothStepToF(&this->timer, 0.0f, 0.1f, 15.0f, 0.1f)) {
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
@ -112,8 +112,8 @@ void BgCtowerRot_DoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * this->timer);
}
void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
void BgCtowerRot_DoorIdle(BgCtowerRot* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Vec3f offset;
Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos);
@ -124,7 +124,7 @@ void BgCtowerRot_DoorIdle(BgCtowerRot* this, GlobalContext* globalCtx) {
}
}
void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, PlayState* play) {
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
if (this->dyna.actor.params == BGCTOWERROT_STONE_DOOR_MAIN) {
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
@ -135,17 +135,17 @@ void BgCtowerRot_SetupDoorClose(BgCtowerRot* this, GlobalContext* globalCtx) {
}
}
void BgCtowerRot_Update(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerRot_Update(Actor* thisx, PlayState* play) {
BgCtowerRot* this = THIS;
this->actionFunc(this, globalCtx);
this->actionFunc(this, play);
}
void BgCtowerRot_Draw(Actor* thisx, GlobalContext* globalCtx) {
void BgCtowerRot_Draw(Actor* thisx, PlayState* play) {
BgCtowerRot* this = THIS;
Gfx_DrawDListOpa(globalCtx, sDLists[this->dyna.actor.params]);
Gfx_DrawDListOpa(play, sDLists[this->dyna.actor.params]);
if (this->dyna.actor.params == BGCTOWERROT_CORRIDOR) {
Gfx_DrawDListXlu(globalCtx, gClockTowerCorridorFoliageDL);
Gfx_DrawDListXlu(play, gClockTowerCorridorFoliageDL);
}
}

View File

@ -5,7 +5,7 @@
struct BgCtowerRot;
typedef void (*BgCtowerRotActionFunc)(struct BgCtowerRot*, GlobalContext*);
typedef void (*BgCtowerRotActionFunc)(struct BgCtowerRot*, PlayState*);
typedef enum {
/* 0 */ BGCTOWERROT_CORRIDOR,

View File

@ -10,9 +10,9 @@
#define THIS ((BgDanpeiMovebg*)thisx)
void BgDanpeiMovebg_Init(Actor* thisx, GlobalContext* globalCtx);
void BgDanpeiMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgDanpeiMovebg_Update(Actor* thisx, GlobalContext* globalCtx);
void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play);
void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play);
void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play);
#if 0
const ActorInit Bg_Danpei_Movebg_InitVars = {

Some files were not shown because too many files have changed in this diff Show More