Merge branch 'master' into enemies

This commit is contained in:
octorock 2023-12-30 22:18:38 +01:00
commit 917ca10ba5
28 changed files with 843 additions and 839 deletions

View File

@ -1,6 +1,8 @@
.ifndef GUARD_ASM_MACROS_ENTITY_INC .ifndef GUARD_ASM_MACROS_ENTITY_INC
.set GUARD_ASM_MACROS_ENTITY_INC, 1 .set GUARD_ASM_MACROS_ENTITY_INC, 1
.set DEFAULT_POOL, 0xF
.set ENTITY_TYPE_ENEMY, 0x3 .set ENTITY_TYPE_ENEMY, 0x3
.set ENTITY_TYPE_SIGN, 0x5 .set ENTITY_TYPE_SIGN, 0x5
.set ENTITY_TYPE_OBJECT, 0x6 .set ENTITY_TYPE_OBJECT, 0x6
@ -14,7 +16,7 @@
.macro object_minish_lilypad x, y, room_property, collision=0 .macro object_minish_lilypad x, y, room_property, collision=0
.byte ENTITY_TYPE_OBJECT | ((\collision) << 4) .byte ENTITY_TYPE_OBJECT | ((\collision) << 4)
.byte 0x0F .byte DEFAULT_POOL
.byte OBJECT_MINISH_LILYPAD .byte OBJECT_MINISH_LILYPAD
.byte 0x00 .byte 0x00
.byte \room_property .byte \room_property
@ -25,7 +27,7 @@
.macro object_item x, y, item, flag, collision=0 .macro object_item x, y, item, flag, collision=0
.byte ENTITY_TYPE_OBJECT | ((\collision) << 4) .byte ENTITY_TYPE_OBJECT | ((\collision) << 4)
.byte 0x0F .byte DEFAULT_POOL
.byte OBJECT_ITEM .byte OBJECT_ITEM
.byte \item .byte \item
.byte 0x00 .byte 0x00
@ -37,7 +39,7 @@
.macro enemy_octorok x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0 .macro enemy_octorok x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4) .byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F .byte DEFAULT_POOL
.byte ENEMY_OCTOROK .byte ENEMY_OCTOROK
.byte 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00
.byte \bound_tile_width, \bound_tile_height .byte \bound_tile_width, \bound_tile_height
@ -47,7 +49,7 @@
.macro enemy_chuchu x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0 .macro enemy_chuchu x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4) .byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F .byte DEFAULT_POOL
.byte ENEMY_CHUCHU .byte ENEMY_CHUCHU
.byte 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00
.byte \bound_tile_width, \bound_tile_height .byte \bound_tile_width, \bound_tile_height
@ -57,16 +59,16 @@
.macro enemy_tree_item x, y, unknown, collision=0 .macro enemy_tree_item x, y, unknown, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4) .byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F .byte DEFAULT_POOL
.byte ENEMY_TREE_ITEM .byte ENEMY_TREE_ITEM
.byte \unknown, 0x00, 0x00, 0x00, 0x00 .byte \unknown, 0x00, 0x00, 0x00, 0x00
.2byte \x, \y .2byte \x, \y
.2byte 0x00, 0x00 .2byte 0x00, 0x00
.endm .endm
.macro entity_raw type:req, subtype:req, collision=0, unknown:req, paramA=0, paramB=0, x=0, y=0, paramC=0 .macro entity_raw type:req, subtype:req, collision=0, pool:req, paramA=0, paramB=0, x=0, y=0, paramC=0
.byte \type | ((\collision) << 4) .byte \type | ((\collision) << 4)
.byte \unknown .byte \pool
.byte \subtype .byte \subtype
.byte \paramA .byte \paramA
.4byte \paramB .4byte \paramB
@ -91,24 +93,24 @@
.2byte \flag2 .2byte \flag2
.endm .endm
.macro manager subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0 .macro manager subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=9, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC entity_raw type=9, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm .endm
.macro object_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0 .macro object_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=6, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC entity_raw type=6, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm .endm
.macro enemy_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0 .macro enemy_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=3, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC entity_raw type=3, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm .endm
.macro npc_raw subtype:req, collision=0, unknown=0x4f, paramA=0, paramB=0, x=0, y=0, script:req .macro npc_raw subtype:req, collision=0, pool=0x4f, paramA=0, paramB=0, x=0, y=0, script:req
entity_raw type=7, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\script entity_raw type=7, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\script
.endm .endm
.macro projectile_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0 .macro projectile_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=4, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC entity_raw type=4, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm .endm
.macro entity_list_end .macro entity_list_end

View File

@ -59,7 +59,7 @@ gUnk_080FED58:: @ 080FED58
.incbin "data_080FC8A4/gUnk_080FED58.bin" .incbin "data_080FC8A4/gUnk_080FED58.bin"
@ kinstone.c @ kinstone.c
gUnk_080FED98:: @ 080FED98 gLilypadRails:: @ 080FED98
.4byte gUnk_080FEDA4 .4byte gUnk_080FEDA4
.4byte gUnk_080FEDDA .4byte gUnk_080FEDDA
.4byte gUnk_080FEDF8 .4byte gUnk_080FEDF8

File diff suppressed because it is too large Load Diff

View File

