-
Notifications
You must be signed in to change notification settings - Fork 74
Some nz1 duplicate functions #3102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,32 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
| #include "nz1.h" | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_red_door", EntityIsNearPlayer); | ||
| extern u16 PLAYER_posX_i_hi; | ||
| extern u16 PLAYER_posY_i_hi; | ||
|
Comment on lines
+4
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused declarations. |
||
|
|
||
| static bool EntityIsNearPlayer(Entity* self) { | ||
| s16 distanceX; | ||
| s16 diffX; | ||
| s16 distanceY; | ||
| s16 diffY; | ||
|
|
||
| diffX = PLAYER.posX.i.hi - self->posX.i.hi; | ||
| distanceX = abs(diffX); | ||
| #ifdef STAGE_IS_NO1 | ||
| if (distanceX > 24) { | ||
| #else | ||
| if (distanceX > 16) { | ||
| #endif | ||
| return false; | ||
| } | ||
|
|
||
| diffY = PLAYER.posY.i.hi - self->posY.i.hi; | ||
| distanceY = abs(diffY); | ||
| if (distanceY > 32) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_red_door", NZ1_EntityRedDoor); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,40 @@ INCLUDE_ASM("st/nz1/nonmatchings/e_skull_lord", EntitySkullLordOutline); | |
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_skull_lord", EntitySkullLordFlames); | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_skull_lord", EntitySkullLordPieces); | ||
| extern EInit g_EInitSkullLord; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused declaration. |
||
| extern EInit D_us_80180BAC; | ||
|
|
||
| void EntitySkullLordPieces(Entity* self) { | ||
| s32 rand; | ||
| s16 angle; | ||
| s32 step = (s32)self->step; | ||
|
|
||
| switch (step) { | ||
| case 0: | ||
| InitializeEntity(D_us_80180BAC); | ||
| self->flags |= FLAG_DESTROY_IF_OUT_OF_CAMERA; | ||
| rand = Random() & 3; | ||
| if (rand == 3) { | ||
| rand = 2; | ||
| } | ||
| self->animCurFrame = rand + 9; | ||
| angle = self->ext.skullLord.unk82; | ||
| rand = (Random() & 0xF) + 2; | ||
| self->velocityX = rand * rcos(angle); | ||
| rand = 0x20 - (Random() & 0x1F); | ||
| self->velocityY = -rand * rsin(angle); | ||
| self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE; | ||
| self->drawFlags = FLAG_DRAW_ROTATE; | ||
| break; | ||
|
|
||
| case 1: | ||
| MoveEntity(); | ||
| self->velocityY += FIX(0.125); | ||
| if (self->velocityX > 0) { | ||
| self->rotate += 0x80; | ||
| } else { | ||
| self->rotate -= 0x80; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,42 @@ | |
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_vandal_sword", VandalSwordDrawAlastor); | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_vandal_sword", VandalSwordTargetPlayer); | ||
| extern Entity g_Entities_224; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a shorthand symbol for the array entry |
||
| extern int g_Timer; | ||
| extern Entity* g_CurrentEntity; | ||
|
Comment on lines
+7
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will come from |
||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_vandal_sword", VandalSwordTrail); | ||
| void VandalSwordTargetPlayer(void) { | ||
| Entity* temp_v0 = NULL; | ||
|
|
||
| if (g_Timer & 7) | ||
| goto done; | ||
|
Comment on lines
+13
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| temp_v0 = AllocEntity( | ||
| &g_Entities_224, (Entity*)((char*)&g_Entities_224 + 0x1780)); | ||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (temp_v0 == NULL) | ||
| goto done; | ||
|
|
||
| CreateEntityFromEntity(E_VANDAL_SWORD_DEATH, g_CurrentEntity, temp_v0); | ||
| temp_v0->rotate = (s16)(u16)g_CurrentEntity->rotate; | ||
| temp_v0->facingLeft = g_CurrentEntity->facingLeft; | ||
|
|
||
| done: | ||
| return; | ||
| } | ||
|
|
||
| bool VandalSwordTrail(s16* val, s16 target, s16 step) { | ||
| if (abs(*val - target) < step) { | ||
| *val = target; | ||
| return true; | ||
| } | ||
| if (*val > target) { | ||
| *val -= step; | ||
| } | ||
| if (*val < target) { | ||
| *val += step; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/e_vandal_sword", EntityVandalSword); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,86 @@ INCLUDE_ASM("st/nz1/nonmatchings/water_effects", EntitySideWaterSplash); | |
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/water_effects", EntitySmallWaterDrop); | ||
|
|
||
| INCLUDE_ASM("st/nz1/nonmatchings/water_effects", EntityWaterDrop); | ||
| extern EInit g_EInitCommon; | ||
| extern s16 (*g_api_func_800EDB58)(s32 kind, s32 count); | ||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like |
||
|
|
||
| void EntityWaterDrop(Entity* self) { | ||
| s16 x = self->posX.i.hi; | ||
| s16 y = self->posY.i.hi; | ||
| FakePrim* prim; | ||
| s32 primIndex; | ||
|
|
||
| switch (self->step) { | ||
| case 0: | ||
| InitializeEntity(g_EInitCommon); | ||
| primIndex = g_api_func_800EDB58(PRIM_TILE_ALT, 0x21); | ||
| if (primIndex == -1) { | ||
| DestroyEntity(self); | ||
| return; | ||
| } | ||
| self->flags |= FLAG_HAS_PRIMS; | ||
| self->primIndex = primIndex; | ||
| self->ext.timer.t = 0x2F; | ||
| prim = (FakePrim*)&g_PrimBuf[primIndex]; | ||
|
|
||
| while (1) { | ||
| prim->drawMode = DRAW_UNK_40 | DRAW_TPAGE2 | DRAW_TPAGE | | ||
| DRAW_UNK02 | DRAW_TRANSP; | ||
| prim->priority = self->zPriority + 2; | ||
|
|
||
| if (prim->next == NULL) { | ||
| prim->drawMode &= ~DRAW_HIDE; | ||
| prim->y0 = prim->x0 = prim->w = 0; | ||
| break; | ||
| } | ||
|
|
||
| prim->posX.i.lo = prim->posY.i.lo = 0; | ||
| prim->velocityY.val = (rand() & PSP_RANDMASK) * 8 + self->velocityY; | ||
| prim->posY.i.hi = y + (rand() & 15); | ||
| prim->posX.i.hi = x + (rand() & 31) - 16; | ||
| prim->delay = (rand() & 15) + 32; | ||
| prim->x0 = prim->posX.i.hi; | ||
| prim->y0 = prim->posY.i.hi; | ||
| prim->r0 = 255; | ||
| prim->g0 = 255; | ||
| prim->b0 = 255; | ||
| prim->w = 2; | ||
| prim->h = 2; | ||
| prim = prim->next; | ||
| } | ||
| break; | ||
|
|
||
| case 1: | ||
| if (--self->ext.timer.t == 0) { | ||
| DestroyEntity(self); | ||
| return; | ||
| } | ||
|
|
||
| prim = (FakePrim*)&g_PrimBuf[self->primIndex]; | ||
|
|
||
| while (1) { | ||
| if (prim->next == NULL) { | ||
| prim->drawMode &= ~DRAW_HIDE; | ||
| prim->y0 = prim->x0 = prim->w = 0; | ||
| return; | ||
| } | ||
| prim->posX.i.hi = prim->x0; | ||
| prim->posY.i.hi = prim->y0; | ||
| if (!--prim->delay) { | ||
| prim->drawMode |= DRAW_HIDE; | ||
| } | ||
| prim->posY.val += prim->velocityY.val; | ||
| if (prim->velocityY.val > FIX(0.5)) { | ||
| prim->r0 -= 4; | ||
| prim->g0 -= 4; | ||
| prim->b0 -= 4; | ||
| } else { | ||
| prim->velocityY.val += FIX(28.0 / 128); | ||
| } | ||
| prim->x0 = prim->posX.i.hi; | ||
| prim->y0 = prim->posY.i.hi; | ||
| prim = prim->next; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks identical to the version in
src/st/e_red_door.h.The "interesting" function in this file is
NZ1_EntityRedDoor, which is only a partial match with the otherEntityRedoDoorimplementations.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just on this - if you're interested in seeing how including the existing shared header is done I did this recently when I imported the RCAT overlay
34beb11
(among other deduplication via shared header, see commits)
If you would like some more guidance on this feel free to reach out on Discord!