Merge branch 'master' into enemies

This commit is contained in:
octorock
2023-12-29 23:04:14 +01:00
434 changed files with 12169 additions and 14806 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ void CopyOAM(void) {
void DrawEntities(void) {
void (*fn)(void);
gOAMControls._0[6] = gRoomTransition.field_0x2c[2] ? 15 : 0;
gOAMControls._0[6] = gRoomTransition.field2f ? 15 : 0;
gOAMControls._4 = gRoomControls.aff_x + gRoomControls.scroll_x;
gOAMControls._6 = gRoomControls.aff_y + gRoomControls.scroll_y;
gOAMControls.field_0x1++;
+186 -25
View File
@@ -116,7 +116,7 @@ void sub_08019764(void) {
UpdateEntities();
DrawEntities();
CopyOAM();
if ((--gUnk_02018EB0.unk_4 == 0) || ((gInput.newKeys & 10) != 0)) {
if ((--gUnk_02018EB0.unk_4 == 0) || ((gInput.newKeys & (B_BUTTON | START_BUTTON)) != 0)) {
gUnk_02018EB0.unk_0++;
}
}
@@ -170,7 +170,7 @@ u32 UpdatePlayerCollision(void) {
u32 index;
const s16* ptr1;
const s16* ptr2;
s32 tmp1;
s32 framestate;
u32 tmp2;
u32 tmp3;
// There are some weird assignment necessary to access gPlayerEntity.animationState correctly.
@@ -178,18 +178,18 @@ u32 UpdatePlayerCollision(void) {
u32 animationState2;
u32 animationState3;
if (gPlayerState.framestate == 0) {
tmp1 = gPlayerState.framestate_last;
if (gPlayerState.framestate == PL_STATE_IDLE) {
framestate = gPlayerState.framestate_last;
} else {
tmp1 = gPlayerState.framestate;
framestate = gPlayerState.framestate;
}
switch (tmp1) {
case 3:
switch (framestate) {
case PL_STATE_GUSTJAR:
return 0;
case 0x12:
case PL_STATE_DIE:
return 0;
case 0x16:
case PL_STATE_DROWN:
return 0;
}
@@ -198,7 +198,7 @@ u32 UpdatePlayerCollision(void) {
} else {
direction = gPlayerState.direction;
}
if (((direction & 0x83) == 0) && (gPlayerState.field_0xa == 0)) {
if (((direction & (DIR_NOT_MOVING_CHECK | 0x3)) == 0) && (gPlayerState.field_0xa == 0)) {
index = sub_0807BDB8(&gPlayerEntity, direction >> 2);
if (index != 0xff && (gRoomControls.scroll_flags & 4) == 0) {
ptr1 = &gUnk_080B4490[index * 2];
@@ -254,10 +254,11 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerState.field_0xa != 0) {
return 0;
}
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) {
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction !=
DirectionNorth) {
return 0;
}
if ((gPlayerEntity.direction & 0x80) != 0) {
if ((gPlayerEntity.direction & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if (sub_080B1B44(position, gPlayerEntity.collisionLayer) != 0xf) {
@@ -305,10 +306,10 @@ u32 UpdatePlayerCollision(void) {
case 0x3a:
case 0x5b:
case 0x4051:
if ((gPlayerState.flags & PL_MINISH) != 0) {
if (gPlayerState.flags & PL_MINISH) {
return 0;
}
if (gPlayerEntity.animationState != 0) {
if (gPlayerEntity.animationState != IdleNorth) {
return 0;
}
gUnk_0200AF00.rActionInteractTile = R_ACTION_READ;
@@ -356,7 +357,8 @@ u32 UpdatePlayerCollision(void) {
return 0;
}
#endif
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction != 0) {
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction !=
DirectionNorth) {
return 0;
}
if ((gPlayerEntity.direction & 0x80) != 0) {
@@ -415,7 +417,7 @@ u32 UpdatePlayerCollision(void) {
if ((animationState1 & 0xff) != 0) {
return 0;
}
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 2) == 0) {
@@ -555,7 +557,7 @@ u32 UpdatePlayerCollision(void) {
if (animationState3 == 0) {
return 0;
}
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 1) == 0) {
@@ -574,7 +576,7 @@ u32 UpdatePlayerCollision(void) {
if ((animationState2) != 4) {
return 0;
}
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 1) == 0) {
@@ -595,7 +597,8 @@ bool32 sub_0801A2B0(LayerStruct* layer, u32 position, u32 collisionType) {
u16 temp4;
uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1];
if ((((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) == 0) && ((gPlayerEntity.frame & 1) != 0)) {
if ((((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) == 0) &&
((gPlayerEntity.frame & 1) != 0)) {
position = (u16)(position - (-uVar1)); // necessary for match
temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer));
switch (temp4) {
@@ -712,18 +715,18 @@ bool32 sub_0801A4F8(void) {
if (GetInventoryValue(ITEM_POWER_BRACELETS) != 1) {
return FALSE;
}
if ((gPlayerState.direction & 0x80) != 0) {
if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE;
}
if (gPlayerState.direction != gPlayerEntity.direction) {
return FALSE;
}
tmp = (((gPlayerEntity.direction + 4) & 0x18) >> 3);
tmp = (((gPlayerEntity.direction + 4) & DirectionWest) >> 3);
if ((gUnk_080B44A0[tmp] & gPlayerEntity.collisions) == 0) {
return FALSE;
}
} else {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & 0x80) != 0) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE;
}
if ((gPlayerEntity.frame & 1) == 0) {
@@ -733,7 +736,165 @@ bool32 sub_0801A4F8(void) {
return TRUE;
}
ASM_FUNC("asm/non_matching/beanstalkSubtask/sub_0801A570.inc", u32 sub_0801A570(Entity* a, u32 b))
u32 sub_0801A570(Entity* this, u32 param_2) {
LayerStruct* layer;
u32 tileType;
u32 position;
u32 index1;
u32 index2;
u16* metatileTypes;
u8* collisionData;
if (this == NULL) {
return 0xffff;
}
layer = GetLayerByIndex(this->collisionLayer);
metatileTypes = layer->metatileTypes;
index1 = 4;
index2 = 2;
switch (this->animationState >> 1) {
case 0:
default:
position = COORD_TO_TILE_OFFSET(this, 0, 10);
do {
if (metatileTypes[layer->mapData[position]] == 0x370)
break;
position--;
index1--;
} while (index1 != 0);
position = position - 0x40;
do {
if (metatileTypes[layer->mapData[(position)]] != 0x374)
break;
index2++;
position -= 0x40;
} while (index2 < 4);
if (param_2 == 0) {
return position;
}
index1 = GetTileType(position, this->collisionLayer);
if ((index1 - 0x369) > 1) {
position = 0xffff;
} else {
collisionData = layer->collisionData - 0x40 + position;
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1] != 0) {
position = 0xffff;
break;
}
}
}
break;
case 1:
position = COORD_TO_TILE_OFFSET(this, -10, 0);
do {
if (layer->metatileTypes[layer->mapData[position]] == 0x370)
break;
position += 0x40;
index1--;
} while (index1 != 0);
position = position - 0x40;
do {
if (metatileTypes[layer->mapData[(position)]] != 0x374)
break;
index2++;
position -= 0x40;
} while (index2 < 4);
if (param_2 == 0) {
return position;
}
index1 = GetTileType(position, this->collisionLayer);
if (!(index1 == 0x369) && !(index1 == 0x36d))
position = 0xffff;
else {
collisionData = layer->collisionData + (position + index2);
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1 * 0x40] != 0) {
position = 0xffff;
break;
}
}
}
break;
case 2:
position = COORD_TO_TILE_OFFSET(this, 0, -10);
do {
if (layer->metatileTypes[layer->mapData[position]] == 0x36f)
break;
position++;
index1--;
} while (index1 != 0);
position = position - 1;
do {
if (metatileTypes[layer->mapData[position]] != 0x372)
break;
index2++;
position--;
} while (index2 < 4);
if (param_2 == 0) {
return position;
}
index1 = GetTileType(position, this->collisionLayer);
if (!(index1 == 0x369) && !(index1 == 0x36b))
position = 0xffff;
else {
collisionData = layer->collisionData + (position + (index2 * 0x40));
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1] != 0) {
position = 0xffff;
break;
}
}
}
break;
case 3:
position = COORD_TO_TILE_OFFSET(this, 10, 0);
do {
if (layer->metatileTypes[layer->mapData[position]] == 0x36f)
break;
position -= 0x40;
index1--;
} while (index1 != 0);
position = position - 1;
do {
if (metatileTypes[layer->mapData[position]] != 0x372)
break;
index2++;
position--;
} while (index2 < 4);
if (param_2 == 0) {
return position;
}
index1 = GetTileType(position, this->collisionLayer);
if (!(index1 == 0x369) && !(index1 == 0x36c))
position = 0xffff;
else {
collisionData = layer->collisionData - 1 + position;
for (index1 = 0; index1 < index2; index1++) {
if (collisionData[index1 * 0x40] != 0) {
position = 0xffff;
break;
}
}
}
}
if (param_2 != 0) {
position |= index2 << 0xc;
}
return position;
}
u32 sub_0801A8D0(Entity* this, u32 param_2) {
u16* mapData;
@@ -1024,7 +1185,7 @@ void sub_0801AE44(bool32 loadGfx) {
}
sub_080809D4();
UpdateIsDiggingCave();
if (gRoomTransition.field_0x2c[0] != 0) {
if (gRoomTransition.field2d != 0) {
sub_0807C898();
}
if (gArea.lightType != 0) {
@@ -1061,7 +1222,7 @@ void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer) {
// Add a new entry at the end of gUnk_0200B240
void sub_0801AF48(u32 data, u32 position, u32 layer) {
u32 index;
if ((data < 0x4000) && (gRoomTransition.field_0x2c[3] == 0)) {
if ((data < 0x4000) && (gRoomTransition.field30 == 0)) {
index = gRoomVars.unk_0e;
if (index < 0x100) {
gUnk_0200B240[index].data = data;
+20 -26
View File
@@ -77,42 +77,36 @@ void UpdatePlayerInput(void) {
u32 prevState;
PlayerInput* playerInput;
PlayerMacroEntry* playerMacro;
u32 zero;
if (gPlayerState.playerInput.playerMacro != NULL) {
// Player is controlled by macro.
playerInput = &gPlayerState.playerInput;
playerMacro = playerInput->playerMacro;
if (playerInput->playerMacroWaiting == 0) { // Execute next macro entry.
zero = 0;
goto code_2;
code_0:
if (flags != 2) {
playerInput->playerMacroWaiting = playerMacro->flags;
playerInput->playerMacroHeldKeys = playerMacro->keys;
}
playerMacro++;
playerInput->playerMacro = playerMacro;
goto code_4;
code_2:
do {
flags = playerMacro->flags >> 0xe;
if (flags != 1) {
break;
if (flags == 1)
(u8*)playerMacro += ((s16)playerMacro->keys);
else {
if (flags == 3) {
playerInput->playerMacroWaiting = 0;
playerInput->playerMacroHeldKeys = 0;
playerMacro = NULL;
playerInput->playerMacro = playerMacro;
break;
} else {
if (flags != 2) {
playerInput->playerMacroWaiting = playerMacro->flags;
playerInput->playerMacroHeldKeys = playerMacro->keys;
}
playerMacro++;
playerInput->playerMacro = playerMacro;
break;
}
}
(u8*)playerMacro += ((s16)playerMacro->keys);
} while (TRUE);
if (flags == 3) {
playerInput->playerMacroWaiting = zero;
playerInput->playerMacroHeldKeys = zero;
playerMacro = NULL;
playerInput->playerMacro = playerMacro;
} else {
goto code_0;
}
} while (TRUE);
}
code_4:
playerInput->playerMacroWaiting--;
keys = playerInput->playerMacroHeldKeys;
} else {
@@ -183,7 +177,7 @@ u32 ConvInputToState(u32 keys) {
}
void sub_0805EE88(void) {
if ((gRoomTransition.field_0x2c[2] != 0) && ((gRoomTransition.frameCount & 3) == 0)) {
if ((gRoomTransition.field2f != 0) && ((gRoomTransition.frameCount & 3) == 0)) {
LoadPaletteGroup((((u32)gRoomTransition.frameCount & 0xc) >> 2) + 0x2f);
}
}
+2 -2
View File
@@ -54,7 +54,7 @@ void sub_0801D000(u32 a1) {
tmp = 0;
}
roomTransition->field_0x2c[2] = tmp;
roomTransition->field2f = tmp;
if (a1) {
CleanUpObjPalettes();
sub_0801CFD0(0xf);
@@ -162,7 +162,7 @@ u32 FindFreeObjPalette(u32 paletteCount) {
void SetEntityObjPalette(Entity* entity, s32 palette) {
u32 uVar1;
u32 mask;
FORCE_REGISTER(u32 tmp, r1);
u32 tmp;
Palette2* pPVar1;
if (palette < 0) {
+317 -143
View File
@@ -25,10 +25,11 @@ typedef struct {
extern u8 gUnk_03003DE0;
extern u8 gzHeap[0x1000];
extern u8 gUnk_02035542[];
extern u32 gUnk_0201AEE0[0x800];
extern s16 gUnk_02018EE0[];
extern void (*const gUnk_080C9CAC[])(void);
extern void (*const gFuseActions[])(void);
static void StoreKeyInput(Input* input, u32 keyInput);
void ClearOAM(void);
@@ -84,6 +85,7 @@ bool32 IsRoomVisited(TileEntity* tileEntity, u32 bank);
u32 sub_0801DF60(u32 a1, u8* p);
u32 sub_0801DF78(u32 a1, u32 a2);
void sub_0801DF28(u32 x, u32 y, s32 color);
void sub_0801E64C(s32 x1, s32 y1, s32 x2, s32 y2, s32 offset);
extern void* GetRoomProperty(u32, u32, u32);
@@ -347,7 +349,106 @@ void sub_0801D898(void* dest, void* src, u32 word, u32 size) {
} while (--size);
}
ASM_FUNC("asm/non_matching/common/zMalloc.inc", void* zMalloc(u32 size));
void* zMalloc(u32 size) {
u16* heapStartOffset;
u32 slotFound;
u8* allocatedEntryStartOffset;
u8* allocatedEntryEndOffset;
u8* candidateSlotEndOffset;
u8* candidateSlotStartOffset;
u16 index1, index2;
u16 numEntries;
// align to 4
size = (size + 3) & ~3;
heapStartOffset = (u16*)(gzHeap);
numEntries = heapStartOffset[0];
slotFound = TRUE;
// Check for a candidate slot at the tail-end of the heap buffer
candidateSlotEndOffset = (u8*)heapStartOffset + sizeof(gzHeap);
candidateSlotStartOffset = candidateSlotEndOffset - size;
for (index2 = 0; index2 < numEntries; index2++) {
// Check if there is overlap with already allocated slots
allocatedEntryStartOffset = gzHeap + heapStartOffset[(index2 * 2) + 1];
allocatedEntryEndOffset = gzHeap + heapStartOffset[(index2 * 2) + 2];
if ((allocatedEntryStartOffset <= candidateSlotStartOffset &&
candidateSlotStartOffset <= allocatedEntryEndOffset)) {
slotFound = FALSE;
break;
}
if ((allocatedEntryStartOffset <= candidateSlotEndOffset &&
candidateSlotEndOffset <= allocatedEntryEndOffset)) {
slotFound = FALSE;
break;
}
if ((allocatedEntryStartOffset <= candidateSlotStartOffset &&
candidateSlotEndOffset <= allocatedEntryEndOffset) ||
(candidateSlotStartOffset <= allocatedEntryStartOffset &&
allocatedEntryEndOffset <= candidateSlotEndOffset)) {
slotFound = FALSE;
break;
}
}
if (!slotFound) {
index1 = 0;
// Start searching for candidate slot from the left side of the heap buffer.
do {
candidateSlotEndOffset = gzHeap + heapStartOffset[(index1 * 2) + 1];
candidateSlotStartOffset = candidateSlotEndOffset - size;
slotFound = FALSE;
// Ensure that the candidate slot doesn't collide with heap offsets section
if (candidateSlotStartOffset >= (u8*)(2 + (u32)heapStartOffset + (numEntries << 2) + 4)) {
slotFound = TRUE;
// Check if there is overlap with already allocated slots
for (index2 = 0; index2 < numEntries; index2++) {
allocatedEntryStartOffset = gzHeap + heapStartOffset[(index2 * 2) + 1];
allocatedEntryEndOffset = gzHeap + heapStartOffset[(index2 * 2) + 2];
if ((allocatedEntryStartOffset <= candidateSlotStartOffset &&
candidateSlotStartOffset < allocatedEntryEndOffset)) {
slotFound = FALSE;
break;
}
if ((allocatedEntryStartOffset < candidateSlotEndOffset &&
candidateSlotEndOffset <= allocatedEntryEndOffset)) {
slotFound = FALSE;
break;
}
if ((allocatedEntryStartOffset <= candidateSlotStartOffset &&
candidateSlotEndOffset <= allocatedEntryEndOffset) ||
(candidateSlotStartOffset <= allocatedEntryStartOffset &&
allocatedEntryEndOffset <= candidateSlotEndOffset)) {
slotFound = FALSE;
break;
}
}
if (slotFound) {
break;
}
}
} while ((index1 = (u16)(index1 + 1)) < numEntries);
}
if (!slotFound)
return 0;
// Register successful allocation
*(u16*)(gUnk_02035542 + (numEntries << 2)) = candidateSlotStartOffset - (gUnk_02035542 - 2);
*(u16*)(gUnk_02035542 + (numEntries << 2) + 2) = candidateSlotStartOffset - (gUnk_02035542 - 2) + size;
*(u16*)(gUnk_02035542 - 2) = numEntries + 1;
MemClear(candidateSlotStartOffset, size);
return candidateSlotStartOffset;
}
void zFree(void* ptr) {
u32 uVar1;
@@ -619,69 +720,71 @@ bool32 IsRoomVisited(TileEntity* tileEntity, u32 bank) {
return FALSE;
}
void sub_0801DFB4(Entity* entity, u32 textIndex, u32 a3, u32 a4) {
void InitializeFuseInfo(Entity* entity, u32 textIndex, u32 cancelledTextIndex, u32 fusingTextIndex) {
MemClear(&gFuseInfo, sizeof(gFuseInfo));
gFuseInfo.textIndex = textIndex;
gFuseInfo._8 = a3;
gFuseInfo._a = a4;
gFuseInfo.ent = entity;
gFuseInfo.cancelledTextIndex = cancelledTextIndex;
gFuseInfo.fusingTextIndex = fusingTextIndex;
gFuseInfo.entity = entity;
gFuseInfo.kinstoneId = gPossibleInteraction.kinstoneId;
if (entity != NULL) {
gFuseInfo.prevUpdatePriority = entity->updatePriority;
entity->updatePriority = 2;
}
gFuseInfo._0 = 0;
gFuseInfo.fusionState = FUSION_STATE_0;
}
u32 sub_0801E00C(void) {
gUnk_080C9CAC[gFuseInfo.action]();
return gFuseInfo._0;
// returns the fusion state
u32 PerformFuseAction(void) {
gFuseActions[gFuseInfo.action]();
return gFuseInfo.fusionState;
}
void sub_0801E02C(void) {
void Fuse_Action0(void) {
MessageFromFusionTarget(gFuseInfo.textIndex);
gFuseInfo._0 = 3;
gFuseInfo.fusionState = FUSION_STATE_3;
gFuseInfo.action = 1;
}
void sub_0801E044(void) {
void Fuse_Action1(void) {
if ((gMessage.doTextBox & 0x7F) == 0) {
MenuFadeIn(4, 0);
gFuseInfo._0 = 4;
gFuseInfo.fusionState = FUSION_STATE_4;
gFuseInfo.action = 2;
SoundReq(SFX_6B);
}
}
void sub_0801E074(void) {
u32 tmp;
switch (gFuseInfo._0) {
case 5:
tmp = gFuseInfo._8;
// Waits until FUSION_STATE_5 or FUSION_STATE_6 is reached and displays the corresponding message.
void Fuse_Action2(void) {
u32 textIndex;
switch (gFuseInfo.fusionState) {
case FUSION_STATE_5:
textIndex = gFuseInfo.cancelledTextIndex;
break;
case 6:
tmp = gFuseInfo._a;
case FUSION_STATE_6:
textIndex = gFuseInfo.fusingTextIndex;
break;
default:
return;
}
MessageFromFusionTarget(tmp);
MessageFromFusionTarget(textIndex);
gFuseInfo.action = 3;
}
void sub_0801E0A0(void) {
void Fuse_Action3(void) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if (gFuseInfo.ent != NULL) {
gFuseInfo.ent->updatePriority = gFuseInfo.prevUpdatePriority;
if (gFuseInfo.entity != NULL) {
gFuseInfo.entity->updatePriority = gFuseInfo.prevUpdatePriority;
}
gFuseInfo._0 = gFuseInfo._0 == 6 ? 2 : 1;
gFuseInfo.fusionState = gFuseInfo.fusionState == FUSION_STATE_6 ? FUSION_STATE_2 : FUSION_STATE_1;
}
}
void MessageFromFusionTarget(u32 textIndex) {
if (textIndex != 0) {
if (gFuseInfo.ent != NULL) {
MessageNoOverlap(textIndex, gFuseInfo.ent);
if (gFuseInfo.entity != NULL) {
MessageNoOverlap(textIndex, gFuseInfo.entity);
} else {
MessageFromTarget(textIndex);
}
@@ -790,46 +893,159 @@ void sub_0801E290(u32 param_1, u32 param_2, u32 count) {
}
}
ASM_FUNC("asm/non_matching/common/sub_0801E31C.inc", void sub_0801E31C(u32 a1, u32 a2, u32 a3, u32 a4));
void sub_0801E31C(u32 sp00, u32 sp04, s32 r10, s32 r9) {
u16 sp1c, sp1c2;
u16 kk, kk2;
u16 uVar2;
s32 r5;
s32 r6;
s32 r7;
s32 r8; // the lower one of param3 and param4
ASM_FUNC("asm/non_matching/common/sub_0801E49C.inc", void sub_0801E49C(u32 a1, u32 a2, u32 a3, u32 a4));
MemClear(&gUnk_02017AA0[gUnk_03003DE4[0]], 0xa00);
if (r10 < r9) {
r6 = 0;
r7 = r8 = r10;
r5 = 3 - r8 * 2;
void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_5) {
s32 sVar1;
s32* ptr = (s32*)gUnk_02018EE0;
register s32 tmp asm("r1");
if ((0 <= param_2 || 0 <= param_4) && (param_2 < 0xa0 || (param_4 < 0xa0))) {
if (param_2 > param_4) {
SWAP(param_2, param_4, tmp);
SWAP(param_1, param_3, tmp);
while (r6 <= r7) {
sp1c = Div(r9 * r6, r10);
kk = Div(r9 * r7, r10);
// TODO: Fix data type in declaration. There shouldn't be a need to cast this.
((u32*)gUnk_02018EE0)[r6] = kk;
((u32*)gUnk_02018EE0)[r7] = sp1c;
if (r5 < 0) {
r5 += 6 + r6 * 4;
r6++;
} else {
r5 += 10 + (r6 - r7) * 4;
r7--;
r6++;
}
}
if (param_2 != param_4) {
sVar1 = Div((param_3 - param_1) * 0x10000, param_4 - param_2);
if (param_2 < 0) {
param_1 += (sVar1 * -param_2) >> 0x10;
param_2 = 0;
} else {
r6 = 0;
r7 = r8 = r9;
r5 = 3 - r8 * 2;
while (r6 <= r7) {
sp1c2 = Div(r10 * r6, r9);
kk2 = Div(r10 * r7, r9);
// TODO: Fix data type in declaration. There shouldn't be a need to cast this.
((u32*)gUnk_02018EE0)[r6] = kk2;
((u32*)gUnk_02018EE0)[r7] = sp1c2;
if (r5 < 0) {
r5 += 6 + r6 * 4;
r6++;
} else {
r5 += 10 + (r6 - r7) * 4;
r7--;
r6++;
}
if (0x9f < param_4) {
param_4 = 0x9f;
}
param_3 = param_1 << 0x10;
ptr += param_2 * 3 + param_5;
do {
if (param_1 < 0) {
param_1 = 0;
}
if (0xf0 < param_1) {
param_1 = 0xf0;
}
*ptr = param_1;
param_3 += sVar1;
param_1 = param_3 >> 0x10;
param_2++;
ptr += 3;
} while (param_2 <= param_4);
}
}
sub_0801E290(sp00, sp04, r8);
SetVBlankDMA((u16*)&gUnk_02017AA0[gUnk_03003DE4[0]], (u16*)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_16BIT | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_RELOAD) << 16) +
0x1);
}
void sub_0801E49C(s32 baseX, s32 baseY, s32 radius, u32 baseAngle) {
u8* ptr2;
u32* ptr1;
u32 angle;
s32 x1, x2, x3, y1, y2, y3;
MemFill16(0xffff, gUnk_02018EE0, 0x780);
angle = (baseAngle - 0x40) & 0xff;
x1 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y1 = baseY + (gSineTable[angle] * radius >> 8);
angle = (baseAngle + 0x68) & 0xff;
x2 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y2 = baseY + (gSineTable[angle] * radius >> 8);
angle = (baseAngle - 0xe8) & 0xff;
x3 = baseX + (gSineTable[angle + 0x40] * radius >> 8);
y3 = baseY + (gSineTable[angle] * radius >> 8);
sub_0801E64C(x1, y1, x2, y2, 0);
sub_0801E64C(x1, y1, x3, y3, 1);
sub_0801E64C(x2, y2, x3, y3, 2);
MemClear(gUnk_02017AA0[gUnk_03003DE4[0]].filler, 0xa00);
ptr1 = (u32*)gUnk_02018EE0;
ptr2 = gUnk_02017AA0[gUnk_03003DE4[0]].filler;
for (y1 = 0xa0; y1 > 0; y1--, ptr2 += 2) {
x1 = ptr1[0];
x2 = ptr1[1];
x3 = ptr1[2];
ptr1 += 3;
if (x1 > x2) {
SWAP(x1, x2, y2);
}
if (x1 > x3) {
SWAP(x1, x3, y2);
}
if (x2 > x3) {
SWAP(x2, x3, y2);
}
if (x1 != 0xffffffff) {
ptr2[0] = x3;
ptr2[1] = x1;
} else {
if (x2 != x1) {
ptr2[0] = x3;
ptr2[1] = x2;
} else {
if (x3 != x1) {
ptr2[1] = x1;
ptr2[0] = x1;
}
}
}
}
SetVBlankDMA((u16*)(gUnk_02017AA0[gUnk_03003DE4[0]].filler), (u16*)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_16BIT | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_RELOAD) << 16) +
0x1);
}
void sub_0801E64C(s32 x1, s32 y1, s32 x2, s32 y2, s32 offset) {
// GBA Resolutions
const s32 MAX_X_COORD = 240;
const s32 MAX_Y_COORD = 160;
s32 slope, preciseX, tmp;
s32* drawPtr = (s32*)gUnk_02018EE0;
if ((y1 < 0 && y2 < 0) || (y1 >= MAX_Y_COORD && y2 >= MAX_Y_COORD))
return;
if (y1 > y2) {
SWAP(y1, y2, tmp);
SWAP(x1, x2, tmp);
}
if (y1 == y2)
return;
slope = Div((x2 - x1) * 0x10000, y2 - y1);
if (y1 < 0) {
x1 += (slope * -y1) >> 0x10;
y1 = 0;
}
if (y2 >= MAX_Y_COORD) {
y2 = MAX_Y_COORD - 1;
}
preciseX = x1 << 0x10;
drawPtr += y1 * 3 + offset;
do {
// Clamp x1 in range
x1 = x1 < 0 ? 0 : x1;
x1 = x1 < MAX_X_COORD ? x1 : MAX_X_COORD;
*drawPtr = x1;
preciseX += slope;
x1 = preciseX >> 0x10;
y1++;
drawPtr += 3;
} while (y1 <= y2);
}
void NotifyFusersOnFusionDone(KinstoneId kinstoneId) {
@@ -837,13 +1053,13 @@ void NotifyFusersOnFusionDone(KinstoneId kinstoneId) {
u32 index;
if (kinstoneId - 1 < 100) {
for (index = 0; index < 0x80; index++) {
if (kinstoneId == gSave.fuserOffers[index]) {
gSave.fuserOffers[index] = KINSTONE_NEEDS_REPLACEMENT;
if (kinstoneId == gSave.kinstones.fuserOffers[index]) {
gSave.kinstones.fuserOffers[index] = KINSTONE_NEEDS_REPLACEMENT;
}
}
tmp = GetFuserId(gFuseInfo.ent);
if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == KINSTONE_NEEDS_REPLACEMENT)) {
gSave.fuserOffers[tmp] = KINSTONE_JUST_FUSED;
tmp = GetFuserId(gFuseInfo.entity);
if ((tmp - 1 < 0x7f) && (gSave.kinstones.fuserOffers[tmp] == KINSTONE_NEEDS_REPLACEMENT)) {
gSave.kinstones.fuserOffers[tmp] = KINSTONE_JUST_FUSED;
}
for (index = 0; index < 0x20; index++) {
if (kinstoneId == gPossibleInteraction.candidates[index].kinstoneId) {
@@ -862,17 +1078,17 @@ void AddKinstoneToBag(KinstoneId kinstoneId) {
index = GetIndexInKinstoneBag(kinstoneId);
if (index < 0) {
index = 0;
while (gSave.kinstoneTypes[index] != KINSTONE_NONE) {
while (gSave.kinstones.types[index] != KINSTONE_NONE) {
index++;
}
}
if ((u32)index < 0x12) {
gSave.kinstoneTypes[index] = kinstoneId;
tmp = gSave.kinstoneAmounts[index] + 1;
gSave.kinstones.types[index] = kinstoneId;
tmp = gSave.kinstones.amounts[index] + 1;
if (tmp > 99) {
tmp = 99;
}
gSave.kinstoneAmounts[index] = tmp;
gSave.kinstones.amounts[index] = tmp;
}
}
}
@@ -880,12 +1096,12 @@ void AddKinstoneToBag(KinstoneId kinstoneId) {
void RemoveKinstoneFromBag(KinstoneId kinstoneId) {
s32 idx = GetIndexInKinstoneBag(kinstoneId);
if (idx >= 0) {
s32 next = gSave.kinstoneAmounts[idx] - 1;
s32 next = gSave.kinstones.amounts[idx] - 1;
if (next <= 0) {
gSave.kinstoneTypes[idx] = KINSTONE_NONE;
gSave.kinstones.types[idx] = KINSTONE_NONE;
next = 0;
}
gSave.kinstoneAmounts[idx] = next;
gSave.kinstones.amounts[idx] = next;
}
}
@@ -894,92 +1110,50 @@ u32 GetAmountInKinstoneBag(KinstoneId kinstoneId) {
if (index < 0) {
return 0;
}
return gSave.kinstoneAmounts[index];
return gSave.kinstones.amounts[index];
}
u32 CheckKinstoneFused(KinstoneId kinstoneId) {
if (kinstoneId - 1 >= 100) {
return 0;
}
return ReadBit(&gSave.fusedKinstones, kinstoneId);
return ReadBit(&gSave.kinstones.fusedKinstones, kinstoneId);
}
bool32 CheckFusionMapMarkerDisabled(KinstoneId kinstoneId) {
if (kinstoneId - 1 >= 100) {
return FALSE;
}
return ReadBit(&gSave.fusionUnmarked, kinstoneId);
return ReadBit(&gSave.kinstones.fusionUnmarked, kinstoneId);
}
void SortKinstoneBag(void) {
#ifdef NON_MATCHING
u32 r5;
u32 i;
for (r5 = 0; r5 < 0x13; r5++) {
if (gSave.kinstoneAmounts[r5] == 0) {
gSave.kinstoneTypes[r5] = gSave.kinstoneAmounts[r5];
KinstoneSave* ptr = &gSave.kinstones;
for (i = 0; i < 19; i++) {
if (ptr->amounts[i] == 0) {
ptr->types[i] = 0;
}
}
gSave.kinstoneTypes[0x12] = 0;
gSave.kinstoneAmounts[0x12] = 0;
ptr->types[18] = 0;
ptr->amounts[18] = 0;
for (r5 = 0; r5 < 0x12; r5++) {
if ((gSave.kinstoneTypes[r5] - 0x65) > 0x10) {
MemCopy(&gSave.kinstoneTypes[r5 + 1], &gSave.kinstoneTypes[r5], 0x12 - r5);
MemCopy(&gSave.kinstoneAmounts[r5 + 1], &gSave.kinstoneAmounts[r5], 0x12 - r5);
for (i = 0; i < 18; i++) {
u32 t = ptr->types[i];
if (t < 0x65 || t > 0x75) {
MemCopy(&ptr->types[i + 1], &ptr->types[i], 0x12 - i);
MemCopy(&ptr->amounts[i + 1], &ptr->amounts[i], 0x12 - i);
}
}
#else
u32 r0, r4, r5;
u32 new_var;
u8 *r1, *r2, *r3, *r6, *r7, *r8, *r9, *r10;
new_var = 4;
r1 = &gSave.inventory[34];
r5 = 0;
r2 = gSave.kinstoneTypes;
code0_0:
r0 = r2[0x13];
r3 = &r1[4];
r10 = r3;
if (r0 == 0) {
*r2 = r0;
}
r2++;
r5++;
if (r5 <= 0x12)
goto code0_0;
r1[0x16] = 0;
r1[0x29] = 0;
r5 = 0;
r9 = &r1[0x17];
r3 = &r1[0x18];
r8 = r3;
r7 = &r1[new_var];
r6 = &r1[5];
code0_2:
r0 = r10[r5] - 0x65;
if (r0 > 0x10) {
MemCopy(r6, r7, 0x12 - r5);
MemCopy(r8, r9, 0x12 - r5);
}
r9++;
r8++;
r7++;
r6++;
r5++;
if (r5 <= 0x11)
goto code0_2;
#endif
}
s32 GetIndexInKinstoneBag(KinstoneId kinstoneId) {
u32 i;
for (i = 0; i < 0x12; ++i) {
if (kinstoneId == gSave.kinstoneTypes[i])
if (kinstoneId == gSave.kinstones.types[i])
return i;
}
return -1;
@@ -1047,7 +1221,7 @@ void UpdateVisibleFusionMapMarkers(void) {
#else
if (sub_0807CB24(tmp, s->flag)) {
#endif
WriteBit(&gSave.fusionUnmarked, kinstoneId);
WriteBit(&gSave.kinstones.fusionUnmarked, kinstoneId);
}
}
}
@@ -1068,8 +1242,8 @@ KinstoneId GetFusionToOffer(Entity* entity) {
if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) {
return KINSTONE_NONE;
}
offeredFusion = gSave.fuserOffers[fuserId];
fuserProgress = gSave.fuserProgress[fuserId];
offeredFusion = gSave.kinstones.fuserOffers[fuserId];
fuserProgress = gSave.kinstones.fuserProgress[fuserId];
fuserFusionData = (u8*)(fuserProgress + (u32)fuserData);
while (TRUE) { // loop through fusions for this fuser
switch (offeredFusion) {
@@ -1100,8 +1274,8 @@ KinstoneId GetFusionToOffer(Entity* entity) {
}
offeredFusion = KINSTONE_NEEDS_REPLACEMENT; // already completed, try next fusion in the list
}
gSave.fuserOffers[fuserId] = offeredFusion;
gSave.fuserProgress[fuserId] = fuserProgress;
gSave.kinstones.fuserOffers[fuserId] = offeredFusion;
gSave.kinstones.fuserProgress[fuserId] = fuserProgress;
randomMood = Random();
fuserStability = fuserData[1];
if (fuserStability <= randomMood % 100) {
@@ -1118,11 +1292,11 @@ const struct_080C9C6C gUnk_080C9C6C[] = {
{ 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 }, { 1, 3, 3 },
};
void (*const gUnk_080C9CAC[])(void) = {
sub_0801E02C,
sub_0801E044,
sub_0801E074,
sub_0801E0A0,
void (*const gFuseActions[])(void) = {
Fuse_Action0,
Fuse_Action1,
Fuse_Action2,
Fuse_Action3,
};
// TODO merge
+3 -3
View File
@@ -461,7 +461,7 @@ void AcroBandit_Type1Action4(AcroBanditEntity* this) {
}
}
if (super->direction & 0xf)
if (super->direction & (0x3 | DirectionEast | DIR_DIAGONAL))
super->spriteSettings.flipX = (super->direction >> 4 ^ 1);
ProcessMovement0(super);
@@ -502,7 +502,7 @@ void AcroBandit_Type1Action6(AcroBanditEntity* this) {
super->action = 7;
dir = fallDirections[this->unk_74.HALF.LO * 5 + super->type2];
super->direction = dir;
if (dir >= 0x10) {
if (dir >= DirectionSouth) {
super->spriteSettings.flipX = 1;
} else {
super->spriteSettings.flipX = 0;
@@ -586,7 +586,7 @@ static void sub_080322E8(AcroBanditEntity* this) {
}
} else {
u8 tmp = super->direction;
if (tmp & 0xF) {
if (tmp & (0x3 | DirectionEast | DIR_DIAGONAL)) {
tmp >>= 4;
tmp ^= 1;
if (tmp != super->spriteSettings.flipX) {
+4 -3
View File
@@ -112,7 +112,8 @@ void sub_080218CC(BeetleEntity* this) {
if (super->subAction == 0) {
super->subAction = 1;
super->spriteSettings.draw = 1;
super->direction = ((sub_08049F84(super, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
super->direction = ((sub_08049F84(super, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
super->speed = 0x100;
super->zVelocity = Q_16_16(1.125);
}
@@ -251,9 +252,9 @@ void sub_08021B64(BeetleEntity* this) {
super->zVelocity = Q_16_16(1.0);
this->unk_87 = 0;
if (gPlayerEntity.direction != 0xff) {
super->direction = 0x10 ^ gPlayerEntity.direction;
super->direction = DirectionSouth ^ gPlayerEntity.direction;
} else {
super->direction = (gPlayerEntity.animationState << 2) ^ 0x10;
super->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth;
}
InitializeAnimation(super, 5);
} else {
+4 -2
View File
@@ -16,18 +16,20 @@ typedef struct {
/*0x74*/ u16 unk_74;
} BladeTrapEntity;
#define DIR_NOT_MOVING_CHECK 0x80
void BladeTrap(BladeTrapEntity* this) {
if (super->action == 0) {
super->action = 1;
super->child = GetCurrentRoomProperty(super->type);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
}
if (!(super->direction & 0x80)) {
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(super);
}
if (!(--this->unk_74)) {
if (!(super->direction & 0x80)) {
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
EnqueueSFX(SFX_METAL_CLINK);
}
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
+10 -10
View File
@@ -71,7 +71,7 @@ void Bobomb_OnCollision(BobombEntity* this) {
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_81 = 1;
InitializeAnimation(super, super->direction >> 4 | 6);
InitializeAnimation(super, super->direction >> 4 | IdleWest);
break;
}
}
@@ -132,7 +132,7 @@ void sub_0802C83C(BobombEntity* this) {
} else {
this->unk_82 = 2;
super->timer = 120;
InitializeAnimation(super, (super->direction >> 4) | 6);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
COLLISION_OFF(super);
super->hitType = 0x6e;
}
@@ -156,7 +156,7 @@ void sub_0802C8D8(BobombEntity* this) {
super->action = 1;
super->timer = 60;
super->subtimer = 0;
super->direction = (Random() & 0x18) | 4;
super->direction = (Random() & 0x18) | DIR_DIAGONAL;
super->carryFlags = 0;
super->gustJarFlags = 0x12;
this->unk_82 = 0;
@@ -172,7 +172,7 @@ void sub_0802C91C(BobombEntity* this) {
if (this->unk_82) {
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, (super->direction >> 4) | 2);
InitializeAnimation(super, (super->direction >> 4) | IdleEast);
}
if (--super->timer == 0) {
sub_0802CBC4(this);
@@ -189,7 +189,7 @@ void sub_0802C91C(BobombEntity* this) {
}
if (--super->timer == 0) {
super->timer = 60;
super->direction = (super->direction + 8) & 0x1c;
super->direction = (super->direction + 8) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, super->direction >> 4);
}
}
@@ -205,7 +205,7 @@ void sub_0802C9D0(BobombEntity* this) {
super->spritePriority.b1 = 0;
this->unk_83 = 1;
sub_0802CC18(this);
InitializeAnimation(super, (super->direction >> 4) | 6);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
GetNextFrame(super);
}
@@ -219,7 +219,7 @@ void sub_0802CA10(BobombEntity* this) {
}
} else {
this->unk_83 = 2;
super->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c;
super->direction = (((gPlayerEntity.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest);
sub_0802CC18(this);
GetNextFrame(super);
}
@@ -243,8 +243,8 @@ void sub_0802CA94(BobombEntity* this) {
super->speed = 0;
this->unk_83 = 0;
this->unk_81 = 0;
super->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c;
InitializeAnimation(super, (super->direction >> 4) | 6);
super->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
}
void sub_0802CAF8(BobombEntity* this) {
@@ -273,7 +273,7 @@ void sub_0802CB68(BobombEntity* this) {
super->action = 1;
super->subAction = 0;
super->direction = Random() & 0x18;
super->direction |= 4;
super->direction |= IdleSouth;
COLLISION_ON(super);
if (this->unk_82) {
super->timer = 200;
+3 -3
View File
@@ -154,10 +154,10 @@ void sub_0802A9A8(BombPeahatEntity* this) {
this->unk_82 = 1;
if (this->unk_80) {
super->x.HALF.HI = gRoomControls.scroll_x - 0x10;
super->direction = 8;
super->direction = DirectionEast;
} else {
super->x.HALF.HI = gRoomControls.scroll_x + 0x100;
super->direction = 0x18;
super->direction = DirectionWest;
}
super->y.HALF.HI = gRoomControls.scroll_y + 0x40;
super->timer = 128;
@@ -234,7 +234,7 @@ void sub_0802AAC0(BombPeahatEntity* this) {
#ifndef EU
this->unk_78 = 0;
this->unk_79 = 4;
super->direction = 0xff;
super->direction = DIR_NONE;
#endif
InitializeAnimation(super, 0);
}
+8 -8
View File
@@ -94,7 +94,7 @@ void BusinessScrub_Action0(BusinessScrubEntity* this) {
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
super->animationState = 0;
super->direction = 0x10;
super->direction = DirectionSouth;
sub_08028E9C(this);
if ((*(u8*)this->unk_7c & 1) || CheckFlags(this->unk_86)) {
super->action = 4;
@@ -373,15 +373,15 @@ void sub_08028EDC(BusinessScrubEntity* this) {
}
void sub_08028F0C(BusinessScrubEntity* this) {
if (super->interactType == 2) {
if (super->interactType == INTERACTION_FUSE) {
super->action = 8;
super->interactType = 0;
sub_0806F118(super);
} else if (super->interactType != 0) {
super->interactType = INTERACTION_NONE;
InitializeNPCFusion(super);
} else if (super->interactType != INTERACTION_NONE) {
u16 dialog;
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
super->interactType = 0;
super->interactType = INTERACTION_NONE;
sub_0804AA1C(super);
super->direction = (GetAnimationState(super) << 3);
sub_080290E0(this, 3);
@@ -470,8 +470,8 @@ void sub_080290FC(BusinessScrubEntity* this) {
if (super->timer != 0) {
super->timer--;
if ((super->timer < 16) && ((super->timer & 1) == 0)) {
s32 sVar3 = ((super->direction & 0x10) != 0) ? -1 : 1;
if ((super->direction & 8) != 0) {
s32 sVar3 = (super->direction & DirectionSouth) ? -1 : 1;
if (super->direction & DirectionEast) {
super->x.HALF.HI += ((super->timer & 8) != 0) ? -sVar3 : sVar3;
} else {
super->y.HALF.HI += ((super->timer & 8) != 0) ? sVar3 : -sVar3;
+3 -3
View File
@@ -72,7 +72,7 @@ void sub_08045C3C(BusinessScrubPrologueEntity* this) {
super->subtimer = 0;
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
super->animationState = 0;
super->animationState = IdleNorth;
super->direction = 0x10;
super->action = 5;
super->timer = 120;
@@ -81,7 +81,7 @@ void sub_08045C3C(BusinessScrubPrologueEntity* this) {
sub_08046030(this, 0);
sub_08095C48(super);
StartCutscene(super, script_BusinessScrubIntro);
sub_0807DD50(super);
InitScriptForNPC(super);
}
void sub_08045CA4(BusinessScrubPrologueEntity* this) {
@@ -206,7 +206,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) {
}
void sub_08045EC8(BusinessScrubPrologueEntity* this) {
sub_0807DD94(super, 0);
ExecuteScriptAndHandleAnimation(super, NULL);
}
void sub_08045ED4(BusinessScrubPrologueEntity* this) {
+1 -1
View File
@@ -34,7 +34,7 @@ void sub_0802B540(Entity* this) {
this->timer--;
} else {
u32 direction = sub_0804A024(this, 1, 0xc);
if (direction != 0xff) {
if (direction != DIR_NONE) {
this->action = 2;
this->speed = 0x40;
this->direction = direction;
+1 -1
View File
@@ -553,7 +553,7 @@ void sub_080262A8(ChuchuBossEntity* this) {
super->timer = 1;
sub_080276F4(super, 6, 1);
if (super->type2 == 0) {
gPlayerState.animation = 0x104;
gPlayerState.animation = ANIM_WALK;
this->unk_84->unk_03 = 1;
} else {
this->unk_7c = 0;
+4 -3
View File
@@ -119,10 +119,11 @@ void sub_08022AA4(Entity* this) {
if (!sub_08049FA0(this) && (rand >> 8) & 3) {
this->direction = sub_08049EE4(this);
} else {
this->direction = (rand >> 0x10) & 0x1f;
this->direction =
(rand >> 0x10) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
}
if (this->direction & 0xf)
if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
}
@@ -144,7 +145,7 @@ void sub_08022B44(Entity* this) {
this->zVelocity = Q_16_16(0.75);
this->direction = GetFacingDirection(this, &gPlayerEntity);
if (this->direction & 0xf)
if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
EnqueueSFX(SFX_VO_CHEEP);
+1 -1
View File
@@ -107,7 +107,7 @@ void Enemy4D_Init(Enemy4DEntity* this) {
super->child = projectile;
COLLISION_ON(super);
super->spriteSettings.draw = TRUE;
super->animationState = 2;
super->animationState = IdleEast;
this->unk_7b = 0;
this->unk_7c = 0;
this->unk_7e = 0x28;
+26 -28
View File
@@ -80,40 +80,38 @@ void Enemy50_OnCollision(Enemy50Entity* this) {
sub_08041134(this);
sub_0803F6EC(this);
}
if (super->hitType == 0x25) {
if (super->hitType == 0x25 && super->contactFlags == 0x80) {
super->action = 8;
InitializeAnimation(super, 3);
} else {
if (super->contactFlags == 0x80) {
super->action = 8;
InitializeAnimation(super, 3);
goto _08040C9C;
this->unk_7c = 0x78;
sub_08041128(this);
}
} else if (super->contactFlags == 0x80) {
this->unk_7c = 0x78;
sub_08041128(this);
}
if (super->contactFlags == 0x9d) {
super->zVelocity = Q_16_16(1.5);
}
if (super->confusedTime != 0) {
super->animationState = super->knockbackDirection >> 4;
InitializeAnimation(super, super->animationState + 7);
Create0x68FX(super, FX_STARS);
}
if (super->health != this->unk_7a) {
if (super->type == 0) {
if (super->contactFlags == 0x9d) {
super->zVelocity = Q_16_16(1.5);
}
if (super->confusedTime != 0) {
super->animationState = super->knockbackDirection >> 4;
InitializeAnimation(super, super->animationState + 7);
} else {
if (super->iframes > 0) {
*((u8*)&super->iframes) |= 0x80;
}
super->flags |= 0x80;
super->health = 0xff;
super->action = 0xa;
super->timer = 60;
Create0x68FX(super, FX_STARS);
}
if (super->health != this->unk_7a) {
if (super->type == 0) {
super->animationState = super->knockbackDirection >> 4;
InitializeAnimation(super, super->animationState + 7);
} else {
if (super->iframes > 0) {
*((u8*)&super->iframes) |= 0x80;
}
super->flags |= 0x80;
super->health = 0xff;
super->action = 0xa;
super->timer = 60;
}
this->unk_7a = super->health;
}
this->unk_7a = super->health;
}
_08040C9C:
EnemyFunctionHandlerAfterCollision(super, Enemy50_Functions);
}
+4 -4
View File
@@ -144,7 +144,7 @@ void Eyegore_OnGrabbed(EyegoreEntity* this) {
void Eyegore_Init(EyegoreEntity* this) {
sub_0804A720(super);
super->action = 1;
super->animationState = 2;
super->animationState = IdleEast;
super->x.HALF.HI &= 0xfff0;
super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) + 0xc;
this->unk_6d |= 8;
@@ -196,7 +196,7 @@ void Eyegore_Action3(EyegoreEntity* this) {
GetNextFrame(super);
if ((super->frame & ANIM_DONE) != 0) {
super->flags |= ENT_COLLIDE;
super->animationState = 2;
super->animationState = IdleEast;
sub_08030E58(this);
InitializeAnimation(super, 2);
sub_08030FB4(this);
@@ -240,7 +240,7 @@ void Eyegore_Action5(EyegoreEntity* this) {
GetNextFrame(super);
switch (super->frame & 7) {
case 1:
if (super->animationState != 2) {
if (super->animationState != IdleEast) {
if (super->animationState >= 3) {
this->unk_7f = (super->animationState - 1) & 3;
} else {
@@ -264,7 +264,7 @@ void Eyegore_Action5(EyegoreEntity* this) {
if (sub_08049FDC(super, 1)) {
sub_08030E58(this);
} else {
if (super->animationState == 2) {
if (super->animationState == IdleEast) {
super->action = 6;
super->flags &= ~ENT_COLLIDE;
InitializeAnimation(super, 0xe);
+1 -1
View File
@@ -123,7 +123,7 @@ void sub_08045524(FireballGuyEntity* this) {
super->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(super, 1, 8);
if (tmp != 0xff && (Random() & 3) == 0) {
if (tmp != DIR_NONE && (Random() & 3) == 0) {
super->timer = Random() & 3;
super->direction = DirectionRound(tmp);
} else {
+1 -1
View File
@@ -1134,7 +1134,7 @@ void sub_0802E300(GleerokEntity* this) {
this->unk_79 &= ~0x80;
heap = this->unk_84;
dir = sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)) << 3;
dir = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) << 3;
index = 0;
ptr2 = &this->unk_80;
tmp = 0;
+2 -2
View File
@@ -162,8 +162,8 @@ void sub_08046930(GyorgMaleEntity* this) {
return;
super->subAction = 1;
super->timer = 1;
super->animationState = 0;
super->direction = 0;
super->animationState = IdleNorth;
super->direction = IdleNorth;
#ifdef EU
super->speed = 0x200;
#else
+2 -2
View File
@@ -222,9 +222,9 @@ void sub_0802BE80(HelmasaurEntity* this) {
}
void sub_0802BEBC(HelmasaurEntity* this) {
super->direction ^= 0x10;
super->direction ^= DirectionSouth;
ProcessMovement2(super);
super->direction ^= 0x10;
super->direction ^= DirectionSouth;
if (!sub_080044EC(super, Q_16_16(0.125))) {
sub_0802C1C0(this);
}
+2 -2
View File
@@ -97,7 +97,7 @@ void sub_0803CD6C(LakituCloudEntity* this) {
void sub_0803CDA8(LakituCloudEntity* this) {
UpdateAnimationSingleFrame(super);
if ((super->direction & 0x80) == 0) {
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(super);
}
@@ -131,7 +131,7 @@ void sub_0803CE14(LakituCloudEntity* this) {
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
direction = super->direction;
if (direction & 0x80) {
if (direction & DIR_NOT_MOVING_CHECK) {
return;
}
+2 -1
View File
@@ -79,7 +79,8 @@ void Leever_Idle(LeeverEntity* this) {
if (Leever_PlayerInRange(super, Random() & 0x1f)) {
super->action = 2;
super->spriteSettings.draw = TRUE;
super->direction = (GetFacingDirection(super, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & 0x1f;
super->direction =
(GetFacingDirection(super, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & (0x3 | DirectionNorthWest);
InitializeAnimation(super, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(super);
} else {
+8 -8
View File
@@ -391,16 +391,16 @@ void sub_08029EEC(MadderpillarEntity* this) {
void sub_08029F0C(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0:
case 0: // UP
this->unk_78.HWORD = super->y.HALF.HI - 0x10;
break;
case 1:
case 1: // RIGHT
this->unk_78.HWORD = super->x.HALF.HI + 0x10;
break;
case 2:
case 2: // DOWN
this->unk_78.HWORD = super->y.HALF.HI + 0x10;
break;
case 3:
case 3: // LEFT
this->unk_78.HWORD = super->x.HALF.HI - 0x10;
break;
}
@@ -408,25 +408,25 @@ void sub_08029F0C(MadderpillarEntity* this) {
bool32 sub_08029F48(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0:
case 0: // UP
if (super->y.HALF.HI <= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 1:
case 1: // RIGHT
if (super->x.HALF.HI >= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 2:
case 2: // DOWN
if (super->y.HALF.HI >= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 3:
case 3: // LEFT
if (super->x.HALF.HI <= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
+6 -3
View File
@@ -531,7 +531,7 @@ void sub_0803A8B8(Entity* this) {
this->action = 0x10;
this->timer = 30;
this->direction = 0;
this->direction = DirectionNorth;
this->speed = 0x80;
ptr = gUnk_080CED6C;
@@ -575,7 +575,7 @@ void sub_0803A978(Entity* this) {
sub_08004596(this, 0x10);
}
LinearMoveUpdate(this);
if (this->direction == 0x10) {
if (this->direction == DirectionSouth) {
this->action = 0x12;
this->timer = 3;
COLLISION_OFF(this);
@@ -1247,7 +1247,10 @@ void sub_0803B724(Entity* param_1) {
void sub_0803B798(void) {
gPlayerState.jump_status = 0x41;
gPlayerState.field_0xa = 0;
gPlayerState.flags &= ~(0xffff0000 | PL_CAPTURED);
gPlayerState.flags &=
~(PL_CAPTURED | PL_FLAGS10000 | PL_GYORG_FIGHT | PL_ROLLING | PL_MOLDWORM_CAPTURED | PL_IN_HOLE |
PL_MOLDWORM_RELEASED | PL_CLONING | PL_USE_LANTERN | PL_PARACHUTE | PL_CONVEYOR_PUSHED | PL_ENTER_MINECART |
PL_SWORD_THRUST | PL_USE_OCARINA | PL_CLIMBING | PL_FLAGS40000000 | PL_FLAGS80000000);
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.z.HALF.HI = -10;
+4 -4
View File
@@ -561,7 +561,7 @@ void sub_0803473C(Entity* this) {
if (roomX + 0xe0 < this->x.HALF.HI) {
return;
}
this->direction = 8;
this->direction = DirectionEast;
} else {
if (playerX + 4 >= this->x.HALF.HI) {
return;
@@ -569,7 +569,7 @@ void sub_0803473C(Entity* this) {
if (roomX + 0x90 > this->x.HALF.HI) {
return;
}
this->direction = 0x18;
this->direction = DirectionWest;
}
LinearMoveUpdate(this);
}
@@ -581,7 +581,7 @@ void sub_080347B4(Entity* this) {
if (roomX + 0xe0 < this->x.HALF.HI) {
return;
}
this->direction = 8;
this->direction = DirectionEast;
} else {
if (playerX + 4 >= this->x.HALF.HI) {
return;
@@ -589,7 +589,7 @@ void sub_080347B4(Entity* this) {
if (roomX + 0x90 > this->x.HALF.HI) {
return;
}
this->direction = 0x18;
this->direction = DirectionWest;
}
LinearMoveUpdate(this);
}
+1 -1
View File
@@ -209,7 +209,7 @@ void sub_08022F14(Entity* this) {
}
this->direction += this->field_0x78.HALF.LO;
this->direction &= 0x1f;
this->direction &= DirectionNorthWest | 0x3;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
+6 -3
View File
@@ -191,7 +191,8 @@ void Peahat_ChargeStart(PeahatEntity* this) {
super->action = 3;
super->timer = 120;
super->speed = 192;
super->direction = (GetFacingDirection(super, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & 0x1f;
super->direction =
(GetFacingDirection(super, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & (0x3 | DirectionNorthWest);
}
} else {
sub_080205F8(this);
@@ -235,6 +236,8 @@ void Peahat_ChargeEnd(PeahatEntity* this) {
}
}
#define DIR_NONE 0xff
void Peahat_Stunned(PeahatEntity* this) {
switch (super->animationState) {
default:
@@ -245,7 +248,7 @@ void Peahat_Stunned(PeahatEntity* this) {
super->hitType = 0x71;
}
if (super->direction == 0xff)
if (super->direction == DIR_NONE)
super->direction = super->knockbackDirection;
ProcessMovement0(super);
@@ -373,7 +376,7 @@ void sub_08020604(PeahatEntity* this) {
super->direction = sub_08049EE4(super);
} else {
super->direction += this->unk_80;
super->direction &= 0x1f;
super->direction &= (0x3 | DirectionNorthWest);
}
}
+7 -7
View File
@@ -387,7 +387,7 @@ void sub_080244E8(Entity* this) {
if (tmp == 0) {
this->field_0x80.HALF.LO++;
this->timer = 12;
this->direction = 0x10;
this->direction = DirectionSouth;
this->speed = tmp;
this->cutsceneBeh.HALF.LO = 0;
this->flags2 &= 0xfc;
@@ -554,13 +554,13 @@ void sub_08024940(Entity* this) {
}
void sub_080249DC(Entity* this) {
u8 direction = ((this->direction + 2) & 0x1c) >> 2;
u8 direction = ((this->direction + 2) & DirectionNorthWest) >> 2;
this->animationState = direction;
InitializeAnimation(this, this->animationState);
}
void sub_080249F4(Entity* this) {
u32 direction = ((this->direction + 2) & 0x1f);
u32 direction = ((this->direction + 2) & (0x3 | DirectionNorthWest));
direction >>= 2;
if (direction != this->animationState) {
this->animationState = direction;
@@ -770,8 +770,8 @@ void sub_08024D00(Entity* this) {
this->field_0x80.HALF.LO++;
this->timer = (Random() & 0xf) + 32;
this->direction += this->field_0x80.HALF.HI ? 4 : 0x1c;
this->direction &= 0x1f;
this->direction += this->field_0x80.HALF.HI ? DirectionNorthEast : DirectionNorthWest;
this->direction &= 0x3 | DirectionNorthWest;
this->field_0x80.HALF.HI ^= 0x40;
sub_08024A14(this, 3, 0x10);
@@ -783,8 +783,8 @@ void sub_08024D00(Entity* this) {
this->timer = (Random() & 0x1f) + 32;
} else {
if (--this->subtimer == 0) {
this->direction += this->field_0x80.HALF.HI ? 1 : 0x1f;
this->direction &= 0x1f;
this->direction += this->field_0x80.HALF.HI ? 1 : (0x3 | DirectionNorthWest);
this->direction &= 0x3 | DirectionNorthWest;
this->subtimer = 16;
sub_080249DC(this);
+2 -2
View File
@@ -358,7 +358,7 @@ void sub_080255AC(Entity* this) {
}
tmp -= 7;
this->direction = (GetFacingDirection(entity, this) + tmp) & 0x1f;
this->direction = (GetFacingDirection(entity, this) + tmp) & (0x3 | DirectionNorthWest);
}
if (this->field_0x78.HWORD == 0) {
@@ -398,7 +398,7 @@ void sub_080256B4(Entity* this) {
this->action = 1;
this->timer = (Random() & 3) + 4;
this->subtimer = 30;
this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & 0x1c;
this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest;
this->field_0x78.HWORD = gUnk_080CC000[Random() & 0xf];
this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1;
this->field_0x7a.HALF.HI = 0;
+7 -7
View File
@@ -46,7 +46,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) {
if (super->hitType == 34 && super->health != 0xff) {
super->action = 4;
super->zVelocity = Q_16_16(2.0);
super->direction = 0xff;
super->direction = DIR_NONE;
super->health = 0xff;
super->hitType = 35;
InitializeAnimation(super, super->animationState + 8);
@@ -56,7 +56,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) {
if (super->action == 4 || super->action == 5) {
super->action = 4;
super->timer = 180;
super->direction = 0xff;
super->direction = DIR_NONE;
InitializeAnimation(super, super->animationState + 0x10);
}
}
@@ -81,7 +81,7 @@ void Rollobite_OnGrabbed(RollobiteEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->action = 4;
COLLISION_ON(super);
super->direction = 0xff;
super->direction = DIR_NONE;
InitializeAnimation(super, super->animationState + 0x10);
} else {
gUnk_080CA6A4[super->subAction](this);
@@ -114,7 +114,7 @@ void sub_080207A8(RollobiteEntity* this) {
COLLISION_ON(super);
super->spritePriority.b0 = 4;
super->gustJarState &= 0xfb;
super->direction ^= 0x10;
super->direction ^= DirectionSouth;
super->zVelocity = Q_16_16(1.5);
super->speed = 0x80;
InitializeAnimation(super, super->animationState + 0x10);
@@ -200,7 +200,7 @@ void Rollobite_RolledUp(RollobiteEntity* this) {
if (unk == 1)
EnqueueSFX(SFX_PLACE_OBJ);
if ((super->direction & 0x80) == 0)
if (!(super->direction & DIR_NOT_MOVING_CHECK))
ProcessMovement2(super);
}
}
@@ -255,8 +255,8 @@ void sub_08020A7C(RollobiteEntity* this) {
if (sub_08049FA0(super) == 0) {
int tmp = DirectionRoundUp(sub_08049EE4(super));
if ((state ^ 0x10) == tmp)
state ^= 0x10;
if ((state ^ DirectionSouth) == tmp)
state ^= DirectionSouth;
}
super->direction = state;
+1 -1
View File
@@ -138,7 +138,7 @@ void sub_08038304(RopeGoldenEntity* this) {
}
this->unk_7a = this->unk_79;
this->unk_79 = cVar2;
super->direction = (super->direction + cVar2) & 0x18;
super->direction = (super->direction + cVar2) & DirectionWest;
} else {
super->direction = this->unk_78;
}
+1 -1
View File
@@ -227,7 +227,7 @@ void sub_08029688(RupeeLikeEntity* this) {
void sub_0802969C(RupeeLikeEntity* this) {
u32 bVar1;
if ((super->direction & 0xf) != 0) {
if (super->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) {
bVar1 = super->direction >> 4;
if (bVar1 != super->animationState) {
+9 -9
View File
@@ -55,16 +55,16 @@ void sub_0802BA18(SensorBladeTrapEntity* this) {
super->direction = direction;
switch (direction >> 3) {
case 0:
case 0: // UP
this->unk_7a = super->y.HALF.HI - this->unk_7e;
break;
case 1:
case 1: // RIGHT
this->unk_7a = super->x.HALF.HI + this->unk_7c;
break;
case 2:
case 2: // DOWN
this->unk_7a = super->y.HALF.HI + this->unk_7e;
break;
case 3:
case 3: // LEFT
this->unk_7a = super->x.HALF.HI - this->unk_7c;
break;
}
@@ -75,19 +75,19 @@ void sub_0802BA8C(SensorBladeTrapEntity* this) {
sub_0802BB10(this);
} else {
switch (super->direction >> 3) {
case 0:
case 0: // UP
if (this->unk_7a >= super->y.HALF.HI)
sub_0802BB10(this);
break;
case 1:
case 1: // RIGHT
if (this->unk_7a <= super->x.HALF.HI)
sub_0802BB10(this);
break;
case 2:
case 2: // DOWN
if (this->unk_7a <= super->y.HALF.HI)
sub_0802BB10(this);
break;
case 3:
case 3: // LEFT
if (this->unk_7a >= super->x.HALF.HI)
sub_0802BB10(this);
break;
@@ -104,7 +104,7 @@ void sub_0802BAFC(SensorBladeTrapEntity* this) {
void sub_0802BB10(SensorBladeTrapEntity* this) {
super->action = 3;
super->speed = 0xc0;
super->direction = super->direction ^ 0x10;
super->direction = super->direction ^ DirectionSouth;
EnqueueSFX(SFX_METAL_CLINK);
}
+2 -2
View File
@@ -97,8 +97,8 @@ void sub_08031714(SmallPestoEntity* this) {
if (sub_08049FA0(super) == 0 && (super->subtimer & 1) != 0) {
super->direction = sub_08049EE4(super);
} else {
super->direction += 0x18;
super->direction = ((Random() & 0xe) + super->direction) & 0x1f;
super->direction += DirectionWest;
super->direction = ((Random() & 0xe) + super->direction) & (0x3 | DirectionNorthWest);
}
sub_080317E0(this);
}
+1 -1
View File
@@ -60,7 +60,7 @@ void sub_0802B35C(Entity* this) {
if (--this->subtimer == 0) {
this->subtimer = 120;
this->direction += is_head ? 0x08 : 0x18;
this->direction += is_head ? DirectionEast : DirectionWest;
this->direction = DirectionRound(this->direction);
}
} else {
+2 -2
View File
@@ -176,7 +176,7 @@ void sub_08028488(Entity* this) {
this->timer = (Random() & 7) * 3 + 64;
break;
case 4:
this->direction = (this->direction + 0x10) & 0x18;
this->direction = (this->direction + 0x10) & DirectionWest;
/* fallthrough */
case 1:
default:
@@ -265,7 +265,7 @@ void sub_08028604(Entity* this) {
this->timer = this->timer + 0x10;
this->field_0x82.HALF.HI--;
}
this->direction = (iVar3 + 4U) & 0x18;
this->direction = (iVar3 + 4U) & DirectionWest;
iVar3 = Direction8ToAnimationState(this->direction);
}
} else {
+1 -1
View File
@@ -107,7 +107,7 @@ void sub_0802B7A4(Entity* this) {
this->timer = gUnk_080CD314[Random() & 3];
this->speed = 0x60;
sub_0802B960(this);
if (this->direction != 0xff) {
if (this->direction != DIR_NONE) {
u32 animation = this->direction >> 3;
if (animation != this->animationState) {
this->animationState = animation & 3;
+16 -17
View File
@@ -451,24 +451,23 @@ u32 sub_08039B28(StalfosEntity* this) {
const u16* ptr;
const s8* ptr2;
if (super->child == NULL) {
ptr2 = &gUnk_080CF930[super->animationState * 2];
pos = COORD_TO_TILE_OFFSET(super, -ptr2[0], -ptr2[1]);
tileType = GetTileType(pos, (u32)super->collisionLayer);
ptr = gUnk_080CF938;
do {
if (ptr[0] != tileType) {
ptr += 2;
} else {
goto found;
}
} while (ptr[0] != 0);
if (super->child != NULL) {
return (u16)-1;
}
return 0xffff;
found:
super->type2 = ptr[1];
return pos;
ptr2 = &gUnk_080CF930[super->animationState * 2];
pos = COORD_TO_TILE_OFFSET(super, -ptr2[0], -ptr2[1]);
tileType = GetTileType(pos, (u32)super->collisionLayer);
ptr = gUnk_080CF938;
do {
if (ptr[0] == tileType) {
super->type2 = ptr[1];
return pos;
}
ptr += 2;
} while (ptr[0] != 0);
return (u16)-1;
}
void (*const Stalfos_Functions[])(StalfosEntity*) = {
+2 -2
View File
@@ -159,7 +159,7 @@ void sub_0802F300(Entity* this) {
} else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
}
if (--this->timer == 0) {
@@ -214,6 +214,6 @@ static void sub_0802F45C(Entity* this) {
this->direction = sub_08049F84(this, 1);
} else {
temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & 0x1f;
this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
}
}
+2 -2
View File
@@ -136,7 +136,7 @@ void sub_08038048(Entity* this) {
} else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
}
if (--this->timer == 0) {
@@ -185,6 +185,6 @@ void sub_08038168(Entity* this) {
this->direction = sub_08049F84(this, 1);
} else {
temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & 0x1f;
this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
}
}
+15 -15
View File
@@ -74,7 +74,7 @@ void sub_0804468C(Entity* this) {
case 0:
this->action = 1;
this->timer = 1;
this->direction = (this->field_0x78.HALF.HI * 8) & 0x1f;
this->direction = (this->field_0x78.HALF.HI * 8) & (0x3 | DirectionNorthWest);
this->field_0x78.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->spriteSettings.draw = 0;
@@ -123,7 +123,7 @@ void sub_0804474C(Entity* this) {
if (--this->timer == 0) {
this->timer = 2;
this->direction++;
this->direction &= 0x1f;
this->direction &= 0x3 | DirectionNorthWest;
}
LinearMoveUpdate(this);
UpdateAnimationSingleFrame(this);
@@ -253,7 +253,7 @@ void sub_080449F8(Entity* this) {
this->timer = 4;
this->direction++;
this->direction &= 0x1f;
this->direction &= 0x3 | DirectionNorthWest;
if (vaati->field_0x80.HALF.LO == 0)
vaati->field_0x74.HALF.LO = 1;
break;
@@ -266,9 +266,9 @@ void sub_080449F8(Entity* this) {
}
break;
case 1:
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
this->timer = 2;
break;
case 3:
@@ -324,7 +324,7 @@ void sub_08044B04(Entity* this) {
if (--this->timer == 0) {
this->timer = this->field_0x78.HALF.LO ? 4 : 2;
this->direction++;
this->direction &= 0x1f;
this->direction &= 0x3 | DirectionNorthWest;
}
if (--this->subtimer == 0) {
if (this->timer != 2) {
@@ -346,11 +346,11 @@ void sub_08044B04(Entity* this) {
case 1:
if (--this->timer == 0) {
this->timer = 6;
this->direction = (this->direction + 1) & 0x1f;
this->direction = (this->direction + 1) & (0x3 | DirectionNorthWest);
if (++this->subtimer == 0x30) {
u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
this->speed = 0;
this->direction = (direction + 16) & 0x1f;
this->direction = (direction + 16) & (0x3 | DirectionNorthWest);
this->timer = 16;
this->subtimer = 16;
this->field_0x74.HALF.LO++;
@@ -485,18 +485,18 @@ void sub_08044E74(Entity* this, u32 state) {
switch (state) {
case 2:
this->action = 2;
this->direction += 0x18;
this->direction &= 0x1f;
this->direction += DirectionWest;
this->direction &= 0x3 | DirectionNorthWest;
PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
this->speed = 12288;
LinearMoveUpdate(this);
this->direction += 0x8;
this->direction &= 0x1f;
this->direction += DirectionEast;
this->direction &= 0x3 | DirectionNorthWest;
this->speed = 1280;
LinearMoveUpdate(this);
break;
case 1:
this->direction = (this->direction + 8) & 0x1f;
this->direction = (this->direction + 8) & (0x3 | DirectionNorthWest);
break;
case 0:
if (this->field_0x78.HALF.LO) {
@@ -507,9 +507,9 @@ void sub_08044E74(Entity* this, u32 state) {
} while (this->timer-- != 3);
break;
case 1:
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
break;
}
} else {
+5 -5
View File
@@ -232,7 +232,7 @@ void sub_0802EFB8(Entity* this) {
}
iVar4 = sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1);
if (iVar4 != 0) {
this->direction = 0xff;
this->direction = DIR_NONE;
} else {
this->timer = (rand & 3) + 1;
this->direction = (uVar1 & 0x18);
@@ -251,7 +251,7 @@ void sub_0802F04C(Entity* this) {
return;
}
switch (this->direction >> 3) {
case 0:
case 0: // UP
if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) {
this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
@@ -263,7 +263,7 @@ void sub_0802F04C(Entity* this) {
return;
}
break;
case 1:
case 1: // RIGHT
if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) {
this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
@@ -275,7 +275,7 @@ void sub_0802F04C(Entity* this) {
return;
}
break;
case 2:
case 2: // DOWN
if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) {
this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
@@ -287,7 +287,7 @@ void sub_0802F04C(Entity* this) {
return;
}
break;
default:
default: // LEFT
if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) {
this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
+1 -1
View File
@@ -187,7 +187,7 @@ void VaatiProjectileFunction0Action5(Entity* this) {
void VaatiProjectileFunction0Action6(Entity* this) {
if (--this->timer == 0) {
this->action = 7;
this->direction = 0x10;
this->direction = DirectionSouth;
this->speed = 0x300;
}
sub_0803E444(this);
+19 -19
View File
@@ -103,7 +103,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) {
this->timer = 0;
this->field_0x76.HALF.LO = 0;
this->spriteSettings.draw = 1;
this->direction = 0xff;
this->direction = DIR_NONE;
this->spritePriority.b0 = 4;
this->z.WORD = 0;
this->field_0x80.HALF.LO = 2;
@@ -149,12 +149,12 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->action = 2;
this->field_0x74.HALF.LO = 0;
this->timer = 16;
this->direction = 0xff;
this->direction = DIR_NONE;
} else {
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) {
this->direction = ((Random() & 0x80) >> 3) | 8;
this->direction = ((Random() & 0x80) >> 3) | DirectionEast;
} else {
this->direction = 0xff;
this->direction = DIR_NONE;
}
}
} else {
@@ -165,7 +165,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80;
this->field_0x74.HALF.LO = 0;
this->timer = 192;
this->direction = 0xff;
this->direction = DIR_NONE;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 0);
}
@@ -176,7 +176,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
case 0:
this->action = 4;
this->timer = 160;
this->direction = 0xff;
this->direction = DIR_NONE;
this->cutsceneBeh.HALF.LO = 0xff;
InitAnimationForceUpdate(this, 1);
break;
@@ -184,21 +184,21 @@ void VaatiRebornEnemyType0Action1(Entity* this) {
this->action = 6;
this->field_0x74.HALF.LO = 0;
this->timer = 0;
this->direction = 0xff;
this->direction = DIR_NONE;
break;
case 3:
this->action = 5;
this->field_0x74.HALF.LO = 0;
this->subtimer = 32;
this->direction = 0xff;
this->direction = DIR_NONE;
break;
case 2:
this->field_0x74.HALF.LO = 0;
this->timer = 32;
if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) {
this->direction = ((Random() & 0x80) >> 3) | 8;
this->direction = ((Random() & 0x80) >> 3) | DirectionEast;
} else {
this->direction = 0xff;
this->direction = DIR_NONE;
}
break;
}
@@ -340,7 +340,7 @@ void VaatiRebornEnemyType0Action4(Entity* this) {
this->action = 1;
this->cutsceneBeh.HALF.LO = 0xff;
this->timer = 1;
this->direction = (this->direction + 0x10) & 0x1f;
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
InitAnimationForceUpdate(this, 0);
} else {
if ((this->frame & 0x10) != 0) {
@@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
if (this->field_0x80.HALF.LO == 0) {
this->action = 1;
this->timer = 1;
this->direction = 0xff;
this->direction = DIR_NONE;
InitAnimationForceUpdate(this, 0);
return;
}
@@ -394,7 +394,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
this->field_0x86.HALF.HI++;
this->subtimer = (Random() & 0x3f) + 64;
uVar3 = GetFacingDirection(this, &gPlayerEntity);
this->direction = (uVar3 & 0x10) | 8;
this->direction = (uVar3 & 0x10) | DirectionEast;
} else {
this->field_0x74.HALF.LO++;
this->field_0x86.HALF.HI = 0;
@@ -408,7 +408,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->timer = 1;
this->direction = 0xff;
this->direction = DIR_NONE;
}
break;
}
@@ -557,7 +557,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) {
this->field_0x74.HALF.LO = 1;
this->field_0x74.HALF.HI = 0;
this->spriteOffsetY = -2;
this->direction = 0xff;
this->direction = DIR_NONE;
PositionRelative(source, this, 0, Q_16_16(2.0));
InitAnimationForceUpdate(this, 2);
}
@@ -601,7 +601,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) {
void VaatiRebornEnemyType3Action0(Entity* this) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
this->direction = 0xff;
this->direction = DIR_NONE;
this->spriteOffsetY = -1;
InitAnimationForceUpdate(this, this->field_0x74.HALF.LO);
sub_0803DC0C(this);
@@ -621,7 +621,7 @@ void VaatiRebornEnemyType3Action1(Entity* this) {
} else {
if (this->field_0x74.HALF.LO != 0) {
this->field_0x74.HALF.LO = 0;
this->direction = 0xff;
this->direction = DIR_NONE;
InitAnimationForceUpdate(this, 2);
}
}
@@ -855,7 +855,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) {
this->field_0x7c = this->y;
}
if (this->field_0x76.HALF.LO == 0) {
if ((this->direction == 0xff) || sub_08049FA0(this)) {
if ((this->direction == DIR_NONE) || sub_08049FA0(this)) {
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (this->animationState + 1) & 3;
this->spriteOffsetX = gUnk_080D04D3[this->animationState];
@@ -863,7 +863,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) {
return;
}
bVar1 = sub_08049EE4(this);
this->direction = (bVar1 & 0x10) | 8;
this->direction = (bVar1 & 0x10) | DirectionEast;
this->field_0x76.HALF.LO = 0x10;
} else {
this->field_0x76.HALF.LO--;
+2 -2
View File
@@ -888,7 +888,7 @@ void sub_080406A0(Entity* this) {
this->direction = tmp + 0x1f;
}
}
this->direction &= 0x1f;
this->direction &= 0x3 | DirectionNorthWest;
this->field_0x86.HALF.LO = uVar5;
}
@@ -974,7 +974,7 @@ void sub_08040770(Entity* this) {
this->direction = tmp3 + 0x1F;
}
}
this->direction &= 0x1F;
this->direction &= 0x3 | DirectionNorthWest;
this->field_0x86.HALF.LO = tmp2;
}
+6 -6
View File
@@ -383,7 +383,7 @@ void VaatiWrathType0Action7(Entity* this) {
UpdateAnimationSingleFrame(this);
if (gRoomControls.origin_y + 0x48 != this->y.HALF.HI) {
this->speed = 0x100;
this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? 0x10 : 0;
this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? DirectionSouth : DirectionNorth;
LinearMoveUpdate(this);
} else {
if (--this->timer == 0) {
@@ -398,7 +398,7 @@ void VaatiWrathType0Action8(Entity* this) {
LinearMoveUpdate(this);
if (((gRoomControls.origin_x + 0x20) > this->x.HALF.HI) || ((gRoomControls.origin_x + 0x140) < this->x.HALF.HI)) {
if (0x3f < this->speed) {
this->direction ^= 0x10;
this->direction ^= DirectionSouth;
}
}
if (--this->timer == 0) {
@@ -451,7 +451,7 @@ void VaatiWrathType0ActionA(Entity* this) {
if (this->field_0x7a.HALF.HI == 0xf0) {
this->action = 0xb;
this->subAction = 0;
this->direction = 0;
this->direction = DirectionNorth;
this->speed = 0x100;
this->zVelocity = Q_16_16(1.125);
ChangeObjPalette(this, 0x16b);
@@ -521,7 +521,7 @@ void VaatiWrathType0ActionC(Entity* this) {
if (this->z.HALF.HI < -4) {
this->subAction = 1;
this->timer = 120;
this->direction = 0x10;
this->direction = DirectionSouth;
this->speed = 0x80;
}
break;
@@ -998,8 +998,8 @@ void sub_0804235C(Entity* this) {
void VaatiWrathType0PreAction(Entity* this) {
int temp;
if ((gRoomTransition.field_0x38 & 2) == 0) {
if (gSave.timers[3] != 0) {
gSave.timers[3]--;
if (gSave.vaati_timer != 0) {
gSave.vaati_timer--;
} else {
temp = gPlayerState.framestate_last;
switch (temp) {
+1 -1
View File
@@ -192,7 +192,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
int tmp = parent->base.gustJarState & 2;
if (tmp == 0) {
sub_08049CF4(&(parent->base));
gSave.unk50++;
gSave.enemies_killed++;
parent->base.gustJarState |= 2;
parent->base.timer = 255;
SetDefaultPriority(&(parent->base), 3);
+9 -9
View File
@@ -179,8 +179,8 @@ void Subtask_PortalCutscene_0(void) {
gScreen.bg1.yOffset = 0;
controls->scroll_y = 0;
portalId = gArea.portal_type;
if ((portalId == 2) && (gUI.roomControls.area != 2)) {
portalId = 3;
if ((portalId == PT_2) && (gUI.roomControls.area != 2)) {
portalId = PT_DUNGEON;
}
ptr = &gUnk_080D4138[portalId];
LoadPaletteGroup(ptr->paletteGroup);
@@ -247,19 +247,19 @@ void RespawnAsMinish(void) {
bool32 sub_0804AD18(void) {
switch (gArea.portal_type) {
case 0:
case 1:
case 2:
case PT_TREESTUMP:
case PT_ROCK:
case PT_2:
if (!CheckGlobalFlag(ENTRANCE_0 + gArea.portal_type)) {
return FALSE;
}
// else: return TRUE implicitely, because it's stored in r0. But does not match if returning explicitely.
break;
case 6:
case PT_TOD:
return FALSE;
case 3:
case 4:
case 5:
case PT_DUNGEON:
case PT_JAR:
case PT_5:
default:
return FALSE;
}
+4 -4
View File
@@ -1146,16 +1146,16 @@ void sub_080610B8(void) {
uVar6 = 0;
tmp4 = 0;
switch (gInput.unk4) {
case 0x40:
case DPAD_UP:
tmp4 = -1;
break;
case 0x80:
case DPAD_DOWN:
tmp4 = 1;
break;
case 0x20:
case DPAD_LEFT:
uVar6 = -1;
break;
case 0x10:
case DPAD_RIGHT:
uVar6 = 1;
break;
}
+1 -1
View File
@@ -229,7 +229,7 @@ static void GameMain_ChangeRoom(void) {
sub_0801855C();
}
#elif defined(DEMO_JP)
if (gRoomTransition.field_0x2c[4])
if (gRoomTransition.field31)
CheckAreaDiscovery();
if (gArea.unk28.textBaseIndex != 0xff) {
sub_0801855C();
+25 -32
View File
@@ -25,8 +25,8 @@
u32 StairsAreValid(void);
void ClearFlagArray(const u16*);
void DummyHandler(u32* a1);
void sub_08053434(u32* a1);
void sub_080534E4(u32* a1);
void DarknutTimerHandler(u32* a1);
void BiggoronTimerHandler(u32* a1);
void InitAllRoomResInfo(void);
void InitRoomResInfo(RoomResInfo* info, RoomHeader* hdr, u32 area, u32 room);
void sub_080532E4(void);
@@ -207,7 +207,7 @@ s32 ModHealth(s32 delta) {
newHealth = 0;
}
if (stats->maxHealth < newHealth) {
newHealth = (u32)stats->maxHealth;
newHealth = stats->maxHealth;
}
stats->health = newHealth;
gPlayerEntity.health = newHealth;
@@ -448,16 +448,10 @@ bool32 CanDispEzloMessage(void) {
void DisplayEzloMessage(void) {
u32 height;
u32 idx;
#if defined(JP) || defined(EU)
idx = 0x10;
#else
idx = 0x11;
#endif
if (gRoomTransition.player_status.field_0x24[idx] == 0) {
if (gRoomTransition.hint_height == 0) {
height = gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y > 96 ? 1 : 13;
} else {
height = gRoomTransition.player_status.field_0x24[idx];
height = gRoomTransition.hint_height;
}
MessageAtHeight(gRoomTransition.hint_idx, height);
}
@@ -466,11 +460,11 @@ void DisplayEzloMessage(void) {
void CreateMiscManager(void) {
Entity* e = NULL;
if (gRoomTransition.player_status.field_0x24[13])
if (gRoomTransition.field31)
return;
gRoomTransition.player_status.field_0x24[13] = 1;
gRoomTransition.field31 = 1;
#ifndef DEMO_JP
gRoomTransition.player_status.field_0x24[10] = gArea.locationIndex;
gRoomTransition.location = gArea.locationIndex;
#endif
e = (Entity*)GetEmptyManager();
if (e == NULL)
@@ -714,7 +708,7 @@ u32 sub_08053144(void) {
return 0;
ret = 0;
if (gArea.locationIndex != 0)
ret = !!(gRoomTransition.player_status.field_0x24[10] ^ gArea.locationIndex);
ret = !!(gRoomTransition.location ^ gArea.locationIndex);
return ret;
}
@@ -722,7 +716,7 @@ void CheckAreaDiscovery(void) {
if (!sub_08053144())
return;
gRoomTransition.player_status.field_0x24[10] = gArea.locationIndex;
gRoomTransition.location = gArea.locationIndex;
if (!CheckGlobalFlag(TABIDACHI))
return;
@@ -772,7 +766,7 @@ void sub_0805329C(void) {
if (sub_08053144()) {
switch (gRoomControls.area) {
case AREA_DEEPWOOD_SHRINE:
gSave.unk7 = 0;
gSave.dws_barrel_state = 0;
break;
case AREA_CAVE_OF_FLAMES:
sub_080530B0();
@@ -837,24 +831,25 @@ void sub_080533CC(void) {
void UpdateTimerCallbacks(void) {
static void (*const sHandlers[])(u32*) = {
sub_08053434, DummyHandler, sub_080534E4, DummyHandler, DummyHandler, DummyHandler, DummyHandler, DummyHandler,
DarknutTimerHandler, DummyHandler, BiggoronTimerHandler, DummyHandler,
DummyHandler, DummyHandler, DummyHandler, DummyHandler,
};
u32* p;
u32 i;
p = gSave.timers;
p = &gSave.darknut_timer;
for (i = 0; i < 8; i++, p++) {
(sHandlers[i])(p);
}
}
void DummyHandler(u32* a1) {
void DummyHandler(u32* timer) {
}
void sub_08053434(u32* a1) {
if (gArea.locationIndex == 29 && *a1) {
if (!--*a1) {
void DarknutTimerHandler(u32* timer) {
if (gArea.locationIndex == 29 && *timer) {
if (!--*timer) {
ResetTimerFlags();
MenuFadeIn(5, 6);
}
@@ -876,33 +871,31 @@ void ResetTimerFlags(void) {
0xFFFF,
};
gSave.timers[0] = 0;
gSave.darknut_timer = 0;
if (CheckLocalFlagByBank(FLAG_BANK_10, LV6_ZELDA_DISCURSE))
ClearGlobalFlag(ZELDA_CHASE);
ClearFlagArray(sClearFlags);
}
void StartDarkNutTimer(void) {
gSave.timers[0] = 10800;
gSave.darknut_timer = 10800;
}
void sub_080534AC(void) {
if (CheckLocalFlagByBank(FLAG_BANK_10, LV6_KANE_START)) {
ClearLocalFlagByBank(FLAG_BANK_10, LV6_KANE_START);
gSave.timers[0] = 0;
gSave.darknut_timer = 0;
SoundReq(SONG_STOP_BGM);
}
}
void sub_080534E4(u32* a1) {
if (gRoomControls.area != AREA_VEIL_FALLS_TOP) {
if (*a1)
--*a1;
}
void BiggoronTimerHandler(u32* timer) {
if (gRoomControls.area != AREA_VEIL_FALLS_TOP && *timer)
--*timer;
}
void InitBiggoronTimer(void) {
gSave.timers[2] = 36000;
gSave.biggoron_timer = 36000;
}
void ResetTmpFlags(void) {
+16 -16
View File
@@ -4,14 +4,14 @@
void sub_08075DF4(ItemBehavior*, u32);
void sub_08075E40(ItemBehavior*, u32);
void sub_08075EC0(ItemBehavior*, u32);
void ItemBowShoot(ItemBehavior*, u32);
void sub_08075F38(ItemBehavior*, u32);
void sub_08075F84(ItemBehavior*, u32);
void sub_08075D88(ItemBehavior*, u32);
void ItemBow(ItemBehavior* this, u32 index) {
static void (*const stateFuncs[])(ItemBehavior*, u32) = {
sub_08075DF4, sub_08075E40, sub_08075EC0, sub_08075F38, sub_08075F84, sub_08075D88,
sub_08075DF4, sub_08075E40, ItemBowShoot, sub_08075F38, sub_08075F84, sub_08075D88,
};
stateFuncs[this->stateID](this, index);
}
@@ -22,14 +22,14 @@ void sub_08075DF4(ItemBehavior* this, u32 index) {
sub_0806F948(&gPlayerEntity);
sub_08077BB8(this);
sub_08077D38(this, index);
gPlayerState.field_0x1f[2] = 1;
gPlayerState.bow_state = 1;
} else {
DeleteItemBehavior(this, index);
}
}
void sub_08075E40(ItemBehavior* this, u32 index) {
if (gPlayerState.field_0x1f[2] != 0) {
if (gPlayerState.bow_state != 0) {
if ((gPlayerState.attack_status & 0x80) == 0) {
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) != 0) {
@@ -43,24 +43,24 @@ void sub_08075E40(ItemBehavior* this, u32 index) {
return;
}
}
gPlayerState.field_0x1f[2] = 0;
gPlayerState.bow_state = 0;
DeleteItemBehavior(this, index);
}
void sub_08075EC0(ItemBehavior* this, u32 index) {
void ItemBowShoot(ItemBehavior* this, u32 index) {
u8 arrowCount;
s32 iVar2;
s32 isShooting;
arrowCount = gSave.stats.arrowCount;
iVar2 = IsItemActive(this);
if (iVar2 != 0 && arrowCount != 0) {
if (((gPlayerState.attack_status & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) {
gPlayerState.field_0x1f[2] = 0;
isShooting = IsItemActive(this);
if (isShooting && arrowCount != 0) {
if (((gPlayerState.attack_status & 0x80) != 0) || (gPlayerState.bow_state == 0)) {
gPlayerState.bow_state = 0;
DeleteItemBehavior(this, index);
}
} else {
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
SetItemAnim(this, 0x27c);
SetItemAnim(this, ANIM_BOW_SHOOT);
this->animPriority = 0xf;
this->priority |= 0xf;
this->stateID = 3;
@@ -68,19 +68,19 @@ void sub_08075EC0(ItemBehavior* this, u32 index) {
}
void sub_08075F38(ItemBehavior* this, u32 index) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.bow_state != 0)) {
UpdateItemAnim(this);
if ((this->playerFrame & 1) != 0) {
this->stateID = 4;
}
} else {
gPlayerState.field_0x1f[2] = 0;
gPlayerState.bow_state = 0;
DeleteItemBehavior(this, index);
}
}
void sub_08075F84(ItemBehavior* this, u32 index) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) {
if (((gPlayerState.attack_status & 0x80) == 0) && (gPlayerState.bow_state != 0)) {
if (GetInventoryValue(ITEM_ARROW_BUTTERFLY) == 1) {
sub_08077E3C(this, 5);
} else {
@@ -90,6 +90,6 @@ void sub_08075F84(ItemBehavior* this, u32 index) {
return;
}
}
gPlayerState.field_0x1f[2] = 0;
gPlayerState.bow_state = 0;
DeleteItemBehavior(this, index);
}
+9 -9
View File
@@ -36,7 +36,7 @@ void sub_08076E60(ItemBehavior* this, u32 index) {
}
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
SetItemAnim(this, 0x504);
SetItemAnim(this, ANIM_GUSTJAR_SUCK);
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
playerItem = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (playerItem != NULL) {
@@ -64,12 +64,12 @@ void sub_08076EC8(ItemBehavior* this, u32 index) {
}
if (gPlayerEntity.subAction == 0x1b) {
animIndex = 0x524;
animIndex = ANIM_GUSTJAR_524;
} else {
if (gPlayerState.direction & 0x80) {
animIndex = 0x504;
if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) {
animIndex = ANIM_GUSTJAR_SUCK;
} else {
animIndex = 0x518;
animIndex = ANIM_GUSTJAR_WALK;
}
}
@@ -100,7 +100,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
gPlayerState.field_0x1c = 1;
gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2;
SetItemAnim(this, 0x504);
SetItemAnim(this, ANIM_GUSTJAR_SUCK);
item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (item) {
item->parent = player;
@@ -108,7 +108,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
return;
} else {
gPlayerState.field_0x1c = 6;
SetItemAnim(this, 0x510);
SetItemAnim(this, ANIM_GUSTJAR_END);
return;
}
} else {
@@ -155,7 +155,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
return;
break;
case 7:
SetItemAnim(this, 0x514);
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
gPlayerState.field_0x1c = 3;
gPlayerState.gustJarSpeed = 0;
return;
@@ -163,7 +163,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) {
case 2:
default:
gPlayerState.field_0x1c = 3;
SetItemAnim(this, 0x514);
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
return;
case 0:
break;
+21 -21
View File
@@ -24,41 +24,41 @@ void sub_08077534(ItemBehavior* this, u32 index) {
sub_08077BB8(this);
this->priority |= 0xf;
tmp = this->behaviorId;
this->timer = gSave.filler86[tmp + 0x14];
this->timer = gSave.stats.bottles[tmp - ITEM_BOTTLE1];
switch (this->timer) {
case 0x20:
SetItemAnim(this, 0x614);
case ITEM_BOTTLE_EMPTY:
SetItemAnim(this, ANIM_BOTTLE_SWING);
return;
case 0x21:
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
case ITEM_BOTTLE_BUTTER:
case ITEM_BOTTLE_MILK:
case ITEM_BOTTLE_HALF_MILK:
case ITEM_BOTTLE_RED_POTION:
case ITEM_BOTTLE_BLUE_POTION:
case ITEM_BOTTLE_PICOLYTE_RED:
case ITEM_BOTTLE_PICOLYTE_ORANGE:
case ITEM_BOTTLE_PICOLYTE_YELLOW:
case ITEM_BOTTLE_PICOLYTE_GREEN:
case ITEM_BOTTLE_PICOLYTE_BLUE:
case ITEM_BOTTLE_PICOLYTE_WHITE:
this->stateID = 3;
gPlayerEntity.animationState = 4;
gPlayerEntity.spriteSettings.flipX = 0;
SetItemAnim(this, 0x2df);
SetItemAnim(this, ANIM_BOTTLE_DRINK);
break;
case 0x2f:
case 0x30:
case 0x31:
case BOTTLE_CHARM_NAYRU:
case BOTTLE_CHARM_FARORE:
case BOTTLE_CHARM_DIN:
default:
this->stateID = 3;
SetItemAnim(this, 0x610);
SetItemAnim(this, ANIM_BOTTLE_POUR);
break;
}
gPlayerEntity.flags &= ~ENT_COLLIDE;
}
void sub_08077618(ItemBehavior* this, u32 index) {
if ((this->playerFrame & 0x80) != 0) {
SetItemAnim(this, 0x618);
if (this->playerFrame & 0x80) {
SetItemAnim(this, ANIM_BOTTLE_SWING_END);
this->stateID++;
} else {
UpdateItemAnim(this);
+1 -1
View File
@@ -104,7 +104,7 @@ void sub_08075B54(ItemBehavior* this, u32 index) {
object->x.HALF.HI = tmp[0] + object->x.HALF.HI;
object->y.HALF.HI = tmp[1] + object->y.HALF.HI;
}
SetItemAnim(this, 0x60c);
SetItemAnim(this, ANIM_LANTERN_BURN);
bVar1 = (8 >> (index));
gPlayerState.field_0xa |= bVar1;
gPlayerState.keepFacing |= bVar1;
+5 -5
View File
@@ -34,7 +34,7 @@ void sub_08077130(ItemBehavior* this, u32 index) {
iVar1 = sub_080774A0();
if (iVar1 != 0) {
if (this->timer == 0) {
SetItemAnim(this, 0x50c);
SetItemAnim(this, ANIM_MOLEMITTS_DIG);
this->stateID = 2;
if (iVar1 == 0x56) {
if ((gPlayerEntity.animationState & 2) != 0) {
@@ -45,7 +45,7 @@ void sub_08077130(ItemBehavior* this, u32 index) {
}
}
} else {
SetItemAnim(this, 0x508);
SetItemAnim(this, ANIM_MOLEMITTS_FLOOR);
this->stateID = 1;
}
} else {
@@ -71,9 +71,9 @@ void sub_080771C8(ItemBehavior* this, u32 index) {
}
if ((this->playerFrame & 0x10) != 0) {
if (sub_0800875A(&gPlayerEntity, 0xd, this) == 0) {
SetItemAnim(this, 0x520);
SetItemAnim(this, ANIM_MOLEMITTS_MISS);
this->stateID = 3;
SoundReq(SFX_107);
SoundReq(SFX_ITEM_GLOVES_AIR);
} else {
if (this->subtimer != 0xff) {
object = CreateObjectWithParent(&gPlayerEntity, OBJECT_1F, 0, this->field_0x2[1]);
@@ -140,7 +140,7 @@ void sub_080772A8(ItemBehavior* this, u32 index) {
SoundReq(SFX_108);
CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 0);
} else {
SetItemAnim(this, 0x51c);
SetItemAnim(this, ANIM_MOLEMITTS_CLANG);
effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0);
if (effect != NULL) {
effect->animationState = this->playerAnimationState;
+13 -12
View File
@@ -67,11 +67,11 @@ void sub_080768F8(ItemBehavior* this, u32 index) {
bVar1 |= bVar2;
if (bVar1 == 0) {
gPlayerState.dash_state = 1;
gPlayerState.field_0x1f[2] = bVar1;
if ((gPlayerState.flags & PL_MINISH) == 0) {
gPlayerState.bow_state = bVar1;
if (!(gPlayerState.flags & PL_MINISH)) {
this->timer = 0x10;
} else {
gPlayerState.animation = 0xc14;
gPlayerState.animation = ANIM_DASH_CHARGE_MINISH;
}
sub_08077D38(this, index);
sub_08076964(this, index);
@@ -104,7 +104,7 @@ void sub_08076964(ItemBehavior* this, u32 index) {
if (HasSwordEquipped() && (gPlayerState.flags & PL_MINISH) == 0 &&
(gPlayerState.skills & SKILL_DASH_ATTACK) != 0) {
gPlayerState.lastSwordMove = SWORD_MOVE_DASH;
SetItemAnim(this, 0x298);
SetItemAnim(this, ANIM_DASH);
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD);
if (entity != NULL) {
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) {
@@ -115,11 +115,11 @@ void sub_08076964(ItemBehavior* this, u32 index) {
entity->field_0x68.HALF.LO = uVar3;
return;
}
} else if ((gPlayerState.flags & PL_MINISH) == 0) {
SetItemAnim(this, 0x104);
} else if (!(gPlayerState.flags & PL_MINISH)) {
SetItemAnim(this, ANIM_WALK);
return;
} else {
gPlayerState.animation = 0xc10;
gPlayerState.animation = ANIM_DASH_MINISH;
return;
}
} else {
@@ -136,7 +136,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
u8* ptr;
if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) {
if ((gPlayerState.flags & PL_MINISH) == 0) {
if (!(gPlayerState.flags & PL_MINISH)) {
gPlayerEntity.speed = 0x300;
} else {
gPlayerEntity.speed = 0x280;
@@ -148,7 +148,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
gPlayerEntity.subAction = 0;
COLLISION_OFF(&gPlayerEntity);
gPlayerState.field_0x38 = 0;
gPlayerState.direction = 0xff;
gPlayerState.direction = DIR_NONE;
return;
}
this->subtimer = 1;
@@ -157,12 +157,13 @@ void sub_08076A88(ItemBehavior* this, u32 index) {
ptr = gUnk_0811BE38;
if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) {
this->direction = (this->playerAnimationState & 0xe) * 4;
if ((gPlayerState.direction != 0xff) && (gPlayerState.direction != this->direction)) {
if (((gPlayerState.direction - this->direction) & 0x1f) < 0x10) {
if ((gPlayerState.direction != DIR_NONE) && (gPlayerState.direction != this->direction)) {
if (((gPlayerState.direction - this->direction) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast |
DirectionSouth | DirectionWest)) < DirectionSouth) {
this->direction = this->direction + 2;
}
this->direction--;
this->direction &= 0x1f;
this->direction &= 0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest;
}
gPlayerState.direction = this->direction;
UpdateItemAnim(this);
+1 -1
View File
@@ -69,7 +69,7 @@ void sub_08076758(ItemBehavior* this, u32 index) {
gPlayerEntity.field_0x7a.HWORD = 2;
gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerState.jump_status |= 0x10;
gPlayerState.animation = 0x288;
gPlayerState.animation = ANIM_ROCS_CAPE;
SoundReq(SFX_172);
}
} else {
+8 -8
View File
@@ -31,7 +31,7 @@ void sub_08075338(ItemBehavior* this, u32 index) {
if (gPlayerState.flags & PL_MINISH) {
this->priority |= 0x80;
sub_08077D38(this, index);
gPlayerState.animation = 0xc00;
gPlayerState.animation = ANIM_SWORD_MINISH;
SoundReq(SFX_PLY_VO1);
return;
}
@@ -80,7 +80,7 @@ void sub_08075338(ItemBehavior* this, u32 index) {
this->priority |= 0x80;
gPlayerState.lastSwordMove = SWORD_MOVE_ROLL;
gPlayerState.flags |= PL_SWORD_THRUST;
SetItemAnim(this, 0x130);
SetItemAnim(this, ANIM_ROLLATTACK_SLIDE);
SoundReq(SFX_PLY_VO3);
return;
}
@@ -150,7 +150,7 @@ void sub_08075580(ItemBehavior* this, u32 index) {
} else {
this->timer = 0x50;
}
SetItemAnim(this, 0x168);
SetItemAnim(this, ANIM_SWORD_CHARGE);
CreateObject(SWORD_PARTICLE, 0, 0);
return;
}
@@ -190,10 +190,10 @@ void sub_08075694(ItemBehavior* this, u32 index) {
if (gPlayerState.flags & PL_SWORD_THRUST) {
gPlayerState.flags &= ~PL_SWORD_THRUST;
gPlayerState.flags &= ~PL_ROLLING;
SetItemAnim(this, 300);
SetItemAnim(this, ANIM_ROLLATTACK_SPIN);
} else {
gPlayerState.lastSwordMove = SWORD_MOVE_SPIN;
SetItemAnim(this, 0x124);
SetItemAnim(this, ANIM_SPINATTACK);
}
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
this->stateID = 4;
@@ -220,7 +220,7 @@ void sub_08075738(ItemBehavior* this, u32 index) {
}
if ((gPlayerState.sword_state & 0x10) != 0) {
if ((gPlayerState.direction & 0x80) == 0) {
if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) {
this->direction = gPlayerState.direction;
}
gPlayerEntity.direction = this->direction;
@@ -252,7 +252,7 @@ void sub_08075738(ItemBehavior* this, u32 index) {
this->timer = 1;
this->subtimer = 1;
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
SetItemAnim(this, 0x128);
SetItemAnim(this, ANIM_GREATSPIN);
}
if ((this->playerFrame & 0x80) != 0) {
@@ -298,7 +298,7 @@ void sub_08075900(ItemBehavior* this, u32 index) {
} else {
if (this->timer != 0) {
if (--this->timer == 0) {
SetItemAnim(this, 0x134);
SetItemAnim(this, ANIM_ROLLATTACK_END);
}
gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3;
gPlayerEntity.speed = 0x300;
+109 -10
View File
@@ -14,6 +14,11 @@ void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
void sub_0807660C(ItemBehavior*, u32);
extern s32 sub_0800875A(Entity*, u32, ItemBehavior*);
extern const u16 gUnk_0811BE38[];
extern const u16 gUnk_0811BE40[];
void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
if (param_2 != NULL) {
if ((param_2->carryFlags & 1) != 0) {
@@ -25,9 +30,9 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
this->field_0x18 = param_2;
if ((gPlayerState.flags & PL_NO_CAP)) {
SetItemAnim(this, 0x928);
SetItemAnim(this, ANIM_PICKUP_NOCAP);
} else {
SetItemAnim(this, 0x338);
SetItemAnim(this, ANIM_PICKUP);
}
gPlayerState.heldObject = 3;
gPlayerState.framestate = 4;
@@ -108,12 +113,12 @@ void ItemPickupCheck(ItemBehavior* this, u32 index) {
this->animPriority = 6;
gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> index) | gPlayerState.keepFacing;
if ((gPlayerState.flags & PL_NO_CAP) == 0) {
SetItemAnim(this, 0x378);
if (!(gPlayerState.flags & PL_NO_CAP)) {
SetItemAnim(this, ANIM_GRAB);
} else {
SetItemAnim(this, 0x948);
SetItemAnim(this, ANIM_GRAB_NOCAP);
}
SoundReq(SFX_88);
SoundReq(SFX_GRAB);
break;
default:
break;
@@ -129,7 +134,101 @@ void sub_080762C4(ItemBehavior* this, Entity* arg1, u8 arg2, u32 arg3) {
sub_08077D38(this, arg3);
}
ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 index))
void sub_080762D8(ItemBehavior* this, u32 index) {
u32 animIndex;
gPlayerState.heldObject &= 0xcf;
if (!PlayerTryDropObject(this, index)) {
return;
}
if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) {
if (this->field_0x18 != NULL) {
if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) {
if (!(gPlayerState.playerInput.heldInput & PLAYER_INPUT_80)) { // Pressing R
this->field_0x18->subAction = 6;
PlayerCancelHoldItem(this, index);
return;
}
} else {
PlayerCancelHoldItem(this, index);
return;
}
}
gPlayerState.framestate = PL_STATE_THROW;
gUnk_0200AF00.rActionGrabbing = 8;
} else {
if (this->field_0x18 != NULL) {
this->field_0x18->subAction = 6;
}
PlayerCancelHoldItem(this, index);
return;
}
if (!gPlayerState.jump_status) {
if (gPlayerState.heldObject == 1 && sub_0800875A(&gPlayerEntity, 6, this) != 0) {
sub_08076088(this, NULL, index);
return;
} else if (gUnk_0811BE38[gPlayerEntity.animationState >> 1] & gPlayerState.playerInput.heldInput) {
UpdateItemAnim(this);
if (!(gPlayerState.flags & PL_NO_CAP)) {
animIndex = ANIM_PULL;
} else {
animIndex = ANIM_PULL_START_NOCAP;
}
if (animIndex != this->animIndex) {
SetItemAnim(this, animIndex);
}
gPlayerState.heldObject |= 0x10;
gPlayerState.framestate = PL_STATE_PULL;
if (gPlayerState.heldObject == 1) {
return;
}
sub_08076088(this, this->field_0x18, index);
} else {
if (gPlayerState.playerInput.heldInput & gUnk_0811BE40[gPlayerEntity.animationState >> 1]) {
if (gPlayerEntity.subtimer < 6) {
gPlayerEntity.subtimer++;
return;
}
gPlayerState.field_0x35 = this->playerAnimationState;
gPlayerState.pushedObject |= 0x80;
gPlayerState.heldObject |= 0x20;
gPlayerState.framestate = PL_STATE_PUSH;
if (!(gPlayerState.flags & PL_NO_CAP)) {
animIndex = ANIM_PUSH;
} else {
animIndex = ANIM_PUSH_NOCAP;
}
if (animIndex == this->animIndex) {
UpdateItemAnim(this);
} else {
SetItemAnim(this, animIndex);
}
} else {
gPlayerEntity.subtimer = 0;
if (!(gPlayerState.flags & PL_NO_CAP)) {
SetItemAnim(this, ANIM_PULL);
} else {
SetItemAnim(this, ANIM_PULL_START_NOCAP);
}
}
}
} else {
PlayerCancelHoldItem(this, index);
}
}
void sub_08076488(ItemBehavior* this, u32 index) {
u32 bVar1;
@@ -172,10 +271,10 @@ void sub_08076518(ItemBehavior* this, u32 index) {
this->field_0x18 = NULL;
this->stateID++;
this->animPriority = 0x0f;
if ((gPlayerState.flags & PL_NO_CAP) != 0) {
SetItemAnim(this, 0x930);
if (gPlayerState.flags & PL_NO_CAP) {
SetItemAnim(this, ANIM_THROW_NOCAP);
} else {
SetItemAnim(this, 0x344);
SetItemAnim(this, ANIM_THROW);
}
gPlayerState.field_0xa |= 8 >> index;
gPlayerState.keepFacing |= 8 >> index;
+23 -23
View File
@@ -4,38 +4,38 @@
const ItemDefinition gItemDefinitions[] = {
[ITEM_NONE] = { TRUE, 1, CREATE_ITEM_0, PLAYER_ITEM_NONE, 0, 0, FALSE, FALSE },
[ITEM_SMITH_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_GREEN_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_RED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_BLUE_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_UNUSED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_FOURSWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, 264, 6, TRUE, TRUE },
[ITEM_SMITH_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_GREEN_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_RED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_BLUE_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_UNUSED_SWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_FOURSWORD] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_SWORD, ANIM_SWORD, 6, TRUE, TRUE },
[ITEM_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
[ITEM_REMOTE_BOMBS] = { TRUE, 3, CREATE_ITEM_4, PLAYER_ITEM_BOMB, 0, 3, FALSE, FALSE },
[ITEM_BOW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
[ITEM_LIGHT_ARROW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, 540, 3, FALSE, FALSE },
[ITEM_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 2072, 3, FALSE, FALSE },
[ITEM_MAGIC_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, 1796, 3, FALSE, FALSE },
[ITEM_SHIELD] = { FALSE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
[ITEM_MIRROR_SHIELD] = { TRUE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, 344, 2, FALSE, FALSE },
[ITEM_BOW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, ANIM_BOW_PULLOUT, 3, FALSE, FALSE },
[ITEM_LIGHT_ARROW] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOW, ANIM_BOW_PULLOUT, 3, FALSE, FALSE },
[ITEM_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, ANIM_BOOMERANG, 3, FALSE, FALSE },
[ITEM_MAGIC_BOOMERANG] = { TRUE, 5, CREATE_ITEM_3, PLAYER_ITEM_BOOMERANG, ANIM_BOOMERANG_MAGIC, 3, FALSE, FALSE },
[ITEM_SHIELD] = { FALSE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, ANIM_SHIELD_PULLOUT, 2, FALSE, FALSE },
[ITEM_MIRROR_SHIELD] = { TRUE, 1, CREATE_ITEM_3, PLAYER_ITEM_SHIELD, ANIM_SHIELD_PULLOUT, 2, FALSE, FALSE },
#ifdef EU
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 6, FALSE, FALSE },
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, ANIM_LANTERN_LIGHT, 6, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, ANIM_LANTERN_LIGHT, 6, FALSE, FALSE },
#else
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, 1536, 2, FALSE, FALSE },
[ITEM_LANTERN_OFF] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, ANIM_LANTERN_LIGHT, 2, FALSE, FALSE },
[ITEM_LANTERN_ON] = { TRUE, 3, CREATE_ITEM_5, PLAYER_ITEM_LANTERN, ANIM_LANTERN_LIGHT, 2, FALSE, FALSE },
#endif
[ITEM_GUST_JAR] = { TRUE, 6, CREATE_ITEM_3, PLAYER_ITEM_GUST_JAR, 1280, 2, FALSE, FALSE },
[ITEM_PACCI_CANE] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_PACCI_CANE, 1576, 6, TRUE, FALSE },
[ITEM_GUST_JAR] = { TRUE, 6, CREATE_ITEM_3, PLAYER_ITEM_GUST_JAR, ANIM_GUSTJAR_PULLOUT, 2, FALSE, FALSE },
[ITEM_PACCI_CANE] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_PACCI_CANE, ANIM_CANE, 6, TRUE, FALSE },
[ITEM_MOLE_MITTS] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NONE2, 0, 2, TRUE, FALSE },
[ITEM_ROCS_CAPE] = { TRUE, 1, CREATE_ITEM_1, PLAYER_ITEM_NONE3, 2060, 0, FALSE, FALSE },
[ITEM_PEGASUS_BOOTS] = { TRUE, CREATE_ITEM_1, PLAYER_ITEM_SWORD, 12, 260, 6, FALSE, FALSE },
[ITEM_FIRE_ROD] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET, 260, 6, FALSE, FALSE },
[ITEM_OCARINA] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_NONE, 2273, 6, FALSE, FALSE },
[ITEM_ROCS_CAPE] = { TRUE, 1, CREATE_ITEM_1, PLAYER_ITEM_NONE3, ANIM_HOP, 0, FALSE, FALSE },
[ITEM_PEGASUS_BOOTS] = { TRUE, 1, CREATE_ITEM_1, PLAYER_ITEM_DASH_SWORD, ANIM_WALK, 6, FALSE, FALSE },
[ITEM_FIRE_ROD] = { TRUE, 4, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET, ANIM_WALK, 6, FALSE, FALSE },
[ITEM_OCARINA] = { TRUE, 7, CREATE_ITEM_3, PLAYER_ITEM_NONE, ANIM_OCARINA, 6, FALSE, FALSE },
[ITEM_ORB_GREEN] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED2, 0, 1, TRUE, TRUE },
[ITEM_ORB_BLUE] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_NULLED, 0, 1, TRUE, TRUE },
[ITEM_ORB_RED] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_CELL_OVERWRITE_SET2, 0, 1, TRUE, TRUE },
[ITEM_TRY_PICKUP_OBJECT] = { TRUE, 2, CREATE_ITEM_3, PLAYER_ITEM_HELD_OBJECT, 832, 4, FALSE, TRUE },
[ITEM_TRY_PICKUP_OBJECT] = { TRUE, 2, CREATE_ITEM_3, PLAYER_ITEM_HELD_OBJECT, ANIM_PULL, 4, FALSE, TRUE },
[ITEM_BOTTLE1] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
[ITEM_BOTTLE2] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
[ITEM_BOTTLE3] = { TRUE, 3, CREATE_ITEM_3, PLAYER_ITEM_BOTTLE, 0, 6, TRUE, FALSE },
+2 -2
View File
@@ -385,7 +385,7 @@ void sub_08054524(void) {
bVar1 = gArea.locationIndex;
if (gArea.locationIndex == 0) {
bVar1 = gRoomTransition.player_status.field_0x24[0xa];
bVar1 = gRoomTransition.location;
}
if (bVar1 > 0x16) {
bVar1 = 0;
@@ -480,7 +480,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
ptr2 = &gDroptableModifiers[DROPTABLE_NO_SHELLS];
}
// don't drop kinstones anymore
if (gSave.didAllFusions != 0) {
if (gSave.kinstones.didAllFusions != 0) {
ptr3 = &gDroptableModifiers[DROPTABLE_NO_KINSTONES];
}
// vector addition, s0 = s0 + ptr2 + ptr3
-5
View File
@@ -179,12 +179,7 @@ void GenerateAreaHint(void) {
struct_area_28* ptr;
gPlayerState.queued_action = PLAYER_TALKEZLO;
#if defined(EU) || defined(JP)
// TODO what fields of the room transition are switched in these variants?
gRoomTransition.field_0x2c[7] = 0;
#else
gRoomTransition.hint_height = 0;
#endif
ptr = &gArea.unk28;
if (ptr->textBaseIndex == 0xff) {
gRoomTransition.hint_idx = ptr->ezloHintTexts[0];
+2 -2
View File
@@ -34,7 +34,7 @@ void MinishPortalManager_Main(MinishPortalManager* this) {
gArea.portal_type = super->type;
if (!CheckGlobalFlag(EZERO_1ST)) {
gArea.portal_mode = 1;
gArea.portal_type = 5;
gArea.portal_type = PT_5;
} else {
if ((gPlayerState.flags & PL_USE_PORTAL) && gPlayerState.jump_status == 0) {
gArea.portal_mode = 2;
@@ -83,7 +83,7 @@ void CreateMagicSparkles(u32 baseX, u32 baseY, u32 layer) {
}
bool32 PortalReadyForMinish(void) {
if ((gPlayerState.flags & PL_MINISH) && gPlayerState.attachedBeetleCount == 0 && (gArea.portal_type != 0x6) &&
if ((gPlayerState.flags & PL_MINISH) && gPlayerState.attachedBeetleCount == 0 && (gArea.portal_type != PT_TOD) &&
(gPlayerState.heldObject == 0)) {
switch (gPlayerState.framestate) {
case PL_STATE_IDLE:
+1 -1
View File
@@ -434,6 +434,6 @@ void MiscManager_TypeF(MiscManager* this) {
if (gPlayerEntity.action == PLAYER_TALKEZLO) {
DeleteThisEntity();
}
gInput.heldKeys |= 0x4;
gInput.heldKeys |= SELECT_BUTTON;
}
#endif
+1 -1
View File
@@ -192,7 +192,7 @@ void sub_08058B5C(RollingBarrelManager* this, u32 unk1) {
gRoomTransition.player_status.start_anim = unk1 & 1 ? 4 : 0;
gRoomTransition.player_status.start_pos_x = gUnk_081082E8[unk1 * 3];
gRoomTransition.player_status.start_pos_y = gUnk_081082E8[unk1 * 3 + 1];
gSave.unk7 = gUnk_081082E8[unk1 * 3 + 2];
gSave.dws_barrel_state = gUnk_081082E8[unk1 * 3 + 2];
SoundReq(SFX_STAIRS);
}
+2 -2
View File
@@ -54,7 +54,7 @@ void Vaati3StartManager_Type0_Init(Vaati3StartManager* this) {
*(u8*)&gRoomTransition.field_0x3a = 0x20;
*((u8*)&gRoomTransition.field_0x3a + 1) = 0x20;
#if !defined(EU) && !defined(JP)
gSave.timers[3] = 0x1194;
gSave.vaati_timer = 0x1194;
#endif
}
@@ -71,7 +71,7 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) {
super->timer = 120;
SetPlayerControl(2);
sub_08078B48();
object = CreateObject(THUNDERBOLD, 0, 0);
object = CreateObject(THUNDERBOLT, 0, 0);
if (object != NULL) {
object->x.HALF.HI = gRoomControls.origin_x + 0x88;
object->y.HALF.HI = gRoomControls.origin_y + 0x48;
+4 -4
View File
@@ -138,16 +138,16 @@ void VaatiAppearingManager_Action2(VaatiAppearingManager* this) {
}
void VaatiAppearingManager_Action3(VaatiAppearingManager* this) {
if ((gInput.heldKeys & 0x40) != 0) {
if ((gInput.heldKeys & DPAD_UP) != 0) {
this->field_0x20--;
}
if ((gInput.heldKeys & 0x80) != 0) {
if ((gInput.heldKeys & DPAD_DOWN) != 0) {
this->field_0x20++;
}
if ((gInput.heldKeys & 0x20) != 0) {
if ((gInput.heldKeys & DPAD_LEFT) != 0) {
this->field_0x28--;
}
if ((gInput.heldKeys & 0x10) != 0) {
if ((gInput.heldKeys & DPAD_RIGHT) != 0) {
this->field_0x28++;
}
}
+80 -80
View File
@@ -57,24 +57,24 @@ extern const struct_08128AD8 gUnk_08128AD8[];
Subtask FigurineMenu0_Type0;
Subtask FigurineMenu0_Type1;
Subtask FigurineMenu0_Type2;
Subtask FigurineMenu0_Type3;
Subtask FigurineMenu0_ViewFigurineAfterDrawing;
Subtask FigurineMenu1_Type0;
Subtask FigurineMenu1_Type1;
Subtask FigurineMenu1_ViewAllFigurines;
Subtask FigurineMenu1_Type2;
Subtask FigurineMenu1_Type3;
Subtask FigurineMenu1_ExitMenu;
void Subtask_FigurineMenu(void) {
static Subtask* const figurineMenu1_Types[] = {
FigurineMenu0_Type0,
FigurineMenu0_Type1,
FigurineMenu0_Type2,
FigurineMenu0_Type3,
FigurineMenu0_ViewFigurineAfterDrawing,
};
static Subtask* const figurineMenu0_Types[] = {
FigurineMenu1_Type0,
FigurineMenu1_Type1,
FigurineMenu1_ViewAllFigurines,
FigurineMenu1_Type2,
FigurineMenu1_Type3,
FigurineMenu1_ExitMenu,
};
#if !(defined(DEMO_USA) || defined(DEMO_JP))
FlushSprites();
@@ -94,7 +94,7 @@ void Subtask_FigurineMenu(void) {
}
void FigurineMenu_080A4608(void) {
s32 iVar2, r1, r2;
s32 iVar2, r1, maxFigurines;
SetBgmVolume(0x80);
sub_080A4DA8(3);
@@ -112,15 +112,15 @@ void FigurineMenu_080A4608(void) {
}
r1 = gUI.field_0x3;
r2 = !gSave.saw_staffroll ? 0x82 : 0x88;
if (r2 < r1) {
maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (maxFigurines < r1) {
r1 = 1;
}
gFigurineMenu.figure_idx = r1;
SetFade(FADE_INSTANT, 8);
}
void FigurineMenu_080A46C0(void) {
void FigurineMenu_ExitMenu(void) {
SetBgmVolume(0x100);
SoundReq(SFX_MENU_CANCEL);
ClearRoomFlag(2);
@@ -147,7 +147,7 @@ void FigurineMenu0_Type2(void) {
gFigurineMenu.unk20++;
switch (gFigurineMenu.unk20) {
case 0x40:
gFigurineMenu.duplicate = WriteBit(&gSave.stats.filler4[4], gFigurineMenu.figure_idx);
gFigurineMenu.duplicate = WriteBit(gSave.figurines, gFigurineMenu.figure_idx);
gMenu.column_idx = 1;
default:
bVar1 = gFigurineMenu.unk20 >> 2;
@@ -175,32 +175,32 @@ void FigurineMenu0_Type2(void) {
}
}
void FigurineMenu0_Type3(void) {
s32 uVar1;
void FigurineMenu0_ViewFigurineAfterDrawing(void) {
s32 infoY;
s32 t;
uVar1 = gFigurineMenu.unk1f;
infoY = gFigurineMenu.unk1f;
switch (gInput.unk4) {
case 2:
case 8:
FigurineMenu_080A46C0();
case B_BUTTON:
case START_BUTTON:
FigurineMenu_ExitMenu();
break;
case 0x10:
uVar1 += 8;
case DPAD_RIGHT:
infoY += 8;
break;
case 0x20:
uVar1 -= 8;
case DPAD_LEFT:
infoY -= 8;
break;
}
t = gFigurineMenu.unk1e;
if (uVar1 < 0) {
uVar1 = 0;
if (infoY < 0) {
infoY = 0;
}
if (t < uVar1) {
uVar1 = t;
if (t < infoY) {
infoY = t;
}
gFigurineMenu.unk1f = uVar1;
gScreen.bg1.yOffset = uVar1 - 0x70;
gFigurineMenu.unk1f = infoY;
gScreen.bg1.yOffset = infoY - 112;
}
void FigurineMenu1_Type0(void) {
@@ -211,85 +211,85 @@ void FigurineMenu1_Type0(void) {
SetMenuType(1);
}
void FigurineMenu1_Type1(void) {
int r0, r1, r4, r5;
void FigurineMenu1_ViewAllFigurines(void) {
int prevFigurineIndex, maxFigurines, figurineIndex, infoY;
if (gFadeControl.active)
return;
r5 = gFigurineMenu.unk1f;
r4 = gFigurineMenu.figure_idx;
infoY = gFigurineMenu.unk1f;
figurineIndex = gFigurineMenu.figure_idx;
switch (gInput.unk4) {
case B_BUTTON:
case START_BUTTON:
SetMenuType(3);
break;
case L_BUTTON:
r4 -= 5;
figurineIndex -= 5;
break;
case R_BUTTON:
r4 += 5;
figurineIndex += 5;
break;
case DPAD_UP:
r4--;
figurineIndex--;
break;
case DPAD_DOWN:
r4++;
figurineIndex++;
break;
case DPAD_RIGHT:
r5 += 8;
infoY += 8;
break;
case DPAD_LEFT:
r5 -= 8;
infoY -= 8;
break;
case A_BUTTON:
break;
}
r1 = !gSave.saw_staffroll ? 0x82 : 0x88;
if (r4 <= 0) {
r4 = 1;
maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (figurineIndex <= 0) {
figurineIndex = 1;
}
if (r1 < r4) {
r4 = r1;
if (maxFigurines < figurineIndex) {
figurineIndex = maxFigurines;
}
r0 = gFigurineMenu.figure_idx;
if (r0 != r4) {
gFigurineMenu.figure_idx = r4;
prevFigurineIndex = gFigurineMenu.figure_idx;
if (prevFigurineIndex != figurineIndex) {
gFigurineMenu.figure_idx = figurineIndex;
SoundReq(SFX_TEXTBOX_CHOICE);
SetMenuType(2);
r5 = 0;
infoY = 0;
}
r0 = gFigurineMenu.unk1e;
if (r5 < 0) {
r5 = 0;
prevFigurineIndex = gFigurineMenu.unk1e;
if (infoY < 0) {
infoY = 0;
}
if (r0 < r5) {
r5 = r0;
if (prevFigurineIndex < infoY) {
infoY = prevFigurineIndex;
}
gFigurineMenu.unk1f = r5;
gScreen.bg1.yOffset = r5 - 0x70;
gFigurineMenu.unk1f = infoY;
gScreen.bg1.yOffset = infoY - 112;
}
void FigurineMenu1_Type2(void) {
SetMenuType(1);
}
void FigurineMenu1_Type3(void) {
FigurineMenu_080A46C0();
void FigurineMenu1_ExitMenu(void) {
FigurineMenu_ExitMenu();
}
u32 sub_080A4948(s32 param_1) {
s32 iVar1;
u32 uVar2;
u32 FigurineMenu_isFigurineOwned(s32 figurineIndex) {
s32 maxFigurines;
u32 hasFigurine;
uVar2 = 0;
iVar1 = !gSave.saw_staffroll ? 0x82 : 0x88;
if ((0 < param_1) || (iVar1 >= param_1)) {
if (ReadBit((u32*)&gSave.stats.filler4[4], param_1)) {
uVar2 = 1;
hasFigurine = 0;
maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if ((0 < figurineIndex) || (maxFigurines >= figurineIndex)) {
if (ReadBit(gSave.figurines, figurineIndex)) {
hasFigurine = 1;
}
}
return uVar2;
return hasFigurine;
}
typedef struct {
@@ -307,7 +307,7 @@ extern const Figurine gFigurines[];
#define sub_080A4978_draw_constant 0x1fc
#endif
void FigurineMenu_080A4978(void) {
int r0, r2, r4, r6;
int r0, maxFigurines, r4, r6;
gOamCmd._4 = 0;
gOamCmd._6 = 0;
@@ -315,11 +315,11 @@ void FigurineMenu_080A4978(void) {
gOamCmd.x = 0x9c;
gOamCmd.y = 0x48;
DrawDirect(sub_080A4978_draw_constant, 0);
r2 = !gSave.saw_staffroll ? 0x82 : 0x88;
maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if ((gMenu.column_idx & 2) != 0) {
if (r2 >= (gFigurineMenu.figure_idx)) {
if (maxFigurines >= (gFigurineMenu.figure_idx)) {
gOamCmd.x = 0xe8;
r0 = (0x5000 / r2) * (gFigurineMenu.figure_idx - 1);
r0 = (0x5000 / maxFigurines) * (gFigurineMenu.figure_idx - 1);
if (r0 < 0) {
r0 += 0xff;
}
@@ -367,7 +367,7 @@ void FigurineMenu_080A4978(void) {
}
}
if (gMenu.column_idx & 1) {
if (sub_080A4948(gFigurineMenu.figure_idx)) {
if (FigurineMenu_isFigurineOwned(gFigurineMenu.figure_idx)) {
gOamCmd.x = 0x2c;
gOamCmd.y = 0x48;
gOamCmd._8 = 0xd4 << 7;
@@ -447,7 +447,7 @@ extern void ShowTextBox(u32, const struct_0812816C*);
void sub_080A4BA0(u32 arg1, u32 arg2) {
int r0, r5, r6;
int tmp;
int maxFigurines;
struct_0812816C s0;
u8 buffer[0x30];
@@ -465,13 +465,13 @@ void sub_080A4BA0(u32 arg1, u32 arg2) {
s0.unk14 = arg2;
}
tmp = !gSave.saw_staffroll ? 0x82 : 0x88;
maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (r5 <= 0 || tmp < r5) {
if (r5 <= 0 || maxFigurines < r5) {
r5 = -1;
} else {
sub_08057044(r5, gUnk_020227E8, 0x303030);
if (sub_080A4948(r5) == 0) {
if (FigurineMenu_isFigurineOwned(r5) == 0) {
r5 += 0x8000;
} else {
r5 += 0x800;
@@ -526,18 +526,18 @@ const struct_0812816C gUnk_08128190 = {
0x5u,
};
u32 sub_080A4CBC(u32 param_1) {
s32 iVar1;
u32 sub_080A4CBC(u32 figurineIndex) {
s32 ownsFigurine;
const u16* psVar2;
u32 uVar3;
if (gFigurineMenu.unk1a != param_1) {
gFigurineMenu.unk1a = param_1;
if (gFigurineMenu.unk1a != figurineIndex) {
gFigurineMenu.unk1a = figurineIndex;
MemClear(&gBG1Buffer, sizeof(gBG1Buffer));
MemCopy(&gBG1Buffer, (void*)0x600e000, sizeof(gBG1Buffer));
iVar1 = sub_080A4948(param_1);
if (iVar1 != 0) {
ShowTextBox(param_1 + 0x900, &gUnk_08128190);
ownsFigurine = FigurineMenu_isFigurineOwned(figurineIndex);
if (ownsFigurine != 0) {
ShowTextBox(figurineIndex + 0x900, &gUnk_08128190);
}
gScreen.bg1.updated = 1;
}
+37 -22
View File
@@ -86,7 +86,7 @@ const ScreenTransitionData gUnk_08128024[] = {
u32 sub_080A3B48(void) {
u32 index;
for (index = 0; index <= 0x12; index++) {
if (gSave.kinstoneAmounts[index] == 0) {
if (gSave.kinstones.amounts[index] == 0) {
break;
}
}
@@ -206,7 +206,7 @@ void KinstoneMenu_Type1(void) {
case A_BUTTON:
if (gMenu.column_idx == 2) {
tmp3 = gGenericMenu.unk10.i / 0x10000;
gGenericMenu.unk2a = gSave.kinstoneTypes[tmp3];
gGenericMenu.unk2a = gSave.kinstones.types[tmp3];
SetMenuType(3);
}
break;
@@ -229,7 +229,7 @@ void KinstoneMenu_Type1(void) {
void KinstoneMenu_Type2(void) {
const KinstoneWorldEvent* ptr;
if (gMenu.column_idx == 6) {
gFuseInfo._0 = 6;
gFuseInfo.fusionState = FUSION_STATE_6;
ptr = &gKinstoneWorldEvents[gFuseInfo.kinstoneId];
if (ptr->subtask != 0) {
MenuFadeIn(ptr->subtask, ptr->worldEventId);
@@ -237,7 +237,7 @@ void KinstoneMenu_Type2(void) {
Subtask_Exit();
}
} else {
gFuseInfo._0 = 5;
gFuseInfo.fusionState = FUSION_STATE_5;
Subtask_Exit();
}
}
@@ -319,9 +319,9 @@ void KinstoneMenu_Type5(void) {
void KinstoneMenu_Type5_Overlay0(void) {
gMenu.column_idx = 5;
WriteBit(gSave.fusedKinstones, gFuseInfo.kinstoneId);
if (++gSave.fusedKinstoneCount > 99) {
gSave.didAllFusions = 1;
WriteBit(gSave.kinstones.fusedKinstones, gFuseInfo.kinstoneId);
if (++gSave.kinstones.fusedCount > 99) {
gSave.kinstones.didAllFusions = 1;
}
KinstoneMenu_080A4468();
SoundReq(SFX_TASK_COMPLETE);
@@ -433,22 +433,36 @@ void KinstoneMenu_080A4080(void) {
}
}
NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void KinstoneMenu_080A414C(void)) {
void KinstoneMenu_080A414C(void) {
s32 uVar1;
s32 iVar2;
s32 uVar3;
s32 tmp1;
s32 tmp2;
s32 tmp3;
s32 tmp4;
const s16* ptr;
OAMCommand* OamCmd;
u16 tmp5;
s32 i;
gOamCmd._4 = 0;
gOamCmd._6 = 0;
uVar1 = gKinstoneMenu.unk10.HALF.LO / 0xb21;
for (i = -3, uVar1 = -uVar1 - 0x45; i < 4; uVar1 += 0x17, i++) {
gOamCmd.y = ((gSineTable[uVar1 & 0xff] * 0x44) / 0x100) + 0x4f;
gOamCmd.x = ((gSineTable[(uVar1 + 0x40) & 0xff] * 0x42) / 0x100) - 0x10;
tmp3 = (s32)(gKinstoneMenu.unk10.HALF_U.LO);
tmp2 = 0xb21;
tmp5 = (tmp3 / tmp2);
i = -3;
tmp1 = 0xff;
OamCmd = &gOamCmd;
ptr = gSineTable;
uVar1 = -tmp5 - 0x45;
while (i < 4) {
OamCmd->y = ((ptr[uVar1 & tmp1] * 0x44) / 0x100) + 0x4f;
OamCmd->x = ((ptr[((uVar1 & tmp1) + 0x40) & tmp1] * 0x42) / 0x100) - 0x10;
iVar2 = gKinstoneMenu.unk10.WORD / 0x10000 + i;
if (iVar2 >= 0) {
uVar3 = gSave.kinstoneAmounts[iVar2];
uVar3 = gSave.kinstones.amounts[iVar2];
if (i == 0) {
switch (gMenu.column_idx) {
case 3:
@@ -459,13 +473,14 @@ NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void K
break;
}
}
if (0 < uVar3) {
sub_080A42E0(gSave.kinstoneTypes[iVar2], uVar3);
if (uVar3 > 0) {
sub_080A42E0(gSave.kinstones.types[iVar2], uVar3);
}
}
uVar1 += 0x17;
i++;
}
}
END_NONMATCH
void KinstoneMenu_080A422C(void) {
static const s8 gUnk_08128120[] = {
@@ -625,9 +640,9 @@ u32 KinstoneMenu_080A4494(void) {
psVar1->unk1 = 0;
sub_080A44E0(psVar1, gSave.name, 0x80);
#if NON_MATCHING
ret = sub_080A44E0(psVar1, GetFuserId(gFuseInfo.ent) >> 0x20, 0xa0);
ret = sub_080A44E0(psVar1, GetFuserId(gFuseInfo.entity) >> 0x20, 0xa0);
#else
GetFuserId(gFuseInfo.ent);
GetFuserId(gFuseInfo.entity);
asm("" : "=r"(r1));
ret = sub_080A44E0(psVar1, r1, 0xa0);
#endif
@@ -652,13 +667,13 @@ u32 sub_080A44E0(WStruct* param_1, u8* param_2, u32 param_3) {
void KinstoneMenu_080A4528(void) {
Entity* entity;
if (gFuseInfo.ent->kind == NPC) {
entity = CreateNPC(gFuseInfo.ent->id, gFuseInfo.ent->type, gFuseInfo.ent->type2);
if (gFuseInfo.entity->kind == NPC) {
entity = CreateNPC(gFuseInfo.entity->id, gFuseInfo.entity->type, gFuseInfo.entity->type2);
} else {
if (gFuseInfo.ent->kind != ENEMY) {
if (gFuseInfo.entity->kind != ENEMY) {
return;
}
entity = CreateEnemy(gFuseInfo.ent->id, gFuseInfo.ent->type);
entity = CreateEnemy(gFuseInfo.entity->id, gFuseInfo.entity->type);
}
if (entity != NULL) {
if (entity->kind == NPC) {
+22 -17
View File
@@ -398,7 +398,7 @@ void PauseMenu_ItemMenu_Update(void) {
}
case B_BUTTON:
if (gPauseMenu.items[menuSlot] != 0) {
u32 slot = !!(gInput.newKeys ^ 1);
u32 slot = !!(gInput.newKeys ^ A_BUTTON);
ForceEquipItem(gPauseMenu.items[menuSlot], slot);
SoundReq(SFX_TEXTBOX_SELECT);
}
@@ -431,7 +431,7 @@ void PauseMenu_ItemMenu_Update(void) {
case MENU_SLOT_BOTTLE2:
case MENU_SLOT_BOTTLE3:
if (item != 0) {
item = gSave.saved_status.field_0x24[item - 6];
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
}
break;
case MENU_SLOT_SAVE_BUTTON:
@@ -666,7 +666,7 @@ void sub_080A5594(void) {
iVar5 = 0;
if (GetInventoryValue(ITEM_KINSTONE_BAG) != 0) {
for (i = 0; i < 0x13; i++) {
iVar5 += gSave.kinstoneAmounts[i];
iVar5 += gSave.kinstones.amounts[i];
}
if (iVar5 >= 0x50) {
@@ -1232,7 +1232,7 @@ bool32 sub_080A5F24(void) {
return result;
}
void sub_080A5F48(u32 param_1, u32 param_2) {
void sub_080A5F48(Item item, u32 param_2) {
extern u32 gSprite_082E68F4[];
u32 ammoCount;
u32 tensDigit;
@@ -1242,19 +1242,24 @@ void sub_080A5F48(u32 param_1, u32 param_2) {
u32 temp3;
register u32 rem asm("r1");
switch (param_1) {
case 0x1c ... 0x1f:
param_1 = (u32)gSave.saved_status.field_0x24[param_1 - 6];
switch (item) {
case ITEM_BOTTLE1:
case ITEM_BOTTLE2:
case ITEM_BOTTLE3:
case ITEM_BOTTLE4:
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
break;
default:
break;
}
temp1 = param_2 * 0x20 + 0x6010000;
temp3 = gSpriteAnimations_322[param_1]->index;
temp3 = gSpriteAnimations_322[item]->index;
temp2 = &gMoreSpritePtrs[1][temp3 * 2];
DmaCopy32(3, &gMoreSpritePtrs[2][temp2[1] * 0x10], temp1, 0x40 * 4);
ammoCount = -1;
switch (param_1) {
switch (item) {
case 7:
case 8:
ammoCount = gSave.stats.bombCount;
@@ -1267,12 +1272,12 @@ void sub_080A5F48(u32 param_1, u32 param_2) {
if (-1 < (int)ammoCount) {
tensDigit = Div(ammoCount, 10);
param_1 = rem;
item = rem;
if ((int)tensDigit >= 10) {
tensDigit = 9;
}
DmaCopy32(3, gUnk_085C4620 + tensDigit * 0x8, temp1, 0x8 * 4);
DmaCopy32(3, gUnk_085C4620 + (param_1 + 10) * 0x8, temp1 + 0x20, 0x8 * 4);
DmaCopy32(3, gUnk_085C4620 + (item + 10) * 0x8, temp1 + 0x20, 0x8 * 4);
}
}
@@ -1300,11 +1305,11 @@ void sub_080A6044(void) {
gOamCmd._6 = 0;
uVar4 = 0;
uVar2 = 0;
uVar1 = gSave.kinstoneTypes[0];
uVar1 = gSave.kinstones.types[0];
while (uVar1 != 0) {
gOamCmd.x = (uVar4 & 3) * 0x30 + 0x2b;
gOamCmd.y = (uVar4 >> 2) * 0x24 + 0x34;
uVar3 = gSave.kinstoneAmounts[uVar2];
uVar3 = gSave.kinstones.amounts[uVar2];
gMenu.column_idx = 0;
sub_080A42E0(uVar1, uVar3);
uVar4++;
@@ -1315,7 +1320,7 @@ void sub_080A6044(void) {
if (0x11 < uVar2) {
return;
}
uVar1 = gSave.kinstoneTypes[uVar2];
uVar1 = gSave.kinstones.types[uVar2];
}
}
}
@@ -1431,7 +1436,7 @@ void sub_080A62E0(void) {
switch (gInput.newKeys) {
case A_BUTTON:
if ((gSave.windcrests & (1 << gMenu.field_0x3)) != 0) {
if (IS_BIT_SET(gSave.windcrests, gMenu.field_0x3)) {
SoundReq(SFX_TEXTBOX_SELECT);
sub_080A4E84(6);
windcrest = -1;
@@ -1495,7 +1500,7 @@ void sub_080A6438(void) {
gOamCmd._4 = 0x400;
gOamCmd._6 = 0;
gOamCmd._8 = 0;
uVar1 = gSave.field_0x20 & gGenericMenu.unk10.h[0];
uVar1 = gSave.map_hints & gGenericMenu.unk10.h[0];
for (pcVar2 = gUnk_08128F58, uVar3 = 0; pcVar2->frameIndex != 0; uVar3++, pcVar2++) {
if ((1 << uVar3 & uVar1) != 0) {
gOamCmd.x = pcVar2->unk1;
@@ -1512,7 +1517,7 @@ void sub_080A6498(void) {
gOamCmd._6 = 0;
gOamCmd._8 = 0;
for (i = 0; i <= 0x10; i++) {
if ((gSave.windcrests & (1 << i)) == 0) {
if (!IS_BIT_SET(gSave.windcrests, i)) {
gUnk_08128DE8_struct* ptr = &gUnk_08128DE8[i];
gOamCmd.x = ptr->unk6;
gOamCmd.y = ptr->unk7;
+1 -1
View File
@@ -196,7 +196,7 @@ void sub_080A68D4(void) {
sub_080A698C(gRoomTransition.player_status.overworld_map_x, gRoomTransition.player_status.overworld_map_y,
DRAW_DIRECT_SPRITE_INDEX, iVar6 + 0x100);
uVar1 = sub_080A6F40();
uVar1 &= gSave.field_0x20;
uVar1 &= gSave.map_hints;
for (pcVar4 = gUnk_08128F58, i = 0; pcVar4->frameIndex != 0; i++, pcVar4++) {
if (((1 << i) & uVar1) != 0) {
+19 -15
View File
@@ -2080,7 +2080,7 @@ bool32 MoveNorthWest(Entity* this, s32 radius, s32 angle, u32 collisionType) {
bool32 ProcessMovement0(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 0);
result = ProcessMovementInternal(this, this->speed, this->direction, 0);
} else {
@@ -2092,7 +2092,7 @@ bool32 ProcessMovement0(Entity* this) {
bool32 ProcessMovement1(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 1);
result = ProcessMovementInternal(this, this->speed, this->direction, 1);
} else {
@@ -2104,7 +2104,7 @@ bool32 ProcessMovement1(Entity* this) {
bool32 ProcessMovement2(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 2);
result = ProcessMovementInternal(this, this->speed, this->direction, 2);
} else {
@@ -2116,7 +2116,7 @@ bool32 ProcessMovement2(Entity* this) {
bool32 ProcessMovement10(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 10);
result = ProcessMovementInternal(this, this->speed, this->direction, 10);
} else {
@@ -2128,7 +2128,7 @@ bool32 ProcessMovement10(Entity* this) {
bool32 ProcessMovement12(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 12);
result = ProcessMovementInternal(this, this->speed, this->direction, 12);
} else {
@@ -2140,7 +2140,7 @@ bool32 ProcessMovement12(Entity* this) {
bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) {
bool32 result;
if ((direction & 0x80) == 0) {
if (!(direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, direction, 0);
result = ProcessMovementInternal(this, speed, direction, 0);
} else {
@@ -2152,7 +2152,7 @@ bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) {
bool32 ProcessMovement3(Entity* this) {
bool32 result;
if (((this->direction & 0x80) == 0) && (sub_080AF0C8(this) == 0)) {
if (!(this->direction & DIR_NOT_MOVING_CHECK) && !sub_080AF0C8(this)) {
CalculateEntityTileCollisions(this, this->direction, 3);
result = ProcessMovementInternal(this, this->speed, this->direction, 3);
} else {
@@ -2165,25 +2165,29 @@ bool32 sub_080AF0C8(Entity* this) {
u32 tileType = GetTileTypeByEntity(this);
switch (tileType) {
case 0x87:
if (((this->direction + 7) & 0x1f) < 0x10) {
if (((this->direction + 7) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth |
DirectionWest)) < DirectionSouth) {
this->collisions = COL_NORTH_ANY;
return TRUE;
}
break;
case 0x8a:
if (((this->direction - 1) & 0x1f) < 0x10) {
if (((this->direction - 1) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth |
DirectionWest)) < DirectionSouth) {
this->collisions = COL_EAST_ANY;
return TRUE;
}
break;
case 0x88:
if (((this->direction - 9) & 0x1f) < 0x10) {
if (((this->direction - 9) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth |
DirectionWest)) < DirectionSouth) {
this->collisions = COL_SOUTH_ANY;
return TRUE;
}
break;
case 0x89:
if (((this->direction - 0x11) & 0x1f) < 0x10) {
if (((this->direction - 0x11) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth |
DirectionWest)) < DirectionSouth) {
this->collisions = COL_WEST_ANY;
return TRUE;
}
@@ -2195,7 +2199,7 @@ bool32 sub_080AF0C8(Entity* this) {
bool32 ProcessMovement4(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 4);
result = ProcessMovementInternal(this, this->speed, this->direction, 4);
} else {
@@ -2207,7 +2211,7 @@ bool32 ProcessMovement4(Entity* this) {
bool32 ProcessMovement5(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 5);
result = ProcessMovementInternal(this, this->speed, this->direction, 5);
} else {
@@ -2231,7 +2235,7 @@ void Knockback2(Entity* this) {
bool32 ProcessMovement6(Entity* this) {
bool32 result;
if ((this->direction & 0x80) == 0) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, this->direction, 6);
result = ProcessMovementInternal(this, this->speed, this->direction, 6);
} else {
@@ -2243,7 +2247,7 @@ bool32 ProcessMovement6(Entity* this) {
bool32 ProcessMovement6_custom(Entity* this, u32 direction, u32 speed) {
bool32 result;
if ((direction & 0x80) == 0) {
if (!(direction & DIR_NOT_MOVING_CHECK)) {
CalculateEntityTileCollisions(this, direction, 6);
result = ProcessMovementInternal(this, speed, direction, 6);
} else {
+37 -25
View File
@@ -1,44 +1,56 @@
/**
* @file anju.c
* @ingroup NPCs
*
* @brief Anju NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "npc.h"
#include "player.h"
void Anju(Entity* this) {
switch (this->action) {
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
} AnjuEntity;
void Anju(AnjuEntity* this) {
switch (super->action) {
case 0:
this->action = 1;
this->spriteSettings.draw = 1;
this->animationState = this->timer;
sub_0807DD50(this);
super->action = 1;
super->spriteSettings.draw = 1;
super->animationState = super->timer;
InitScriptForNPC(super);
return;
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
InitializeAnimation(this,
(this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4(
GetFacingDirection(super, &gPlayerEntity)));
InitializeNPCFusion(super);
} else {
sub_0807DD94(this, 0);
ExecuteScriptAndHandleAnimation(super, NULL);
}
return;
case 2:
if (UpdateFuseInteraction(this)) {
this->action = 1;
if (UpdateFuseInteraction(super)) {
super->action = 1;
}
}
}
void Anju_MakeInteractable(Entity* this) {
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
void Anju_MakeInteractable(AnjuEntity* this) {
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
}
void Anju_Fusion(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 6);
void Anju_Fusion(AnjuEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
InitAnimationForceUpdate(super, 6);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
+40 -34
View File
@@ -1,12 +1,18 @@
#include "global.h"
/**
* @file beedle.c
* @ingroup NPCs
*
* @brief Beedle NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "game.h"
#include "item.h"
#include "message.h"
#include "npc.h"
#include "room.h"
#include "script.h"
#include "npc.h"
#include "game.h"
#include "functions.h"
#include "item.h"
typedef struct {
Rect customHitbox;
@@ -14,10 +20,10 @@ typedef struct {
u8 unused[3];
} InteractCollisionData;
void sub_080632E0(Entity* this);
void sub_08063314(Entity* this);
void sub_0806336C(Entity* this);
void sub_08063390(Entity* this);
void Beedle_Init(Entity* this);
void Beedle_Action1(Entity* this);
void Beedle_Action2(Entity* this);
void Beedle_Action3(Entity* this);
static const u8 gBeedleItems[] = {
ITEM_NONE,
@@ -41,30 +47,30 @@ static const SpriteLoadData gUnk_0810C8D4[] = {
{ 0, 0, 0 },
};
void sub_080632C8(Entity* this);
void Beedle_Update(Entity* this);
void sub_08063410(Entity* this);
s32 sub_080633C8(Entity* this);
s32 Beedle_GetAnimIndexFacingPlayer(Entity* this);
void sub_0806346C(Entity* this);
void Beedle(Entity* this) {
if (this->flags & ENT_SCRIPTED) {
sub_08063410(this);
} else {
sub_080632C8(this);
Beedle_Update(this);
}
}
void sub_080632C8(Entity* this) {
static void (*const gUnk_0810C8E0[])(Entity*) = {
sub_080632E0,
sub_08063314,
sub_0806336C,
sub_08063390,
void Beedle_Update(Entity* this) {
static void (*const beedleActions[])(Entity*) = {
Beedle_Init,
Beedle_Action1,
Beedle_Action2,
Beedle_Action3,
};
gUnk_0810C8E0[this->action](this);
beedleActions[this->action](this);
}
void sub_080632E0(Entity* this) {
void Beedle_Init(Entity* this) {
if (LoadExtraSpriteData(this, gUnk_0810C8D4)) {
InitializeAnimation(this, 0);
AddInteractableWhenBigObject(this);
@@ -73,27 +79,28 @@ void sub_080632E0(Entity* this) {
}
}
void sub_08063314(Entity* this) {
u32 offset;
void Beedle_Action1(Entity* this) {
u32 animIndex;
if (((++this->subtimer & 0xF) == 0) && (offset = sub_080633C8(this), this->animIndex != offset)) {
InitializeAnimation(this, offset);
if (((++this->subtimer & 0xF) == 0) &&
(animIndex = Beedle_GetAnimIndexFacingPlayer(this), this->animIndex != animIndex)) {
InitializeAnimation(this, animIndex);
}
if (this->interactType != 0) {
if (this->interactType != INTERACTION_NONE) {
MessageFromTarget(this->timer + TEXT_INDEX(TEXT_EMPTY, 0x01));
this->action++;
}
sub_0806ED78(this);
}
void sub_0806336C(Entity* this) {
void Beedle_Action2(Entity* this) {
if ((gMessage.doTextBox & 0x7F) == 0) {
this->action++;
InitializeAnimation(this, 8);
}
}
void sub_08063390(Entity* this) {
void Beedle_Action3(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
@@ -103,14 +110,13 @@ void sub_08063390(Entity* this) {
sub_0806ED78(this);
}
s32 sub_080633C8(Entity* this) {
s32 uVar1;
uVar1 = GetAnimationStateInRectRadius(this, 0x20, 0x20);
if (uVar1 < 0) {
uVar1 = this->animIndex;
// If the player is inside a 32x32 rect, face the player. Otherwise keep facing the same direction.
s32 Beedle_GetAnimIndexFacingPlayer(Entity* this) {
s32 animationState = GetAnimationStateInRectRadius(this, 32, 32);
if (animationState < 0) {
animationState = this->animIndex;
}
return uVar1;
return animationState;
}
void Beedle_Head(Entity* this) {
+167 -156
View File
@@ -1,8 +1,20 @@
#include "npc.h"
/**
* @file bigGoron.c
* @ingroup NPCs
*
* @brief BigGoron NPC
*/
#define NENT_DEPRECATED
#include "functions.h"
#include "screen.h"
#include "hitbox.h"
#include "item.h"
#include "npc.h"
#include "screen.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u16 originalX;
} BigGoronEntity;
static const u16 goronSounds[] = {
SFX_VO_GORON1,
@@ -14,19 +26,18 @@ static const u16 goronSounds[] = {
extern u8 gMapDataTopSpecial[];
extern u8 gUnk_02006F00[];
void sub_0806D520(Entity*, u32);
void sub_0806D41C(Entity*);
void sub_0806CF30(Entity*);
void sub_0806D1D0(Entity*);
void sub_0806D274(Entity*);
void sub_0806D348(Entity*);
void sub_0806D3C0(Entity*);
void sub_0806D41C(Entity*);
void sub_0806D4F0(Entity*);
void sub_0806D4FC(Entity*);
void sub_0806D508(Entity*);
void sub_0806D514(Entity*);
void sub_0806D40C(Entity*);
void sub_0806D520(BigGoronEntity* this, u32);
void sub_0806CF30(BigGoronEntity* this);
void sub_0806D1D0(BigGoronEntity* this);
void sub_0806D274(BigGoronEntity* this);
void sub_0806D348(BigGoronEntity* this);
void sub_0806D3C0(BigGoronEntity* this);
void sub_0806D41C(BigGoronEntity* this);
void sub_0806D4F0(BigGoronEntity* this);
void sub_0806D4FC(BigGoronEntity* this);
void sub_0806D508(BigGoronEntity* this);
void sub_0806D514(BigGoronEntity* this);
void sub_0806D40C(BigGoronEntity* this);
static void sub_0806D02C(Entity* this);
@@ -48,7 +59,7 @@ void sub_0806D164(Entity* this);
Entity* sub_0806D00C(Entity* this);
void sub_0806D4C0(Entity*, u32);
void sub_0806D4C0(BigGoronEntity* this, u32 type);
typedef struct {
s8 type;
@@ -57,51 +68,51 @@ typedef struct {
u8 direction;
} struct_08114104;
void BigGoron(Entity* this) {
static void (*const typeFunctions[])(Entity*) = {
void BigGoron(BigGoronEntity* this) {
static void (*const typeFunctions[])(BigGoronEntity*) = {
sub_0806CF30, sub_0806D1D0, sub_0806D274, sub_0806D348, sub_0806D3C0, sub_0806D41C,
sub_0806D4F0, sub_0806D4FC, sub_0806D508, sub_0806D514, sub_0806D40C,
};
typeFunctions[this->type](this);
typeFunctions[super->type](this);
}
void sub_0806CF30(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->subAction = 1;
this->field_0x68.HWORD = this->x.HALF.HI;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0806D0B0(this);
sub_0807DD64(this);
void sub_0806CF30(BigGoronEntity* this) {
if (super->action == 0) {
super->action = 1;
super->subAction = 1;
this->originalX = super->x.HALF.HI;
SetDefaultPriority(super, PRIO_MESSAGE);
sub_0806D0B0(super);
sub_0807DD64(super);
} else {
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
}
switch (this->subAction) {
switch (super->subAction) {
case 0:
case 1:
if (gRoomTransition.frameCount % 4 == 0) {
if (gPlayerEntity.x.HALF.HI < this->x.HALF.HI && this->field_0x68.HWORD - 32 < this->x.HALF.HI) {
this->x.HALF.HI--;
if (gPlayerEntity.x.HALF.HI < super->x.HALF.HI && this->originalX - 32 < super->x.HALF.HI) {
super->x.HALF.HI--;
}
if (gPlayerEntity.x.HALF.HI > this->x.HALF.HI && this->field_0x68.HWORD + 32 > this->x.HALF.HI) {
this->x.HALF.HI++;
if (gPlayerEntity.x.HALF.HI > super->x.HALF.HI && this->originalX + 32 > super->x.HALF.HI) {
super->x.HALF.HI++;
}
}
break;
case 2:
if (--this->timer == 0) {
if (--super->timer == 0) {
u32 uVar2 = Random();
SoundReq(goronSounds[uVar2 % 4]);
this->timer = ((u8)uVar2 & 7) * 16;
this->timer += 128;
super->timer = ((u8)uVar2 & 7) * 16;
super->timer += 128;
}
break;
case 3:
break;
}
sub_0806D02C(this);
sub_0806D02C(super);
}
Entity* sub_0806D00C(Entity* this) {
@@ -192,228 +203,228 @@ void sub_0806D164(Entity* this) {
gScreen.bg1.updated = 1;
}
void sub_0806D1D0(Entity* this) {
if (this->action == 0) {
if (sub_0806D00C(this) == NULL) {
void sub_0806D1D0(BigGoronEntity* this) {
if (super->action == 0) {
if (sub_0806D00C(super) == NULL) {
DeleteThisEntity();
}
this->action = 1;
this->spriteOrientation.flipY = 3;
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 7;
this->spriteSettings.draw = 3;
this->frameIndex = 0;
this->timer = 30;
SetDefaultPriority(this, PRIO_MESSAGE);
super->action = 1;
super->spriteOrientation.flipY = 3;
super->spriteRendering.b3 = 3;
super->spritePriority.b0 = 7;
super->spriteSettings.draw = 3;
super->frameIndex = 0;
super->timer = 30;
SetDefaultPriority(super, PRIO_MESSAGE);
}
switch (this->subAction) {
switch (super->subAction) {
case 0:
default:
if (--this->timer == 0) {
this->timer = (Random() & 0x7f) + 48;
this->subtimer = 8;
this->frameIndex = 1;
if (--super->timer == 0) {
super->timer = (Random() & 0x7f) + 48;
super->subtimer = 8;
super->frameIndex = 1;
}
if (this->subtimer != 0) {
if (--this->subtimer == 0) {
this->frameIndex = 0;
if (super->subtimer != 0) {
if (--super->subtimer == 0) {
super->frameIndex = 0;
}
}
break;
case 1:
this->frameIndex = this->subAction;
super->frameIndex = super->subAction;
break;
case 2:
this->spriteSettings.draw = 0;
super->spriteSettings.draw = 0;
break;
}
this->x.HALF.HI = this->parent->x.HALF.HI;
this->y.HALF.HI = this->parent->y.HALF.HI;
super->x.HALF.HI = super->parent->x.HALF.HI;
super->y.HALF.HI = super->parent->y.HALF.HI;
}
void sub_0806D274(Entity* this) {
void sub_0806D274(BigGoronEntity* this) {
Entity* npc;
if (this->action == 0) {
if (sub_0806D00C(this) == NULL) {
if (super->action == 0) {
if (sub_0806D00C(super) == NULL) {
DeleteThisEntity();
}
this->action = 1;
this->spriteOrientation.flipY = 3;
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 7;
this->frameIndex = 2;
this->timer = 8;
SetDefaultPriority(this, PRIO_MESSAGE);
super->action = 1;
super->spriteOrientation.flipY = 3;
super->spriteRendering.b3 = 3;
super->spritePriority.b0 = 7;
super->frameIndex = 2;
super->timer = 8;
SetDefaultPriority(super, PRIO_MESSAGE);
npc = CreateNPC(BIG_GORON, 3, 0);
if (npc != NULL) {
npc->child = this;
npc->child = super;
}
}
switch (this->subAction) {
switch (super->subAction) {
case 0:
case 1:
default:
if ((gMessage.doTextBox & 0x7f) == 0) {
this->frameIndex = 2;
super->frameIndex = 2;
break;
}
if (--this->timer == 0) {
this->timer = 8;
this->frameIndex ^= 1;
if (--super->timer == 0) {
super->timer = 8;
super->frameIndex ^= 1;
}
break;
case 2:
if (--this->timer == 0) {
this->timer = 8;
this->frameIndex ^= 1;
if (--super->timer == 0) {
super->timer = 8;
super->frameIndex ^= 1;
}
break;
case 3:
this->frameIndex = 4;
super->frameIndex = 4;
break;
case 4:
this->frameIndex = 2;
super->frameIndex = 2;
break;
}
this->x.HALF.HI = this->parent->x.HALF.HI;
this->y.HALF.HI = this->parent->y.HALF.HI;
super->x.HALF.HI = super->parent->x.HALF.HI;
super->y.HALF.HI = super->parent->y.HALF.HI;
}
void sub_0806D348(Entity* this) {
if (this->action == 0) {
if (sub_0806D00C(this) == NULL) {
void sub_0806D348(BigGoronEntity* this) {
if (super->action == 0) {
if (sub_0806D00C(super) == NULL) {
DeleteThisEntity();
}
this->action = 1;
this->spriteOrientation.flipY = 3;
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 6;
this->spriteSettings.draw = 0;
this->frameIndex = 5;
SetDefaultPriority(this, PRIO_MESSAGE);
super->action = 1;
super->spriteOrientation.flipY = 3;
super->spriteRendering.b3 = 3;
super->spritePriority.b0 = 6;
super->spriteSettings.draw = 0;
super->frameIndex = 5;
SetDefaultPriority(super, PRIO_MESSAGE);
}
if (this->child->frameIndex == 4) {
this->spriteSettings.draw = 3;
if (super->child->frameIndex == 4) {
super->spriteSettings.draw = 3;
} else {
this->spriteSettings.draw = 0;
super->spriteSettings.draw = 0;
}
this->x.HALF.HI = this->parent->x.HALF.HI;
this->y.HALF.HI = this->parent->y.HALF.HI;
super->x.HALF.HI = super->parent->x.HALF.HI;
super->y.HALF.HI = super->parent->y.HALF.HI;
}
void sub_0806D3C0(Entity* this) {
if (this->action == 0) {
if (sub_0806D00C(this) == NULL) {
void sub_0806D3C0(BigGoronEntity* this) {
if (super->action == 0) {
if (sub_0806D00C(super) == NULL) {
DeleteThisEntity();
}
this->action = 1;
this->hitbox = (Hitbox*)&gHitbox_3;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD64(this);
super->action = 1;
super->hitbox = (Hitbox*)&gHitbox_3;
SetDefaultPriority(super, PRIO_MESSAGE);
sub_0807DD64(super);
} else {
this->x.HALF.HI = this->parent->x.HALF.HI;
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
super->x.HALF.HI = super->parent->x.HALF.HI;
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
}
}
void sub_0806D40C(Entity* this) {
this->spriteSettings.flipX = 1;
void sub_0806D40C(BigGoronEntity* this) {
super->spriteSettings.flipX = 1;
sub_0806D41C(this);
}
void sub_0806D41C(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->frameIndex = 6;
sub_0807DD64(this);
void sub_0806D41C(BigGoronEntity* this) {
if (super->action == 0) {
super->action = 1;
super->frameIndex = 6;
sub_0807DD64(super);
sub_0806D4C0(this, 0);
sub_0806D4C0(this, 1);
sub_0806D4C0(this, 2);
sub_0806D4C0(this, 3);
SetDefaultPriority(this, PRIO_MESSAGE);
SetDefaultPriority(super, PRIO_MESSAGE);
} else {
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
}
if ((gRoomTransition.frameCount & 1) == 0) {
if (CheckPlayerProximity(this->x.HALF.HI - 0x20, this->y.HALF.HI, 0x40, 0x40) != 0) {
if (this->spriteOffsetY > -8) {
this->spriteOffsetY--;
if (CheckPlayerProximity(super->x.HALF.HI - 0x20, super->y.HALF.HI, 0x40, 0x40) != 0) {
if (super->spriteOffsetY > -8) {
super->spriteOffsetY--;
}
} else {
if (this->spriteOffsetY < 0) {
this->spriteOffsetY++;
if (super->spriteOffsetY < 0) {
super->spriteOffsetY++;
}
}
}
}
void sub_0806D4C0(Entity* this, u32 param) {
Entity* npc = CreateNPC(BIG_GORON, param + 6, 0);
void sub_0806D4C0(BigGoronEntity* this, u32 type) {
Entity* npc = CreateNPC(BIG_GORON, type + 6, 0);
if (npc != NULL) {
npc->parent = this;
CopyPosition(this, npc);
SortEntityAbove(this, npc);
npc->parent = super;
CopyPosition(super, npc);
SortEntityAbove(super, npc);
SetDefaultPriority(npc, PRIO_MESSAGE);
}
}
void sub_0806D4F0(Entity* this) {
void sub_0806D4F0(BigGoronEntity* this) {
sub_0806D520(this, 0);
}
void sub_0806D4FC(Entity* this) {
void sub_0806D4FC(BigGoronEntity* this) {
sub_0806D520(this, 1);
}
void sub_0806D508(Entity* this) {
void sub_0806D508(BigGoronEntity* this) {
sub_0806D520(this, 2);
}
void sub_0806D514(Entity* this) {
void sub_0806D514(BigGoronEntity* this) {
sub_0806D520(this, 3);
}
void sub_0806D520(Entity* this, u32 param_2) {
void sub_0806D520(BigGoronEntity* this, u32 param_2) {
static const u8 gUnk_08114100[] = {
10,
7,
4,
1,
};
if (this->action == 0) {
this->action = 1;
this->subtimer = gUnk_08114100[param_2] + 6;
this->frameIndex = this->subtimer;
this->timer = 8;
if (super->action == 0) {
super->action = 1;
super->subtimer = gUnk_08114100[param_2] + 6;
super->frameIndex = super->subtimer;
super->timer = 8;
}
this->x.HALF.HI = this->parent->x.HALF.HI;
this->y.HALF.HI = this->parent->y.HALF.HI;
this->spriteOffsetX = this->parent->spriteOffsetX;
this->spriteOffsetY = this->parent->spriteOffsetY;
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
if (this->subAction != 0 ||
CheckPlayerProximity(this->x.HALF.HI + param_2 * -0x10 + 0xc, this->y.HALF.HI, 0x18, 0x40)) {
if (this->frameIndex >= this->subtimer + 2) {
super->x.HALF.HI = super->parent->x.HALF.HI;
super->y.HALF.HI = super->parent->y.HALF.HI;
super->spriteOffsetX = super->parent->spriteOffsetX;
super->spriteOffsetY = super->parent->spriteOffsetY;
super->spriteOrientation.flipY = super->parent->spriteOrientation.flipY;
if (super->subAction != 0 ||
CheckPlayerProximity(super->x.HALF.HI + param_2 * -0x10 + 0xc, super->y.HALF.HI, 0x18, 0x40)) {
if (super->frameIndex >= super->subtimer + 2) {
return;
}
if (--this->timer != 0) {
if (--super->timer != 0) {
return;
}
this->timer = 8;
this->frameIndex++;
super->timer = 8;
super->frameIndex++;
} else {
if (this->frameIndex <= this->subtimer) {
if (super->frameIndex <= super->subtimer) {
return;
}
if (--this->timer != 0) {
if (--super->timer != 0) {
return;
}
this->timer = 8;
this->frameIndex--;
super->timer = 8;
super->frameIndex--;
}
}
@@ -429,7 +440,7 @@ void sub_0806D5D4(void) {
}
void sub_0806D600(Entity* this, ScriptExecutionContext* context) {
context->condition = gSave.timers[2] == 0;
context->condition = gSave.biggoron_timer == 0;
}
void sub_0806D620(void) {
@@ -443,7 +454,7 @@ void sub_0806D638(Entity* this) {
void sub_0806D640(Entity* this) {
this->y.HALF.HI += 0x20;
this->interactType = 0;
this->interactType = INTERACTION_NONE;
}
void sub_0806D650(Entity* this) {
+58 -46
View File
@@ -1,15 +1,28 @@
#include "global.h"
/**
* @file bladeBrothers.c
* @ingroup NPCs
*
* @brief Blade Brothers NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "flags.h"
#include "player.h"
#include "room.h"
#include "message.h"
#include "save.h"
#include "script.h"
#include "npc.h"
#include "functions.h"
#include "game.h"
#include "item.h"
#include "message.h"
#include "npc.h"
#include "player.h"
#include "room.h"
#include "save.h"
#include "script.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 itemSlotA;
/*0x6a*/ u8 itemSlotB;
} BladeBrothersEntity;
void sub_08068A1C(Entity*);
void sub_08068A4C(Entity*);
@@ -21,10 +34,10 @@ void (*const gUnk_081115C0[])(Entity*) = {
sub_08068AA4,
sub_08068ADC,
};
void sub_08068AFC(Entity*);
void sub_08068b2c(Entity*);
void sub_08068B70(Entity*);
void (*const gUnk_081115D0[])(Entity*) = {
void sub_08068AFC(BladeBrothersEntity*);
void sub_08068b2c(BladeBrothersEntity*);
void sub_08068B70(BladeBrothersEntity*);
void (*const gUnk_081115D0[])(BladeBrothersEntity*) = {
sub_08068AFC,
sub_08068b2c,
sub_08068B70,
@@ -212,16 +225,16 @@ extern EntityData gUnk_080F3494;
static void sub_08068BEC(Entity* this, u32 unused);
void BladeBrothers(Entity* this) {
if ((this->flags & ENT_SCRIPTED) != 0) {
gUnk_081115D0[this->action](this);
void BladeBrothers(BladeBrothersEntity* this) {
if ((super->flags & ENT_SCRIPTED) != 0) {
gUnk_081115D0[super->action](this);
} else {
gUnk_081115C0[this->action](this);
sub_0806ED78(this);
gUnk_081115C0[super->action](super);
sub_0806ED78(super);
}
if ((this->frame & 1) != 0) {
this->frame &= 0xfe;
sub_08068BEC(this, 0);
if ((super->frame & 1) != 0) {
super->frame &= 0xfe;
sub_08068BEC(super, 0);
}
}
@@ -262,8 +275,8 @@ void sub_08068A4C(Entity* this) {
if (iVar2 == 0) {
GetNextFrame(this);
}
if (this->interactType != 0) {
this->interactType = 0;
if (this->interactType != INTERACTION_NONE) {
this->interactType = INTERACTION_NONE;
this->action = 2;
MessageFromTarget(0);
}
@@ -288,31 +301,30 @@ void sub_08068ADC(Entity* this) {
sub_0806FD3C(this);
}
void sub_08068AFC(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
sub_0807DD50(this);
void sub_08068AFC(BladeBrothersEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
InitScriptForNPC(super);
}
void sub_08068b2c(Entity* this) {
u32 uVar1;
if (this->interactType == '\x02') {
this->action = 2;
this->interactType = 0;
uVar1 = sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity));
InitAnimationForceUpdate(this, uVar1);
sub_0806F118(this);
void sub_08068b2c(BladeBrothersEntity* this) {
u32 animationState;
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
animationState = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity));
InitAnimationForceUpdate(super, animationState);
InitializeNPCFusion(super);
} else {
sub_0807DD94(this, NULL);
ExecuteScriptAndHandleAnimation(super, NULL);
}
}
void sub_08068B70(Entity* this) {
if (UpdateFuseInteraction(this)) {
this->action = 1;
void sub_08068B70(BladeBrothersEntity* this) {
if (UpdateFuseInteraction(super)) {
super->action = 1;
}
}
@@ -326,18 +338,18 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext
InitPlayerMacro((PlayerMacroEntry*)BladeBrothers_PlayerMacros[this->timer]);
}
void sub_08068BB4(Entity* this) {
void sub_08068BB4(BladeBrothersEntity* this) {
u32 item = gSave.stats.itemButtons[SLOT_A];
this->field_0x68.HALF.HI = item;
this->itemSlotA = item;
item = gSave.stats.itemButtons[SLOT_B];
*(&this->field_0x68.HALF.HI + 1) = item;
this->itemSlotB = item;
}
// Restore previous equipped items.
void sub_08068BD0(Entity* this) {
ForceEquipItem(this->field_0x68.HALF.HI, EQUIP_SLOT_A);
ForceEquipItem(*(u8*)(&this->field_0x68.HALF.HI + 1), EQUIP_SLOT_B);
void sub_08068BD0(BladeBrothersEntity* this) {
ForceEquipItem(this->itemSlotA, EQUIP_SLOT_A);
ForceEquipItem(this->itemSlotB, EQUIP_SLOT_B);
}
static void sub_08068BEC(Entity* this, u32 unused) {
+41 -27
View File
@@ -1,19 +1,32 @@
/**
* @file brocco.c
* @ingroup NPCs
*
* @brief Brocco NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "message.h"
#include "save.h"
#include "npc.h"
#include "save.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 animIndex;
} BroccoEntity;
void sub_08063544(Entity*);
void sub_0806362C(Entity*);
void sub_0806362C(BroccoEntity*);
void sub_0806355C(Entity*);
void sub_08063584(Entity*);
void sub_08063608(Entity*);
void Brocco(Entity* this) {
if ((this->flags & ENT_SCRIPTED) != 0) {
void Brocco(BroccoEntity* this) {
if ((super->flags & ENT_SCRIPTED) != 0) {
sub_0806362C(this);
} else {
sub_08063544(this);
sub_08063544(super);
}
}
@@ -50,7 +63,7 @@ void sub_08063584(Entity* this) {
}
}
if (this->interactType != 0) {
if (this->interactType != INTERACTION_NONE) {
this->action = 2;
InitAnimationForceUpdate(this, GetAnimationState(this) + 4);
MessageFromTarget(this->timer + TEXT_INDEX(TEXT_EMPTY, 0x01));
@@ -67,32 +80,33 @@ void sub_08063608(Entity* this) {
}
}
void sub_0806362C(Entity* this) {
switch (this->action) {
void sub_0806362C(BroccoEntity* this) {
switch (super->action) {
case 0:
this->action = 1;
this->spriteSettings.draw = 1;
this->field_0x68.HALF.HI = 0;
sub_0807DD64(this);
super->action = 1;
super->spriteSettings.draw = 1;
this->animIndex = 0;
sub_0807DD64(super);
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
this->field_0x68.HALF.HI = this->animIndex;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4);
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
this->animIndex = super->animIndex;
InitAnimationForceUpdate(super,
GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 4);
InitializeNPCFusion(super);
} else {
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
UpdateAnimationSingleFrame(this);
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
UpdateAnimationSingleFrame(super);
}
break;
case 2:
if (UpdateFuseInteraction(this) == 0) {
if (UpdateFuseInteraction(super) == 0) {
return;
}
this->action = 1;
InitAnimationForceUpdate(this, this->field_0x68.HALF.HI);
super->action = 1;
InitAnimationForceUpdate(super, this->animIndex);
break;
}
}
@@ -114,9 +128,9 @@ void sub_080636D8(Entity* this) {
ShowNPCDialogue(this, &gUnk_0810CAAC[gSave.global_progress]);
}
void Brocco_MakeInteractable(Entity* this) {
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
void Brocco_MakeInteractable(BroccoEntity* this) {
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
}
void Brocco_Fusion(Entity* this) {
+11 -4
View File
@@ -1,14 +1,21 @@
#include "sound.h"
/**
* @file carlov.c
* @ingroup NPCs
*
* @brief Carlov NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "room.h"
#include "npc.h"
#include "room.h"
#include "sound.h"
void Carlov(Entity* this) {
if (this->action == 0) {
this->action++;
sub_0807DD50(this);
InitScriptForNPC(this);
} else {
sub_0807DD94(this, 0);
ExecuteScriptAndHandleAnimation(this, NULL);
}
if ((this->frame & 0x10) != 0) {
this->frame &= ~0x10;
+42 -28
View File
@@ -1,8 +1,22 @@
#include "global.h"
/**
* @file carpenter.c
* @ingroup NPCs
*
* @brief Carpenter NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "npc.h"
#include "item.h"
#include "npc.h"
#include "player.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 animIndex;
/*0x6a*/ u8 unused[26];
/*0x84*/ ScriptExecutionContext* context;
} CarpenterEntity;
static const SpriteLoadData gUnk_08110CA8[] = {
{ 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0x4001, 0x3f, 0x4 }, { 0, 0, 0 },
@@ -11,38 +25,38 @@ static const SpriteLoadData gUnk_08110CA8[] = {
{ 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0, 0, 0 }, { 0, 0, 0 },
};
void Carpenter(Entity* this) {
if (*(u32*)&this->cutsceneBeh == 0) {
void Carpenter(CarpenterEntity* this) {
if (this->context == NULL) {
DeleteThisEntity();
}
switch (this->action) {
switch (super->action) {
case 0:
if (!LoadExtraSpriteData(this, gUnk_08110CA8 + this->type * 4))
if (!LoadExtraSpriteData(super, gUnk_08110CA8 + super->type * 4))
break;
this->action = 1;
this->field_0x68.HALF.HI = 0;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD64(this);
super->action = 1;
this->animIndex = 0;
SetDefaultPriority(super, PRIO_MESSAGE);
sub_0807DD64(super);
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
this->field_0x68.HALF.HI = this->animIndex;
InitializeAnimation(this,
sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4 + (this->type * 8));
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
this->animIndex = super->animIndex;
InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) +
4 + (super->type * 8));
InitializeNPCFusion(super);
} else {
ExecuteScriptForEntity(this, 0);
HandleEntity0x82Actions(this);
GetNextFrame(this);
ExecuteScriptForEntity(super, 0);
HandleEntity0x82Actions(super);
GetNextFrame(super);
}
break;
case 2:
if (!UpdateFuseInteraction(this))
if (!UpdateFuseInteraction(super))
break;
this->action = 1;
InitializeAnimation(this, this->field_0x68.HALF.HI);
super->action = 1;
InitializeAnimation(super, this->animIndex);
break;
}
}
@@ -91,15 +105,15 @@ void sub_08067304(Entity* this) {
ShowNPCDialogue(this, &dialog);
}
void Carpenter_MakeInteractable(Entity* this) {
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
void Carpenter_MakeInteractable(CarpenterEntity* this) {
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
}
void Carpenter_Fusion(Entity* this) {
if (this->action == 0) {
if (LoadExtraSpriteData(this, &gUnk_08110CA8[this->type * 4])) {
this->action = this->action + 1;
this->action++;
this->spriteSettings.draw = 1;
SetDefaultPriority(this, PRIO_MESSAGE);
InitializeAnimation(this, (u32)this->type * 8 + 2);
+16 -10
View File
@@ -1,12 +1,18 @@
/**
* @file castleMaid.c
* @ingroup NPCs
*
* @brief Castle Maid NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "script.h"
#include "save.h"
#include "flags.h"
#include "functions.h"
#include "manager.h"
#include "message.h"
#include "npc.h"
#include "manager.h"
#include "functions.h"
#include "save.h"
#include "script.h"
typedef struct {
Entity base;
@@ -80,13 +86,13 @@ void sub_08064570(CastleMaidEntity* this) {
this->field_0x6e = tmp2;
}
this->dialogFunc = NULL;
sub_0807DD50(super);
InitScriptForNPC(super);
case 1:
sub_0807DD94(super, NULL);
if (super->interactType != 0) {
ExecuteScriptAndHandleAnimation(super, NULL);
if (super->interactType != INTERACTION_NONE) {
super->action++;
super->interactType = 0;
InitializeAnimation(super, sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)));
super->interactType = INTERACTION_NONE;
InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)));
if (this->dialogFunc != NULL) {
this->dialogFunc();
}
@@ -172,7 +178,7 @@ void sub_080646A4(CastleMaidEntity* this, ScriptExecutionContext* context) {
break;
}
super->direction = dir;
super->animationState = sub_0806F5B0(dir);
super->animationState = GetAnimationStateForDirection8(dir);
super->speed = 0x80;
}
+45 -33
View File
@@ -1,10 +1,22 @@
#include "sound.h"
#include "entity.h"
#include "script.h"
#include "functions.h"
#include "flags.h"
/**
* @file castorWildsStatue.c
* @ingroup NPCs
*
* @brief Castor Wilds Statue NPC
*/
#define NENT_DEPRECATED
#include "effects.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"
#include "npc.h"
#include "script.h"
#include "sound.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[12];
/*0x74*/ u16 tilePos;
} CastorWildsStatueEntity;
static const Hitbox gUnk_08110E94;
@@ -17,25 +29,25 @@ void sub_080673C0(Entity*);
void sub_080673F4(Entity*);
void sub_08067410(Entity*);
void sub_0806752C(Entity*);
void sub_08067418(Entity*);
void sub_08067514(Entity*);
void sub_08067418(CastorWildsStatueEntity*);
void sub_08067514(CastorWildsStatueEntity*);
void CastorWildsStatue(Entity* this) {
void CastorWildsStatue(CastorWildsStatueEntity* this) {
static void (*const actionFuncs[])(Entity*) = {
sub_080673C0,
sub_080673F4,
sub_08067410,
sub_0806752C,
};
static void (*const scriptedActionFuncs[])(Entity*) = {
static void (*const scriptedActionFuncs[])(CastorWildsStatueEntity*) = {
sub_08067418,
sub_08067514,
};
if ((this->flags & ENT_SCRIPTED) != 0) {
scriptedActionFuncs[this->action](this);
if ((super->flags & ENT_SCRIPTED) != 0) {
scriptedActionFuncs[super->action](this);
} else {
actionFuncs[this->action](this);
sub_0806ED78(this);
actionFuncs[super->action](super);
sub_0806ED78(super);
}
}
@@ -52,9 +64,9 @@ void sub_080673C0(Entity* this) {
}
void sub_080673F4(Entity* this) {
if (this->interactType != 0) {
if (this->interactType != INTERACTION_NONE) {
this->action = 2;
this->interactType = 0;
this->interactType = INTERACTION_NONE;
}
}
@@ -62,20 +74,20 @@ void sub_08067410(Entity* this) {
this->action = 1;
}
void sub_08067418(Entity* this) {
this->action = 1;
this->field_0x74.HWORD = COORD_TO_TILE(this);
if (this->type == 0) {
this->hitbox = (Hitbox*)&gUnk_08110E94;
SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD + 0x3f, this->collisionLayer);
SetTile(0x4022, this->field_0x74.HWORD + 0x40, this->collisionLayer);
void sub_08067418(CastorWildsStatueEntity* this) {
super->action = 1;
this->tilePos = COORD_TO_TILE(super);
if (super->type == 0) {
super->hitbox = (Hitbox*)&gUnk_08110E94;
SetTile(0x4022, this->tilePos - 1, super->collisionLayer);
SetTile(0x4022, this->tilePos, super->collisionLayer);
SetTile(0x4022, this->tilePos + 0x3f, super->collisionLayer);
SetTile(0x4022, this->tilePos + 0x40, super->collisionLayer);
} else {
this->collisionLayer = 3;
this->spriteOrientation.flipY = 1;
this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 2;
super->collisionLayer = 3;
super->spriteOrientation.flipY = 1;
super->spriteRendering.b3 = 1;
super->spritePriority.b0 = 2;
if (CheckLocalFlag(HIKYOU_00_SEKIZOU) == 0) {
SetTile(0x4022, 0xe81, 1);
SetTile(0x4022, 0xe82, 1);
@@ -83,13 +95,13 @@ void sub_08067418(Entity* this) {
SetTile(0x4022, 0xec3, 1);
}
}
sub_0807DD50(this);
InitScriptForNPC(super);
}
void sub_08067514(Entity* this) {
sub_0807DD94(this, NULL);
if (this->type == 0) {
sub_0806ED78(this);
void sub_08067514(CastorWildsStatueEntity* this) {
ExecuteScriptAndHandleAnimation(super, NULL);
if (super->type == 0) {
sub_0806ED78(super);
}
}
+178 -163
View File
@@ -1,35 +1,55 @@
#include "global.h"
/**
* @file cat.c
* @ingroup NPCs
*
* @brief Cat NPC
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "save.h"
#include "message.h"
#include "npc.h"
#include "enemy.h"
#include "save.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 unk_69;
/*0x6a*/ u8 unused[2];
/*0x6c*/ u16 unk_6c;
/*0x6e*/ u16 unk_6e;
/*0x70*/ u8 unk_70;
/*0x71*/ u8 unk_71;
/*0x72*/ u16 unk_72;
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unk_75;
} CatEntity;
static const Hitbox gUnk_08110EF0 = { 0, -1, { 5, 3, 3, 5 }, 5, 4 };
void sub_08067C44(Entity*);
void sub_08067B08(Entity*);
u32 sub_08067D20(Entity*);
void sub_08067AAC(Entity*);
void sub_08067B34(Entity*);
void sub_08067B80(Entity*, u32);
void sub_08067B70(Entity*);
void sub_08067C24(Entity*);
void sub_08067C44(CatEntity*);
void sub_08067B08(CatEntity*);
bool32 sub_08067D20(CatEntity*);
void sub_08067AAC(CatEntity*);
void sub_08067B34(CatEntity*);
void sub_08067B80(CatEntity*, u32);
void sub_08067B70(CatEntity*);
void sub_08067C24(CatEntity*);
void sub_08067BD4(Entity*);
u32 sub_08067D74(Entity*);
bool32 sub_08067D74(Entity*);
void sub_08067C18(Entity*);
void sub_08067DCC(Entity*, u32);
void sub_08067DCC(CatEntity*, u32);
void sub_08067DDC(Entity*);
void sub_080677EC(Entity*);
void sub_080678AC(Entity*);
void sub_08067904(Entity*);
void sub_0806797C(Entity*);
void sub_0806799C(Entity*);
void sub_080679C4(Entity*);
void sub_08067A0C(Entity*);
void sub_08067A78(Entity*);
void sub_08067A98(Entity*);
void sub_080677EC(CatEntity*);
void sub_080678AC(CatEntity*);
void sub_08067904(CatEntity*);
void sub_0806797C(CatEntity*);
void sub_0806799C(CatEntity*);
void sub_080679C4(CatEntity*);
void sub_08067A0C(CatEntity*);
void sub_08067A78(CatEntity*);
void sub_08067A98(CatEntity*);
extern Hitbox* gUnk_08111154[8];
@@ -100,159 +120,154 @@ void sub_08067790(Entity* this) {
}
// Main
void Cat(Entity* ent) {
static void (*const actionFuncs[9])(Entity*) = {
void Cat(CatEntity* this) {
static void (*const actionFuncs[9])(CatEntity*) = {
sub_080677EC, sub_080678AC, sub_08067904, sub_0806797C, sub_0806799C,
sub_080679C4, sub_08067A0C, sub_08067A78, sub_08067A98,
};
actionFuncs[ent->action](ent);
sub_08067C44(ent);
if (((ent->flags & ENT_COLLIDE) == 0) && (ent->type != 5)) {
sub_0806ED78(ent);
actionFuncs[super->action](this);
sub_08067C44(this);
if (((super->flags & ENT_COLLIDE) == 0) && (super->type != 5)) {
sub_0806ED78(super);
}
}
void sub_080677EC(Entity* this) {
void sub_080677EC(CatEntity* this) {
u32 uVar2;
this->spriteSettings.draw = 1;
this->direction = 8;
this->speed = 0x80;
this->collisionFlags = 7;
this->hurtType = 0x48;
this->hitType = -0x58;
this->flags2 = 1;
this->field_0x68.HALF.HI = 0xff;
if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
this->spriteSettings.flipX = 1;
super->spriteSettings.draw = 1;
super->direction = 8;
super->speed = 0x80;
super->collisionFlags = 7;
super->hurtType = 0x48;
super->hitType = -0x58;
super->flags2 = 1;
this->unk_69 = 0xff;
if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
super->spriteSettings.flipX = 1;
} else {
this->spriteSettings.flipX = 0;
super->spriteSettings.flipX = 0;
}
this->field_0x68.HALF.LO = GetFusionToOffer(this);
this->hitbox = (Hitbox*)&gUnk_08110EF0;
uVar2 = sub_0805ACC0(this);
this->fusionOffer = GetFusionToOffer(super);
super->hitbox = (Hitbox*)&gUnk_08110EF0;
uVar2 = sub_0805ACC0(super);
if (uVar2 == 0) {
uVar2 = this->x.HALF.HI;
uVar2 = super->x.HALF.HI;
} else {
uVar2 >>= 0x10;
}
this->field_0x6c.HWORD = uVar2;
this->field_0x6e.HWORD = this->timer + uVar2;
this->timer = 0;
this->field_0x74.HALF.HI = 0;
this->field_0x74.HALF.LO = (Random() & 0x7f) + 0x1e;
this->field_0x68.HALF.HI = 0xff;
this->unk_6c = uVar2;
this->unk_6e = super->timer + uVar2;
super->timer = 0;
this->unk_75 = 0;
this->unk_74 = (Random() & 0x7f) + 0x1e;
this->unk_69 = 0xff;
sub_08067B08(this);
}
void sub_080678AC(Entity* this) {
u32 iVar1;
u16* psVar2;
iVar1 = sub_08067D20(this);
if (iVar1 != 0) {
void sub_080678AC(CatEntity* this) {
if (sub_08067D20(this)) {
sub_08067B80(this, 5);
} else {
psVar2 = (u16*)&this->field_0x70.HALF.HI;
if (*psVar2 != 0) {
*psVar2 = *psVar2 - 1;
if (this->unk_72 != 0) {
this->unk_72--;
}
if ((this->frame == 1) && (*psVar2 == 0)) {
if ((super->frame == 1) && (this->unk_72 == 0)) {
sub_08067AAC(this);
} else {
UpdateAnimationSingleFrame(this);
if ((this->frame & ANIM_DONE) != 0) {
UpdateAnimationSingleFrame(super);
if ((super->frame & ANIM_DONE) != 0) {
sub_08067B34(this);
}
}
}
}
void sub_08067904(Entity* this) {
void sub_08067904(CatEntity* this) {
if (sub_08067D20(this) != 0) {
sub_08067B80(this, 8);
return;
}
this->field_0x70.HALF.HI--;
if (this->field_0x70.HALF.HI == 0) {
this->unk_72--;
if (this->unk_72 == 0) {
sub_08067B70(this);
return;
}
if (this->direction == 8) {
if (this->x.HALF.HI > this->field_0x6e.HWORD) {
this->direction = 0x18;
this->spriteSettings.flipX = 0;
if (super->direction == 8) {
if (super->x.HALF.HI > this->unk_6e) {
super->direction = 0x18;
super->spriteSettings.flipX = 0;
}
} else {
if (this->x.HALF.HI < this->field_0x6c.HWORD) {
this->direction = 8;
this->spriteSettings.flipX = 1;
if (super->x.HALF.HI < this->unk_6c) {
super->direction = 8;
super->spriteSettings.flipX = 1;
}
}
LinearMoveUpdate(this);
UpdateAnimationSingleFrame(this);
LinearMoveUpdate(super);
UpdateAnimationSingleFrame(super);
}
void sub_0806797C(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
void sub_0806797C(CatEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
sub_08067B08(this);
}
}
void sub_0806799C(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_0806799C(CatEntity* this) {
UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
sub_08067B08(this);
SetDefaultPriority(this, PRIO_PLAYER);
SetDefaultPriority(super, PRIO_PLAYER);
}
}
void sub_080679C4(Entity* this) {
if (this->field_0x74.HALF.LO == 0 || --this->field_0x74.HALF.LO == 0 || sub_08067D20(this) == 0) {
void sub_080679C4(CatEntity* this) {
if (this->unk_74 == 0 || --this->unk_74 == 0 || sub_08067D20(this) == 0) {
sub_08067C24(this);
} else {
UpdateAnimationSingleFrame(this);
sub_08067BD4(this);
if (sub_08067D74(this) != 0) {
sub_08067C18(this);
UpdateAnimationSingleFrame(super);
sub_08067BD4(super);
if (sub_08067D74(super) != 0) {
sub_08067C18(super);
}
}
}
void sub_08067A0C(Entity* this) {
void sub_08067A0C(CatEntity* this) {
u8 tmp;
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
if (sub_08067D20(this) != 0) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
if (sub_08067D20(this)) {
sub_08067B80(this, 5);
this->timer += 20;
super->timer += 20;
} else {
sub_08067C24(this);
}
} else {
tmp = (this->frame & 7);
tmp = (super->frame & 7);
if (tmp != 0) {
COLLISION_ON(this);
this->hitbox = gUnk_08111154[tmp - 1 + ((this->spriteSettings.flipX << 2))];
COLLISION_ON(super);
super->hitbox = gUnk_08111154[tmp - 1 + ((super->spriteSettings.flipX << 2))];
} else {
sub_08067DDC(this);
sub_08067DDC(super);
}
}
}
void sub_08067A78(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
void sub_08067A78(CatEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
sub_08067AAC(this);
}
}
void sub_08067A98(Entity* this) {
if (UpdateFuseInteraction(this) != 0) {
void sub_08067A98(CatEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
sub_08067B08(this);
}
}
@@ -274,43 +289,43 @@ static const u16 gUnk_08111104[] = {
static const u8 gUnk_0811110C[] = { 0x3c, 0x96, 0x14 };
static const u8 gUnk_0811110F[] = { 0, -4, 8, 8, 0 };
void sub_08067AAC(Entity* this) {
this->action = 2;
this->field_0x70.HALF.HI = gUnk_081110FC[(Random() & 3)];
void sub_08067AAC(CatEntity* this) {
super->action = 2;
this->unk_72 = gUnk_081110FC[(Random() & 3)];
this->spriteSettings.flipX = this->direction >> 4 ^ 1;
super->spriteSettings.flipX = super->direction >> 4 ^ 1;
sub_08067DCC(this, 3);
SetInteractableObjectCollision(this, 0, gUnk_0811110C[2], gUnk_0811110F);
SetInteractableObjectCollision(super, 0, gUnk_0811110C[2], gUnk_0811110F);
}
void sub_08067B08(Entity* this) {
this->action = 1;
this->field_0x70.HALF.HI = gUnk_08111104[Random() & 3];
void sub_08067B08(CatEntity* this) {
super->action = 1;
this->unk_72 = gUnk_08111104[Random() & 3];
sub_08067B34(this);
}
void sub_08067B34(Entity* this) {
void sub_08067B34(CatEntity* this) {
sub_08067DCC(this, 0);
this->frameDuration = (Random() & 0x30) + 0xb4;
SetInteractableObjectCollision(this, 0, gUnk_0811110C[this->spriteSettings.flipX], gUnk_0811110F);
super->frameDuration = (Random() & 0x30) + 0xb4;
SetInteractableObjectCollision(super, 0, gUnk_0811110C[super->spriteSettings.flipX], gUnk_0811110F);
}
void sub_08067B70(Entity* this) {
this->action = 3;
void sub_08067B70(CatEntity* this) {
super->action = 3;
sub_08067DCC(this, 4);
}
void sub_08067B80(Entity* this, u32 param) {
this->action = 5;
this->timer = 20;
this->field_0x74.HALF.LO = (Random() & 0x7f) + 0x1e;
InitAnimationForceUpdate(this, param);
sub_08067DDC(this);
if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
this->spriteSettings.flipX = 1;
void sub_08067B80(CatEntity* this, u32 animIndex) {
super->action = 5;
super->timer = 20;
this->unk_74 = (Random() & 0x7f) + 0x1e;
InitAnimationForceUpdate(super, animIndex);
sub_08067DDC(super);
if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
super->spriteSettings.flipX = 1;
} else {
this->spriteSettings.flipX = 0;
super->spriteSettings.flipX = 0;
}
}
@@ -331,14 +346,14 @@ void sub_08067C18(Entity* this) {
InitAnimationForceUpdate(this, 6);
}
void sub_08067C24(Entity* this) {
this->action = 7;
this->field_0x74.HALF.HI = 0x14;
sub_08067DDC(this);
InitAnimationForceUpdate(this, 7);
void sub_08067C24(CatEntity* this) {
super->action = 7;
this->unk_75 = 0x14;
sub_08067DDC(super);
InitAnimationForceUpdate(super, 7);
}
void sub_08067C44(Entity* this) {
void sub_08067C44(CatEntity* this) {
s32 iVar4;
u32 uVar5;
@@ -348,78 +363,78 @@ void sub_08067C44(Entity* this) {
uVar5 = FALSE;
}
if (uVar5 != this->field_0x68.HALF.HI) {
if (uVar5 != this->unk_69) {
if (uVar5 == 0) {
AddInteractableWhenBigObject(this);
AddInteractableWhenBigObject(super);
} else {
AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO);
AddInteractableAsMinishFuser(super, this->fusionOffer);
}
}
this->field_0x68.HALF.HI = uVar5;
this->unk_69 = uVar5;
if (this->interactType == 0) {
if (super->interactType == INTERACTION_NONE) {
return;
}
iVar4 = sub_0806FCA0(this, &gPlayerEntity);
switch (this->animIndex) {
iVar4 = sub_0806FCA0(super, &gPlayerEntity);
switch (super->animIndex) {
case 0:
default:
if (iVar4 == 2) {
InitAnimationForceUpdate(this, 2);
InitAnimationForceUpdate(super, 2);
} else {
InitAnimationForceUpdate(this, 1);
InitAnimationForceUpdate(super, 1);
}
break;
case 3:
if (iVar4 == 1) {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
} else {
if (this->spriteSettings.flipX == 3) { // TODO 3 ???
this->spriteSettings.flipX = 0;
if (super->spriteSettings.flipX == 3) { // TODO 3 ???
super->spriteSettings.flipX = 0;
}
}
if (iVar4 != 2) {
InitAnimationForceUpdate(this, 1);
InitAnimationForceUpdate(super, 1);
} else {
InitAnimationForceUpdate(this, 2);
InitAnimationForceUpdate(super, 2);
}
break;
}
if (this->interactType == 2) {
this->action = 8;
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 8;
InitializeNPCFusion(super);
} else {
this->action = 4;
sub_08067790(this);
SetDefaultPriority(this, PRIO_MESSAGE);
super->action = 4;
sub_08067790(super);
SetDefaultPriority(super, PRIO_MESSAGE);
}
this->interactType = 0;
super->interactType = INTERACTION_NONE;
SoundReq(SFX_VO_CAT);
}
u32 sub_08067D20(Entity* this) {
bool32 sub_08067D20(CatEntity* this) {
s32 tmp;
Entity* entity;
int iVar4;
if (this->field_0x74.HALF.HI != 0) {
this->field_0x74.HALF.HI--;
if (this->unk_75 != 0) {
this->unk_75--;
} else {
entity = sub_08049DF4(2);
if (entity != NULL) {
iVar4 = this->spriteSettings.flipX ? 0x10 : 0x28;
if (((u32)(entity->x.HALF.HI - (this->x.HALF.HI - iVar4)) < 0x31) &&
((((u32)entity->y.HALF.HI) - (this->y.HALF.HI - 4)) < 0x39)) {
return 1;
iVar4 = super->spriteSettings.flipX ? 0x10 : 0x28;
if (((u32)(entity->x.HALF.HI - (super->x.HALF.HI - iVar4)) < 0x31) &&
((((u32)entity->y.HALF.HI) - (super->y.HALF.HI - 4)) < 0x39)) {
return TRUE;
}
}
}
return 0;
return FALSE;
}
u32 sub_08067D74(Entity* this) {
bool32 sub_08067D74(Entity* this) {
Entity* entity;
int iVar2;
@@ -433,16 +448,16 @@ u32 sub_08067D74(Entity* this) {
if ((((u32)(entity->x.HALF.HI - (this->x.HALF.HI - iVar2)) < 0x1f) &&
((u32)(entity->y.HALF.HI - this->y.HALF.HI) < 0x17)) &&
(this->timer == 0)) {
return 1;
return TRUE;
}
}
}
return 0;
return FALSE;
}
void sub_08067DCC(Entity* this, u32 param) {
this->field_0x70.BYTES.byte1 = param;
InitAnimationForceUpdate(this, param);
void sub_08067DCC(CatEntity* this, u32 animIndex) {
this->unk_71 = animIndex;
InitAnimationForceUpdate(super, animIndex);
}
void sub_08067DDC(Entity* this) {
+15 -9
View File
@@ -1,4 +1,11 @@
/**
* @file clothesRack.c
* @ingroup NPCs
*
* @brief Clothes Rack NPC
*/
#include "npc.h"
#define NENT_DEPRECATED
void sub_0806DD90(Entity*);
void sub_0806DEC8(Entity*);
@@ -12,23 +19,22 @@ void ClothesRack(Entity* this) {
}
void sub_0806DD90(Entity* this) {
u32 uVar1;
u32 uVar2;
u32 animIndex;
u32 x;
u32 y;
this->action = 1;
uVar2 = 0;
animIndex = 0;
if (CheckGlobalFlag(DRUG_1)) {
uVar2 = 1;
animIndex = 1;
}
if (CheckGlobalFlag(DRUG_2) != 0) {
uVar2 = 2;
if (CheckGlobalFlag(DRUG_2)) {
animIndex = 2;
}
if (CheckGlobalFlag(DRUG_3) != 0) {
uVar2 = 3;
if (CheckGlobalFlag(DRUG_3)) {
animIndex = 3;
}
InitializeAnimation(this, uVar2);
InitializeAnimation(this, animIndex);
x = this->x.HALF.HI;
y = this->y.HALF.HI;
SetTile(0x4072, TILE(x - 0x18, y - 0x10), this->collisionLayer);
+137 -123
View File
@@ -1,194 +1,208 @@
#include "global.h"
#include "sound.h"
/**
* @file cow.c
* @ingroup NPCs
*
* @brief Cow NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "npc.h"
#include "functions.h"
#include "npc.h"
#include "player.h"
#include "sound.h"
void sub_0806920C(Entity* ent);
void sub_0806924C(Entity* ent);
void sub_08068FC0(Entity* ent);
void sub_08069018(Entity* ent);
void sub_08069068(Entity* ent);
void sub_08069124(Entity* ent);
void sub_080691E0(Entity* ent);
void sub_08069148(Entity* ent);
void sub_08069168(Entity* ent);
void sub_08069188(Entity* ent);
void sub_080691BC(Entity* ent);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u16 unk_68;
/*0x6a*/ u16 unk_6a;
/*0x6c*/ u8 fusionOffer;
/*0x6d*/ u8 unk_6d;
} CowEntity;
void Cow(Entity* ent) {
static void (*const actionFuncs[])(Entity*) = {
void sub_0806920C(CowEntity* this);
void sub_0806924C(CowEntity* this);
void sub_08068FC0(CowEntity* this);
void sub_08069018(CowEntity* this);
void sub_08069068(CowEntity* this);
void sub_08069124(CowEntity* this);
void sub_080691E0(CowEntity* this);
void sub_08069148(CowEntity* this);
void sub_08069168(CowEntity* this);
void sub_08069188(CowEntity* this);
void sub_080691BC(CowEntity* this);
void Cow(CowEntity* this) {
static void (*const actionFuncs[])(CowEntity*) = {
sub_08068FC0, sub_08069018, sub_08069068, sub_08069124, sub_080691E0,
};
actionFuncs[ent->action](ent);
sub_0806ED78(ent);
sub_0806920C(ent);
actionFuncs[super->action](this);
sub_0806ED78(super);
sub_0806920C(this);
}
void sub_08068FC0(Entity* ent) {
void sub_08068FC0(CowEntity* this) {
u32 r2;
ent->action = 1;
ent->animationState = ent->type2;
ent->speed = 0x40;
super->action = 1;
super->animationState = super->type2;
super->speed = 0x40;
ent->field_0x6c.HALF.HI = 0xFF;
this->unk_6d = 0xff;
r2 = sub_0805ACC0(ent);
r2 = sub_0805ACC0(super);
if (r2 == 0) {
u16 x, y;
x = ent->x.HALF.HI;
*(u16*)&ent->field_0x68 = x;
x = super->x.HALF.HI;
this->unk_68 = x;
y = ent->y.HALF.HI;
ent->field_0x6a.HWORD = y;
y = super->y.HALF.HI;
this->unk_6a = y;
} else {
u32 var1 = r2 >> 16;
// 0x68+0x69 probably a SplitWord
*(u16*)&ent->field_0x68 = var1;
ent->field_0x6a.HWORD = r2;
this->unk_68 = var1;
this->unk_6a = r2;
}
ent->field_0x6c.HALF.LO = GetFusionToOffer(ent);
this->fusionOffer = GetFusionToOffer(super);
InitAnimationForceUpdate(ent, ent->animationState + 4);
InitAnimationForceUpdate(super, super->animationState + 4);
}
void sub_08069018(Entity* ent) {
void sub_08069018(CowEntity* this) {
s32 var0;
if (ent->subAction == 0) {
ent->subAction++;
ent->subtimer = (Random() & 0x3F) + 0x3C;
InitAnimationForceUpdate(ent, ent->animationState);
if (super->subAction == 0) {
super->subAction++;
super->subtimer = (Random() & 0x3F) + 0x3C;
InitAnimationForceUpdate(super, super->animationState);
}
UpdateAnimationSingleFrame(ent);
var0 = --ent->subtimer;
UpdateAnimationSingleFrame(super);
var0 = --super->subtimer;
if (var0 == 0) {
if (ent->timer == 0) {
ent->action = 2;
if (super->timer == 0) {
super->action = 2;
} else {
ent->action = 3;
super->action = 3;
}
ent->subAction = var0;
super->subAction = var0;
}
sub_0806924C(ent);
sub_0806924C(this);
}
void sub_08069068(Entity* ent) {
void sub_08069068(CowEntity* this) {
s32 var0;
if (ent->subAction == 0) {
if (super->subAction == 0) {
u32 anim;
ent->subAction++;
super->subAction++;
anim = (Random() & 2) - 1;
anim = (anim + ent->animationState) & 3;
ent->animationState = anim;
ent->direction = anim <<= 3;
anim = (anim + super->animationState) & 3;
super->animationState = anim;
super->direction = anim <<= 3;
ent->subtimer = (Random() & 0x3F) + 60;
InitAnimationForceUpdate(ent, ent->animationState + 4);
super->subtimer = (Random() & 0x3F) + 60;
InitAnimationForceUpdate(super, super->animationState + 4);
}
ProcessMovement0(ent);
UpdateAnimationSingleFrame(ent);
ProcessMovement0(super);
UpdateAnimationSingleFrame(super);
{
s32 x = ent->x.HALF.HI;
s16* x2 = (s16*)&ent->field_0x68;
s32 x = super->x.HALF.HI;
s16* x2 = (s16*)&this->unk_68;
x -= *x2;
if (x > 16) {
ent->x.HALF.HI = *x2 + 16;
ent->subtimer = 1;
super->x.HALF.HI = *x2 + 16;
super->subtimer = 1;
}
if (x < -16) {
ent->x.HALF.HI = *x2 - 16;
ent->subtimer = 1;
super->x.HALF.HI = *x2 - 16;
super->subtimer = 1;
}
}
{
s32 y = ent->y.HALF.HI;
s16* y2 = &ent->field_0x6a.HWORD;
s32 y = super->y.HALF.HI;
s16* y2 = &this->unk_6a;
y -= *y2;
if (y > 16) {
ent->y.HALF.HI = *y2 + 16;
ent->subtimer = 1;
super->y.HALF.HI = *y2 + 16;
super->subtimer = 1;
}
if (y < -16) {
ent->y.HALF.HI = *y2 - 16;
ent->subtimer = 1;
super->y.HALF.HI = *y2 - 16;
super->subtimer = 1;
}
}
var0 = --ent->subtimer;
var0 = --super->subtimer;
if (var0 == 0) {
ent->action = 3;
ent->subAction = var0;
super->action = 3;
super->subAction = var0;
}
sub_0806924C(ent);
sub_0806924C(this);
}
void sub_08069124(Entity* ent) {
static void (*const subActionFuncs[])(Entity*) = {
void sub_08069124(CowEntity* this) {
static void (*const subActionFuncs[])(CowEntity*) = {
sub_08069148,
sub_08069168,
sub_08069188,
sub_080691BC,
};
UpdateAnimationSingleFrame(ent);
subActionFuncs[ent->subAction](ent);
sub_0806924C(ent);
UpdateAnimationSingleFrame(super);
subActionFuncs[super->subAction](this);
sub_0806924C(this);
}
void sub_08069148(Entity* ent) {
void sub_08069148(CowEntity* this) {
u32 var0 = Random() & 3;
var0 += 3;
ent->subtimer = var0;
ent->subAction = 1;
InitAnimationForceUpdate(ent, ent->animationState + 8);
super->subtimer = var0;
super->subAction = 1;
InitAnimationForceUpdate(super, super->animationState + 8);
}
void sub_08069168(Entity* ent) {
if ((s8)ent->frame < 0) {
ent->subAction = 2;
InitAnimationForceUpdate(ent, ent->animationState + 12);
void sub_08069168(CowEntity* this) {
if ((s8)super->frame < 0) {
super->subAction = 2;
InitAnimationForceUpdate(super, super->animationState + 12);
}
}
void sub_08069188(Entity* ent) {
if ((ent->frame & 1) == 0)
void sub_08069188(CowEntity* this) {
if ((super->frame & 1) == 0)
return;
ent->frame = 0;
super->frame = 0;
if (--ent->subtimer != 0)
if (--super->subtimer != 0)
return;
ent->subAction = 3;
InitAnimationForceUpdate(ent, ent->animationState + 16);
super->subAction = 3;
InitAnimationForceUpdate(super, super->animationState + 16);
}
void sub_080691BC(Entity* ent) {
if ((s8)ent->frame < 0) {
ent->action = 1;
ent->subAction = 0;
InitAnimationForceUpdate(ent, ent->animationState + 4);
void sub_080691BC(CowEntity* this) {
if ((s8)super->frame < 0) {
super->action = 1;
super->subAction = 0;
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
void sub_080691E0(Entity* ent) {
if (UpdateFuseInteraction(ent) != 0) {
ent->action = 1;
ent->subAction = 0;
void sub_080691E0(CowEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
super->subAction = 0;
}
}
// Show dialogue
void Cow_ShowDialogue(Entity* ent) {
void Cow_ShowDialogue(CowEntity* this) {
static const Dialog gUnk_08111938[] = {
{ 0x0, 0x0, DIALOG_MINISH, 1, { TEXT_INDEX(TEXT_LON_LON, 0X18), TEXT_INDEX(TEXT_TINGLE, 0x34) } },
{ 0x0, 0x0, DIALOG_MINISH, 1, { TEXT_INDEX(TEXT_LON_LON, 0X18), TEXT_INDEX(TEXT_TINGLE, 0x35) } },
@@ -196,10 +210,10 @@ void Cow_ShowDialogue(Entity* ent) {
{ 0x0, 0x0, DIALOG_MINISH, 1, { TEXT_INDEX(TEXT_LON_LON, 0X18), TEXT_INDEX(TEXT_TINGLE, 0x37) } },
{ 0x0, 0x0, DIALOG_MINISH, 1, { TEXT_INDEX(TEXT_LON_LON, 0X18), TEXT_INDEX(TEXT_TINGLE, 0x38) } }
};
ShowNPCDialogue(ent, &gUnk_08111938[ent->type]);
ShowNPCDialogue(super, &gUnk_08111938[super->type]);
}
void sub_0806920C(Entity* ent) {
void sub_0806920C(CowEntity* this) {
u32 var1;
if ((gPlayerState.flags & PL_MINISH) != 0) {
var1 = TRUE;
@@ -207,43 +221,43 @@ void sub_0806920C(Entity* ent) {
var1 = FALSE;
}
if (var1 != ent->field_0x6c.HALF.HI) {
if (var1 != this->unk_6d) {
if (var1 == 0) {
AddInteractableWhenBigObject(ent);
AddInteractableWhenBigObject(super);
} else {
AddInteractableAsMinishFuser(ent, ent->field_0x6c.HALF.LO);
AddInteractableAsMinishFuser(super, this->fusionOffer);
}
}
ent->field_0x6c.HALF.HI = var1;
this->unk_6d = var1;
}
// Check if player interacting
void sub_0806924C(Entity* ent) {
s8 itype = ent->interactType;
if (itype != 0) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
if (itype == 2) {
ent->action = 4;
sub_0806F118(ent);
void sub_0806924C(CowEntity* this) {
s8 itype = super->interactType;
if (itype != INTERACTION_NONE) {
if (gPlayerState.flags & PL_MINISH) {
if (itype == INTERACTION_FUSE) {
super->action = 4;
InitializeNPCFusion(super);
} else {
Cow_ShowDialogue(ent);
Cow_ShowDialogue(this);
}
} else {
Cow_ShowDialogue(ent);
Cow_ShowDialogue(this);
ResetPlayerAnimationAndAction();
}
SoundReq(SFX_VO_COW);
ent->interactType = 0;
super->interactType = INTERACTION_NONE;
}
}
void Cow_Fusion(Entity* ent) {
if (ent->action == 0) {
ent->action++;
ent->spriteSettings.draw = 1;
InitAnimationForceUpdate(ent, 15);
void Cow_Fusion(CowEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
InitAnimationForceUpdate(super, 15);
} else {
UpdateAnimationSingleFrame(ent);
UpdateAnimationSingleFrame(super);
}
}
+68 -56
View File
@@ -1,105 +1,117 @@
#include "npc.h"
/**
* @file cucco.c
* @ingroup NPCs
*
* @brief Cucco NPC
*/
#define NENT_DEPRECATED
#include "functions.h"
#include "kinstone.h"
#include "npc.h"
void (*const Cucco_Actions[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
} CuccoEntity;
void (*const Cucco_Actions[])(CuccoEntity*);
const u16 Cucco_Sounds[];
const u16 Cucco_Messages[];
void sub_0806E4EC(Entity*);
void sub_0806E4EC(CuccoEntity*);
void Cucco_ShowMessage(Entity*);
void sub_0806E65C(Entity* this);
void Cucco(Entity* this) {
Cucco_Actions[this->action](this);
void Cucco(CuccoEntity* this) {
Cucco_Actions[super->action](this);
}
void Cucco_Init(Entity* this) {
this->action++;
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO);
SetDefaultPriority(this, PRIO_MESSAGE);
this->subAction = 0;
void Cucco_Init(CuccoEntity* this) {
super->action++;
this->fusionOffer = GetFusionToOffer(super);
AddInteractableAsMinishFuser(super, this->fusionOffer);
SetDefaultPriority(super, PRIO_MESSAGE);
super->subAction = 0;
sub_0806E4EC(this);
}
void sub_0806E4EC(Entity* this) {
if (this->subAction == 0) {
this->subAction++;
this->timer = (Random() & 0x1f) + 60;
InitAnimationForceUpdate(this, 0);
void sub_0806E4EC(CuccoEntity* this) {
if (super->subAction == 0) {
super->subAction++;
super->timer = (Random() & 0x1f) + 60;
InitAnimationForceUpdate(super, 0);
}
if (--this->timer == 0) {
if (--super->timer == 0) {
if ((Random() & 1) != 0) {
this->action = 3;
super->action = 3;
} else {
this->action = 2;
super->action = 2;
}
this->subAction = 0;
super->subAction = 0;
if ((Random() & 1) != 0) {
EnqueueSFX(Cucco_Sounds[Random() & 3]);
}
}
sub_0806E65C(this);
UpdateAnimationSingleFrame(this);
sub_0806E65C(super);
UpdateAnimationSingleFrame(super);
}
void Cucco_Fly(Entity* this) {
if (this->subAction == 0) {
this->subAction++;
void Cucco_Fly(CuccoEntity* this) {
if (super->subAction == 0) {
super->subAction++;
if (Random() & 1) {
this->spriteSettings.flipX ^= 1;
super->spriteSettings.flipX ^= 1;
}
this->timer = (Random() & 1) + 1;
this->zVelocity = Q_16_16(1.5);
InitAnimationForceUpdate(this, 1);
super->timer = (Random() & 1) + 1;
super->zVelocity = Q_16_16(1.5);
InitAnimationForceUpdate(super, 1);
}
if (GravityUpdate(this, Q_8_8(40.0)) == 0) {
if (--this->timer == 0) {
this->action = 1;
this->subAction = 0;
if (GravityUpdate(super, Q_8_8(40.0)) == 0) {
if (--super->timer == 0) {
super->action = 1;
super->subAction = 0;
} else {
this->zVelocity = Q_16_16(1.5);
super->zVelocity = Q_16_16(1.5);
}
}
sub_0806E65C(this);
UpdateAnimationSingleFrame(this);
sub_0806E65C(super);
UpdateAnimationSingleFrame(super);
}
void Cucco_Idle(Entity* this) {
if (this->subAction == 0) {
this->subAction++;
void Cucco_Idle(CuccoEntity* this) {
if (super->subAction == 0) {
super->subAction++;
if (Random() & 1) {
this->spriteSettings.flipX ^= 1;
super->spriteSettings.flipX ^= 1;
}
InitAnimationForceUpdate(this, (Random() & 1) + 2);
InitAnimationForceUpdate(super, (Random() & 1) + 2);
}
if (this->frame & ANIM_DONE) {
this->action = 1;
this->subAction = 0;
if (super->frame & ANIM_DONE) {
super->action = 1;
super->subAction = 0;
}
sub_0806E65C(this);
UpdateAnimationSingleFrame(this);
sub_0806E65C(super);
UpdateAnimationSingleFrame(super);
}
void sub_0806E648(Entity* this) {
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
void sub_0806E648(CuccoEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
}
}
void sub_0806E65C(Entity* this) {
if (this->interactType != 0) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
if (this->interactType == 2) {
if (this->interactType != INTERACTION_NONE) {
if (gPlayerState.flags & PL_MINISH) {
if (this->interactType == INTERACTION_FUSE) {
this->action = 4;
sub_0806F118(this);
InitializeNPCFusion(this);
} else {
Cucco_ShowMessage(this);
}
@@ -107,14 +119,14 @@ void sub_0806E65C(Entity* this) {
ResetPlayerAnimationAndAction();
}
SoundReq(SFX_VO_CUCCO_CALL);
this->interactType = 0;
this->interactType = INTERACTION_NONE;
}
}
void Cucco_ShowMessage(Entity* this) {
u32 val = 0;
u32 index = GetFuserId(this);
if (gSave.fuserOffers[index] == KINSTONE_FUSER_DONE) {
if (gSave.kinstones.fuserOffers[index] == KINSTONE_FUSER_DONE) {
val = 1;
}
@@ -131,7 +143,7 @@ void Cucco_Fusion(Entity* this) {
}
}
void (*const Cucco_Actions[])(Entity*) = {
void (*const Cucco_Actions[])(CuccoEntity*) = {
Cucco_Init, sub_0806E4EC, Cucco_Fly, Cucco_Idle, sub_0806E648,
};
+68 -56
View File
@@ -1,44 +1,56 @@
#include "npc.h"
/**
* @file cuccoChick.c
* @ingroup NPCs
*
* @brief Cucco Chick NPC
*/
#define NENT_DEPRECATED
#include "functions.h"
#include "npc.h"
void CuccoChick_Init(Entity*);
void sub_0806E764(Entity*);
void CuccoChick_Fly(Entity*);
void sub_0806E824(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
} CuccoChickEntity;
void sub_0806E838(Entity* this);
void CuccoChick_Init(CuccoChickEntity*);
void sub_0806E764(CuccoChickEntity*);
void CuccoChick_Fly(CuccoChickEntity*);
void sub_0806E824(CuccoChickEntity*);
void sub_0806E884(Entity* this);
void sub_0806E838(CuccoChickEntity* this);
void CuccoChick(Entity* this) {
static void (*const CuccoChick_Actions[])(Entity*) = {
void sub_0806E884(CuccoChickEntity* this);
void CuccoChick(CuccoChickEntity* this) {
static void (*const CuccoChick_Actions[])(CuccoChickEntity*) = {
CuccoChick_Init,
sub_0806E764,
CuccoChick_Fly,
sub_0806E824,
};
CuccoChick_Actions[this->action](this);
sub_0806ED78(this);
CuccoChick_Actions[super->action](this);
sub_0806ED78(super);
}
void CuccoChick_Init(Entity* this) {
this->action++;
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO);
SetDefaultPriority(this, PRIO_MESSAGE);
this->subAction = 0;
void CuccoChick_Init(CuccoChickEntity* this) {
super->action++;
this->fusionOffer = GetFusionToOffer(super);
AddInteractableAsMinishFuser(super, this->fusionOffer);
SetDefaultPriority(super, PRIO_MESSAGE);
super->subAction = 0;
sub_0806E764(this);
}
void sub_0806E764(Entity* this) {
if (this->subAction == 0) {
this->subAction++;
this->timer = (Random() & 0x1f) + 30;
this->frameIndex = 0;
void sub_0806E764(CuccoChickEntity* this) {
if (super->subAction == 0) {
super->subAction++;
super->timer = (Random() & 0x1f) + 30;
super->frameIndex = 0;
}
if (--this->timer == 0) {
this->action = 2;
this->subAction = 0;
if (--super->timer == 0) {
super->action = 2;
super->subAction = 0;
if ((Random() & 1) != 0) {
EnqueueSFX(SFX_VO_CHEEP);
}
@@ -46,39 +58,39 @@ void sub_0806E764(Entity* this) {
sub_0806E838(this);
}
void CuccoChick_Fly(Entity* this) {
if (this->subAction == 0) {
this->subAction++;
void CuccoChick_Fly(CuccoChickEntity* this) {
if (super->subAction == 0) {
super->subAction++;
if ((Random() & 1) != 0) {
this->spriteSettings.flipX ^= 1;
super->spriteSettings.flipX ^= 1;
}
this->timer = (Random() & 3) + 1;
this->zVelocity = Q_16_16(1.0);
this->frameIndex = 1;
super->timer = (Random() & 3) + 1;
super->zVelocity = Q_16_16(1.0);
super->frameIndex = 1;
}
if (GravityUpdate(this, Q_8_8(48.0)) == 0) {
if (--this->timer == 0) {
this->action = 1;
this->subAction = 0;
if (GravityUpdate(super, Q_8_8(48.0)) == 0) {
if (--super->timer == 0) {
super->action = 1;
super->subAction = 0;
} else {
this->zVelocity = Q_16_16(1.0);
super->zVelocity = Q_16_16(1.0);
}
}
sub_0806E838(this);
}
void sub_0806E824(Entity* this) {
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
void sub_0806E824(CuccoChickEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
}
}
void sub_0806E838(Entity* this) {
if (this->interactType != 0) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
if (this->interactType == 2) {
this->action = 3;
sub_0806F118(this);
void sub_0806E838(CuccoChickEntity* this) {
if (super->interactType != INTERACTION_NONE) {
if (gPlayerState.flags & PL_MINISH) {
if (super->interactType == INTERACTION_FUSE) {
super->action = 3;
InitializeNPCFusion(super);
} else {
sub_0806E884(this);
}
@@ -86,22 +98,22 @@ void sub_0806E838(Entity* this) {
ResetPlayerAnimationAndAction();
}
SoundReq(SFX_VO_CHEEP);
this->interactType = 0;
super->interactType = INTERACTION_NONE;
}
}
void sub_0806E884(Entity* this) {
MessageNoOverlap(TEXT_INDEX(TEXT_MINISH, 0Xb6), this);
void sub_0806E884(CuccoChickEntity* this) {
MessageNoOverlap(TEXT_INDEX(TEXT_MINISH, 0xB6), super);
}
void CuccoChick_Fusion(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
this->frameIndex = 1;
void CuccoChick_Fusion(CuccoChickEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
super->frameIndex = 1;
} else {
if (GravityUpdate(this, Q_8_8(48.0)) == 0) {
this->zVelocity = Q_16_16(1.0);
if (GravityUpdate(super, Q_8_8(48.0)) == 0) {
super->zVelocity = Q_16_16(1.0);
}
}
}
+25 -13
View File
@@ -1,11 +1,22 @@
#include "global.h"
/**
* @file dampe.c
* @ingroup NPCs
*
* @brief Dampe NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "room.h"
#include "flags.h"
#include "item.h"
#include "message.h"
#include "npc.h"
#include "item.h"
#include "player.h"
#include "room.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
} DampeEntity;
void Dampe(Entity* this) {
switch (this->action) {
@@ -13,16 +24,17 @@ void Dampe(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
InitScriptForNPC(this);
return;
case 1:
if (this->interactType == 2) {
if (this->interactType == INTERACTION_FUSE) {
this->action = 2;
this->interactType = 0;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4);
sub_0806F118(this);
this->interactType = INTERACTION_NONE;
InitAnimationForceUpdate(this,
GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity)) + 4);
InitializeNPCFusion(this);
} else {
sub_0807DD94(this, 0);
ExecuteScriptAndHandleAnimation(this, NULL);
}
return;
case 2:
@@ -33,9 +45,9 @@ void Dampe(Entity* this) {
}
}
void Dampe_MakeInteractable(Entity* this) {
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
void Dampe_MakeInteractable(DampeEntity* this) {
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
}
void Dampe_Fusion(Entity* this) {
+30 -18
View File
@@ -1,30 +1,42 @@
#include "global.h"
/**
* @file din.c
* @ingroup NPCs
*
* @brief Din NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "npc.h"
#include "kinstone.h"
#include "npc.h"
void Din(Entity* this) {
switch (this->action) {
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 animIndex;
} DinEntity;
void Din(DinEntity* this) {
switch (super->action) {
case 0:
this->action = 1;
this->spriteSettings.draw = 1;
sub_0807DD50(this);
super->action = 1;
super->spriteSettings.draw = 1;
InitScriptForNPC(super);
break;
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
sub_0806F118(this);
this->field_0x68.HALF.LO = this->animIndex;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
InitializeNPCFusion(super);
this->animIndex = super->animIndex;
InitAnimationForceUpdate(super,
GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)));
} else {
sub_0807DD94(this, NULL);
ExecuteScriptAndHandleAnimation(super, NULL);
}
break;
case 2:
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
InitAnimationForceUpdate(this, this->field_0x68.HALF.LO);
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
InitAnimationForceUpdate(super, this->animIndex);
}
break;
}
@@ -32,7 +44,7 @@ void Din(Entity* this) {
void Din_MakeInteractable(Entity* this) {
u32 kinstoneId = GetFusionToOffer(this);
if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
if ((gSave.kinstones.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
kinstoneId = KINSTONE_NONE;
}
AddInteractableWhenBigFuser(this, kinstoneId);
+177 -158
View File
@@ -1,18 +1,37 @@
#include "entity.h"
/**
* @file dog.c
* @ingroup NPCs
*
* @brief Dog NPC
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "entity.h"
#include "functions.h"
#include "npc.h"
#include "item.h"
#include "npc.h"
void sub_08069FE8(Entity*);
bool32 sub_08069EF0(Entity*);
bool32 sub_08069F90(Entity*);
void sub_08069F6C(Entity*);
void sub_08069D00(Entity*);
void sub_08069CB8(Entity*);
void sub_0806A028(Entity*);
void sub_08069FBC(Entity*);
void sub_0806A080(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u16 unk_68;
/*0x6a*/ u8 unk_6a;
/*0x6b*/ u8 unk_6b;
/*0x6c*/ u16 unk_6c;
/*0x6e*/ u16 unk_6e;
/*0x70*/ u16 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ u8 unk_74;
} DogEntity;
void sub_08069FE8(DogEntity*);
bool32 sub_08069EF0(DogEntity*);
bool32 sub_08069F90(DogEntity*);
void sub_08069F6C(DogEntity*);
void sub_08069D00(DogEntity*);
void sub_08069CB8(DogEntity*);
void sub_0806A028(DogEntity*);
void sub_08069FBC(DogEntity*);
void sub_0806A080(DogEntity*);
const SpriteLoadData gUnk_08111D58[] = {
#ifdef EU
@@ -23,15 +42,15 @@ const SpriteLoadData gUnk_08111D58[] = {
{ 4, 68, 4 }, { 7172, 68, 4 }, { 0, 0, 0 }, { 83, 69, 4 }, { 7251, 69, 4 }, { 0, 0, 0 },
};
void sub_08069B44(Entity*);
void sub_08069C40(Entity*);
void sub_08069D54(Entity*);
void sub_08069DF8(Entity*);
void sub_08069E44(Entity*);
void sub_08069E50(Entity*);
void sub_08069ECC(Entity*);
void sub_08069EE0(Entity*);
void (*const gUnk_08111D88[])(Entity*) = {
void sub_08069B44(DogEntity*);
void sub_08069C40(DogEntity*);
void sub_08069D54(DogEntity*);
void sub_08069DF8(DogEntity*);
void sub_08069E44(DogEntity*);
void sub_08069E50(DogEntity*);
void sub_08069ECC(DogEntity*);
void sub_08069EE0(DogEntity*);
void (*const gUnk_08111D88[])(DogEntity*) = {
sub_08069B44, sub_08069C40, sub_08069D54, sub_08069DF8, sub_08069E44, sub_08069E50, sub_08069ECC, sub_08069EE0,
};
@@ -175,254 +194,254 @@ const u16 gUnk_08111FD8[] = {
TEXT_INDEX(TEXT_TOWN8, 0x7), TEXT_INDEX(TEXT_TOWN8, 0x8), TEXT_INDEX(TEXT_TOWN8, 0x9),
TEXT_INDEX(TEXT_TOWN8, 0x11), TEXT_INDEX(TEXT_TOWN8, 0x3),
};
void Dog(Entity* this) {
gUnk_08111D88[this->action](this);
sub_0806ED78(this);
void Dog(DogEntity* this) {
gUnk_08111D88[super->action](this);
sub_0806ED78(super);
sub_08069FE8(this);
}
void sub_08069B44(Entity* this) {
void sub_08069B44(DogEntity* this) {
u32 uVar2;
u32 sVar3;
u32 uVar4;
u32 uVar5;
if (sub_08069EF0(this)) {
uVar5 = sub_0805ACC0(this);
uVar5 = sub_0805ACC0(super);
if (uVar5 == 0) {
sVar3 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
sVar3 = super->x.HALF.HI;
uVar2 = super->y.HALF.HI;
} else {
sVar3 = uVar5 >> 0x10;
uVar2 = uVar5;
}
uVar4 = this->timer == 0 ? 0x20 : this->timer;
uVar4 = super->timer == 0 ? 0x20 : super->timer;
this->field_0x6e.HWORD = sVar3 - uVar4;
this->field_0x6c.HWORD = sVar3 + uVar4;
this->field_0x70.HALF.LO = uVar2 - 8;
this->field_0x70.HALF.HI = uVar2 + 8;
this->speed = 0x100;
this->timer = 30;
this->animationState = 2;
this->field_0x6a.HALF.LO = 0xff;
this->field_0x74.HALF.LO = GetFusionToOffer(this);
SetDefaultPriority(this, PRIO_MESSAGE);
InitAnimationForceUpdate(this, 10);
if ((this->flags & ENT_SCRIPTED) != 0) {
sub_0807DD50(this);
this->unk_6e = sVar3 - uVar4;
this->unk_6c = sVar3 + uVar4;
this->unk_70 = uVar2 - 8;
this->unk_72 = uVar2 + 8;
super->speed = 0x100;
super->timer = 30;
super->animationState = 2;
this->unk_6a = 0xff;
this->unk_74 = GetFusionToOffer(super);
SetDefaultPriority(super, PRIO_MESSAGE);
InitAnimationForceUpdate(super, 10);
if ((super->flags & ENT_SCRIPTED) != 0) {
InitScriptForNPC(super);
}
if (((this->type == 0) && ((gPlayerState.flags & PL_MINISH) == 0)) &&
if (((super->type == 0) && ((gPlayerState.flags & PL_MINISH) == 0)) &&
(GetInventoryValue(ITEM_QST_DOGFOOD) != 2)) {
this->action = 4;
super->action = 4;
}
if ((this->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) {
SetTile(0x4072, TILE(this->x.HALF.HI, this->y.HALF.HI - 8), this->collisionLayer);
if ((super->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) {
SetTile(0x4072, TILE(super->x.HALF.HI, super->y.HALF.HI - 8), super->collisionLayer);
}
}
}
void sub_08069C40(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08069C40(DogEntity* this) {
UpdateAnimationSingleFrame(super);
if (sub_08069F90(this)) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
sub_08069CB8(this);
} else {
this->animationState = GetAnimationState(this);
super->animationState = GetAnimationState(super);
sub_08069D00(this);
}
this->timer = 30;
super->timer = 30;
} else {
this->timer--;
if (this->timer == 0) {
this->action = 2;
this->timer = (Random() & 0x1f) + 30;
this->direction = gUnk_08111DA8[Random() & 7];
super->timer--;
if (super->timer == 0) {
super->action = 2;
super->timer = (Random() & 0x1f) + 30;
super->direction = gUnk_08111DA8[Random() & 7];
sub_08069F6C(this);
}
}
}
void sub_08069CB8(Entity* this) {
void sub_08069CB8(DogEntity* this) {
u32 direction;
u32 animState;
direction = GetFacingDirection(this, &gPlayerEntity);
animState = gUnk_08111DB0[direction + this->animationState * 0x20];
this->animationState = animState >> 6;
this->field_0x6a.HALF.HI = animState & 0x3f;
direction = GetFacingDirection(super, &gPlayerEntity);
animState = gUnk_08111DB0[direction + super->animationState * 0x20];
super->animationState = animState >> 6;
this->unk_6b = animState & 0x3f;
sub_0806A028(this);
if (this->animIndex != this->field_0x6a.HALF.HI) {
InitAnimationForceUpdate(this, this->field_0x6a.HALF.HI);
if (super->animIndex != this->unk_6b) {
InitAnimationForceUpdate(super, this->unk_6b);
}
}
void sub_08069D00(Entity* this) {
this->field_0x6a.HALF.HI = 8;
void sub_08069D00(DogEntity* this) {
this->unk_6b = 8;
sub_0806A028(this);
if (0x1f < this->animIndex) {
if ((this->frame & ANIM_DONE) == 0) {
if (0x1f < super->animIndex) {
if ((super->frame & ANIM_DONE) == 0) {
return;
}
this->field_0x6a.HALF.HI = 8;
this->unk_6b = 8;
}
if ((Random() & 0x1ff) < 3) {
sub_08069FBC(this);
}
if (this->animIndex != this->field_0x6a.HALF.HI + this->animationState) {
InitAnimationForceUpdate(this, this->field_0x6a.HALF.HI + this->animationState);
if (super->animIndex != this->unk_6b + super->animationState) {
InitAnimationForceUpdate(super, this->unk_6b + super->animationState);
}
}
void sub_08069D54(Entity* this) {
void sub_08069D54(DogEntity* this) {
u16 collisions;
if (!sub_08069F90(this)) {
this->timer--;
if (this->timer != 0) {
UpdateAnimationSingleFrame(this);
ProcessMovement0(this);
collisions = this->collisions;
super->timer--;
if (super->timer != 0) {
UpdateAnimationSingleFrame(super);
ProcessMovement0(super);
collisions = super->collisions;
if (this->x.HALF.HI < this->field_0x6e.HWORD) {
this->x.HALF.HI = this->field_0x6e.HWORD + 1;
if (super->x.HALF.HI < this->unk_6e) {
super->x.HALF.HI = this->unk_6e + 1;
collisions = COL_WEST_ANY;
} else if (this->x.HALF.HI > this->field_0x6c.HWORD) {
this->x.HALF.HI = this->field_0x6c.HWORD - 1;
} else if (super->x.HALF.HI > this->unk_6c) {
super->x.HALF.HI = this->unk_6c - 1;
collisions = COL_EAST_ANY;
}
if (this->y.HALF.HI < this->field_0x70.HALF_U.LO) {
this->y.HALF.HI = this->field_0x70.HALF_U.LO + 1;
if (super->y.HALF.HI < this->unk_70) {
super->y.HALF.HI = this->unk_70 + 1;
collisions = COL_NORTH_ANY;
} else if (this->y.HALF.HI > this->field_0x70.HALF_U.HI) {
this->y.HALF.HI = this->field_0x70.HALF_U.HI - 1;
} else if (super->y.HALF.HI > this->unk_72) {
super->y.HALF.HI = this->unk_72 - 1;
collisions = COL_SOUTH_ANY;
}
sub_0800417E(this, collisions);
sub_0800417E(super, collisions);
sub_08069F6C(this);
return;
}
}
if (sub_08069F90(this)) {
this->action = 1;
super->action = 1;
} else {
this->action = 3;
super->action = 3;
}
this->timer = (Random() & 0x1f) + 30;
super->timer = (Random() & 0x1f) + 30;
}
void sub_08069DF8(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08069DF8(DogEntity* this) {
UpdateAnimationSingleFrame(super);
if (sub_08069F90(this)) {
this->action = 1;
super->action = 1;
} else {
this->timer--;
if (this->timer != 0) {
super->timer--;
if (super->timer != 0) {
sub_08069D00(this);
return;
}
if ((Random() & 0xff) < 0x30) {
this->action = 2;
super->action = 2;
} else {
this->action = 3;
super->action = 3;
}
}
this->timer = (Random() & 0x1f) + 30;
super->timer = (Random() & 0x1f) + 30;
}
void sub_08069E44(Entity* this) {
sub_0807DD94(this, NULL);
void sub_08069E44(DogEntity* this) {
ExecuteScriptAndHandleAnimation(super, NULL);
}
void sub_08069E50(Entity* this) {
this->animationState = GetAnimationState(this);
this->field_0x6a.HALF.HI = 8;
void sub_08069E50(DogEntity* this) {
super->animationState = GetAnimationState(super);
this->unk_6b = 8;
sub_0806A028(this);
UpdateAnimationSingleFrame(this);
if (this->animIndex > 0x1f) {
if ((this->frame & ANIM_DONE) == 0) {
UpdateAnimationSingleFrame(super);
if (super->animIndex > 0x1f) {
if ((super->frame & ANIM_DONE) == 0) {
return;
}
this->field_0x6a.HALF.HI = 8;
this->unk_6b = 8;
}
sub_08069FBC(this);
if (this->animIndex != this->field_0x6a.HALF.HI + this->animationState) {
InitAnimationForceUpdate(this, this->field_0x6a.HALF.HI + this->animationState);
if (super->animIndex != this->unk_6b + super->animationState) {
InitAnimationForceUpdate(super, this->unk_6b + super->animationState);
}
if (GetInventoryValue(ITEM_QST_DOGFOOD) == 2) {
this->action = 7;
InitAnimationForceUpdate(this, 0x29);
RemoveInteractableObject(this);
super->action = 7;
InitAnimationForceUpdate(super, 0x29);
RemoveInteractableObject(super);
EnqueueSFX(SFX_VO_DOG);
EnqueueSFX(SFX_TASK_COMPLETE);
}
}
void sub_08069ECC(Entity* this) {
if (UpdateFuseInteraction(this) != 0) {
void sub_08069ECC(DogEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
#ifdef EU
if (GetInventoryValue(ITEM_QST_DOGFOOD) != 2) {
this->action = 5;
super->action = 5;
} else {
this->action = 1;
super->action = 1;
}
#else
this->action = 1;
super->action = 1;
#endif
}
}
void sub_08069EE0(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08069EE0(DogEntity* this) {
UpdateAnimationSingleFrame(super);
}
void sub_08069EE8(Entity* this) {
this->action = 5;
void sub_08069EE8(DogEntity* this) {
super->action = 5;
}
bool32 sub_08069EF0(Entity* this) {
if (!LoadExtraSpriteData(this, &gUnk_08111D58[this->type * 3])) {
bool32 sub_08069EF0(DogEntity* this) {
if (!LoadExtraSpriteData(super, &gUnk_08111D58[super->type * 3])) {
return FALSE;
}
this->action = 1;
this->field_0x68.HWORD = gUnk_08111E30[this->type];
super->action = 1;
this->unk_68 = gUnk_08111E30[super->type];
return TRUE;
}
void Dog_Head(Entity* this) {
void Dog_Head(DogEntity* this) {
u32 frame;
frame = this->frame & ~ANIM_DONE;
frame = super->frame & ~ANIM_DONE;
if (frame != 0) {
frame += this->field_0x68.HWORD;
frame += this->unk_68;
}
SetExtraSpriteFrame(this, 0, frame - 1);
SetExtraSpriteFrame(this, 1, this->frameIndex);
SetSpriteSubEntryOffsetData1(this, 1, 0);
sub_0807000C(this);
SetExtraSpriteFrame(super, 0, frame - 1);
SetExtraSpriteFrame(super, 1, super->frameIndex);
SetSpriteSubEntryOffsetData1(super, 1, 0);
sub_0807000C(super);
}
void sub_08069F6C(Entity* this) {
this->animationState = sub_0806F5A4(this->direction);
if (this->animationState + 4 != this->animIndex) {
InitAnimationForceUpdate(this, this->animationState + 4);
void sub_08069F6C(DogEntity* this) {
super->animationState = GetAnimationStateForDirection4(super->direction);
if (super->animationState + 4 != super->animIndex) {
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
bool32 sub_08069F90(Entity* this) {
if ((this->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) {
bool32 sub_08069F90(DogEntity* this) {
if ((super->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) {
return TRUE;
} else {
return EntityInRectRadius(this, &gPlayerEntity, 0x14, 0x14);
return EntityInRectRadius(super, &gPlayerEntity, 0x14, 0x14);
}
}
void sub_08069FBC(Entity* this) {
void sub_08069FBC(DogEntity* this) {
u32 tmp = (gPlayerState.flags & PL_MINISH) != 0 ? 0x24 : 0x20;
if ((this->animationState == 1) || (this->animationState == 3)) {
this->field_0x6a.HALF.HI = tmp;
if ((super->animationState == 1) || (super->animationState == 3)) {
this->unk_6b = tmp;
}
}
void sub_08069FE8(Entity* this) {
void sub_08069FE8(DogEntity* this) {
u32 tmp;
if ((gPlayerState.flags & PL_MINISH) != 0) {
tmp = TRUE;
@@ -430,22 +449,22 @@ void sub_08069FE8(Entity* this) {
tmp = FALSE;
}
if (tmp != this->field_0x6a.HALF.LO) {
if (tmp != this->unk_6a) {
if (tmp == 0) {
AddInteractableWhenBigObject(this);
AddInteractableWhenBigObject(super);
} else {
AddInteractableAsMinishFuser(this, this->field_0x74.HALF.LO);
AddInteractableAsMinishFuser(super, this->unk_74);
}
}
this->field_0x6a.HALF.LO = tmp;
this->unk_6a = tmp;
}
void sub_0806A028(Entity* this) {
if (this->interactType != 0) {
void sub_0806A028(DogEntity* this) {
if (super->interactType != INTERACTION_NONE) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
if (this->interactType == 2) {
this->action = 6;
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 6;
InitializeNPCFusion(super);
} else {
sub_0806A080(this);
}
@@ -455,12 +474,12 @@ void sub_0806A028(Entity* this) {
SoundReq(SFX_VO_DOG);
ResetPlayerAnimationAndAction();
}
this->interactType = 0;
super->interactType = INTERACTION_NONE;
}
}
void sub_0806A080(Entity* this) {
ShowNPCDialogue(this, &(gUnk_08111E34[this->type2][gSave.global_progress]));
void sub_0806A080(DogEntity* this) {
ShowNPCDialogue(super, &(gUnk_08111E34[super->type2][gSave.global_progress]));
}
void sub_0806A0A4(Entity* this) {
@@ -501,15 +520,15 @@ void sub_0806A144(Entity* this) {
MessageNoOverlap(gUnk_08111FD8[dialog], this);
}
void Dog_Fusion(Entity* this) {
if (this->action == 0) {
void Dog_Fusion(DogEntity* this) {
if (super->action == 0) {
if (sub_08069EF0(this)) {
this->action++;
this->spriteSettings.draw = 1;
SetDefaultPriority(this, PRIO_MESSAGE);
InitializeAnimation(this, 0x23);
super->action++;
super->spriteSettings.draw = 1;
SetDefaultPriority(super, PRIO_MESSAGE);
InitializeAnimation(super, 0x23);
}
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
+9 -2
View File
@@ -1,6 +1,13 @@
#include "npc.h"
/**
* @file drLeft.c
* @ingroup NPCs
*
* @brief Dr Left NPC
*/
#define NENT_DEPRECATED
#include "functions.h"
#include "item.h"
#include "npc.h"
void sub_0806BFD8(Entity* this);
@@ -9,7 +16,7 @@ void DrLeft(Entity* this) {
if (this->action == 0) {
this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
InitScriptForNPC(this);
}
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
+9 -2
View File
@@ -1,3 +1,10 @@
/**
* @file emma.c
* @ingroup NPCs
*
* @brief Emma NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "screenTransitions.h"
@@ -7,9 +14,9 @@ void Emma(Entity* this) {
if (this->action == 0) {
this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
InitScriptForNPC(this);
} else {
sub_0807DD94(this, 0);
ExecuteScriptAndHandleAnimation(this, NULL);
}
}
+66 -54
View File
@@ -1,68 +1,80 @@
#include "global.h"
#include "sound.h"
/**
* @file epona.c
* @ingroup NPCs
*
* @brief Epona NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "message.h"
#include "npc.h"
#include "functions.h"
#include "sound.h"
void sub_08065A64(Entity* this);
void sub_08065AA4(Entity*);
void sub_080659B8(Entity*);
void sub_080659F0(Entity*);
void sub_08065A00(Entity*);
void sub_08065A10(Entity*);
void sub_08065A34(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 unk_69;
} EponaEntity;
void Epona(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void sub_08065A64(EponaEntity* this);
void sub_08065AA4(EponaEntity* this);
void sub_080659B8(EponaEntity* this);
void sub_080659F0(EponaEntity* this);
void sub_08065A00(EponaEntity* this);
void sub_08065A10(EponaEntity* this);
void sub_08065A34(EponaEntity* this);
void Epona(EponaEntity* this) {
static void (*const actionFuncs[])(EponaEntity*) = {
sub_080659B8, sub_080659F0, sub_08065A00, sub_08065A10, sub_08065A34,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
sub_08065A64(this);
sub_0806ED78(this);
sub_0806ED78(super);
}
void sub_080659B8(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->animationState = 6;
this->field_0x68.HALF.HI = -1;
this->field_0x68.HALF.LO = GetFusionToOffer(this);
InitAnimationForceUpdate(this, this->animationState / 2);
void sub_080659B8(EponaEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->animationState = 6;
this->unk_69 = -1;
this->fusionOffer = GetFusionToOffer(super);
InitAnimationForceUpdate(super, super->animationState / 2);
}
void sub_080659F0(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_080659F0(EponaEntity* this) {
UpdateAnimationSingleFrame(super);
sub_08065AA4(this);
}
void sub_08065A00(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08065A00(EponaEntity* this) {
UpdateAnimationSingleFrame(super);
sub_08065AA4(this);
}
void sub_08065A10(Entity* this) {
void sub_08065A10(EponaEntity* this) {
if ((gMessage.doTextBox & 0x7F) == 0) {
this->action = 1;
InitAnimationForceUpdate(this, this->animationState / 2);
super->action = 1;
InitAnimationForceUpdate(super, super->animationState / 2);
}
}
void sub_08065A34(Entity* this) {
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
InitAnimationForceUpdate(this, this->animationState / 2);
void sub_08065A34(EponaEntity* this) {
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
InitAnimationForceUpdate(super, super->animationState / 2);
}
}
void sub_08065A50(Entity* this) {
void sub_08065A50(EponaEntity* this) {
static const Dialog typeDialogs[] = {
{ 0, 0, DIALOG_MINISH, 1, { TEXT_INDEX(TEXT_LON_LON, 0X17), TEXT_INDEX(TEXT_TINGLE, 0x3c) } },
};
ShowNPCDialogue(this, &typeDialogs[this->type]);
ShowNPCDialogue(super, &typeDialogs[super->type]);
}
void sub_08065A64(Entity* this) {
void sub_08065A64(EponaEntity* this) {
u32 uVar2;
if ((gPlayerState.flags & PL_MINISH) != 0) {
@@ -71,43 +83,43 @@ void sub_08065A64(Entity* this) {
uVar2 = FALSE;
}
if (uVar2 != this->field_0x68.HALF.HI) {
if (uVar2 != this->unk_69) {
if (uVar2 == 0) {
AddInteractableWhenBigObject(this);
AddInteractableWhenBigObject(super);
} else {
AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO);
AddInteractableAsMinishFuser(super, this->fusionOffer);
}
}
this->field_0x68.HALF.HI = uVar2;
this->unk_69 = uVar2;
}
void sub_08065AA4(Entity* this) {
if (this->interactType != 0) {
void sub_08065AA4(EponaEntity* this) {
if (super->interactType != INTERACTION_NONE) {
if (gPlayerState.flags & PL_MINISH) {
if (this->interactType == 2) {
this->action = 4;
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 4;
InitializeNPCFusion(super);
} else {
this->action = 3;
SetDefaultPriority(this, PRIO_MESSAGE);
super->action = 3;
SetDefaultPriority(super, PRIO_MESSAGE);
sub_08065A50(this);
}
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)));
} else {
sub_08065A50(this);
ResetPlayerAnimationAndAction();
}
SoundReq(SFX_VO_EPONA);
this->interactType = 0;
super->interactType = INTERACTION_NONE;
}
}
void Epona_Fusion(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 7);
void Epona_Fusion(EponaEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
InitAnimationForceUpdate(super, 7);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
+8 -1
View File
@@ -1,3 +1,10 @@
/**
* @file ezlo.c
* @ingroup NPCs
*
* @brief Ezlo NPC
*/
#define NENT_DEPRECATED
#include "npc.h"
const u8 gUnk_08114134[];
@@ -8,7 +15,7 @@ void Ezlo(Entity* this) {
if (this->action == 0) {
this->action++;
SetDefaultPriority(this, PRIO_MESSAGE);
sub_0807DD50(this);
InitScriptForNPC(this);
}
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
+8 -1
View File
@@ -1,7 +1,14 @@
/**
* @file farmers.c
* @ingroup NPCs
*
* @brief Farmers NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "script.h"
#include "functions.h"
#include "npc.h"
#include "script.h"
static const SpriteLoadData gUnk_08113140[] = {
{ 0xf7, 0x48, 0x4 }, { 0x40f7, 0x48, 0x4 }, { 0, 0, 0 }, { 0xf8, 0x49, 0x4 }, { 0x40f8, 0x49, 0x4 }, { 0, 0, 0 },
+29 -17
View File
@@ -1,30 +1,42 @@
#include "global.h"
/**
* @file farore.c
* @ingroup NPCs
*
* @brief Farore NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "npc.h"
#include "kinstone.h"
void Farore(Entity* this) {
switch (this->action) {
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 animIndex;
} FaroreEntity;
void Farore(FaroreEntity* this) {
switch (super->action) {
case 0:
this->action = 1;
this->spriteSettings.draw = 1;
sub_0807DD50(this);
super->action = 1;
super->spriteSettings.draw = 1;
InitScriptForNPC(super);
break;
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
sub_0806F118(this);
this->field_0x68.HALF.LO = this->animIndex;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
InitializeNPCFusion(super);
this->animIndex = super->animIndex;
InitAnimationForceUpdate(super,
GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)));
} else {
sub_0807DD94(this, NULL);
ExecuteScriptAndHandleAnimation(super, NULL);
}
break;
case 2:
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
InitAnimationForceUpdate(this, this->field_0x68.HALF.LO);
if (UpdateFuseInteraction(super) != 0) {
super->action = 1;
InitAnimationForceUpdate(super, this->animIndex);
}
break;
}
@@ -32,7 +44,7 @@ void Farore(Entity* this) {
void Farore_MakeInteractable(Entity* this) {
u32 kinstoneId = GetFusionToOffer(this);
if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
if ((gSave.kinstones.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) {
kinstoneId = KINSTONE_NONE;
}
AddInteractableWhenBigFuser(this, kinstoneId);
+69 -54
View File
@@ -1,79 +1,94 @@
#include "global.h"
/**
* @file festari.c
* @ingroup NPCs
*
* @brief Festari NPC
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "npc.h"
void sub_0805FF2C(Entity*, ScriptExecutionContext*);
void sub_0805FE10(Entity* this);
void sub_0805FE48(Entity* this);
void sub_0805FF18(Entity* this);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 unused[23];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
/*0x84*/ ScriptExecutionContext* context;
} FestariEntity;
void Festari(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void sub_0805FF2C(FestariEntity* this, ScriptExecutionContext* context);
void sub_0805FE10(FestariEntity* this);
void sub_0805FE48(FestariEntity* this);
void sub_0805FF18(FestariEntity* this);
void Festari(FestariEntity* this) {
static void (*const actionFuncs[])(FestariEntity*) = {
sub_0805FE10,
sub_0805FE48,
sub_0805FF18,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void sub_0805FE10(Entity* this) {
this->action = 1;
this->spriteSettings.draw = TRUE;
SetDefaultPriority(this, PRIO_MESSAGE);
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
sub_0807DD50(this);
void sub_0805FE10(FestariEntity* this) {
super->action = 1;
super->spriteSettings.draw = TRUE;
SetDefaultPriority(super, PRIO_MESSAGE);
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
InitScriptForNPC(super);
}
void sub_0805FE48(Entity* this) {
void sub_0805FE48(FestariEntity* this) {
u32 uVar4;
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)));
InitializeNPCFusion(super);
} else {
ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh);
sub_0805FF2C(this, *(ScriptExecutionContext**)&this->cutsceneBeh);
uVar4 = this->field_0x80.HWORD;
ExecuteScript(super, this->context);
sub_0805FF2C(this, this->context);
uVar4 = this->unk_80;
if (uVar4 < 8) {
if ((this->field_0x82.HWORD & 1) != 0) {
uVar4 = (uVar4 & 0xfc) + (this->subtimer >> 1);
if ((this->unk_82 & 1) != 0) {
uVar4 = (uVar4 & 0xfc) + (super->subtimer >> 1);
} else {
uVar4 = (uVar4 & 0xfc) + (this->animationState >> 1);
this->subtimer = this->animationState;
uVar4 = (uVar4 & 0xfc) + (super->animationState >> 1);
super->subtimer = super->animationState;
}
}
if (uVar4 != this->animIndex) {
InitAnimationForceUpdate(this, uVar4);
if (uVar4 != super->animIndex) {
InitAnimationForceUpdate(super, uVar4);
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
if (this->frame & ANIM_DONE) {
switch (this->animIndex) {
if (super->frame & ANIM_DONE) {
switch (super->animIndex) {
case 8:
case 10:
case 11:
case 12:
this->field_0x80.HWORD = 0;
this->unk_80 = 0;
break;
}
}
if ((this->field_0x82.HWORD & (~this->field_0x82.HWORD + 1)) == 2) {
sub_0806ED78(this);
if ((this->unk_82 & (~this->unk_82 + 1)) == 2) {
sub_0806ED78(super);
}
}
}
void sub_0805FF18(Entity* this) {
if (UpdateFuseInteraction(this)) {
this->action = 1;
void sub_0805FF18(FestariEntity* this) {
if (UpdateFuseInteraction(super)) {
super->action = 1;
}
}
void sub_0805FF2C(Entity* this, ScriptExecutionContext* context) {
void sub_0805FF2C(FestariEntity* this, ScriptExecutionContext* context) {
u32 actions;
u32 bit;
@@ -86,35 +101,35 @@ void sub_0805FF2C(Entity* this, ScriptExecutionContext* context) {
actions ^= bit;
switch (bit) {
case 4:
this->field_0x80.HWORD = 9;
this->unk_80 = 9;
break;
case 0x200000:
this->field_0x80.HWORD = 10;
this->unk_80 = 10;
break;
case 0x400000:
if (this->animationState == 2) {
this->field_0x80.HWORD = 0xb;
if (super->animationState == 2) {
this->unk_80 = 0xb;
} else {
this->field_0x80.HWORD = 0xc;
this->unk_80 = 0xc;
}
break;
case 0x100000:
this->field_0x80.HWORD = 8;
this->unk_80 = 8;
break;
}
}
}
HandlePostScriptActions(this, context);
HandlePostScriptActions(super, context);
}
void Festari_Fusion(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
SetDefaultPriority(this, PRIO_MESSAGE);
InitAnimationForceUpdate(this, 8);
void Festari_Fusion(FestariEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
SetDefaultPriority(super, PRIO_MESSAGE);
InitAnimationForceUpdate(super, 8);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
+69 -52
View File
@@ -1,3 +1,10 @@
/**
* @file forestMinish.c
* @ingroup NPCs
*
* @brief Forest Minish NPC
*/
#define NENT_DEPRECATED
#include "functions.h"
#include "item.h"
#include "kinstone.h"
@@ -5,6 +12,15 @@
#include "object.h"
#include "playeritem.h"
#include "structures.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 fusionOffer;
/*0x69*/ u8 animIndex;
/*0x6a*/ u8 unused[22];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
/*0x84*/ ScriptExecutionContext* context;
} ForestMinishEntity;
const FrameStruct gUnk_08109C98[] = {
{ 36, 26 }, { 37, 26 }, { 38, 26 }, { 39, 155 }, { 40, 155 }, { 41, 155 }, { 42, 155 }, { 43, 152 },
@@ -499,44 +515,45 @@ const u16 gUnk_0810A362[] = {
TEXT_INDEX(TEXT_BELARI, 0x8),
};
static void sub_080600F0(Entity* this);
static void sub_080600F0(ForestMinishEntity* this);
extern void sub_08060158(ForestMinishEntity* this);
void ForestMinish(Entity* this) {
switch (this->action) {
void ForestMinish(ForestMinishEntity* this) {
switch (super->action) {
case 0:
if (LoadExtraSpriteData(this, gUnk_0810A348)) {
this->action = 1;
this->spriteSettings.draw = TRUE;
this->field_0x68.HALF.HI = this->animationState = this->timer << 1;
this->timer = 0;
SetDefaultPriority(this, PRIO_MESSAGE);
StartCutscene(this, (u16*)gUnk_08109D18[this->type2]);
sub_0807DD50(this);
if (LoadExtraSpriteData(super, gUnk_0810A348)) {
super->action = 1;
super->spriteSettings.draw = TRUE;
this->animIndex = super->animationState = super->timer << 1;
super->timer = 0;
SetDefaultPriority(super, PRIO_MESSAGE);
StartCutscene(super, (u16*)gUnk_08109D18[super->type2]);
InitScriptForNPC(super);
}
break;
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
sub_0806F118(this);
if (super->interactType == INTERACTION_FUSE) {
super->action = 2;
super->interactType = INTERACTION_NONE;
InitializeNPCFusion(super);
} else {
ExecuteScriptForEntity(this, NULL);
HandleEntity0x82Actions(this);
if (this->frameDuration != 0xf0) {
ExecuteScriptForEntity(super, NULL);
HandleEntity0x82Actions(super);
if (super->frameDuration != 0xf0) {
sub_080600F0(this);
}
}
break;
case 2:
if (UpdateFuseInteraction(this)) {
this->action = 1;
if (UpdateFuseInteraction(super)) {
super->action = 1;
}
}
}
void ForestMinish_MakeInteractable(Entity* this) {
this->field_0x68.HALF.LO = GetFusionToOffer(this);
AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO);
void ForestMinish_MakeInteractable(ForestMinishEntity* this) {
this->fusionOffer = GetFusionToOffer(super);
AddInteractableWhenBigFuser(super, this->fusionOffer);
}
void ForestMinish_Head(Entity* this) {
@@ -555,64 +572,64 @@ void ForestMinish_Head(Entity* this) {
sub_0807000C(this);
}
static void sub_080600F0(Entity* this) {
static void sub_080600F0(ForestMinishEntity* this) {
u32 uVar1;
u32 uVar2;
uVar2 = this->field_0x80.HWORD;
if (this->field_0x80.HWORD < 8) {
if ((this->field_0x82.HWORD & 1) != 0) {
uVar2 = (uVar2 & 0xfc) + (this->subtimer >> 1);
uVar2 = this->unk_80;
if (this->unk_80 < 8) {
if ((this->unk_82 & 1) != 0) {
uVar2 = (uVar2 & 0xfc) + (super->subtimer >> 1);
} else {
uVar2 = (uVar2 & 0xfc) + (this->animationState >> 1);
this->subtimer = this->animationState;
uVar2 = (uVar2 & 0xfc) + (super->animationState >> 1);
super->subtimer = super->animationState;
}
}
if (uVar2 != this->animIndex) {
InitAnimationForceUpdate(this, uVar2);
if (uVar2 != super->animIndex) {
InitAnimationForceUpdate(super, uVar2);
}
if ((this->field_0x82.HWORD & 4) != 0) {
if ((this->unk_82 & 4) != 0) {
uVar1 = 2;
} else {
uVar1 = 1;
}
sub_080042BA(this, uVar1);
sub_080042BA(super, uVar1);
}
void sub_0806014C(Entity* this) {
this->timer = 0;
void sub_0806014C(ForestMinishEntity* this) {
super->timer = 0;
sub_08060158(this);
}
void sub_08060158(Entity* this) {
void sub_08060158(ForestMinishEntity* this) {
int index;
const FrameStruct* idx3;
u8 tmp1, tmp2;
if (this->timer) {
this->timer--;
if (super->timer) {
super->timer--;
} else {
this->timer = 2;
index = GetFacingDirectionInRectRadius(this, 0x20, 0x20);
super->timer = 2;
index = GetFacingDirectionInRectRadius(super, 0x20, 0x20);
if (index < 0) {
int state = this->field_0x68.HALF.HI;
this->animationState = state;
int state = this->animIndex;
super->animationState = state;
index = state * 4;
}
idx3 = gUnk_08109C98 + (this->animationState / 2) * 0x10 + (index >> 1);
idx3 = gUnk_08109C98 + (super->animationState / 2) * 0x10 + (index >> 1);
tmp1 = idx3->frame;
tmp2 = idx3->frameIndex;
if (tmp2 & 0x80) {
this->animationState = sub_0806F5B0(index);
super->animationState = GetAnimationStateForDirection8(index);
}
tmp2 &= ~0x80;
this->frame = tmp1;
this->frameIndex = tmp2;
this->frameSpriteSettings = 1;
this->animIndex = 0;
this->frameDuration = 0xf0;
super->frame = tmp1;
super->frameIndex = tmp2;
super->frameSpriteSettings = 1;
super->animIndex = 0;
super->frameDuration = 0xf0;
}
}
@@ -706,13 +723,13 @@ void sub_08060318(void) {
}
void sub_08060340(void) {
gSave.timers[1] = gSave.unk50;
gSave.drug_kill_count = gSave.enemies_killed;
}
u32 sub_08060354(void) {
s32 iVar2;
iVar2 = gSave.unk50 - gSave.timers[1];
iVar2 = gSave.enemies_killed - gSave.drug_kill_count;
if (CheckGlobalFlag(DRUG_1) == 0) {
if (4 < iVar2) {
return 0x8444;

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