@ -197,7 +197,7 @@ typedef enum {
WORLD_EVENT_TYPE_8, // set a tile type WORLD_EVENT_TYPE_8, // set a tile type
WORLD_EVENT_TYPE_9, // LoadRoomEntity and set some tile type WORLD_EVENT_TYPE_9, // LoadRoomEntity and set some tile type
WORLD_EVENT_TYPE_BEANSTALK, WORLD_EVENT_TYPE_BEANSTALK,
WORLD_EVENT_TYPE_11, // LoadRoomEntity and set gRoomVars.field_0x8c WORLD_EVENT_TYPE_11, // LoadRoomEntity and set gRoomVars.entityRails
WORLD_EVENT_TYPE_12, WORLD_EVENT_TYPE_12,
WORLD_EVENT_TYPE_13, WORLD_EVENT_TYPE_13,
WORLD_EVENT_TYPE_14, WORLD_EVENT_TYPE_14,

View File

@ -60,29 +60,26 @@ typedef struct {
extern RoomControls gRoomControls; extern RoomControls gRoomControls;
typedef struct { typedef struct {
/* 0x00 */ u8 field_0x0; /* 0x00 */ bool8 didEnterScrolling;
/* 0x01 */ u8 filler_0x1; /* 0x01 */ bool8 destructableManagerLoaded;
/* 0x02 */ bool8 randomDropsDisabled; /* 0x02 */ bool8 randomDropsDisabled;
/* 0x03 */ u8 field_0x3; /* 0x03 */ bool8 remFlagUnused;
/* 0x04 */ u8 field_0x4; /* 0x04 */ u8 numKinstoneDrops;
/* 0x05 */ u8 filler1[1]; /* 0x05 */ u8 numKinstoneDropsPrevFrame;
/* 0x06 */ u8 shopItemType; /* 0x06 */ u8 shopItemType;
/* 0x07 */ u8 shopItemType2; /* 0x07 */ u8 shopItemType2;
/* 0x08 */ u8 field_0x8; /* 0x08 */ u8 unused;
/* 0x09 */ u8 fight_bgm; /* 0x09 */ u8 fight_bgm;
/* 0x0a */ u8 unk2; /* 0x0a */ u8 needHealthDrop;
/* 0x0b */ u8 filler2;
/* 0x0c */ s16 lightLevel; /* 0x0c */ s16 lightLevel;
/* 0x0e */ u16 unk_0e; /* 0x0e */ u16 tileEntityCount;
/* 0x10 */ u8 unk_10[4]; /* 0x10 */ u8 graphicsGroups[4];
/* 0x14 */ u32 flags; /* 0x14 */ u8 flags[52];
/* 0x18 */ u32 unk3;
/* 0x1c */ u8 filler4[44];
/* 0x48 */ Droptable currentAreaDroptable; /* 0x48 */ Droptable currentAreaDroptable;
/* 0x68 */ u32 animFlags; /* 0x68 */ u32 animFlags;
/* 0x6c */ void* field_0x6c[8]; /* 0x6c */ void* properties[8];
/* 0x8c */ void* field_0x8c[8]; /* 0x8c */ void* entityRails[8];
/* 0xac */ Entity* entities[8]; /* 0xac */ Entity* puzzleEntities[8];
} RoomVars; } RoomVars;
static_assert(sizeof(RoomVars) == 0xCC); static_assert(sizeof(RoomVars) == 0xCC);
extern RoomVars gRoomVars; extern RoomVars gRoomVars;

View File

@ -27,7 +27,7 @@ extern u8 gUpdateVisibleTiles;
extern u16 gMapDataTopSpecial[]; extern u16 gMapDataTopSpecial[];
extern u16 gMapDataBottomSpecial[]; extern u16 gMapDataBottomSpecial[];
extern const u8 gGlobalGfxAndPalettes[]; extern const u8 gGlobalGfxAndPalettes[];
extern const u8 gUnk_081091E4[]; extern const u8 gEntityListLUT[];
typedef struct { typedef struct {
u16 tileType; u16 tileType;
@ -1084,7 +1084,7 @@ u32 sub_0801AC68(u32 position, u32 data) {
u32 end; u32 end;
ptr = gUnk_0200B240; ptr = gUnk_0200B240;
end = gRoomVars.unk_0e; end = gRoomVars.tileEntityCount;
for (index = 0; index < end; ptr++, index++) { for (index = 0; index < end; ptr++, index++) {
if (position == ptr->position) { if (position == ptr->position) {
return ptr->data << 2; return ptr->data << 2;
@ -1150,7 +1150,7 @@ void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
entity->y.HALF.HI = tmpY1 + gRoomControls.origin_y; entity->y.HALF.HI = tmpY1 + gRoomControls.origin_y;
entity->collisionLayer = 0; entity->collisionLayer = 0;
ResolveCollisionLayer(entity); ResolveCollisionLayer(entity);
AppendEntityToList(entity, gUnk_081091E4[entity->kind]); AppendEntityToList(entity, gEntityListLUT[entity->kind]);
} }
} else { } else {
manager = GetEmptyManager(); manager = GetEmptyManager();
@ -1164,7 +1164,7 @@ void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
*(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x; *(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x;
tmpY2 = (s16)((tilePosition & 0xfc0) >> 2) + 8; tmpY2 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
*(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y; *(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y;
AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->kind]); AppendEntityToList((Entity*)manager, gEntityListLUT[manager->kind]);
} }
} }
} }
@ -1224,11 +1224,11 @@ void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer) {
void sub_0801AF48(u32 data, u32 position, u32 layer) { void sub_0801AF48(u32 data, u32 position, u32 layer) {
u32 index; u32 index;
if ((data < 0x4000) && (gRoomTransition.field30 == 0)) { if ((data < 0x4000) && (gRoomTransition.field30 == 0)) {
index = gRoomVars.unk_0e; index = gRoomVars.tileEntityCount;
if (index < 0x100) { if (index < 0x100) {
gUnk_0200B240[index].data = data; gUnk_0200B240[index].data = data;
gUnk_0200B240[index].position = (layer << 0xc) | position; gUnk_0200B240[index].position = (layer << 0xc) | position;
gRoomVars.unk_0e = index + 1; gRoomVars.tileEntityCount = index + 1;
} }
} }
} }
@ -1242,7 +1242,7 @@ void DeleteLoadedTileEntity(u32 position, s32 layer) {
layer = layer << 12; layer = layer << 12;
positionLayer = position | layer; positionLayer = position | layer;
ptr = gUnk_0200B240; ptr = gUnk_0200B240;
count = gRoomVars.unk_0e; count = gRoomVars.tileEntityCount;
t = 0; t = 0;
if (t >= count) { if (t >= count) {
@ -1251,7 +1251,7 @@ void DeleteLoadedTileEntity(u32 position, s32 layer) {
if (positionLayer == ptr->position) { if (positionLayer == ptr->position) {
count--; count--;
gRoomVars.unk_0e = count; gRoomVars.tileEntityCount = count;
ptr[0] = ptr[count]; ptr[0] = ptr[count];
return; return;
} }
@ -1263,7 +1263,7 @@ void DeleteLoadedTileEntity(u32 position, s32 layer) {
} }
} }
count--; count--;
gRoomVars.unk_0e = count; gRoomVars.tileEntityCount = count;
ptr = gUnk_0200B240; ptr = gUnk_0200B240;
ptr[t] = ptr[count]; ptr[t] = ptr[count];
} }

View File

@ -75,45 +75,42 @@ void sub_0802C318(FallingBoulderEntity* this) {
} }
void sub_0802C334(FallingBoulderEntity* this) { void sub_0802C334(FallingBoulderEntity* this) {
register Entity* entity asm("r2"); Entity* entity;
u32 diff; u32 roomOriginY, tmp;
u16 tmp; s32 y, i;
if (this->unk_7c == 0) { if (this->unk_7c == 0) {
u32 tmp = gRoomControls.origin_y; roomOriginY = gRoomControls.origin_y;
entity = &gPlayerEntity.base; entity = &gPlayerEntity.base;
if (entity == NULL) if (entity == NULL)
return; return;
if (entity->y.HALF.HI - tmp <= 0x38) { tmp = entity->y.HALF.HI;
if (0x38 >= tmp - roomOriginY)
return; return;
}
this->unk_7c = 1; this->unk_7c = 1;
super->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
} }
GetNextFrame(super); GetNextFrame(super);
this->unk_7e = COORD_TO_TILE(super); this->unk_7e = COORD_TO_TILE(super);
if (sub_080044EC(super, this->unk_84) == 1) { if (sub_080044EC(super, this->unk_84) == 1) {
EnqueueSFX(0x14c); EnqueueSFX(0x14c);
COLLISION_ON(super); COLLISION_ON(super);
this->unk_7a = 0xc; this->unk_7a = 12;
sub_0802C4B0(this); sub_0802C4B0(this);
} else { } else {
s32 y;
if (this->unk_7a) { if (this->unk_7a) {
tmp = --this->unk_7a; switch (--this->unk_7a) {
switch (tmp) {
case 0: case 0:
COLLISION_OFF(super); COLLISION_OFF(super);
break; break;
case 8: case 8:
if (super->type2 != 0 && !sub_08049FA0(super)) { if (super->type2 != 0 && !sub_08049FA0(super)) {
diff = 0; for (i = 0; i < 2; i++) {
for (y = 1; y > -1; y--) {
entity = CreateFx(super, FX_ROCK2, 0); entity = CreateFx(super, FX_ROCK2, 0);
if (entity) { if (entity) {
entity->x.HALF.HI = entity->x.HALF.HI + 12 - diff; entity->x.HALF.HI += 12 - i * 0x18;
} }
diff += 0x18;
} }
sub_0802C62C(this); sub_0802C62C(this);
this->unk_7a = (Random() & 0xff) | 0x100; this->unk_7a = (Random() & 0xff) | 0x100;
@ -122,11 +119,9 @@ void sub_0802C334(FallingBoulderEntity* this) {
break; break;
} }
} }
roomOriginY = gRoomControls.origin_y;
{ tmp = gRoomControls.height;
FORCE_REGISTER(RoomControls * tmp, r0) = &gRoomControls; y = roomOriginY + tmp - super->y.HALF.HI;
y = tmp->origin_y + tmp->height - super->y.HALF.HI;
}
if (y >= 5) { if (y >= 5) {
ProcessMovement1(super); ProcessMovement1(super);
@ -141,6 +136,7 @@ void sub_0802C334(FallingBoulderEntity* this) {
} }
} }
} }
super->collisionLayer = 3; super->collisionLayer = 3;
super->spritePriority.b0 = 1; super->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(super); UpdateSpriteForCollisionLayer(super);

View File

@ -40,51 +40,54 @@ typedef struct {
extern UpdateContext gUpdateContext; extern UpdateContext gUpdateContext;
// List by entity kind. // List by entity kind.
const u8 gUnk_081091E4[] = { const u8 gEntityListLUT[] = {
8, 1, 8, 4, 5, 8, 6, 7, 2, 6, 8, 1, 8, 4, 5, 8, 6, 7, 2, 6,
}; };
// TODO: wrong file, maybe an "enter.c" according to lexicographical order
void sub_0805E248(void) { void sub_0805E248(void) {
s32 v0; s32 idx;
v0 = gDiggingCaveEntranceTransition.entrance->targetTilePosition; idx = gDiggingCaveEntranceTransition.entrance->targetTilePosition;
if (gRoomControls.area == AREA_VEIL_FALLS || gRoomControls.area == AREA_VEIL_FALLS_DIG_CAVE) { if (gRoomControls.area == AREA_VEIL_FALLS || gRoomControls.area == AREA_VEIL_FALLS_DIG_CAVE) {
SetTileType(0x27c, v0 + TILE_POS(-1, -1), 1); SetTileType(0x27c, idx + TILE_POS(-1, -1), 1);
SetTileType(0x283, v0 + TILE_POS(-1, -1), 2); SetTileType(0x283, idx + TILE_POS(-1, -1), 2);
SetTileType(0x27d, v0 + TILE_POS(0, -1), 1); SetTileType(0x27d, idx + TILE_POS(0, -1), 1);
SetTileType(0x284, v0 + TILE_POS(0, -1), 2); SetTileType(0x284, idx + TILE_POS(0, -1), 2);
SetTileType(0x27e, v0 + TILE_POS(1, -1), 1); SetTileType(0x27e, idx + TILE_POS(1, -1), 1);
SetTileType(0x285, v0 + TILE_POS(1, -1), 2); SetTileType(0x285, idx + TILE_POS(1, -1), 2);
SetTileType(0x27f, v0 + TILE_POS(-1, 0), 1); SetTileType(0x27f, idx + TILE_POS(-1, 0), 1);
SetTileType(0x280, v0 + TILE_POS(0, 0), 1); SetTileType(0x280, idx + TILE_POS(0, 0), 1);
SetTileType(0x282, v0 + TILE_POS(1, 0), 1); SetTileType(0x282, idx + TILE_POS(1, 0), 1);
} else { } else {
SetTileType(0x26c, v0 + TILE_POS(-1, -1), 1); SetTileType(0x26c, idx + TILE_POS(-1, -1), 1);
SetTileType(0x273, v0 + TILE_POS(-1, -1), 2); SetTileType(0x273, idx + TILE_POS(-1, -1), 2);
SetTileType(0x26d, v0 + TILE_POS(0, -1), 1); SetTileType(0x26d, idx + TILE_POS(0, -1), 1);
SetTileType(0x274, v0 + TILE_POS(0, -1), 2); SetTileType(0x274, idx + TILE_POS(0, -1), 2);
SetTileType(0x26e, v0 + TILE_POS(1, -1), 1); SetTileType(0x26e, idx + TILE_POS(1, -1), 1);
SetTileType(0x275, v0 + TILE_POS(1, -1), 2); SetTileType(0x275, idx + TILE_POS(1, -1), 2);
SetTileType(0x26f, v0 + TILE_POS(-1, 0), 1); SetTileType(0x26f, idx + TILE_POS(-1, 0), 1);
SetTileType(0x270, v0 + TILE_POS(0, 0), 1); SetTileType(0x270, idx + TILE_POS(0, 0), 1);
SetTileType(0x272, v0 + TILE_POS(1, 0), 1); SetTileType(0x272, idx + TILE_POS(1, 0), 1);
} }
gUpdateVisibleTiles = 0; gUpdateVisibleTiles = 0;
} }
const u8 gUnk_081091EE[] = { const u8 gPrioritiesDefault[] = {
0, 1, 0, 0, 0, 0, 1, 1, 1, 1, [0] = 0, [PLAYER] = 1, [2] = 0, [ENEMY] = 0, [PROJECTILE] = 0,
[5] = 0, [OBJECT] = 1, [NPC] = 1, [PLAYER_ITEM] = 1, [MANAGER] = 1,
}; };
const u8 gUnk_081091F8[] = { const u8 gPrioritiesKinstoneMenu[] = {
0, 3, 0, 3, 3, 0, 3, 3, 3, 3, [0] = 0, [PLAYER] = 3, [2] = 0, [ENEMY] = 3, [PROJECTILE] = 3,
[5] = 0, [OBJECT] = 3, [NPC] = 3, [PLAYER_ITEM] = 3, [MANAGER] = 3,
}; };
void SetEntityPriorityForKind(Entity* e) { void InitDefaultPriority(Entity* e) {
u8 r3 = gRoomTransition.entity_update_type; u8 r3 = gRoomTransition.entity_update_type;
const u8* array = gUnk_081091F8; const u8* array = gPrioritiesKinstoneMenu;
if (r3 != 2) { if (r3 != 2) {
array = gUnk_081091EE; array = gPrioritiesDefault;
} }
SetEntityPriority(e, array[e->kind]); SetEntityPriority(e, array[e->kind]);
} }
@ -214,8 +217,10 @@ void ClearEventPriority(void) {
void UpdateEntities(void) { void UpdateEntities(void) {
void (*f)(u32); void (*f)(u32);
gRoomVars.filler1[0] = gRoomVars.field_0x4; // TODO: why is this needed? Does this avoid a bug?
gRoomVars.field_0x4 = 0; gRoomVars.numKinstoneDropsPrevFrame = gRoomVars.numKinstoneDrops;
gRoomVars.numKinstoneDrops = 0;
UpdatePlayerInput(); UpdatePlayerInput();
UpdatePriority(); UpdatePriority();
ClearHitboxList(); ClearHitboxList();
@ -505,7 +510,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) {
} else { } else {
gManagerCount++; gManagerCount++;
} }
SetEntityPriorityForKind(entity); InitDefaultPriority(entity);
} }
void PrependEntityToList(Entity* entity, u32 listIndex) { void PrependEntityToList(Entity* entity, u32 listIndex) {

View File

@ -236,7 +236,7 @@ static void GameMain_ChangeRoom(void) {
} }
CreateMiscManager(); CreateMiscManager();
#endif #endif
if (!gRoomVars.field_0x0) { if (!gRoomVars.didEnterScrolling) {
RequestPriorityDuration(NULL, 1); RequestPriorityDuration(NULL, 1);
} }
} }
@ -355,7 +355,7 @@ static void InitializeEntities(void) {
static void sub_08051D98(void) { static void sub_08051D98(void) {
sub_08052EA0(); sub_08052EA0();
gRoomVars.field_0x0 = 1; gRoomVars.didEnterScrolling = TRUE;
// remove old entities, unless persistent // remove old entities, unless persistent
RecycleEntities(); RecycleEntities();

View File

@ -495,8 +495,8 @@ extern EntityData gUnk_080FECC8[];
extern EntityData gUnk_080FEC28[]; extern EntityData gUnk_080FEC28[];
extern const EntityData gUnk_080FED18[]; extern const EntityData gUnk_080FED18[];
extern EntityData gUnk_080FED58[]; extern EntityData gUnk_080FED58[];
// TODO need to find out what gRoomVars.field_0x8c[ptr->entity_idx] is. // TODO need to find out what gRoomVars.entityRails[ptr->entity_idx] is.
extern const void* gUnk_080FED98[]; extern const void* gLilypadRails[];
// gUnk_080FEDA4 // gUnk_080FEDA4
// gUnk_080FEDDA // gUnk_080FEDDA
// gUnk_080FEDF8 // gUnk_080FEDF8

View File

@ -571,10 +571,10 @@ RoomResInfo* GetCurrentRoomInfo(void) {
void sub_08052EA0(void) { void sub_08052EA0(void) {
MemClear(&gRoomVars, sizeof gRoomVars); MemClear(&gRoomVars, sizeof gRoomVars);
gRoomVars.unk_10[0] = -1; gRoomVars.graphicsGroups[0] = -1;
gRoomVars.unk_10[1] = gRoomVars.unk_10[0]; gRoomVars.graphicsGroups[1] = gRoomVars.graphicsGroups[0];
gRoomVars.unk_10[2] = gRoomVars.unk_10[0]; gRoomVars.graphicsGroups[2] = gRoomVars.graphicsGroups[0];
gRoomVars.unk_10[3] = gRoomVars.unk_10[0]; gRoomVars.graphicsGroups[3] = gRoomVars.graphicsGroups[0];
gRoomVars.lightLevel = 256; gRoomVars.lightLevel = 256;
gArea.locationIndex = gAreaMetadata[gRoomControls.area].location; gArea.locationIndex = gAreaMetadata[gRoomControls.area].location;
UpdateRoomTracker(); UpdateRoomTracker();
@ -601,7 +601,7 @@ void UpdateFakeScroll(void) {
LinkedList* ll; LinkedList* ll;
Entity* e; Entity* e;
if (gArea.unk_0c_0 == 0 || !gRoomVars.field_0x0) if (gArea.unk_0c_0 == 0 || !gRoomVars.didEnterScrolling)
return; return;
y = 0; y = 0;
@ -727,7 +727,7 @@ void CheckAreaDiscovery(void) {
e->kind = MANAGER; e->kind = MANAGER;
e->id = ENTER_ROOM_TEXTBOX_MANAGER; e->id = ENTER_ROOM_TEXTBOX_MANAGER;
AppendEntityToList(e, 8); AppendEntityToList(e, 8);
if (!gRoomVars.field_0x0 && !ReadBit(gSave.areaVisitFlags, gArea.locationIndex)) { if (!gRoomVars.didEnterScrolling && !ReadBit(gSave.areaVisitFlags, gArea.locationIndex)) {
e->type2 = 1; e->type2 = 1;
SetPlayerControl(3); SetPlayerControl(3);
SetInitializationPriority(); SetInitializationPriority();

View File

@ -198,39 +198,39 @@ void WaitForNextFrame(void) {
FadeVBlank(); FadeVBlank();
} }
void PlayerUpdate(Entity* this) { void PlayerUpdate(PlayerEntity* this) {
if (gSave.stats.effect != 0) if (gSave.stats.effect != 0)
gPlayerState.flags |= PL_DRUGGED; gPlayerState.flags |= PL_DRUGGED;
else else
gPlayerState.flags &= ~PL_DRUGGED; gPlayerState.flags &= ~PL_DRUGGED;
if (!EntityDisabled(this)) { if (!EntityDisabled(super)) {
if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) {
PutAwayItems(); PutAwayItems();
if (gPlayerState.flags & PL_MOLDWORM_RELEASED) { if (gPlayerState.flags & PL_MOLDWORM_RELEASED) {
gPlayerState.queued_action = PLAYER_ROLL; gPlayerState.queued_action = PLAYER_ROLL;
gPlayerState.flags &= ~PL_MOLDWORM_CAPTURED; gPlayerState.flags &= ~PL_MOLDWORM_CAPTURED;
gPlayerState.hurtBlinkSpeed = 240; gPlayerState.hurtBlinkSpeed = 240;
COLLISION_ON(this); COLLISION_ON(super);
} else { } else {
COLLISION_OFF(this); COLLISION_OFF(super);
gPlayerState.framestate = PL_STATE_F; gPlayerState.framestate = PL_STATE_F;
} }
} }
HandlePlayerLife(this); HandlePlayerLife(super);
DoPlayerAction(this); DoPlayerAction(this);
if ((this->z.WORD == 0) && (this->action == 1 || this->action == 9)) if ((super->z.WORD == 0) && (super->action == 1 || super->action == 9))
sub_08008790(this, 8); sub_08008790(super, 8);
sub_080171F0(); sub_080171F0();
} }
sub_08078FB0(this); sub_08078FB0(super);
DrawEntity(this); DrawEntity(super);
UpdatePlayerPalette(); UpdatePlayerPalette();
} }
// Responsible for some life things like low health beep and initiating the death sequence // Responsible for some life things like low health beep and initiating the death sequence
static void HandlePlayerLife(Entity* this) { static void HandlePlayerLife(Entity* this) {
u32 temp; u32 threshold;
gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE; gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE;
gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE; gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE;
@ -263,26 +263,27 @@ static void HandlePlayerLife(Entity* this) {
#ifdef EU #ifdef EU
if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) { if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) {
temp = gSave.stats.maxHealth / 4; threshold = gSave.stats.maxHealth / 4;
if (temp > 24) if (threshold > 24)
temp = 24; threshold = 24;
if (temp < 8) if (threshold < 8)
temp = 8; threshold = 8;
if (gSave.stats.health <= temp) { if (gSave.stats.health <= threshold) {
EnqueueSFX(SFX_LOW_HEALTH); EnqueueSFX(SFX_LOW_HEALTH);
} }
} }
#else #else
gRoomVars.unk2 = gMessage.state & MESSAGE_ACTIVE; // TODO: why does message state affect health drops in US/JP?
temp = gSave.stats.maxHealth / 4; gRoomVars.needHealthDrop = gMessage.state & MESSAGE_ACTIVE;
if (temp > 24) threshold = gSave.stats.maxHealth / 4;
temp = 24; if (threshold > 24)
if (temp < 8) threshold = 24;
temp = 8; if (threshold < 8)
threshold = 8;
if (gSave.stats.health <= temp) { if (gSave.stats.health <= threshold) {
gRoomVars.unk2 = 1; gRoomVars.needHealthDrop = TRUE;
if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) { if ((gUnk_0200AF00.unk_1 == 0) && gRoomTransition.frameCount % 90 == 0) {
EnqueueSFX(SFX_LOW_HEALTH); EnqueueSFX(SFX_LOW_HEALTH);
} }

View File

@ -428,7 +428,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) {
#ifndef EU #ifndef EU
case 24: case 24:
case 25: case 25:
r0 = gRoomVars.unk2; r0 = gRoomVars.needHealthDrop;
ptr4 = &gUnk_0800191C[0]; ptr4 = &gUnk_0800191C[0];
if (r0) { if (r0) {
ptr4++; ptr4++;
@ -545,7 +545,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) {
if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0) { if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0) {
return ITEM_NONE; return ITEM_NONE;
} }
if (3 < gRoomVars.filler1[0]) { if (3 < gRoomVars.numKinstoneDropsPrevFrame) {
return ITEM_NONE; return ITEM_NONE;
} }

View File

@ -22,7 +22,7 @@ extern const EntityData gUnk_080FEE38[];
extern const EntityData gUnk_080FEE18[]; extern const EntityData gUnk_080FEE18[];
extern const EntityData gUnk_080FEE48[]; extern const EntityData gUnk_080FEE48[];
extern const EntityData gUnk_080FEE58[]; extern const EntityData gUnk_080FEE58[];
extern const void* gUnk_080FED98[]; extern const void* gLilypadRails[];
void sub_08018AB4(int); void sub_08018AB4(int);
void sub_08018BB4(u32 worldEventId); void sub_08018BB4(u32 worldEventId);
@ -339,8 +339,9 @@ void sub_0801876C(u32 worldEventId, bool32 isKinstoneFused) {
break; break;
case WORLD_EVENT_TYPE_11: case WORLD_EVENT_TYPE_11:
if (isKinstoneFused != 0) { if (isKinstoneFused != 0) {
// lilypad rails
LoadRoomEntity(&gUnk_080FED58[ptr->entity_idx]); LoadRoomEntity(&gUnk_080FED58[ptr->entity_idx]);
gRoomVars.field_0x8c[ptr->entity_idx] = (void*)gUnk_080FED98[ptr->entity_idx]; gRoomVars.entityRails[ptr->entity_idx] = (void*)gLilypadRails[ptr->entity_idx];
} }
break; break;
case WORLD_EVENT_TYPE_9: case WORLD_EVENT_TYPE_9:

View File

@ -29,7 +29,7 @@ void HorizontalMinishPathBackgroundManager_Main(HorizontalMinishPathBackgroundMa
} }
void sub_08057EFC(void* this) { void sub_08057EFC(void* this) {
LoadGfxGroup((u32)gRoomVars.unk_10[0]); LoadGfxGroup((u32)gRoomVars.graphicsGroups[0]);
sub_08058034(); sub_08058034();
((HorizontalMinishPathBackgroundManager*)this)->unk_3c = 0; ((HorizontalMinishPathBackgroundManager*)this)->unk_3c = 0;
((HorizontalMinishPathBackgroundManager*)this)->unk_38 = 0; ((HorizontalMinishPathBackgroundManager*)this)->unk_38 = 0;
@ -103,7 +103,7 @@ void sub_080580B0(u32 unk1) {
gMapTop.bgSettings = 0; gMapTop.bgSettings = 0;
REG_DISPCNT = 0; REG_DISPCNT = 0;
LoadGfxGroup(unk1); LoadGfxGroup(unk1);
gRoomVars.unk_10[0] = unk1; gRoomVars.graphicsGroups[0] = unk1;
sub_08058034(); sub_08058034();
tmp = gRoomControls.scroll_x - gRoomControls.origin_x; tmp = gRoomControls.scroll_x - gRoomControls.origin_x;
tmp = tmp + (tmp >> 3) + (0x400 - gRoomControls.width) / 2; tmp = tmp + (tmp >> 3) + (0x400 - gRoomControls.width) / 2;

View File

@ -72,9 +72,9 @@ void HyruleTownTilesetManager_Main(HyruleTownTilesetManager* this) {
} }
void sub_08059A2C(HyruleTownTilesetManager* this) { void sub_08059A2C(HyruleTownTilesetManager* this) {
gRoomVars.unk_10[2] = 0xff; gRoomVars.graphicsGroups[2] = 0xff;
gRoomVars.unk_10[1] = 0xff; gRoomVars.graphicsGroups[1] = 0xff;
gRoomVars.unk_10[0] = 0xff; gRoomVars.graphicsGroups[0] = 0xff;
this->field_0x22 = 0xff; this->field_0x22 = 0xff;
this->field_0x21 = 0xff; this->field_0x21 = 0xff;
this->field_0x20 = 0xff; this->field_0x20 = 0xff;
@ -147,8 +147,8 @@ bool32 sub_08059C8C(HyruleTownTilesetManager* this, u32 param_2, u8* param_3, co
bool32 bVar2; bool32 bVar2;
*param_3 = CheckRegionsOnScreen(param_4); *param_3 = CheckRegionsOnScreen(param_4);
if ((*param_3 != 0xff) && (gRoomVars.unk_10[param_2] != *param_3)) { if ((*param_3 != 0xff) && (gRoomVars.graphicsGroups[param_2] != *param_3)) {
gRoomVars.unk_10[param_2] = *param_3; gRoomVars.graphicsGroups[param_2] = *param_3;
return TRUE; return TRUE;
} else { } else {
return FALSE; return FALSE;
@ -158,7 +158,7 @@ bool32 sub_08059C8C(HyruleTownTilesetManager* this, u32 param_2, u8* param_3, co
void sub_08059CC0(u32 param_1, u32 param_2) { void sub_08059CC0(u32 param_1, u32 param_2) {
const Unknown* unknown; const Unknown* unknown;
gRoomVars.unk_10[param_1] = param_2; gRoomVars.graphicsGroups[param_1] = param_2;
if (gRoomControls.area != AREA_FESTIVAL_TOWN) { if (gRoomControls.area != AREA_FESTIVAL_TOWN) {
unknown = &gUnk_08108408[param_2]; unknown = &gUnk_08108408[param_2];
} else { } else {

View File

@ -69,7 +69,7 @@ void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) {
return; return;
if (sub_08057E40(this)) { if (sub_08057E40(this)) {
tmp = (u32)gRoomVars.unk_10[0]; tmp = (u32)gRoomVars.graphicsGroups[0];
if (this->unk_20 != tmp) { if (this->unk_20 != tmp) {
this->unk_20 = tmp; this->unk_20 = tmp;
super->timer = 0; super->timer = 0;
@ -115,7 +115,7 @@ void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) {
RegisterTransitionManager(this, sub_08057E30, 0); RegisterTransitionManager(this, sub_08057E30, 0);
} }
if (sub_08057E40(this)) { if (sub_08057E40(this)) {
tmp = (u32)gRoomVars.unk_10[0]; tmp = (u32)gRoomVars.graphicsGroups[0];
if (this->unk_20 != tmp) { if (this->unk_20 != tmp) {
this->unk_20 = tmp; this->unk_20 = tmp;
super->timer = 0; super->timer = 0;
@ -153,13 +153,13 @@ void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) {
#endif #endif
void sub_08057E30(void* this) { void sub_08057E30(void* this) {
sub_08057E7C(gRoomVars.unk_10[0]); sub_08057E7C(gRoomVars.graphicsGroups[0]);
} }
bool32 sub_08057E40(MinishVillageTilesetManager* this) { bool32 sub_08057E40(MinishVillageTilesetManager* this) {
u32 tmp = CheckRegionsOnScreen(gUnk_08108050); u32 tmp = CheckRegionsOnScreen(gUnk_08108050);
if (tmp != 0xFF) { if (tmp != 0xFF) {
gRoomVars.unk_10[0] = tmp; gRoomVars.graphicsGroups[0] = tmp;
return TRUE; return TRUE;
} else { } else {
return FALSE; return FALSE;
@ -187,5 +187,5 @@ void sub_08057E7C(u32 unk1) {
for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) { for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) {
DmaCopy32(3, &gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x400 * 4); DmaCopy32(3, &gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x400 * 4);
} }
gRoomVars.unk_10[0] = unk1; gRoomVars.graphicsGroups[0] = unk1;
} }

View File

@ -392,7 +392,7 @@ void MiscManager_TypeD(MiscManager* this) {
SetPlayerControl(3); SetPlayerControl(3);
if (gRoomControls.reload_flags) if (gRoomControls.reload_flags)
return; return;
if (gRoomVars.field_0x0) { if (gRoomVars.didEnterScrolling) {
StartPlayerScript(gUnk_08108380[gRoomControls.scroll_direction]); StartPlayerScript(gUnk_08108380[gRoomControls.scroll_direction]);
} else { } else {
StartPlayerScript(gUnk_08108380[gPlayerEntity.base.animationState >> 1]); StartPlayerScript(gUnk_08108380[gPlayerEntity.base.animationState >> 1]);

View File

@ -51,7 +51,7 @@ void sub_080575C8(u32 param) {
gMapTop.bgSettings = 0; gMapTop.bgSettings = 0;
REG_DISPCNT = 0; REG_DISPCNT = 0;
LoadGfxGroup(param); LoadGfxGroup(param);
gRoomVars.unk_10[0] = param; gRoomVars.graphicsGroups[0] = param;
bgOffset = (gRoomControls.scroll_y - gRoomControls.origin_y); bgOffset = (gRoomControls.scroll_y - gRoomControls.origin_y);
bgOffset += bgOffset >> 3; bgOffset += bgOffset >> 3;
@ -80,7 +80,7 @@ void sub_08057688(void) {
} }
void sub_080576A0(void* this) { void sub_080576A0(void* this) {
LoadGfxGroup(gRoomVars.unk_10[0]); LoadGfxGroup(gRoomVars.graphicsGroups[0]);
((VerticalMinishPathBackgroundManager*)this)->field_0x38 = NULL; ((VerticalMinishPathBackgroundManager*)this)->field_0x38 = NULL;
((VerticalMinishPathBackgroundManager*)this)->field_0x3c = NULL; ((VerticalMinishPathBackgroundManager*)this)->field_0x3c = NULL;
sub_0805754C((VerticalMinishPathBackgroundManager*)this); sub_0805754C((VerticalMinishPathBackgroundManager*)this);

View File

@ -46,7 +46,7 @@ void WeatherChangeManager_Main(WeatherChangeManager* this) {
this->unk_20 = 0x1F; this->unk_20 = 0x1F;
this->unk_22 = 5; this->unk_22 = 5;
} }
gRoomVars.unk_10[0] = 0xFF; gRoomVars.graphicsGroups[0] = 0xFF;
RegisterTransitionManager(this, sub_080595E4, 0); RegisterTransitionManager(this, sub_080595E4, 0);
} }
sub_08059608(this); sub_08059608(this);
@ -55,7 +55,7 @@ void WeatherChangeManager_Main(WeatherChangeManager* this) {
} }
void sub_080595E4(WeatherChangeManager* this) { void sub_080595E4(WeatherChangeManager* this) {
gRoomVars.unk_10[0] = 0xFF; gRoomVars.graphicsGroups[0] = 0xFF;
sub_08059690(this); sub_08059690(this);
sub_080596E0(this); sub_080596E0(this);
LoadStaticBackground(0); LoadStaticBackground(0);
@ -134,8 +134,8 @@ void sub_080596E0(WeatherChangeManager* this) {
} }
break; break;
} }
if (gRoomVars.unk_10[0] != this->unk_22) { if (gRoomVars.graphicsGroups[0] != this->unk_22) {
gRoomVars.unk_10[0] = this->unk_22; gRoomVars.graphicsGroups[0] = this->unk_22;
switch (this->unk_22) { switch (this->unk_22) {
case 0 ... 3: case 0 ... 3:
LoadGfxGroup(this->unk_22 + 0x2B); LoadGfxGroup(this->unk_22 + 0x2B);

View File

@ -434,18 +434,18 @@ void sub_0806AA50(Entity* this, ScriptExecutionContext* context) {
MessageNoOverlap(messageIndex, this); MessageNoOverlap(messageIndex, this);
switch (context->intVariable) { switch (context->intVariable) {
case 0: case 0:
gRoomVars.entities[0] = this; gRoomVars.puzzleEntities[0] = this;
PrependEntityToList(this, NPC); PrependEntityToList(this, NPC);
this->zVelocity = Q_16_16(1.5); this->zVelocity = Q_16_16(1.5);
break; break;
case 1: case 1:
pEnt = FindNextDuplicateID(gRoomVars.entities[0], NPC); pEnt = FindNextDuplicateID(gRoomVars.puzzleEntities[0], NPC);
gRoomVars.entities[1] = pEnt; gRoomVars.puzzleEntities[1] = pEnt;
pEnt->zVelocity = Q_16_16(1.5); pEnt->zVelocity = Q_16_16(1.5);
break; break;
case 2: case 2:
pEnt = FindNextDuplicateID(gRoomVars.entities[1], NPC); pEnt = FindNextDuplicateID(gRoomVars.puzzleEntities[1], NPC);
gRoomVars.entities[2] = pEnt; gRoomVars.puzzleEntities[2] = pEnt;
pEnt->zVelocity = Q_16_16(1.5); pEnt->zVelocity = Q_16_16(1.5);
break; break;
} }
@ -456,7 +456,7 @@ void sub_0806AA50(Entity* this, ScriptExecutionContext* context) {
context->unk_18 = 1; context->unk_18 = 1;
break; break;
case 1: case 1:
pEnt = gRoomVars.entities[context->intVariable]; pEnt = gRoomVars.puzzleEntities[context->intVariable];
if (pEnt->z.HALF.HI < 0) { if (pEnt->z.HALF.HI < 0) {
break; break;
} }
@ -474,7 +474,7 @@ void sub_0806AA50(Entity* this, ScriptExecutionContext* context) {
} }
void sub_0806AB74(Entity* this) { void sub_0806AB74(Entity* this) {
gRoomVars.field_0x3 = 1; gRoomVars.remFlagUnused = TRUE;
if ((s32)(this->y.HALF.HI - (u32)gRoomControls.origin_y) < 0xa8) { if ((s32)(this->y.HALF.HI - (u32)gRoomControls.origin_y) < 0xa8) {
this->y.HALF.HI = gRoomControls.origin_y + 0xa8; this->y.HALF.HI = gRoomControls.origin_y + 0xa8;
} }

View File

@ -95,7 +95,7 @@ void ItemOnGround(ItemOnGroundEntity* this) {
} }
if (super->type == 0x5C) { if (super->type == 0x5C) {
gRoomVars.field_0x4++; gRoomVars.numKinstoneDrops++;
} }
sub_08080CB4(super); sub_08080CB4(super);

View File

@ -104,7 +104,7 @@ static u32 sub_08088938(PressurePlateEntity* this) {
x = super->x.HALF.HI - 8; x = super->x.HALF.HI - 8;
y = super->y.HALF.HI - 8; y = super->y.HALF.HI - 8;
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
Entity* e = gRoomVars.entities[i]; Entity* e = gRoomVars.puzzleEntities[i];
if (e != NULL) { if (e != NULL) {
if ((u16)(e->x.HALF.HI - x) < 0x11 && ((u16)(e->y.HALF_U.HI - y) < 0x11)) { if ((u16)(e->x.HALF.HI - x) < 0x11 && ((u16)(e->y.HALF_U.HI - y) < 0x11)) {
e->spriteOffsetY = sSpriteOffsets[this->dir]; e->spriteOffsetY = sSpriteOffsets[this->dir];

View File

@ -172,8 +172,8 @@ void sub_08089454(PushableStatueEntity* this) {
void sub_080894C8(PushableStatueEntity* this) { void sub_080894C8(PushableStatueEntity* this) {
u32 index; u32 index;
for (index = 0; index < 8; index++) { for (index = 0; index < 8; index++) {
if (gRoomVars.entities[index] == NULL) { if (gRoomVars.puzzleEntities[index] == NULL) {
gRoomVars.entities[index] = super; gRoomVars.puzzleEntities[index] = super;
break; break;
} }
} }
@ -182,8 +182,8 @@ void sub_080894C8(PushableStatueEntity* this) {
void sub_080894FC(PushableStatueEntity* this) { void sub_080894FC(PushableStatueEntity* this) {
u32 index; u32 index;
for (index = 0; index <= 7; index++) { for (index = 0; index <= 7; index++) {
if (super == gRoomVars.entities[index]) { if (super == gRoomVars.puzzleEntities[index]) {
gRoomVars.entities[index] = NULL; gRoomVars.puzzleEntities[index] = NULL;
break; break;
} }
} }

View File

@ -1989,7 +1989,7 @@ static void sub_080724DC(PlayerEntity* this) {
} else { } else {
super->spriteSettings.draw = 3; super->spriteSettings.draw = 3;
super->subAction = 1; super->subAction = 1;
if (gRoomVars.field_0x0 == 0) { if (!gRoomVars.didEnterScrolling) {
if (gPlayerState.flags & PL_MINISH) { if (gPlayerState.flags & PL_MINISH) {
gPlayerState.animation = ANIM_BOUNCE_MINISH; gPlayerState.animation = ANIM_BOUNCE_MINISH;
} else { } else {

View File

@ -21,7 +21,7 @@
static void sub_08077E54(ItemBehavior* beh); static void sub_08077E54(ItemBehavior* beh);
extern void sub_0800857C(Entity*); extern void sub_0800857C(Entity*);
extern void SetEntityPriorityForKind(Entity*); extern void InitDefaultPriority(Entity*);
extern void sub_0809D738(Entity*); extern void sub_0809D738(Entity*);
extern s32 Mod(s32, s32); extern s32 Mod(s32, s32);
extern u32 sub_08003FDE(Entity*, Entity*, u32, u32); extern u32 sub_08003FDE(Entity*, Entity*, u32, u32);
@ -1671,7 +1671,7 @@ bool32 CheckQueuedAction(void) {
gPlayerEntity.base.action = gPlayerState.queued_action; gPlayerEntity.base.action = gPlayerState.queued_action;
gPlayerEntity.base.subAction = 0; gPlayerEntity.base.subAction = 0;
gPlayerState.queued_action = PLAYER_INIT; gPlayerState.queued_action = PLAYER_INIT;
DoPlayerAction(&gPlayerEntity.base); DoPlayerAction(&gPlayerEntity);
return TRUE; return TRUE;
} }
} }
@ -1851,7 +1851,7 @@ void PlayerSetNormalAndCollide(void) {
PL_MOLDWORM_RELEASED | PL_PARACHUTE); PL_MOLDWORM_RELEASED | PL_PARACHUTE);
ResolvePlayerAnimation(); ResolvePlayerAnimation();
SetPlayerActionNormal(); SetPlayerActionNormal();
SetEntityPriorityForKind(&gPlayerEntity.base); InitDefaultPriority(&gPlayerEntity.base);
} }
void PlayerMinishSetNormalAndCollide(void) { void PlayerMinishSetNormalAndCollide(void) {
@ -1867,7 +1867,7 @@ void PlayerMinishSetNormalAndCollide(void) {
~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE);
gPlayerState.swim_state = 0; gPlayerState.swim_state = 0;
gPlayerState.queued_action = PLAYER_INIT; gPlayerState.queued_action = PLAYER_INIT;
SetEntityPriorityForKind(&gPlayerEntity.base); InitDefaultPriority(&gPlayerEntity.base);
} }
void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) { void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) {
@ -2018,7 +2018,7 @@ bool32 sub_08079550(void) {
gPlayerEntity.base.subAction = 0; gPlayerEntity.base.subAction = 0;
COLLISION_OFF(&gPlayerEntity.base); COLLISION_OFF(&gPlayerEntity.base);
gPlayerState.jump_status = 0x81; gPlayerState.jump_status = 0x81;
DoPlayerAction(&gPlayerEntity.base); DoPlayerAction(&gPlayerEntity);
return TRUE; return TRUE;
} }
} }

View File

@ -14,7 +14,7 @@ extern u32 sub_08049D1C(u32);
extern void** gCurrentRoomProperties; extern void** gCurrentRoomProperties;
extern void*** gAreaTable[]; extern void*** gAreaTable[];
extern u8 gUnk_081091E4[]; extern u8 gEntityListLUT[];
extern void sub_080186EC(void); extern void sub_080186EC(void);
extern void sub_0804B16C(void); extern void sub_0804B16C(void);
@ -102,7 +102,7 @@ void RegisterRoomEntity(Entity* ent, const EntityData* dat) {
kind = dat->kind & 0xF; kind = dat->kind & 0xF;
if (ent->prev == NULL) { if (ent->prev == NULL) {
if (list == 0xF) { if (list == 0xF) {
AppendEntityToList(ent, gUnk_081091E4[kind]); AppendEntityToList(ent, gEntityListLUT[kind]);
} else if (list == 8) { } else if (list == 8) {
AppendEntityToList(ent, 8); AppendEntityToList(ent, 8);
} else { } else {
@ -122,6 +122,8 @@ void sub_0804AF0C(Entity* ent, const EntityData* dat) {
ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y;
break; break;
case 0x20: case 0x20:
// TODO: for enemies, I think this is for delayed spawn
// see mulldozerSpawnPoint.c
((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x20; ((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x20;
ent->x.HALF.HI = dat->xPos + gRoomControls.origin_x; ent->x.HALF.HI = dat->xPos + gRoomControls.origin_x;
ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y;
@ -145,7 +147,7 @@ void sub_0804AFB0(void** properties) {
gCurrentRoomProperties = properties; gCurrentRoomProperties = properties;
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
gRoomVars.field_0x6c[i] = gCurrentRoomProperties[i]; gRoomVars.properties[i] = gCurrentRoomProperties[i];
} }
} }
@ -247,9 +249,9 @@ void* GetCurrentRoomProperty(u32 idx) {
return NULL; return NULL;
if (idx >= 0x80) { if (idx >= 0x80) {
return gRoomVars.field_0x8c[idx & 7]; return gRoomVars.entityRails[idx & 7];
} else if (idx <= 7) { } else if (idx <= 7) {
return gRoomVars.field_0x6c[idx]; return gRoomVars.properties[idx];
} else { } else {
return gCurrentRoomProperties[idx]; return gCurrentRoomProperties[idx];
} }
@ -353,9 +355,9 @@ static void LoadDarknessTile(TileEntity* tile) {
static void LoadDestructibleTile(TileEntity* tile) { static void LoadDestructibleTile(TileEntity* tile) {
if (CheckLocalFlag(*(u16*)&tile->_2)) { if (CheckLocalFlag(*(u16*)&tile->_2)) {
SetTileType(*(u16*)&tile->_6, tile->tilePos, tile->localFlag); SetTileType(*(u16*)&tile->_6, tile->tilePos, tile->localFlag);
} else if (!gRoomVars.filler_0x1) { } else if (!gRoomVars.destructableManagerLoaded) {
Manager* mgr; Manager* mgr;
gRoomVars.filler_0x1 = 1; gRoomVars.destructableManagerLoaded = TRUE;
mgr = GetEmptyManager(); mgr = GetEmptyManager();
if (mgr != NULL) { if (mgr != NULL) {
mgr->kind = MANAGER; mgr->kind = MANAGER;

View File

@ -399,7 +399,7 @@ u32 sub_unk3_HouseInteriors1_InnWestRoom(void) {
index = 0; index = 0;
SetLocalFlag(BILL05_YADO1F_MATSU_T0); SetLocalFlag(BILL05_YADO1F_MATSU_T0);
} }
gRoomVars.field_0x6c[3] = gUnk_080D6A74[index]; gRoomVars.properties[3] = gUnk_080D6A74[index];
return 1; return 1;
} }
@ -427,7 +427,7 @@ u32 sub_unk3_HouseInteriors1_InnMiddleRoom(void) {
index = 0; index = 0;
SetLocalFlag(BILL06_YADO1F_TAKE_T0); SetLocalFlag(BILL06_YADO1F_TAKE_T0);
} }
gRoomVars.field_0x6c[3] = gUnk_080D6B18[index]; gRoomVars.properties[3] = gUnk_080D6B18[index];
return 1; return 1;
} }
@ -453,7 +453,7 @@ u32 sub_unk3_HouseInteriors1_InnEastRoom(void) {
index = 0; index = 0;
SetLocalFlag(BILL07_YADO1F_UME_T0); SetLocalFlag(BILL07_YADO1F_UME_T0);
} }
gRoomVars.field_0x6c[3] = gUnk_080D6BB8[index]; gRoomVars.properties[3] = gUnk_080D6BB8[index];
return 1; return 1;
} }
@ -533,7 +533,7 @@ void sub_StateChange_HouseInteriors1_SchoolWest(void) {
if (gSave.global_progress < 8) { if (gSave.global_progress < 8) {
LoadRoomEntityList(&gUnk_080D7038); LoadRoomEntityList(&gUnk_080D7038);
} }
if (gRoomVars.field_0x0 == 0) { if (!gRoomVars.didEnterScrolling) {
SetWorldMapPos(2, 0, 0x2c8, 0xa8); SetWorldMapPos(2, 0, 0x2c8, 0xa8);
} }
} }
@ -566,8 +566,8 @@ extern u32 gUnk_080D7348;
u32 sub_unk3_HyruleCastle_0(void) { u32 sub_unk3_HyruleCastle_0(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080D7348; gRoomVars.properties[0] = &gUnk_080D7348;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -600,8 +600,8 @@ extern u32 gUnk_080D7410;
u32 sub_unk3_HyruleCastle_1(void) { u32 sub_unk3_HyruleCastle_1(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080D7410; gRoomVars.properties[0] = &gUnk_080D7410;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -1077,7 +1077,7 @@ extern TileEntity gUnk_080D9328[];
static void sub_0804C128(void) { static void sub_0804C128(void) {
sub_080AF250(0); sub_080AF250(0);
if (gRoomVars.field_0x0 != 0) { if (gRoomVars.didEnterScrolling) {
if ((gArea.unk_0c_1) == 0) { if ((gArea.unk_0c_1) == 0) {
if ((gArea.unk_0c_4) == 0) { if ((gArea.unk_0c_4) == 0) {
gArea.unk_0c_1 = 1; gArea.unk_0c_1 = 1;
@ -1271,7 +1271,7 @@ extern u32 gUnk_080DA230;
u32 sub_unk3_CastorDarknut_Main(void) { u32 sub_unk3_CastorDarknut_Main(void) {
if (!CheckLocalFlag(LV4_0a_TSUBO)) if (!CheckLocalFlag(LV4_0a_TSUBO))
gRoomVars.field_0x6c[0] = &gUnk_080DA230; gRoomVars.properties[0] = &gUnk_080DA230;
return 1; return 1;
} }
@ -1633,7 +1633,7 @@ extern u32 gUnk_080DB910;
u32 sub_unk3_TownMinishHoles_LibraryBookshelf(void) { u32 sub_unk3_TownMinishHoles_LibraryBookshelf(void) {
if (CheckGlobalFlag(MIZUKAKI_START) && !CheckLocalFlag(MIZUKAKI_BOOK_ALLBACK)) { if (CheckGlobalFlag(MIZUKAKI_START) && !CheckLocalFlag(MIZUKAKI_BOOK_ALLBACK)) {
gRoomVars.field_0x6c[1] = &gUnk_080DB910; gRoomVars.properties[1] = &gUnk_080DB910;
} }
return 1; return 1;
} }
@ -2456,7 +2456,7 @@ extern u32 gUnk_080E103C;
u32 sub_unk3_CaveOfFlames_BeforeGleerok(void) { u32 sub_unk3_CaveOfFlames_BeforeGleerok(void) {
if (CheckGlobalFlag(LV2_CLEAR)) { if (CheckGlobalFlag(LV2_CLEAR)) {
gRoomVars.field_0x6c[1] = &gUnk_080E103C; gRoomVars.properties[1] = &gUnk_080E103C;
} }
return 1; return 1;
} }
@ -3758,16 +3758,16 @@ extern u32 gUnk_080EB5D4;
u32 sub_unk3_DarkHyruleCastle_1FEntrance(void) { u32 sub_unk3_DarkHyruleCastle_1FEntrance(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080EB604; gRoomVars.properties[0] = &gUnk_080EB604;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
gArea.bgm = gArea.queued_bgm = BGM_BEAT_VAATI; gArea.bgm = gArea.queued_bgm = BGM_BEAT_VAATI;
} else if (CheckLocalFlag(0x79)) { } else if (CheckLocalFlag(0x79)) {
gRoomVars.field_0x6c[0] = NULL; gRoomVars.properties[0] = NULL;
if (!CheckLocalFlag(0x7a)) { if (!CheckLocalFlag(0x7a)) {
SetGlobalFlag(ZELDA_CHASE); SetGlobalFlag(ZELDA_CHASE);
gRoomVars.field_0x6c[0] = &gUnk_080EB5D4; gRoomVars.properties[0] = &gUnk_080EB5D4;
gRoomVars.field_0x6c[7] = sub_0804D9B0; gRoomVars.properties[7] = sub_0804D9B0;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
} }
return 1; return 1;
@ -3830,8 +3830,8 @@ void sub_StateChange_Dojos_ToSplitblade1(void) {
u32 sub_unk3_DarkHyruleCastle_3FTripleDarknut(void) { u32 sub_unk3_DarkHyruleCastle_3FTripleDarknut(void) {
if (!CheckLocalFlag(0x77)) { if (!CheckLocalFlag(0x77)) {
gRoomVars.field_0x6c[0] = 0; gRoomVars.properties[0] = 0;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -4023,7 +4023,7 @@ void sub_StateChange_Dojos_ToGreatblade8(void) {
u32 sub_unk3_DarkHyruleCastle_B1Entrance(void) { u32 sub_unk3_DarkHyruleCastle_B1Entrance(void) {
if (CheckLocalFlag(0x79)) { if (CheckLocalFlag(0x79)) {
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -4056,8 +4056,8 @@ extern u32 gUnk_080ED1E4;
u32 sub_unk3_DarkHyruleCastle_1FThroneRoom(void) { u32 sub_unk3_DarkHyruleCastle_1FThroneRoom(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080ED1E4; gRoomVars.properties[0] = &gUnk_080ED1E4;
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -4217,8 +4217,8 @@ void sub_StateChange_Ruins_Beanstalk1(void) {
u32 sub_unk3_DarkHyruleCastle_B1Left(void) { u32 sub_unk3_DarkHyruleCastle_B1Left(void) {
if (CheckLocalFlag(0x79)) { if (CheckLocalFlag(0x79)) {
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
gRoomVars.field_0x6c[0] = 0; gRoomVars.properties[0] = 0;
} }
return 1; return 1;
} }
@ -4242,7 +4242,7 @@ void sub_StateChange_Ruins_Beanstalk2(void) {
u32 sub_unk3_DarkHyruleCastle_B1Map(void) { u32 sub_unk3_DarkHyruleCastle_B1Map(void) {
if (CheckLocalFlag(0x79)) { if (CheckLocalFlag(0x79)) {
gRoomVars.field_0x6c[2] = 0; gRoomVars.properties[2] = 0;
} }
return 1; return 1;
} }
@ -4564,7 +4564,7 @@ extern u32 gUnk_080F09A0;
u32 sub_unk3_CastleGarden_Main(void) { u32 sub_unk3_CastleGarden_Main(void) {
if (GetInventoryValue(ITEM_FOURSWORD)) { if (GetInventoryValue(ITEM_FOURSWORD)) {
gRoomVars.field_0x6c[1] = &gUnk_080F09A0; gRoomVars.properties[1] = &gUnk_080F09A0;
} }
return 1; return 1;
} }
@ -5022,9 +5022,9 @@ extern u32 gUnk_080F3EA4;
u32 sub_unk3_LakeHylia_Main(void) { u32 sub_unk3_LakeHylia_Main(void) {
if (CheckGlobalFlag(LV4_CLEAR) && !CheckLocalFlag(4)) { if (CheckGlobalFlag(LV4_CLEAR) && !CheckLocalFlag(4)) {
gRoomVars.field_0x6c[2] = &gUnk_080F3EA4; gRoomVars.properties[2] = &gUnk_080F3EA4;
} else { } else {
gRoomVars.field_0x6c[2] = &Enemies_LakeHylia_Main; gRoomVars.properties[2] = &Enemies_LakeHylia_Main;
} }
return 1; return 1;
} }
@ -5177,8 +5177,8 @@ extern u32 gUnk_080F4EB0;
u32 sub_unk3_MinishWoods_Main(void) { u32 sub_unk3_MinishWoods_Main(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080F4EB0; gRoomVars.properties[0] = &gUnk_080F4EB0;
gRoomVars.field_0x6c[2] = NULL; gRoomVars.properties[2] = NULL;
} }
return 1; return 1;
} }
@ -5234,9 +5234,9 @@ extern u32 gUnk_080F5348;
u32 sub_unk3_SanctuaryEntrance_Main(void) { u32 sub_unk3_SanctuaryEntrance_Main(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080F5348; gRoomVars.properties[0] = &gUnk_080F5348;
gRoomVars.field_0x6c[7] = sub_0804ED18; gRoomVars.properties[7] = sub_0804ED18;
gRoomVars.field_0x6c[2] = NULL; gRoomVars.properties[2] = NULL;
} }
return 1; return 1;
} }
@ -5687,7 +5687,7 @@ extern u32 gUnk_080F7680;
u32 sub_unk3_HyruleField_EasternHillsNorth(void) { u32 sub_unk3_HyruleField_EasternHillsNorth(void) {
if (GetInventoryValue(ITEM_GUST_JAR) && !GetInventoryValue(ITEM_PACCI_CANE)) { if (GetInventoryValue(ITEM_GUST_JAR) && !GetInventoryValue(ITEM_PACCI_CANE)) {
gRoomVars.field_0x6c[2] = &gUnk_080F7680; gRoomVars.properties[2] = &gUnk_080F7680;
} }
return 1; return 1;
} }
@ -5748,13 +5748,13 @@ extern void sub_0804F4E4(void);
u32 sub_unk3_HyruleField_OutsideCastle(void) { u32 sub_unk3_HyruleField_OutsideCastle(void) {
if (CheckGlobalFlag(TABIDACHI) && !GetInventoryValue(ITEM_GUST_JAR)) { if (CheckGlobalFlag(TABIDACHI) && !GetInventoryValue(ITEM_GUST_JAR)) {
gRoomVars.field_0x6c[0] = &gUnk_080F7CD0; gRoomVars.properties[0] = &gUnk_080F7CD0;
gRoomVars.field_0x6c[7] = sub_0804F5E8; gRoomVars.properties[7] = sub_0804F5E8;
} }
if (CheckGlobalFlag(LV2_CLEAR) && GetInventoryValue(ITEM_RED_SWORD) && !CheckLocalFlag(SOUGEN_06_SAIKAI)) { if (CheckGlobalFlag(LV2_CLEAR) && GetInventoryValue(ITEM_RED_SWORD) && !CheckLocalFlag(SOUGEN_06_SAIKAI)) {
gRoomVars.field_0x6c[0] = &gUnk_080F7C80; gRoomVars.properties[0] = &gUnk_080F7C80;
gRoomVars.field_0x6c[7] = sub_0804F4E4; gRoomVars.properties[7] = sub_0804F4E4;
gRoomVars.field_0x6c[2] = NULL; gRoomVars.properties[2] = NULL;
} }
#ifndef EU #ifndef EU
if (CheckGlobalFlag(TABIDACHI)) { if (CheckGlobalFlag(TABIDACHI)) {
@ -6255,7 +6255,7 @@ extern u32 gUnk_080F9BF8;
u32 sub_unk3_VeilFallsTop_Main(void) { u32 sub_unk3_VeilFallsTop_Main(void) {
if (!CheckKinstoneFused(KINSTONE_E)) { if (!CheckKinstoneFused(KINSTONE_E)) {
gRoomVars.field_0x6c[0] = &gUnk_080F9BF8; gRoomVars.properties[0] = &gUnk_080F9BF8;
} }
return 1; return 1;
} }
@ -6541,8 +6541,8 @@ extern u32 gUnk_080FAD48;
u32 sub_unk3_MtCrenel_MountainTop(void) { u32 sub_unk3_MtCrenel_MountainTop(void) {
if (CheckGlobalFlag(ENDING)) { if (CheckGlobalFlag(ENDING)) {
gRoomVars.field_0x6c[0] = &gUnk_080FAD48; gRoomVars.properties[0] = &gUnk_080FAD48;
gRoomVars.field_0x6c[2] = NULL; gRoomVars.properties[2] = NULL;
} }
return 1; return 1;
} }