Rename Stage Layout Functions and Vars Uniformly (#1162)

This change renames functions and global stage variables uniformly
across the stages so that these functions can be pulled out and shared
across all of the stages. Based on some other tests there are 12 or so
functions that this will allow to be pulled out of each stage. Since
these implementations are shared, an additional 12 asm functions can be
eliminated in a subsequent pass.

**Vars**
* `g_pStObjLayoutHorizontal` - a horizontally sorted array of stage
entities
* `g_pStObjLayoutVertical` - a vertically sorted array of stage entities
* `g_LayoutObjHorizontal` - a pointer to a `LayoutEntity` in
`g_pStObjLayoutHorizontal`
* `g_LayoutObjVertical` - a pointer to a `LayoutEntity` in
`g_pStObjLayoutVertical`
* `g_LayoutObjPosHorizontal` - the direction last traversed in
`g_LayoutObjHorizontal`
* `g_LayoutObjPosVertical` - the direction last traversed in
`g_pStObjLayoutVertical `

**Functions**
* `FindFirstEntityToTheRight` - given an `x` position, update
`g_LayoutObjHorizontal` with the first entity to the right of `x`
* `FindFirstEntityToTheLeft` - given a `x` position, update
`g_LayoutObjHorizontal` with the first entity to the left of `x`
(backwards)
* `CreateEntitiesToTheRight` - given an `x` position, create all
entities to the right (mutates `g_LayoutObjHorizontal`)
* `CreateEntitiesToTheLeft` - given an `x` position, create all entities
to the left (mutates `g_LayoutObjHorizontal`)
* `FindFirstEntityAbove` - given an `y` position, update
`g_LayoutObjVertical ` with the first entity to the above of `y`
* `FindFirstEntityBelow` - given an `y` position, update
`g_LayoutObjVertical ` with the first entity to the below of `y`
* `CreateEntitiesAbove` - given an `y` position, create all entities
above (mutates `g_LayoutObjVertical`)
* `CreateEntitiesBelow` - given an `y` position, create all entities
beneath (mutates `g_LayoutObjVertical`)
* `UpdateRoomPosition` - look at the current game loop scroll delta and
create any entities given the room layout

I believe all of these implementations are shared across all stages
(including `InitRoomEntities`, and two more `CreateEntity` functions)
(in my initial tests I had a small difference in `DER`, but I believe
that had to do with an incorrect symbol table change).

Co-authored-by: Jonathan Hohle <jon@ttkb.co>
This commit is contained in:
Jonathan Hohle 2024-05-22 15:34:41 -07:00 committed by GitHub
parent 867c7e12c8
commit 3b0943b25a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 693 additions and 542 deletions

View File

@ -73,3 +73,9 @@ EntityUnkId15 = 0x80195B44;
EntityIsNearPlayer = 0x801910A8;
UnkPolyFunc2 = 0x801996EC;
PrimDecreaseBrightness = 0x8019976C;
g_LayoutObjHorizontal = 0x801997D8;
FindFirstEntityToTheLeft = 0x80190884;
g_LayoutObjPosHorizontal = 0x801997E0;
g_LayoutObjVertical = 0x801997DC;
g_LayoutObjPosVertical = 0x801997E4;
UpdateRoomPosition = 0x80190F04;

View File

@ -1,4 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayoutHorizontal = 0x801801EC;
g_pStObjLayoutVertical = 0x801802C0;
PfnEntityUpdates = 0x80180394;
g_InitializeData0 = 0x80180410;
g_InitializeEntityData0 = 0x8018041C;
@ -26,7 +28,13 @@ UpdateStageEntities = 0x80191178;
TestCollisions = 0x80191280;
EntityDamageDisplay = 0x80192398;
CreateEntityWhenInHorizontalRange = 0x80192C18;
CreateEntitiesToTheRight = 0x80192DD4;
CreateEntitiesToTheLeft = 0x80192ED0;
FindFirstEntityBelow = 0x80193030;
CreateEntitiesAbove = 0x80193088;
CreateEntitiesBelow = 0x80193184;
InitRoomEntities = 0x80193298;
UpdateRoomPosition = 0x80193410;
CreateEntityFromEntity = 0x80193538;
EntityIsNearPlayer = 0x801935B4;
EntityRedDoor = 0x8019362C;
@ -58,5 +66,9 @@ EntitySoulStealOrb = 0x8019B274;
EntityEnemyBlood = 0x8019B608;
EntityUnkId08 = 0x8019BAB8;
BottomCornerText = 0x8019BBA4;
g_LayoutObjHorizontal = 0x8019C764;
g_LayoutObjVertical = 0x8019C768;
g_LayoutObjPosHorizontal = 0x8019C76C;
g_LayoutObjPosVertical = 0x8019C770;
g_Dialogue = 0x8019D378;
g_ItemIconSlots = 0x8019D42C;

View File

@ -1,4 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayoutHorizontal = 0x80180220;
g_pStObjLayoutVertical = 0x801802F4;
PfnEntityUpdates = 0x801803C8;
g_eBreakableInit = 0x80180458;
g_InitializeData0 = 0x80180464;
@ -39,7 +41,16 @@ TestCollisions = 0x801973C4;
EntityDamageDisplay = 0x801984DC;
CreateEntityWhenInVerticalRange = 0x80198C44;
CreateEntityWhenInHorizontalRange = 0x80198D5C;
FindFirstEntityToTheRight = 0x80198E74;
FindFirstEntityToTheLeft = 0x80198EC0;
CreateEntitiesToTheRight = 0x80198F18;
CreateEntitiesToTheLeft = 0x80199014;
FindFirstEntityAbove = 0x80199128;
FindFirstEntityBelow = 0x80199174;
CreateEntitiesAbove = 0x801991CC;
CreateEntitiesBelow = 0x801992C8;
InitRoomEntities = 0x801993DC;
UpdateRoomPosition = 0x80199554;
CreateEntityFromCurrentEntity = 0x80199608;
CreateEntityFromEntity = 0x8019967C;
EntityIsNearPlayer = 0x801996F8;
@ -75,5 +86,9 @@ EntityRoomForeground = 0x801A1BFC;
BottomCornerText = 0x801A1CE8;
EntityUnkId17 = 0x801A2E20;
Entity3DBackgroundHouse = 0x801A2F10;
g_LayoutObjHorizontal = 0x801A32C4;
g_LayoutObjVertical = 0x801A32C8;
g_LayoutObjPosHorizontal = 0x801A32CC;
g_LayoutObjPosVertical = 0x801A32D0;
g_Dialogue = 0x801A3ED8;
g_ItemIconSlots = 0x801A3F8C;

View File

@ -1,5 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayout = 0x8018077C;
g_pStObjLayoutHorizontal = 0x8018077C;
g_pStObjLayoutVertical = 0x80180850;
PfnEntityUpdates = 0x80180924;
g_eBreakableInit = 0x80180AAC;
g_InitializeData0 = 0x80180AB8;
@ -71,6 +72,7 @@ UpdateStageEntities = 0x801C1B78;
TestCollisions = 0x801C1C80;
EntityDamageDisplay = 0x801C2D98;
InitRoomEntities = 0x801C3C98;
UpdateRoomPosition = 0x801C3E10;
CreateEntityFromCurrentEntity = 0x801C3EC4;
CreateEntityFromEntity = 0x801C3F38;
EntityIsNearPlayer = 0x801C3FB4;
@ -137,5 +139,9 @@ EntityZombie = 0x801D64B0;
EntityZombieSpawner = 0x801D6710;
UnkPrimHelper = 0x801D6880;
UnkPolyFunc2 = 0x801D6FCC;
g_LayoutObjHorizontal = 0x801D7110;
g_LayoutObjVertical = 0x801D7114;
g_LayoutObjPosHorizontal = 0x801D7118;
g_LayoutObjPosVertical = 0x801D711C;
g_Dialogue = 0x801D7D24;
g_ItemIconSlots = 0x801D7DD8;

View File

@ -1,5 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayout = 0x80180728;
g_pStObjLayoutHorizontal = 0x80180728;
g_pStObjLayoutVertical = 0x801807FC;
PfnEntityUpdates = 0x801808D0;
g_eBreakableInit = 0x80180A3C;
g_InitializeData0 = 0x80180A48;
@ -48,6 +49,7 @@ UpdateStageEntities = 0x801B93E8;
TestCollisions = 0x801B94F0;
EntityDamageDisplay = 0x801BA608;
InitRoomEntities = 0x801BB508;
UpdateRoomPosition = 0x801BB680;
CreateEntityFromCurrentEntity = 0x801BB734;
CreateEntityFromEntity = 0x801BB7A8;
EntityIsNearPlayer = 0x801BB824;
@ -109,4 +111,8 @@ EntityGurkhaSword = 0x801D0730;
EntityBlade = 0x801D0D40;
EntityBladeSword = 0x801D1BB8;
PrimDecreaseBrightness = 0x801D2704;
g_LayoutObjHorizontal = 0x801D2768;
g_LayoutObjVertical = 0x801D276C;
g_LayoutObjPosHorizontal = 0x801D2770;
g_LayoutObjPosVertical = 0x801D2774;
g_ItemIconSlots = 0x801D33F4;

View File

@ -2,6 +2,8 @@ g_SpriteBanks = 0x8018002C;
g_Cluts = 0x80180160;
g_TileLayers = 0x80180394;
g_EntityGfxs = 0x80180888;
g_pStObjLayoutHorizontal = 0x801808EC;
g_pStObjLayoutVertical = 0x801809C0;
PfnEntityUpdates = 0x80180A94;
g_InitializeData0 = 0x80180BD4;
g_InitializeEntityData0 = 0x80180BE0;
@ -46,6 +48,7 @@ UpdateStageEntities = 0x801B9800;
TestCollisions = 0x801B9908;
EntityDamageDisplay = 0x801BAA20;
InitRoomEntities = 0x801BB920;
UpdateRoomPosition = 0x801BBA98;
CreateEntityFromCurrentEntity = 0x801BBB4C;
CreateEntityFromEntity = 0x801BBBC0;
EntityIsNearPlayer = 0x801BBC3C;
@ -89,5 +92,9 @@ EntityMagicallySealedDoor = 0x801C7D68;
EntityStageNamePopup = 0x801C8CAC;
UnkPolyFunc2 = 0x801CA07C;
EntityLifeUpSpawn = 0x801CA160;
g_LayoutObjHorizontal = 0x801CAA74;
g_LayoutObjVertical = 0x801CAA78;
g_LayoutObjPosHorizontal = 0x801CAA7C;
g_LayoutObjPosVertical = 0x801CAA80;
g_Dialogue = 0x801CB688;
g_ItemIconSlots = 0x801CB740;

View File

@ -1,4 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayoutHorizontal = 0x8018023C;
g_pStObjLayoutVertical = 0x80180310;
PfnEntityUpdates = 0x801803E4;
g_InitializeData0 = 0x8018044C;
g_InitializeEntityData0 = 0x80180458;
@ -15,6 +17,16 @@ UpdateStageEntities = 0x8018A494;
TestCollisions = 0x8018A59C;
CreateEntityWhenInVerticalRange = 0x8018BE1C;
CreateEntityWhenInHorizontalRange = 0x8018BF34;
FindFirstEntityToTheRight = 0x8018C04C;
FindFirstEntityToTheLeft = 0x8018C098;
CreateEntitiesToTheRight = 0x8018C0F0;
CreateEntitiesToTheLeft = 0x8018C1EC;
FindFirstEntityAbove = 0x8018C300;
FindFirstEntityBelow = 0x8018C34C;
CreateEntitiesAbove = 0x8018C3A4;
CreateEntitiesBelow = 0x8018C4A0;
InitRoomEntities = 0x8018C5B4;
UpdateRoomPosition = 0x8018C72C;
CreateEntityFromEntity = 0x8018C854;
EntityIsNearPlayer = 0x8018C8D0;
DestroyEntity = 0x8018D580;
@ -46,4 +58,8 @@ EntityStageNamePopup = 0x8019390C;
EntitySoulStealOrb = 0x80194590;
EntityEnemyBlood = 0x80194924;
BottomCornerText = 0x80194EC0;
g_LayoutObjHorizontal = 0x80195A30;
g_LayoutObjVertical = 0x80195A34;
g_LayoutObjPosHorizontal = 0x80195A38;
g_LayoutObjPosVertical = 0x80195A3C;
g_ItemIconSlots = 0x801966A8;

View File

@ -1,4 +1,6 @@
g_SpriteBanks = 0x80180040;
g_pStObjLayoutHorizontal = 0x80180314;
g_pStObjLayoutVertical = 0x801803E8;
PfnEntityUpdates = 0x801804BC;
g_InitializeData0 = 0x80180580;
g_InitializeEntityData0 = 0x8018058C;
@ -36,6 +38,7 @@ UpdateStageEntities = 0x801B1B98;
TestCollisions = 0x801B1CA0;
EntityDamageDisplay = 0x801B2A3C;
InitRoomEntities = 0x801B393C;
UpdateRoomPosition = 0x801B3AB4;
CreateEntityFromCurrentEntity = 0x801B3B68;
CreateEntityFromEntity = 0x801B3BDC;
EntityIsNearPlayer = 0x801B3C58;
@ -63,5 +66,9 @@ EntityClockTower3D = 0x801BB2AC;
EntityCutscenePhotograph = 0x801BB764;
EntityCutscenePhotographFire = 0x801BC4D0;
EntityBackgroundVortex = 0x801BE1B4;
g_LayoutObjHorizontal = 0x801C00A0;
g_LayoutObjVertical = 0x801C00A4;
g_LayoutObjPosHorizontal = 0x801C00A8;
g_LayoutObjPosVertical = 0x801C00AC;
g_Dialogue = 0x801C24CC;
g_ItemIconSlots = 0x801C2584;

View File

@ -61,4 +61,8 @@ CollectGold = 0x8018CD10;
EntityEquipItemDrop = 0x8018DA34;
EntityStageNamePopup = 0x8019198C;
BottomCornerText = 0x80192F40;
g_LayoutObjHorizontal = 0x80193AB0;
g_LayoutObjVertical = 0x80193AB4;
g_LayoutObjPosHorizontal = 0x80193AB8;
g_LayoutObjPosVertical = 0x80193ABC;
g_ItemIconSlots = 0x80194728;

View File

@ -8,6 +8,12 @@
#include "objects.h"
#include "sfx.h"
#define LAYOUT_OBJ_START 0xffff
#define LAYOUT_OBJ_END 0xfffe
#define LAYOUT_OBJ_POSITION_END 0
#define LAYOUT_OBJ_POSITION_START 1
typedef struct {
/* 0x0 */ u16 posX;
/* 0x2 */ u16 posY;

View File

@ -85,51 +85,54 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_80192D30(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (1) {
if ((D_8019C764->posX != 0xFFFE) && ((s32)D_8019C764->posX >= arg0)) {
if ((g_LayoutObjHorizontal->posX != 0xFFFE) &&
((s32)g_LayoutObjHorizontal->posX >= arg0)) {
break;
}
D_8019C764++;
g_LayoutObjHorizontal++;
}
}
void func_80192D7C(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if (((D_8019C764->posX != 0xFFFF) &&
((arg0 >= D_8019C764->posX) || (D_8019C764->posX == 0xFFFE)))) {
if (((g_LayoutObjHorizontal->posX != 0xFFFF) &&
((arg0 >= g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE)))) {
break;
}
D_8019C764--;
g_LayoutObjHorizontal--;
}
}
void func_80192DD4(s16 arg0) {
void CreateEntitiesToTheRight(s16 arg0) {
s32 expected;
u8 flag;
if (D_8019C76C != 0) {
func_80192D30(arg0 - g_ScrollDeltaX);
D_8019C76C = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_8019C764->posX == 0xFFFF) || (arg0 < D_8019C764->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_8019C764->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_8019C764);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_8019C764++;
g_LayoutObjHorizontal++;
}
}
void func_80192ED0(s16 arg0) {
void CreateEntitiesToTheLeft(s16 arg0) {
u8 flag;
s32 expected;
@ -137,98 +140,103 @@ void func_80192ED0(s16 arg0) {
arg0 = 0;
}
if (D_8019C76C == 0) {
func_80192D7C(arg0 - g_ScrollDeltaX);
D_8019C76C = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if (D_8019C764->posX == 0xFFFE || arg0 > D_8019C764->posX) {
if (g_LayoutObjHorizontal->posX == 0xFFFE ||
arg0 > g_LayoutObjHorizontal->posX) {
return;
}
expected = 0;
flag = (D_8019C764->entityRoomIndex >> 8) + 255;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 255;
if (flag == 0xFF ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_8019C764);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_8019C764--;
g_LayoutObjHorizontal--;
}
}
void func_80192FE4(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if ((D_8019C768[1] != 0xFFFE) && ((s32)D_8019C768[1] >= arg0)) {
if ((g_LayoutObjVertical->posY != 0xFFFE) &&
((s32)g_LayoutObjVertical->posY >= arg0)) {
break;
}
D_8019C768 += 5;
g_LayoutObjVertical++;
}
}
void func_80193030(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if ((D_8019C768[1] != 0xFFFF) &&
((arg0 >= D_8019C768[1]) || !(D_8019C768[1] != 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
((arg0 >= g_LayoutObjVertical->posY) ||
!(g_LayoutObjVertical->posY != 0xFFFE))) {
break;
}
D_8019C768 -= 5;
g_LayoutObjVertical--;
}
}
void func_80193088(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
u8 flag;
s32 expected;
if (D_8019C770 != 0) {
func_80192FE4(arg0 - g_ScrollDeltaY);
D_8019C770 = 0;
if (g_LayoutObjPosVertical != 0) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if ((D_8019C768[1] == 0xFFFF) || (arg0 < D_8019C768[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFF) ||
(arg0 < g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_8019C768[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_8019C768);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_8019C768 += 5;
g_LayoutObjVertical++;
}
}
INCLUDE_ASM("st/cen/nonmatchings/11280", func_80193184);
INCLUDE_ASM("st/cen/nonmatchings/11280", CreateEntitiesBelow);
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_801801EC[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_8019C764 = pObjLayoutStart;
D_8019C768 = D_801802C0[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_8019C764 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_8019C764;
D_8019C764 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_8019C764 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_8019C764 = (temp_v1[2] << 0x10) + temp_v1[1];
D_8019C768 += i * 2 + 2;
D_8019C768 = (D_8019C768[1] << 0x10) + D_8019C768[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -237,14 +245,14 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_8019C76C = 0;
D_8019C770 = 0;
func_80192D30(i);
func_80192DD4(temp_s0);
func_80192FE4(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
INCLUDE_ASM("st/cen/nonmatchings/11280", func_80193410);
INCLUDE_ASM("st/cen/nonmatchings/11280", UpdateRoomPosition);
void CreateEntityFromCurrentEntity(u16 entityId, Entity* entity) {
DestroyEntity(entity);

View File

@ -48,8 +48,8 @@ void CreateEntityFromLayout(Entity*, LayoutEntity*);
extern u16 func_80194E44(u16 arg0, u16 arg1, u16 arg2);
void EntityUnkId15(Entity* entity);
extern LayoutEntity* D_801801EC[];
extern LayoutEntity* D_801802C0[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
extern PfnEntityUpdate PfnEntityUpdates[];
/*** Initializers ***/
@ -83,9 +83,10 @@ extern u16 D_801811D8[];
extern u8 D_80181238;
extern ObjInit2 D_8018125C[];
extern LayoutEntity* D_8019C764;
extern u16* D_8019C768;
extern u8 D_8019C76C;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern s16 D_8019D37E;
extern u16 D_8019D380;
extern s16 D_8019D382;
@ -95,8 +96,6 @@ extern s16 D_8019D38A;
extern s8 D_8019D38E;
extern s8 D_8019D38F;
extern u32 D_8019D424;
extern u8 D_8019C76C;
extern u8 D_8019C770;
extern u16 g_InitializeEntityData0[];

View File

@ -85,80 +85,85 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_80198E74(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (1) {
if ((D_801A32C4->posX != 0xFFFE) && ((s32)D_801A32C4->posX >= arg0)) {
if ((g_LayoutObjHorizontal->posX != 0xFFFE) &&
((s32)g_LayoutObjHorizontal->posX >= arg0)) {
break;
}
D_801A32C4++;
g_LayoutObjHorizontal++;
}
}
void func_80198EC0(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if ((D_801A32C4->posX != 0xFFFF) &&
((arg0 >= (s32)D_801A32C4->posX) || (D_801A32C4->posX == 0xFFFE))) {
if ((g_LayoutObjHorizontal->posX != 0xFFFF) &&
((arg0 >= (s32)g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE))) {
break;
}
D_801A32C4--;
g_LayoutObjHorizontal--;
}
}
INCLUDE_ASM("st/dre/nonmatchings/173C4", func_80198F18);
INCLUDE_ASM("st/dre/nonmatchings/173C4", CreateEntitiesToTheRight);
INCLUDE_ASM("st/dre/nonmatchings/173C4", func_80199014);
INCLUDE_ASM("st/dre/nonmatchings/173C4", CreateEntitiesToTheLeft);
void func_80199128(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (1) {
if ((D_801A32C8[1] != 0xFFFE) && ((s32)D_801A32C8[1] >= arg0)) {
if ((g_LayoutObjVertical->posY != 0xFFFE) &&
((s32)g_LayoutObjVertical->posY >= arg0)) {
break;
}
D_801A32C8 += 5;
g_LayoutObjVertical++;
}
}
void func_80199174(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if ((D_801A32C8[1] != 0xFFFF) &&
(((s32)arg0 >= D_801A32C8[1]) || (D_801A32C8[1] == 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
(((s32)arg0 >= g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_801A32C8 -= 5;
g_LayoutObjVertical--;
}
}
INCLUDE_ASM("st/dre/nonmatchings/173C4", func_801991CC);
INCLUDE_ASM("st/dre/nonmatchings/173C4", CreateEntitiesAbove);
INCLUDE_ASM("st/dre/nonmatchings/173C4", func_801992C8);
INCLUDE_ASM("st/dre/nonmatchings/173C4", CreateEntitiesBelow);
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_80180220[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_801A32C4 = pObjLayoutStart;
D_801A32C8 = D_801802F4[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801A32C4 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801A32C4;
D_801A32C4 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801A32C4 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801A32C4 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801A32C8 += i * 2 + 2;
D_801A32C8 = (D_801A32C8[1] << 0x10) + D_801A32C8[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -167,31 +172,31 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801A32CC = 0;
D_801A32D0 = 0;
func_80198E74(i);
func_80198F18(temp_s0);
func_80199128(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_80199554(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0) {
func_80198F18(tmp + 0x140);
CreateEntitiesToTheRight(tmp + 0x140);
} else {
func_80199014(tmp - 0x40);
CreateEntitiesToTheLeft(tmp - 0x40);
}
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0) {
func_801991CC(tmp + 0x120);
CreateEntitiesAbove(tmp + 0x120);
} else {
func_801992C8(tmp - 0x40);
CreateEntitiesBelow(tmp - 0x40);
}
}
}

View File

@ -33,10 +33,10 @@ typedef enum {
void ReplaceBreakableWithItemDrop(Entity* arg0);
void DestroyEntity(Entity* entity);
void func_80198F18(s16);
void func_80199014(s16);
void func_801991CC(s16);
void func_801992C8(s16);
void CreateEntitiesToTheRight(s16);
void CreateEntitiesToTheLeft(s16);
void CreateEntitiesAbove(s16);
void CreateEntitiesBelow(s16);
s32 func_8019AC78(u8, s16);
void PreventEntityFromRespawning(Entity* entity);
void FallEntity(void);
@ -48,8 +48,8 @@ Entity* func_8019AC18(Entity*, Entity*);
void func_8019E5E0(Entity* entity);
void EntityUnkId15(Entity* entity);
extern LayoutEntity* D_80180220[];
extern LayoutEntity* D_801802F4[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
/* *** Initializers *** */
extern u16 g_InitializeData0[];
@ -132,10 +132,10 @@ extern u8 D_801813FC;
// *** EntitySoulStealOrb properties END ***
extern LayoutEntity* D_801A32C4;
extern u16* D_801A32C8;
extern s8 D_801A32CC;
extern u8 D_801A32D0;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern s8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern s32 D_801A3ED4;
extern s32 D_801A3ED8;
extern s16 D_801A3EDE;

View File

@ -87,20 +87,22 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
void func_80190838(s16 arg0) {
while (true) {
if ((D_801997D8->posX != (u16)~1) && !(D_801997D8->posX < arg0)) {
if ((g_LayoutObjHorizontal->posX != (u16)~1) &&
!(g_LayoutObjHorizontal->posX < arg0)) {
break;
}
D_801997D8++;
g_LayoutObjHorizontal++;
}
}
void func_80190884(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if ((D_801997D8->posX != 0xFFFF) &&
((arg0 >= (s32)D_801997D8->posX) || (D_801997D8->posX == 0xFFFE))) {
if ((g_LayoutObjHorizontal->posX != 0xFFFF) &&
((arg0 >= (s32)g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE))) {
break;
}
D_801997D8--;
g_LayoutObjHorizontal--;
}
}
@ -108,23 +110,24 @@ void func_801908DC(s16 arg0) {
s32 expected;
u8 flag;
if (D_801997E0 != 0) {
if (g_LayoutObjPosHorizontal != 0) {
func_80190838(arg0 - g_ScrollDeltaX);
D_801997E0 = 0;
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_801997D8->posX == 0xFFFF) || (arg0 < D_801997D8->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801997D8->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801997D8);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801997D8++;
g_LayoutObjHorizontal++;
}
}
@ -132,21 +135,23 @@ INCLUDE_ASM("asm/us/st/mad/nonmatchings/EDB8", func_801909D8);
void func_80190AD8(s16 arg0) {
while (true) {
if ((D_801997DC[1] != 0xFFFE) && ((s32)D_801997DC[1] >= arg0)) {
if ((g_LayoutObjVertical->posY != 0xFFFE) &&
(g_LayoutObjVertical->posY >= arg0)) {
break;
}
D_801997DC += 5;
g_LayoutObjVertical++;
}
}
void func_80190B24(s16 arg0) {
while (true) {
if ((D_801997DC[1] != 0xFFFF) &&
((arg0 >= D_801997DC[1] || D_801997DC[1] == 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
((arg0 >= g_LayoutObjVertical->posY ||
g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_801997DC -= 5;
g_LayoutObjVertical--;
}
}
@ -162,24 +167,25 @@ void InitRoomEntities(s32 objLayoutId) {
s16 i;
u16* temp_v1;
D_801997D8 = pObjLayoutStart;
D_801997DC = D_801803C8[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = D_801803C8[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801997D8 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801997D8;
D_801997D8 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801997D8 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801997D8 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801997DC += i * 2 + 2;
D_801997DC = (D_801997DC[1] << 0x10) + D_801997DC[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -188,14 +194,14 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801997E0 = 0;
D_801997E4 = 0;
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
func_80190838(i);
func_801908DC(temp_s0);
func_80190AD8(tilemap->scrollY.i.hi + 0x120);
}
void func_80190F04(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {

View File

@ -70,10 +70,10 @@ extern LayoutEntity* g_pStObjLayout[];
extern LayoutEntity* D_801803C8[];
extern PfnEntityUpdate PfnEntityUpdates[];
extern LayoutEntity* D_801997D8;
extern u16* D_801997DC;
extern u8 D_801997E0;
extern s8 D_801997E4;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern s8 g_LayoutObjPosVertical;
extern u16 g_eBreakableInit[];
extern u8* g_eBreakableAnimations[8];

View File

@ -85,51 +85,54 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_801C3730(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if ((D_801D7110->posX != (u16)~1) && !(D_801D7110->posX < arg0)) {
if ((g_LayoutObjHorizontal->posX != (u16)~1) &&
!(g_LayoutObjHorizontal->posX < arg0)) {
break;
}
D_801D7110++;
g_LayoutObjHorizontal++;
}
}
void func_801C377C(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if ((D_801D7110->posX == (u16)~0) ||
((arg0 < D_801D7110->posX) && (D_801D7110->posX != (u16)~1))) {
D_801D7110--;
if ((g_LayoutObjHorizontal->posX == (u16)~0) ||
((arg0 < g_LayoutObjHorizontal->posX) &&
(g_LayoutObjHorizontal->posX != (u16)~1))) {
g_LayoutObjHorizontal--;
} else {
break;
}
}
}
void func_801C37D4(s16 arg0) {
void CreateEntitiesToTheRight(s16 arg0) {
s32 expected;
u8 flag;
if (D_801D7118 != 0) {
func_801C3730(arg0 - g_ScrollDeltaX);
D_801D7118 = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_801D7110->posX == 0xFFFF) || (arg0 < D_801D7110->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801D7110->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801D7110);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801D7110++;
g_LayoutObjHorizontal++;
}
}
void func_801C38D0(s16 arg0) {
void CreateEntitiesToTheLeft(s16 arg0) {
u8 flag;
s32 expected;
@ -137,71 +140,75 @@ void func_801C38D0(s16 arg0) {
arg0 = 0;
}
if (D_801D7118 == 0) {
func_801C377C(arg0 - g_ScrollDeltaX);
D_801D7118 = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if ((D_801D7110->posX == 0xFFFE) || (arg0 > D_801D7110->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFE) ||
(arg0 > g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801D7110->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801D7110);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801D7110--;
g_LayoutObjHorizontal--;
}
}
void func_801C39E4(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if ((D_801D7114[1] != (u16)~1) && !(D_801D7114[1] < arg0)) {
if ((g_LayoutObjVertical->posY != (u16)~1) &&
!(g_LayoutObjVertical->posY < arg0)) {
break;
}
D_801D7114 += 5;
g_LayoutObjVertical++;
}
}
void func_801C3A30(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if (D_801D7114[1] == (u16)~0)
D_801D7114 -= 5;
else if ((arg0 >= (s32)D_801D7114[1]) || (D_801D7114[1] == (u16)~1))
if (g_LayoutObjVertical->posY == (u16)~0)
g_LayoutObjVertical--;
else if ((arg0 >= (s32)g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == (u16)~1))
break;
else
D_801D7114 -= 5;
g_LayoutObjVertical--;
}
}
void func_801C3A88(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
u8 flag;
s32 expected;
if (D_801D711C != 0) {
func_801C39E4(arg0 - g_ScrollDeltaY);
D_801D711C = 0;
if (g_LayoutObjPosVertical != 0) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if ((D_801D7114[1] == 0xFFFF) || (arg0 < D_801D7114[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFF) ||
(arg0 < g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801D7114[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801D7114);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801D7114 += 5;
g_LayoutObjVertical++;
}
}
void func_801C3B84(s16 arg0) {
void CreateEntitiesBelow(s16 arg0) {
u8 flag;
s32 expected;
@ -209,52 +216,54 @@ void func_801C3B84(s16 arg0) {
arg0 = 0;
}
if (D_801D711C == 0) {
func_801C3A30(arg0 - g_ScrollDeltaY);
D_801D711C = 1;
if (g_LayoutObjPosVertical == 0) {
FindFirstEntityBelow(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 1;
}
while (true) {
if ((D_801D7114[1] == 0xFFFE) || (arg0 > D_801D7114[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFE) ||
(arg0 > g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801D7114[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801D7114);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801D7114 -= 5;
g_LayoutObjVertical--;
}
}
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_801D7110 = pObjLayoutStart;
D_801D7114 = D_80180850[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801D7110 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801D7110;
D_801D7110 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801D7110 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801D7110 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801D7114 += i * 2 + 2;
D_801D7114 = (D_801D7114[1] << 0x10) + D_801D7114[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -263,35 +272,35 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801D7118 = 0;
D_801D711C = 0;
func_801C3730(i);
func_801C37D4(temp_s0);
func_801C39E4(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_801C37D4(s16);
void func_801C38D0(s16);
void func_801C3A88(s16);
void func_801C3B84(s16);
void CreateEntitiesToTheRight(s16);
void CreateEntitiesToTheLeft(s16);
void CreateEntitiesAbove(s16);
void CreateEntitiesBelow(s16);
void func_801C3E10(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0)
func_801C37D4(tmp + 0x140);
CreateEntitiesToTheRight(tmp + 0x140);
else
func_801C38D0(tmp - 0x40);
CreateEntitiesToTheLeft(tmp - 0x40);
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0)
func_801C3A88(tilemap->scrollY.i.hi + 0x120);
CreateEntitiesAbove(tilemap->scrollY.i.hi + 0x120);
else
func_801C3B84(tmp - 0x40);
CreateEntitiesBelow(tmp - 0x40);
}
}

View File

@ -89,7 +89,7 @@ extern void ReplaceBreakableWithItemDrop(Entity*);
extern s32 func_801C5D18(Entity* entity, s32 arg1, s32 arg2, s32 arg3);
extern Primitive* FindFirstUnkPrim(Primitive* poly);
extern LayoutEntity* D_80180850[];
extern LayoutEntity* g_pStObjLayoutVertical[];
extern u16 g_InitializeData0[];
extern u16 g_InitializeEntityData0[];
extern s16 D_80182A38[];
@ -235,10 +235,10 @@ extern u8 D_80183C84[];
extern u8 D_80183C98[];
extern s32 D_80183CAC;
extern s32 D_80183CBC;
extern LayoutEntity* D_801D7110;
extern u16* D_801D7114;
extern u8 D_801D7118;
extern u8 D_801D711C;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern s32 D_801D7D20;
extern s16 D_801D7D2A;
extern u16 D_801D7D2C;
@ -253,7 +253,7 @@ extern s32 D_801D7D58;
extern u32 D_801D7DD0;
extern u16 g_ItemIconSlots[0x20];
extern LayoutEntity* g_pStObjLayout[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern PfnEntityUpdate PfnEntityUpdates[];
// *** EntitySoulStealOrb properties START ***

View File

@ -79,50 +79,53 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_801BAFA0(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if ((D_801D2768->posX != 0xFFFE) && (D_801D2768->posX >= (s32)arg0)) {
if ((g_LayoutObjHorizontal->posX != 0xFFFE) &&
(g_LayoutObjHorizontal->posX >= (s32)arg0)) {
break;
}
D_801D2768++;
g_LayoutObjHorizontal++;
}
}
void func_801BAFEC(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if ((D_801D2768->posX != 0xFFFF) &&
((arg0 >= D_801D2768->posX) || (D_801D2768->posX == 0xFFFE))) {
if ((g_LayoutObjHorizontal->posX != 0xFFFF) &&
((arg0 >= g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE))) {
break;
}
D_801D2768--;
g_LayoutObjHorizontal--;
}
}
void func_801BB044(s16 arg0) {
void CreateEntitiesToTheRight(s16 arg0) {
s32 expected;
u8 flag;
if (D_801D2770 != 0) {
func_801BAFA0(arg0 - g_ScrollDeltaX);
D_801D2770 = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_801D2768->posX == 0xFFFF) || (arg0 < D_801D2768->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801D2768->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801D2768);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801D2768++;
g_LayoutObjHorizontal++;
}
}
void func_801BB140(s16 arg0) {
void CreateEntitiesToTheLeft(s16 arg0) {
u8 flag;
s32 expected;
@ -130,70 +133,74 @@ void func_801BB140(s16 arg0) {
arg0 = 0;
}
if (D_801D2770 == 0) {
func_801BAFEC(arg0 - g_ScrollDeltaX);
D_801D2770 = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if ((D_801D2768->posX == 0xFFFE) || (arg0 > D_801D2768->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFE) ||
(arg0 > g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801D2768->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801D2768);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801D2768--;
g_LayoutObjHorizontal--;
}
}
void func_801BB254(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if ((D_801D276C[1] != (u16)~1) && !(D_801D276C[1] < arg0)) {
if ((g_LayoutObjVertical->posY != (u16)~1) &&
!(g_LayoutObjVertical->posY < arg0)) {
break;
}
D_801D276C += 5;
g_LayoutObjVertical++;
}
}
void func_801BB2A0(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if ((D_801D276C[1] != 0xFFFF) &&
((arg0 >= D_801D276C[1]) || (D_801D276C[1] == 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
((arg0 >= g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_801D276C -= 5;
g_LayoutObjVertical--;
}
}
void func_801BB2F8(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
u8 flag;
s32 expected;
if (D_801D2774 != 0) {
func_801BB254(arg0 - g_ScrollDeltaY);
D_801D2774 = 0;
if (g_LayoutObjPosVertical != 0) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if ((D_801D276C[1] == 0xFFFF) || (arg0 < D_801D276C[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFF) ||
(arg0 < g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801D276C[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801D276C);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801D276C += 5;
g_LayoutObjVertical++;
}
}
void func_801BB3F4(s16 arg0) {
void CreateEntitiesBelow(s16 arg0) {
u8 flag;
s32 expected;
@ -201,52 +208,54 @@ void func_801BB3F4(s16 arg0) {
arg0 = 0;
}
if (D_801D2774 == 0) {
func_801BB2A0(arg0 - g_ScrollDeltaY);
D_801D2774 = 1;
if (g_LayoutObjPosVertical == 0) {
FindFirstEntityBelow(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 1;
}
while (true) {
if ((D_801D276C[1] == 0xFFFE) || (arg0 > D_801D276C[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFE) ||
(arg0 > g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801D276C[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801D276C);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801D276C -= 5;
g_LayoutObjVertical--;
}
}
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_801D2768 = pObjLayoutStart;
D_801D276C = D_801807FC[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801D2768 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801D2768;
D_801D2768 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801D2768 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801D2768 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801D276C += i * 2 + 2;
D_801D276C = (D_801D276C[1] << 0x10) + D_801D276C[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -255,30 +264,30 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801D2770 = 0;
D_801D2774 = 0;
func_801BAFA0(i);
func_801BB044(temp_s0);
func_801BB254(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_801BB680(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0)
func_801BB044(tmp + 320);
CreateEntitiesToTheRight(tmp + 320);
else
func_801BB140(tmp - 64);
CreateEntitiesToTheLeft(tmp - 64);
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0)
func_801BB2F8(tilemap->scrollY.i.hi + 288);
CreateEntitiesAbove(tilemap->scrollY.i.hi + 288);
else
func_801BB3F4(tmp - 64);
CreateEntitiesBelow(tmp - 64);
}
}

View File

@ -66,8 +66,8 @@ extern u16 g_eBreakableanimSets[];
extern u8 g_eBreakableDrawModes[];
extern u16 g_InitializeData0[];
extern u16 g_InitializeEntityData0[];
extern LayoutEntity* g_pStObjLayout[];
extern LayoutEntity* D_801807FC[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
extern u16 D_80180A60[];
extern u16 g_EInitGeneric[];
extern u16 D_80180A78[];
@ -288,10 +288,10 @@ extern s32 D_80182530;
// *** EntityBloodyZombie properties START ***
extern u16 D_80180B38[]; // InitProps
extern u8 D_801D2770;
extern u8 D_801D2774;
extern LayoutEntity* D_801D2768;
extern u16* D_801D276C;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern s32 D_801D3378;
extern s32 D_801D337C;
extern s32 D_801D3380;

View File

@ -85,50 +85,53 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_801BB3B8(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if ((D_801CAA74->posX != 0xFFFE) && (D_801CAA74->posX >= (s32)arg0)) {
if ((g_LayoutObjHorizontal->posX != 0xFFFE) &&
(g_LayoutObjHorizontal->posX >= (s32)arg0)) {
break;
}
D_801CAA74++;
g_LayoutObjHorizontal++;
}
}
void func_801BB404(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if (!(D_801CAA74->posX == 0xFFFF) &&
(((s32)arg0 >= D_801CAA74->posX) || (D_801CAA74->posX == 0xFFFE))) {
if (!(g_LayoutObjHorizontal->posX == 0xFFFF) &&
(((s32)arg0 >= g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE))) {
break;
}
D_801CAA74--;
g_LayoutObjHorizontal--;
}
}
void func_801BB45C(s16 arg0) {
void CreateEntitiesToTheRight(s16 arg0) {
s32 expected;
u8 flag;
if (D_801CAA7C != 0) {
func_801BB3B8(arg0 - g_ScrollDeltaX);
D_801CAA7C = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_801CAA74->posX == 0xFFFF) || (arg0 < D_801CAA74->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801CAA74->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801CAA74);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801CAA74++;
g_LayoutObjHorizontal++;
}
}
void func_801BB558(s16 arg0) {
void CreateEntitiesToTheLeft(s16 arg0) {
u8 flag;
s32 expected;
@ -136,70 +139,74 @@ void func_801BB558(s16 arg0) {
arg0 = 0;
}
if (D_801CAA7C == 0) {
func_801BB404(arg0 - g_ScrollDeltaX);
D_801CAA7C = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if ((D_801CAA74->posX == 0xFFFE) || (arg0 > D_801CAA74->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFE) ||
(arg0 > g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801CAA74->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801CAA74);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801CAA74--;
g_LayoutObjHorizontal--;
}
}
void func_801BB66C(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if ((D_801CAA78[1] != 0xFFFE) && (D_801CAA78[1] >= (s32)arg0)) {
if ((g_LayoutObjVertical->posY != 0xFFFE) &&
(g_LayoutObjVertical->posY >= (s32)arg0)) {
break;
}
D_801CAA78 += 5;
g_LayoutObjVertical++;
}
}
void func_801BB6B8(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if (!(D_801CAA78[1] == 0xFFFF) &&
(((s32)arg0 >= D_801CAA78[1]) || (D_801CAA78[1] == 0xFFFE))) {
if (!(g_LayoutObjVertical->posY == 0xFFFF) &&
(((s32)arg0 >= g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_801CAA78 -= 5;
g_LayoutObjVertical--;
}
}
void func_801BB710(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
u8 flag;
s32 expected;
if (D_801CAA80 != 0) {
func_801BB66C(arg0 - g_ScrollDeltaY);
D_801CAA80 = 0;
if (g_LayoutObjPosVertical != 0) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if ((D_801CAA78[1] == 0xFFFF) || (arg0 < D_801CAA78[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFF) ||
(arg0 < g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801CAA78[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801CAA78);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801CAA78 += 5;
g_LayoutObjVertical++;
}
}
void func_801BB80C(s16 arg0) {
void CreateEntitiesBelow(s16 arg0) {
u8 flag;
s32 expected;
@ -207,52 +214,54 @@ void func_801BB80C(s16 arg0) {
arg0 = 0;
}
if (D_801CAA80 == 0) {
func_801BB6B8(arg0 - g_ScrollDeltaY);
D_801CAA80 = 1;
if (g_LayoutObjPosVertical == 0) {
FindFirstEntityBelow(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 1;
}
while (true) {
if ((D_801CAA78[1] == 0xFFFE) || (arg0 > D_801CAA78[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFE) ||
(arg0 > g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801CAA78[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801CAA78);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801CAA78 -= 5;
g_LayoutObjVertical--;
}
}
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_801808EC[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_801CAA74 = pObjLayoutStart;
D_801CAA78 = D_801809C0[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801CAA74 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801CAA74;
D_801CAA74 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801CAA74 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801CAA74 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801CAA78 += i * 2 + 2;
D_801CAA78 = (D_801CAA78[1] << 0x10) + D_801CAA78[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -261,30 +270,30 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801CAA7C = 0;
D_801CAA80 = 0;
func_801BB3B8(i);
func_801BB45C(temp_s0);
func_801BB66C(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_801BBA98(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0)
func_801BB45C(tmp + 320);
CreateEntitiesToTheRight(tmp + 320);
else
func_801BB558(tmp - 64);
CreateEntitiesToTheLeft(tmp - 64);
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0)
func_801BB710(tilemap->scrollY.i.hi + 288);
CreateEntitiesAbove(tilemap->scrollY.i.hi + 288);
else
func_801BB80C(tmp - 64);
CreateEntitiesBelow(tmp - 64);
}
}

View File

@ -48,8 +48,8 @@ void EntityUnkId15(Entity* entity);
void func_801C4CC0(void);
extern u8 D_8003BE6F[];
extern LayoutEntity* D_801808EC[];
extern LayoutEntity* D_801809C0[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
extern PfnEntityUpdate PfnEntityUpdates[];
extern const u16 g_InitializeEntityData0[];
extern u16 D_80180BEC[];
@ -203,10 +203,10 @@ extern s32 D_80180ED0[];
extern s16 D_80181EDC[];
extern u32 D_80181EEC[];
extern ObjInit2 D_80182014[];
extern LayoutEntity* D_801CAA74;
extern u16* D_801CAA78;
extern u8 D_801CAA7C;
extern u8 D_801CAA80;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
// *** EntityAxeKnight properties START ***

View File

@ -85,55 +85,59 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_8018C04C(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if (D_80195A30->posX != 0xFFFE && (s32)D_80195A30->posX >= arg0) {
if (g_LayoutObjHorizontal->posX != 0xFFFE &&
(s32)g_LayoutObjHorizontal->posX >= arg0) {
break;
}
D_80195A30++;
g_LayoutObjHorizontal++;
}
}
void func_8018C098(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if ((D_80195A30->posX != 0xFFFF) &&
((arg0 >= D_80195A30->posX) || (D_80195A30->posX == 0xFFFE))) {
if ((g_LayoutObjHorizontal->posX != 0xFFFF) &&
((arg0 >= g_LayoutObjHorizontal->posX) ||
(g_LayoutObjHorizontal->posX == 0xFFFE))) {
break;
}
D_80195A30--;
g_LayoutObjHorizontal--;
}
}
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C0F0);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", CreateEntitiesToTheRight);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C1EC);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", CreateEntitiesToTheLeft);
void func_8018C300(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if (D_80195A34->posY != 0xFFFE && (s32)D_80195A34->posY >= arg0) {
if (g_LayoutObjVertical->posY != 0xFFFE &&
(s32)g_LayoutObjVertical->posY >= arg0) {
break;
}
D_80195A34++;
g_LayoutObjVertical++;
}
}
void func_8018C34C(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if ((D_80195A34->posY != 0xFFFF) &&
((arg0 >= D_80195A34->posY) || (D_80195A34->posY == 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
((arg0 >= g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_80195A34--;
g_LayoutObjVertical--;
}
}
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C3A4);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", CreateEntitiesAbove);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C4A0);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", CreateEntitiesBelow);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C5B4);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", InitRoomEntities);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", func_8018C72C);
INCLUDE_ASM("st/rwrp/nonmatchings/A59C", UpdateRoomPosition);
void CreateEntityFromCurrentEntity(u16 entityId, Entity* entity) {
DestroyEntity(entity);

View File

@ -15,8 +15,8 @@ extern u16 D_80180494[];
extern s16 D_80180A94[];
extern ObjInit2 D_80181134[];
extern LayoutEntity* D_80195A30;
extern LayoutEntity* D_80195A34;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
void CreateEntityFromLayout(Entity*, LayoutEntity*);
// *** EntitySoulStealOrb properties START ***

View File

@ -85,51 +85,53 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
extern LayoutEntity* D_801C00A0;
void func_801B33D4(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if (D_801C00A0->posX != 0xFFFE && D_801C00A0->posX >= arg0) {
if (g_LayoutObjHorizontal->posX != 0xFFFE &&
g_LayoutObjHorizontal->posX >= arg0) {
break;
}
D_801C00A0++;
g_LayoutObjHorizontal++;
}
}
void func_801B3420(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if (D_801C00A0->posX != 0xFFFF &&
(arg0 >= D_801C00A0->posX || D_801C00A0->posX == 0xFFFE)) {
if (g_LayoutObjHorizontal->posX != 0xFFFF &&
(arg0 >= g_LayoutObjHorizontal->posX ||
g_LayoutObjHorizontal->posX == 0xFFFE)) {
break;
}
D_801C00A0--;
g_LayoutObjHorizontal--;
}
}
void func_801B3478(s16 arg0) {
void CreateEntitiesToTheRight(s16 arg0) {
s32 expected;
u8 flag;
if (D_801C00A8 != 0) {
func_801B33D4(arg0 - g_ScrollDeltaX);
D_801C00A8 = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if ((D_801C00A0->posX == 0xFFFF) || (arg0 < D_801C00A0->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFF) ||
(arg0 < g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801C00A0->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801C00A0);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801C00A0++;
g_LayoutObjHorizontal++;
}
}
void func_801B3574(s16 arg0) {
void CreateEntitiesToTheLeft(s16 arg0) {
u8 flag;
s32 expected;
@ -137,70 +139,74 @@ void func_801B3574(s16 arg0) {
arg0 = 0;
}
if (D_801C00A8 == 0) {
func_801B3420(arg0 - g_ScrollDeltaX);
D_801C00A8 = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(arg0 - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if ((D_801C00A0->posX == 0xFFFE) || (arg0 > D_801C00A0->posX)) {
if ((g_LayoutObjHorizontal->posX == 0xFFFE) ||
(arg0 > g_LayoutObjHorizontal->posX)) {
return;
}
expected = 0;
flag = (D_801C00A0->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_801C00A0);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_801C00A0--;
g_LayoutObjHorizontal--;
}
}
void func_801B3688(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
while (true) {
if (D_801C00A4[1] != 0xFFFE && (s32)D_801C00A4[1] >= arg0) {
if (g_LayoutObjVertical->posY != 0xFFFE &&
g_LayoutObjVertical->posY >= arg0) {
break;
}
D_801C00A4 += 5;
g_LayoutObjVertical++;
}
}
void func_801B36D4(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if ((D_801C00A4[1] != 0xFFFF) &&
((arg0 >= D_801C00A4[1]) || (D_801C00A4[1] == 0xFFFE))) {
if ((g_LayoutObjVertical->posY != 0xFFFF) &&
((arg0 >= g_LayoutObjVertical->posY) ||
(g_LayoutObjVertical->posY == 0xFFFE))) {
break;
}
D_801C00A4 -= 5;
g_LayoutObjVertical--;
}
}
void func_801B372C(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
s32 expected;
u8 flag;
if (D_801C00AC != 0) {
func_801B3688(arg0 - g_ScrollDeltaY);
D_801C00AC = 0;
if (g_LayoutObjPosVertical != 0) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if ((D_801C00A4[1] == 0xFFFF) || (arg0 < D_801C00A4[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFF) ||
(arg0 < g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801C00A4[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801C00A4);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801C00A4 += 5;
g_LayoutObjVertical++;
}
}
void func_801B3828(s16 arg0) {
void CreateEntitiesBelow(s16 arg0) {
u8 flag;
s32 expected;
@ -208,52 +214,54 @@ void func_801B3828(s16 arg0) {
arg0 = 0;
}
if (D_801C00AC == 0) {
func_801B36D4(arg0 - g_ScrollDeltaY);
D_801C00AC = 1;
if (g_LayoutObjPosVertical == 0) {
FindFirstEntityBelow(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 1;
}
while (true) {
if ((D_801C00A4[1] == 0xFFFE) || (arg0 > D_801C00A4[1])) {
if ((g_LayoutObjVertical->posY == 0xFFFE) ||
(arg0 > g_LayoutObjVertical->posY)) {
return;
}
expected = 0;
flag = (D_801C00A4[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if ((flag == 0xFF) ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_801C00A4);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_801C00A4 -= 5;
g_LayoutObjVertical--;
}
}
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_80180314[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_801C00A0 = pObjLayoutStart;
D_801C00A4 = D_801803E8[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_801C00A0 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_801C00A0;
D_801C00A0 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_801C00A0 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_801C00A0 = (temp_v1[2] << 0x10) + temp_v1[1];
D_801C00A4 += i * 2 + 2;
D_801C00A4 = (D_801C00A4[1] << 0x10) + D_801C00A4[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -262,30 +270,30 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_801C00A8 = 0;
D_801C00AC = 0;
func_801B33D4(i);
func_801B3478(temp_s0);
func_801B3688(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_801B3AB4(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0)
func_801B3478(tmp + 320);
CreateEntitiesToTheRight(tmp + 320);
else
func_801B3574(tmp - 64);
CreateEntitiesToTheLeft(tmp - 64);
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0)
func_801B372C(tilemap->scrollY.i.hi + 288);
CreateEntitiesAbove(tilemap->scrollY.i.hi + 288);
else
func_801B3828(tmp - 64);
CreateEntitiesBelow(tmp - 64);
}
}

View File

@ -44,8 +44,8 @@ extern PfnEntityUpdate PfnEntityUpdates[];
extern bool g_isSecretStairsButtonPressed;
extern bool g_isDraculaFirstFormDefeated;
extern LayoutEntity* D_80180314[];
extern LayoutEntity* D_801803E8[];
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
// *** Initializers ***
extern u16 D_80180574[];
@ -145,9 +145,10 @@ extern u16 D_80181CDC[];
extern u32 D_80181CF0[];
extern s8 D_801A7B7C;
extern Point32 D_801BEB64[];
extern LayoutEntity* D_801C00A0;
extern u8 D_801C00A8;
extern u8 D_801C00AC;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern s32 D_801C2578;
extern u32 D_801C257C;
extern s32 D_801C2578;
@ -170,7 +171,6 @@ extern u8 D_801824CC[];
extern s8 D_801A7BDC;
extern Point32 D_801BEB64[];
extern u16* D_801C00A4;
extern s32 D_801C24C8;
extern s32 D_801C2578;
extern s32 D_801C2580;

View File

@ -64,7 +64,7 @@ LayoutEntity D_801812C8[];
LayoutEntity D_80181278[];
LayoutEntity D_801812F0[];
LayoutEntity D_80181304[];
LayoutEntity* g_pStObjLayout[] = {
LayoutEntity* g_pStObjLayoutHorizontal[] = {
/* 0x23C */ D_801812F0,
/* 0x240 */ D_80181228,
/* 0x244 */ D_80181250,
@ -127,7 +127,7 @@ LayoutEntity D_8018139C[];
LayoutEntity D_801813C4[];
LayoutEntity D_801813EC[];
LayoutEntity D_80181400[];
LayoutEntity* D_80180310[] = {
LayoutEntity* g_pStObjLayoutVertical[] = {
/* 310 */ D_801813EC,
/* 314 */ D_80181324,
/* 318 */ D_8018134C,
@ -1053,10 +1053,10 @@ u8* D_80180F70[] = {
};
// *** bss? section start ***
extern LayoutEntity* D_80193AB0;
extern u16* D_80193AB4;
extern u8 D_80193AB8;
extern u8 D_80193ABC;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern u8 g_LayoutObjPosVertical;
extern u16 g_ItemIconSlots[];
// *** bss? section end ***

View File

@ -8,13 +8,14 @@ extern u16 D_80180DF4[];
extern u16 g_ItemIconSlots[];
extern u16 UNK_Invincibility0[];
extern PfnEntityUpdate PfnEntityUpdates[];
extern LayoutEntity* D_80193AB0;
extern u8 D_80193AB8;
extern u16* D_80193AB4;
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
extern u8 g_LayoutObjPosHorizontal;
extern s16 D_80180A94[];
extern LayoutEntity* D_80180310[];
extern u8 D_80193ABC;
extern LayoutEntity* g_pStObjLayout[];
extern u8 g_LayoutObjPosVertical;
extern LayoutEntity* g_pStObjLayoutHorizontal[];
extern LayoutEntity* g_pStObjLayoutVertical[];
INCLUDE_ASM("st/wrp/nonmatchings/861C", TestCollisions);
@ -102,125 +103,131 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
}
}
void func_8018A0CC(s16 arg0) {
void FindFirstEntityToTheRight(s16 arg0) {
while (true) {
if (D_80193AB0->posX != 0xFFFE && D_80193AB0->posX >= arg0) {
if (g_LayoutObjHorizontal->posX != 0xFFFE &&
g_LayoutObjHorizontal->posX >= arg0) {
break;
}
D_80193AB0++;
g_LayoutObjHorizontal++;
}
}
void func_8018A118(s16 arg0) {
void FindFirstEntityToTheLeft(s16 arg0) {
while (true) {
if (D_80193AB0->posX != 0xFFFF &&
(arg0 >= D_80193AB0->posX || D_80193AB0->posX == 0xFFFE)) {
if (g_LayoutObjHorizontal->posX != 0xFFFF &&
(arg0 >= g_LayoutObjHorizontal->posX ||
g_LayoutObjHorizontal->posX == 0xFFFE)) {
break;
}
D_80193AB0--;
g_LayoutObjHorizontal--;
}
}
void func_8018A170(s16 x) {
void CreateEntitiesToTheRight(s16 x) {
u8 flag;
s32 expected;
if (D_80193AB8 != 0) {
func_8018A0CC(x - g_ScrollDeltaX);
D_80193AB8 = 0;
if (g_LayoutObjPosHorizontal != 0) {
FindFirstEntityToTheRight(x - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 0;
}
while (true) {
if (D_80193AB0->posX == 0xFFFF || D_80193AB0->posX > x) {
if (g_LayoutObjHorizontal->posX == 0xFFFF ||
g_LayoutObjHorizontal->posX > x) {
return;
}
expected = 0;
flag = (D_80193AB0->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if (flag == 0xFF ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_80193AB0);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_80193AB0++;
g_LayoutObjHorizontal++;
}
}
void func_8018A26C(s16 x) {
void CreateEntitiesToTheLeft(s16 x) {
u8 flag;
s32 expected;
if (x < 0) {
x = 0;
}
if (D_80193AB8 == 0) {
func_8018A118(x - g_ScrollDeltaX);
D_80193AB8 = 1;
if (g_LayoutObjPosHorizontal == 0) {
FindFirstEntityToTheLeft(x - g_ScrollDeltaX);
g_LayoutObjPosHorizontal = 1;
}
while (true) {
if (D_80193AB0->posX == 0xFFFE || x > D_80193AB0->posX) {
if (g_LayoutObjHorizontal->posX == 0xFFFE ||
x > g_LayoutObjHorizontal->posX) {
return;
}
expected = 0;
flag = (D_80193AB0->entityRoomIndex >> 8) + 0xFF;
flag = (g_LayoutObjHorizontal->entityRoomIndex >> 8) + 0xFF;
if (flag == 0xFF ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInVerticalRange(D_80193AB0);
CreateEntityWhenInVerticalRange(g_LayoutObjHorizontal);
}
D_80193AB0 -= 1;
g_LayoutObjHorizontal--;
}
}
void func_8018A26C(s16);
void func_8018A380(s16 arg0) {
void FindFirstEntityAbove(s16 arg0) {
u16 a1 = -2;
s32 tmp = arg0;
arg0 = (s16)arg0;
loop_1:
if (D_80193AB4[1] == (s32)a1 || D_80193AB4[1] < tmp) {
D_80193AB4 += sizeof(LayoutEntity) / sizeof(u16);
if (g_LayoutObjVertical->posY == (s32)a1 ||
g_LayoutObjVertical->posY < tmp) {
g_LayoutObjVertical++;
goto loop_1;
}
}
void func_8018A3CC(s16 arg0) {
void FindFirstEntityBelow(s16 arg0) {
while (true) {
if (D_80193AB4[1] == 0xFFFF) {
D_80193AB4 -= sizeof(LayoutEntity) / sizeof(u16);
} else if ((s32)arg0 >= (s32)D_80193AB4[1] || D_80193AB4[1] == 0xFFFE) {
if (g_LayoutObjVertical->posY == 0xFFFF) {
g_LayoutObjVertical--;
} else if ((s32)arg0 >= (s32)g_LayoutObjVertical->posY ||
g_LayoutObjVertical->posY == 0xFFFE) {
break;
} else {
D_80193AB4 -= sizeof(LayoutEntity) / sizeof(u16);
g_LayoutObjVertical--;
}
}
}
void func_8018A424(s16 arg0) {
void CreateEntitiesAbove(s16 arg0) {
u8 flag;
s32 expected;
if (D_80193ABC) {
func_8018A380(arg0 - g_ScrollDeltaY);
D_80193ABC = 0;
if (g_LayoutObjPosVertical) {
FindFirstEntityAbove(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 0;
}
while (true) {
if (D_80193AB4[1] == 0xFFFF || D_80193AB4[1] > arg0) {
if (g_LayoutObjVertical->posY == 0xFFFF ||
g_LayoutObjVertical->posY > arg0) {
break;
}
expected = 0;
flag = (D_80193AB4[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if (flag == 0xFF ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_80193AB4);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_80193AB4 += sizeof(LayoutEntity) / sizeof(u16);
g_LayoutObjVertical++;
}
}
void func_8018A520(s16 arg0) {
void CreateEntitiesBelow(s16 arg0) {
u8 flag;
s32 expected;
@ -228,52 +235,54 @@ void func_8018A520(s16 arg0) {
arg0 = 0;
}
if (D_80193ABC == 0) {
func_8018A3CC(arg0 - g_ScrollDeltaY);
D_80193ABC = 1;
if (g_LayoutObjPosVertical == 0) {
FindFirstEntityBelow(arg0 - g_ScrollDeltaY);
g_LayoutObjPosVertical = 1;
}
while (true) {
if (D_80193AB4[1] == 0xFFFE || arg0 > D_80193AB4[1]) {
if (g_LayoutObjVertical->posY == 0xFFFE ||
arg0 > g_LayoutObjVertical->posY) {
return;
}
expected = 0;
flag = (D_80193AB4[3] >> 8) + 0xFF;
flag = (g_LayoutObjVertical->entityRoomIndex >> 8) + 0xFF;
if (flag == 0xFF ||
(g_entityDestroyed[flag >> 5] & (1 << (flag & 0x1F))) == expected) {
CreateEntityWhenInHorizontalRange(D_80193AB4);
CreateEntityWhenInHorizontalRange(g_LayoutObjVertical);
}
D_80193AB4 -= sizeof(LayoutEntity) / sizeof(u16);
g_LayoutObjVertical--;
}
}
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
u16* pObjLayoutStart = g_pStObjLayoutHorizontal[objLayoutId];
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
u16* temp_v1;
D_80193AB0 = pObjLayoutStart;
D_80193AB4 = D_80180310[objLayoutId];
g_LayoutObjHorizontal = pObjLayoutStart;
g_LayoutObjVertical = g_pStObjLayoutVertical[objLayoutId];
if (*pObjLayoutStart != 0xFFFE) {
D_80193AB0 = pObjLayoutStart + 1;
g_LayoutObjHorizontal = pObjLayoutStart + 1;
arg0 = Random() & 0xFF;
for (i = 0; true; i++) {
temp_v1 = D_80193AB0;
D_80193AB0 = temp_v1 + 1;
temp_v1 = g_LayoutObjHorizontal;
g_LayoutObjHorizontal = temp_v1 + 1;
arg0 -= temp_v1[0];
if (arg0 < 0) {
break;
}
D_80193AB0 = temp_v1 + 3;
g_LayoutObjHorizontal = temp_v1 + 3;
}
D_80193AB0 = (temp_v1[2] << 0x10) + temp_v1[1];
D_80193AB4 += i * 2 + 2;
D_80193AB4 = (D_80193AB4[1] << 0x10) + D_80193AB4[0];
g_LayoutObjHorizontal = (temp_v1[2] << 0x10) + temp_v1[1];
((u16*)g_LayoutObjVertical) += i * 2 + 2;
g_LayoutObjVertical =
(g_LayoutObjVertical->posY << 0x10) + g_LayoutObjVertical->posX;
}
arg0 = tilemap->scrollX.i.hi;
temp_s0 = arg0 + 0x140;
@ -282,30 +291,30 @@ void InitRoomEntities(s32 objLayoutId) {
i = 0;
}
D_80193AB8 = 0;
D_80193ABC = 0;
func_8018A0CC(i);
func_8018A170(temp_s0);
func_8018A380(tilemap->scrollY.i.hi + 0x120);
g_LayoutObjPosHorizontal = 0;
g_LayoutObjPosVertical = 0;
FindFirstEntityToTheRight(i);
CreateEntitiesToTheRight(temp_s0);
FindFirstEntityAbove(tilemap->scrollY.i.hi + 0x120);
}
void func_8018A7AC(void) {
void UpdateRoomPosition(void) {
Tilemap* tilemap = &g_Tilemap;
if (g_ScrollDeltaX != 0) {
s16 tmp = tilemap->scrollX.i.hi;
if (g_ScrollDeltaX > 0)
func_8018A170(tmp + 0x140);
CreateEntitiesToTheRight(tmp + 0x140);
else
func_8018A26C(tmp - 0x40);
CreateEntitiesToTheLeft(tmp - 0x40);
}
if (g_ScrollDeltaY != 0) {
s16 tmp = tilemap->scrollY.i.hi;
if (g_ScrollDeltaY > 0)
func_8018A424(tilemap->scrollY.i.hi + 0x120);
CreateEntitiesAbove(tilemap->scrollY.i.hi + 0x120);
else
func_8018A520(tmp - 0x40);
CreateEntitiesBelow(tmp - 0x40);
}
}

View File

@ -4,7 +4,7 @@ void Update(void);
void TestCollisions(void);
void CreateEntityWhenInHorizontalRange(LayoutEntity*);
void func_8018A520(s16);
void func_8018A7AC(void);
void UpdateRoomPosition(void);
void func_8018CAB0(void);
void InitRoomEntities(s32 objLayoutId);
void func_801916C4(u16);
@ -20,7 +20,7 @@ void UpdateStageEntities(void);
Overlay g_StageOverlay = {
/* 0x00 */ Update,
/* 0x04 */ TestCollisions,
/* 0x08 */ func_8018A7AC,
/* 0x08 */ UpdateRoomPosition,
/* 0x0C */ InitRoomEntities,
/* 0x10 */ g_Rooms,
/* 0x14 */ g_SpriteBanks,