diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-06-11 19:48:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-11 19:48:16 -0700 |
| commit | 16ffc97541e2ce3d8c010854addb7af8ae7da7ff (patch) | |
| tree | dafeda60efe80c74e94c1e073b7c80f0578dd70b /src | |
| parent | 06d6f7aaa4502698ddef83821c258f835ea41fbd (diff) | |
| parent | e11cfed066a3c7cc2fdbbdb34ca15e80b224997b (diff) | |
Merge pull request #520 from octorock/misc
Decompile some functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/enemy/armos.c | 4 | ||||
| -rw-r--r-- | src/enemy/gyorgFemale.c | 13 | ||||
| -rw-r--r-- | src/enemy/helmasaur.c | 7 | ||||
| -rw-r--r-- | src/enemy/sensorBladeTrap.c | 9 | ||||
| -rw-r--r-- | src/game.c | 33 | ||||
| -rw-r--r-- | src/movement.c | 6 | ||||
| -rw-r--r-- | src/npc.c | 6 | ||||
| -rw-r--r-- | src/npc/npc5.c | 23 | ||||
| -rw-r--r-- | src/object/fan.c | 14 | ||||
| -rw-r--r-- | src/object/objectB2.c | 11 | ||||
| -rw-r--r-- | src/playerUtils.c | 61 | ||||
| -rw-r--r-- | src/projectile/guardLineOfSight.c | 3 | ||||
| -rw-r--r-- | src/scroll.c | 91 |
13 files changed, 200 insertions, 81 deletions
diff --git a/src/enemy/armos.c b/src/enemy/armos.c index 076c278d..a2be046f 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -28,8 +28,6 @@ typedef struct { } ArmosEntity; extern Entity* gUnk_020000B0; -extern u8 gUnk_02027EB4[]; -extern u8 gUnk_0200D654[]; extern void (*const gUnk_080CE124[])(ArmosEntity*); extern void (*const gUnk_080CE13C[])(ArmosEntity*); @@ -380,7 +378,7 @@ void sub_080306C4(ArmosEntity* this) { if (!var) { super->direction = (4 + uVar3 + ((Random() & 2) - 1) * 8) & 0x18; } - if (IsTileCollision(super->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4, + if (IsTileCollision(super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData, super->x.HALF.HI + gUnk_080CE164[super->direction >> 2], super->y.HALF.HI + gUnk_080CE164[(super->direction >> 2) + 1], 0)) { super->direction = ((u8)(((uVar3 & 4) ^ 4) << 1)) | (uVar3 & 0x10); diff --git a/src/enemy/gyorgFemale.c b/src/enemy/gyorgFemale.c index a5f35588..a5948446 100644 --- a/src/enemy/gyorgFemale.c +++ b/src/enemy/gyorgFemale.c @@ -30,7 +30,6 @@ void sub_080467DC(GyorgFemaleEntity*); extern u8 gUpdateVisibleTiles; extern u8 gUnk_080B3E80[]; extern u8 gUnk_080B37A0[]; -extern u16 gMetatileTypesTop[]; extern const u8 gUnk_080D1A94[]; extern const u8 gUnk_080D1AAC[]; @@ -249,17 +248,17 @@ NONMATCH("asm/non_matching/gyorg_female/sub_08046518.inc", void sub_08046518(voi u8* r6; u32 i; u16* sl; - sl = &gMetatileTypesTop[0xFFFFBCB0]; - stack1 = &gMetatileTypesTop[0xFFFFECB0]; - stack2 = (u8*)&gMetatileTypesTop[0x00006658]; - r6 = (u8*)&gMetatileTypesTop[0xFFFFD658]; + sl = &gMapTop.metatileTypes[0xFFFFBCB0]; + stack1 = &gMapTop.metatileTypes[0xFFFFECB0]; + stack2 = (u8*)&gMapTop.metatileTypes[0x00006658]; + r6 = (u8*)&gMapTop.metatileTypes[0xFFFFD658]; for (i = 0; i < 0x10; i++) { sl += 0x40; stack1 += 0x40; for (r5 = 0; r5 < 0x10; r5++) { stack1[r5] = sl[r5]; - stack2[r5] = gUnk_080B37A0[gMetatileTypesTop[sl[r5]]]; - r6[r5] = gUnk_080B3E80[gMetatileTypesTop[sl[r5]]]; + stack2[r5] = gUnk_080B37A0[gMapTop.metatileTypes[sl[r5]]]; + r6[r5] = gUnk_080B3E80[gMapTop.metatileTypes[sl[r5]]]; } stack2 = stack2 + 0x40; r6 = r6 + 0x40; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 553e20e9..dd279482 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -12,9 +12,6 @@ extern u32 sub_0804A024(Entity*, u32, u32); -extern u8 gUnk_0200D654[]; -extern u8 gUnk_02027EB4[]; - void sub_0802C18C(Entity*); void sub_0802C218(Entity*); void sub_0802C1C0(Entity*); @@ -317,7 +314,7 @@ bool32 sub_0802C06C(Entity* this) { u32 xdiff = gUnk_080CD45C[(this->direction >> 2) + 0]; u32 ydiff = gUnk_080CD45C[(this->direction >> 2) + 1]; - u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData; u32 i; for (i = 0; i < 8; i++) { @@ -340,7 +337,7 @@ bool32 sub_0802C0E8(Entity* this) { s32 x = this->x.HALF.HI + this->hitbox->offset_x + ptr[0] * 6; s32 y = this->y.HALF.HI + this->hitbox->offset_y + ptr[1] * 6; - u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData; u32 ret = FALSE; if (!sub_0806FC24(TILE(x, y), 9)) { if (IsTileCollision(layer, x, y, 0)) { diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c index 3736305c..627a75bb 100644 --- a/src/enemy/sensorBladeTrap.c +++ b/src/enemy/sensorBladeTrap.c @@ -4,16 +4,13 @@ * * @brief Sensor Blade Trap enemy */ - +#include "collision.h" #include "enemy.h" +#include "map.h" #include "physics.h" -#include "collision.h" extern u32 sub_0804A024(Entity*, u32, u32); -extern u8 gUnk_02027EB4[]; -extern u8 gUnk_0200D654[]; - void sub_0802BB10(Entity*); bool32 sub_0802BB2C(Entity*, u32); @@ -99,7 +96,7 @@ void sub_0802BB10(Entity* this) { } bool32 sub_0802BB2C(Entity* this, u32 param_2) { - u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData; const s8* ptr = &gUnk_080CD3DC[param_2 >> 2]; return IsTileCollision(layer, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0); } @@ -242,6 +242,16 @@ extern void sub_0806F38C(void); extern void sub_08018710(u32); +typedef struct { + Font* font; + u16 width; + u16 height; + u16 transitionTimer; + u16 fadeSpeed; +} struct_080FCCB4; + +extern struct_080FCCB4 gUnk_080FCCB4[]; + void GameTask(void) { static GameState* const sStates[] = { GameTask_Transition, @@ -1888,7 +1898,28 @@ void sub_08053758(void) { SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100); } -ASM_FUNC("asm/non_matching/game/sub_08053800.inc", void sub_08053800()) +void sub_08053800(void) { + u32 index; + struct_080FCCB4* ptr; + if (gFadeControl.active == 0) { + index = gGenericMenu.unk10.a[0]; + ptr = &gUnk_080FCCB4[index]; + gGenericMenu.base.transitionTimer = ptr->transitionTimer; + gGenericMenu.base.field_0xa = 0x1e; + gGenericMenu.unk10.a[0]++; + gGenericMenu.base.overlayType++; + gGenericMenu.base.storyPanelIndex = 0; + LoadPaletteGroup(index + 0x8a); + LoadGfxGroup(index + 0x3a); + MemClear(&gBG1Buffer, 0x800); + sub_0805F46C(index + 0xf01, ptr->font); + gScreen.bg1.updated = 1; + gScreen.controls.alphaBlend = 0x10; + gScreen.controls.window0HorizontalDimensions = ptr->width; + gScreen.controls.window0VerticalDimensions = ptr->height; + SetFade(FADE_INSTANT, ptr->fadeSpeed); + } +} void sub_08053894(void) { u32 tmp; diff --git a/src/movement.c b/src/movement.c index 3224af88..87c70b0c 100644 --- a/src/movement.c +++ b/src/movement.c @@ -281,14 +281,14 @@ bool32 TileCollisionFunction9(s32 x, s32 y) { return gUnk_081339F8[y & 0xf] >> (x & 0xf) & 1; } -bool32 IsTileCollision(const u8* layer, s32 x, s32 y, u32 collisionType) { +bool32 IsTileCollision(const u8* collisionData, s32 x, s32 y, u32 collisionType) { static bool32 (*const tileCollisionFunctions[])(s32, s32) = { TileCollisionFunction0, TileCollisionFunction1, TileCollisionFunction2, TileCollisionFunction3, TileCollisionFunction4, TileCollisionFunction5, TileCollisionFunction6, TileCollisionFunction7, TileCollisionFunction8, TileCollisionFunction9, }; - u32 tileType = layer[TILE(x, y)]; + u32 tileType = collisionData[TILE(x, y)]; if (tileType == 0) { if (collisionType == 4) { return TRUE; @@ -311,7 +311,7 @@ bool32 IsTileCollision(const u8* layer, s32 x, s32 y, u32 collisionType) { } // Calculation for 0xff in previous lookup. if ((y & 8) == 0) { - tileType = layer[TILE(x, y)]; + tileType = collisionData[TILE(x, y)]; tileType >>= 2; } if ((x & 8) == 0) { @@ -144,7 +144,7 @@ typedef struct { u16 x; u16 y; } NPCStruct; -extern NPCStruct gUnk_02031EC0[100]; +extern NPCStruct gNPCData[100]; void InitNPC(Entity*); @@ -161,8 +161,8 @@ NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this gNPCFunctions[this->id][1](this); if ((this->health & 0x7f) != 0) { u32 temp = this->health & 0x7f; - gUnk_02031EC0[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x; - gUnk_02031EC0[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y; + gNPCData[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x; + gNPCData[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y; } DrawEntity(this); } diff --git a/src/npc/npc5.c b/src/npc/npc5.c index dc198f48..ecfc685f 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -48,9 +48,6 @@ void sub_08061B18(Entity*); u32 PointInsideRadius(s32, s32, s32); -extern u8 gUnk_0200D654[]; -extern u8 gUnk_02027EB4[]; - u32 sub_080611D4(Entity*); extern u32 sub_08079FD4(Entity*, u32); extern void sub_08016AD2(Entity*); @@ -376,9 +373,9 @@ bool32 sub_08060FD0(Entity* this, u32 a, u32 b) { sVar2 = gSineTable[(iVar3 + 0x40)] * 6; if (this->collisionLayer != 2) { - puVar8 = gUnk_02027EB4; + puVar8 = gMapBottom.collisionData; } else { - puVar8 = gUnk_0200D654; + puVar8 = gMapTop.collisionData; } while (1) { @@ -685,7 +682,7 @@ void sub_08061464(Entity* this, u32 param_a, u32 param_b) { bool32 sub_08061630(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A74(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; @@ -702,7 +699,7 @@ bool32 sub_08061630(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_080616A8(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A1C(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; @@ -719,7 +716,7 @@ bool32 sub_080616A8(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061720(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_080619F0(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; @@ -736,7 +733,7 @@ bool32 sub_08061720(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061798(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A48(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; @@ -753,7 +750,7 @@ bool32 sub_08061798(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061810(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A74(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; @@ -770,7 +767,7 @@ bool32 sub_08061810(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061888(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A1C(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; @@ -787,7 +784,7 @@ bool32 sub_08061888(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061900(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_080619F0(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; @@ -804,7 +801,7 @@ bool32 sub_08061900(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061978(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + u8* layer = (this->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { if (sub_08061A48(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; diff --git a/src/object/fan.c b/src/object/fan.c index b9a98d01..0a3c3550 100644 --- a/src/object/fan.c +++ b/src/object/fan.c @@ -37,8 +37,6 @@ void Fan_Action2(FanEntity* this); void Fan_Action3(FanEntity* this); bool32 sub_0809EF78(FanEntity*, Entity*); -extern const u8 gUnk_02027EB4[]; - void Fan(Entity* this) { static void (*const actionFuncs[])(FanEntity*) = { Fan_Init, @@ -172,19 +170,19 @@ void sub_0809EFB0(FanEntity* this) { s32 sVar4; int iVar6; int iVar7; - const u8* ptr; + const u8* collisionData; cVar1 = tileTypeOffsets[super->type * 2]; cVar2 = tileTypeOffsets[super->type * 2 + 1]; iVar7 = super->x.HALF.HI; iVar6 = super->y.HALF.HI; - ptr = gUnk_02027EB4; + collisionData = gMapBottom.collisionData; sVar4 = 0; do { sVar4++; iVar7 = iVar7 + cVar1; iVar6 = iVar6 + cVar2; - } while (!IsTileCollision(ptr, iVar7, iVar6, 9)); + } while (!IsTileCollision(collisionData, iVar7, iVar6, 9)); sVar4 = (sVar4 - 1) << 4; switch (super->type) { @@ -237,13 +235,13 @@ void sub_0809F08C(FanEntity* this) { void sub_0809F0E4(FanEntity* this) { static const s8 typeOffsets[] = { 0, 12, -12, 0, 0, -12, 12, 0 }; Entity* pEVar1; - const s8* ptr; + const s8* collisionData; EnqueueSFX(SFX_183); pEVar1 = CreateObject(OBJECT_B2, super->type ^ 2, 0); if (pEVar1 != NULL) { pEVar1->parent = super; - ptr = typeOffsets + super->type * 2; - PositionRelative(super, pEVar1, ptr[0] << 0x10, ptr[1] << 0x10); + collisionData = typeOffsets + super->type * 2; + PositionRelative(super, pEVar1, collisionData[0] << 0x10, collisionData[1] << 0x10); } } diff --git a/src/object/objectB2.c b/src/object/objectB2.c index dae02bf1..7cbff895 100644 --- a/src/object/objectB2.c +++ b/src/object/objectB2.c @@ -3,22 +3,19 @@ #include "functions.h" #include "collision.h" -extern u8 gUnk_02027EB4[]; -extern u8 gUnk_0200D654[]; - void ObjectB2(Entity* this) { - u8* layer; + u8* collisionData; if (this->action == 0) { this->action = 1; this->timer = 0x10; this->direction = this->type << 3; if (this->collisionLayer == 2) { - layer = gUnk_0200D654; + collisionData = gMapTop.collisionData; } else { - layer = gUnk_02027EB4; + collisionData = gMapBottom.collisionData; } - this->child = (Entity*)layer; + this->child = (Entity*)collisionData; InitializeAnimation(this, this->type); } this->speed = this->parent->speed; diff --git a/src/playerUtils.c b/src/playerUtils.c index f262b98b..684693eb 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -150,7 +150,6 @@ extern const u8 gUnk_080B3E80[]; // collisions for tiles > 0x4000 extern const u8 gUnk_080B79A7[]; -extern void sub_08080B60(LayerStruct*); extern void sub_0801AB08(u16*, LayerStruct*); extern u8 gUnk_02006F00[]; @@ -166,6 +165,12 @@ void sub_0807BC84(void); void sub_0807C5F4(u16*, u16*); void sub_0807C5B0(void); +extern u8 gUnk_080082DC[]; +extern u32 sub_08004202(Entity*, u8*, u32); + +extern s8* gUnk_0811C0B0[]; +extern u8 gUnk_0811C01C[]; + void sub_08077698(PlayerEntity* this) { ItemBehavior* puVar2; u32 idx; @@ -1207,7 +1212,28 @@ void UpdateCarriedObject(void) { } } -ASM_FUNC("asm/non_matching/playerUtils/sub_08078CD0.inc", void sub_08078CD0()) +void sub_08078CD0(PlayerEntity* this) { + Entity* entity; + u32 tmp; + s8* ptr; + + entity = this->unk_70; + entity->z.HALF.HI = super->z.HALF.HI - 1; + entity->spriteOrientation.flipY = super->spriteOrientation.flipY; + entity->collisionLayer = super->collisionLayer; + tmp = gUnk_0811C01C[gPlayerState.item->frameIndex]; + ptr = (gUnk_0811C0B0[(((entity->gustJarFlags & 0x30) / 16))] + (tmp * 2)); + if (super->spriteSettings.flipX) { + entity->x.HALF.HI = -ptr[0] + super->x.HALF_U.HI; + } else { + entity->x.HALF.HI = super->x.HALF_U.HI + ptr[0]; + } + entity->y.HALF.HI = super->y.HALF.HI + ptr[1]; + sub_0806FEBC(super, 0, entity); + if (entity->parent != NULL) { + CopyPosition(entity, entity->parent); + } +} ASM_FUNC("asm/non_matching/playerUtils/sub_08078D60.inc", void sub_08078D60()) @@ -1655,7 +1681,36 @@ u32 sub_08079FC4(u32 param_1) { return sub_08079FD4(&gPlayerEntity, param_1); } -ASM_FUNC("asm/non_matching/playerUtils/sub_08079FD4.inc", u32 sub_08079FD4(Entity* a, u32 b)) +u32 sub_08079FD4(Entity* this, u32 param_2) { + u32 tilePosition; + u8* collisionData; + u32 collision; + u32 index; + u8 auStack20[4]; + + tilePosition = COORD_TO_TILE(this) * 2; + collisionData = gMapBottom.collisionData; + if (param_2 == 2) { + collisionData = gMapTop.collisionData; + } + index = 0; + while (TRUE) { + do { + index++; + tilePosition = sub_08004202(this, auStack20, tilePosition); + collision = collisionData[tilePosition / 2]; + if (collision < 0xf) { + return index; + } + } while (collision < 0x10); + if (collision == 0x1d) + break; + if (((collision != 0x23) && (collision != 0x27)) && (gUnk_080082DC[collision - 0x10] == 0)) { + return index; + } + } + return index; +} void sub_0807A050(void) { u32 palette; diff --git a/src/projectile/guardLineOfSight.c b/src/projectile/guardLineOfSight.c index 37027b06..52c8cada 100644 --- a/src/projectile/guardLineOfSight.c +++ b/src/projectile/guardLineOfSight.c @@ -7,7 +7,6 @@ #include "collision.h" extern u32 sub_080644C8(Entity*); -extern u8 gUnk_02027EB4[]; extern const u8 gUnk_081299C8[]; @@ -63,7 +62,7 @@ void GuardLineOfSight(Entity* this) { DeleteThisEntity(); } LinearMoveUpdate(this); - if (IsTileCollision(gUnk_02027EB4, this->x.HALF.HI, this->y.HALF.HI, 2)) { + if (IsTileCollision(gMapBottom.collisionData, this->x.HALF.HI, this->y.HALF.HI, 2)) { DeleteThisEntity(); } } diff --git a/src/scroll.c b/src/scroll.c index 4a3c4742..7a4abdc0 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -13,8 +13,8 @@ extern void sub_08080BC4(void); extern void sub_080197D4(const void*); -extern void sub_0807C8B0(u8*, u32, u32); -extern void sub_0801AB08(u8*, u8*); +extern void sub_0807C8B0(u16*, u32, u32); +extern void sub_0801AB08(u8*, LayerStruct*); extern void sub_0807C810(); extern void DeleteSleepingEntities(void); extern void sub_0807BBE4(); @@ -24,10 +24,8 @@ extern void sub_0805E248(); extern u8 gUpdateVisibleTiles; extern u16 gUnk_0200B640; extern u32** gUnk_08109194[]; -extern u8 gMapDataTop[]; -extern u8 gMapDataBottom[]; extern u8 gUnk_02022830[]; -extern u8 gUnk_020246B0[]; +extern u16 gUnk_020246B0[]; void sub_0807FC64(RoomControls*); void sub_0807FC7C(RoomControls*); @@ -51,7 +49,7 @@ u32 sub_080803D0(); u32 sub_08080278(); void sub_08080C80(u32*); void sub_08080368(); -void sub_08080B60(u8*); +void sub_08080B60(LayerStruct*); bool32 sub_08080794(const Transition* transition, u32 param_2, u32 param_3, u32 param_4); bool32 sub_08080808(const Transition* transition, u32 param_2, u32 param_3, u32 param_4); void sub_080808D8(s32); @@ -61,6 +59,8 @@ void sub_08080910(s32); extern u8 gMapDataTopSpecial[]; +extern const s8 gUnk_080169A4[]; + void UpdateScroll(void) { static void (*const gUnk_0811E768[])(RoomControls*) = { sub_0807FC64, sub_0807FC7C, sub_0807FDB0, NULL, sub_0807FEF0, sub_0807FF54, @@ -214,8 +214,8 @@ void sub_0807FFE4(RoomControls* controls) { controls->filler2[0] = sub_080803D0() + 6; gUnk_0200B640 = sub_08080278(); sub_080197D4(*gUnk_08109194[gDiggingCaveEntranceTransition.entrance->type]); - sub_0807C8B0(gMapDataTop, controls->width >> 4, controls->height >> 4); - sub_0801AB08(gMapDataTopSpecial, gMapDataTop - 4); + sub_0807C8B0(gMapTop.mapData, controls->width >> 4, controls->height >> 4); + sub_0801AB08(gMapDataTopSpecial, &gMapTop); } void sub_08080040(RoomControls* controls) { @@ -262,18 +262,18 @@ void sub_08080040(RoomControls* controls) { void sub_08080108(RoomControls* controls) { controls->unk4 = 4; - MemCopy(gMapDataBottom, gMapDataBottom + 0x3000, 0x2000); - MemCopy(gMapDataTop, gMapDataTop + 0x3000, 0x2000); + MemCopy(gMapBottom.mapData, gMapBottom.mapDataClone, sizeof(gMapBottom.mapData)); + MemCopy(gMapTop.mapData, gMapTop.mapDataClone, sizeof(gMapTop.mapData)); sub_08080368(); gUnk_02034480.unk_00 = gUnk_0200B640; MemCopy(gUnk_02022830, gUnk_020246B0, 0x1800); - sub_08080B60(gMapDataBottom - 4); - sub_08080B60(gMapDataTop - 4); + sub_08080B60(&gMapBottom); + sub_08080B60(&gMapTop); sub_0807BBE4(); sub_0807BC84(); sub_0805E248(); - sub_0801AB08((u8*)&gMapDataBottomSpecial, gMapDataBottom - 4); - sub_0801AB08(gMapDataTopSpecial, gMapDataTop - 4); + sub_0801AB08((u8*)&gMapDataBottomSpecial, &gMapBottom); + sub_0801AB08(gMapDataTopSpecial, &gMapTop); } void sub_08080198(RoomControls* controls) { @@ -332,7 +332,26 @@ void sub_080801BC(RoomControls* controls) { ASM_FUNC("asm/non_matching/scroll/sub_08080278.inc", u32 sub_08080278()) -ASM_FUNC("asm/non_matching/scroll/sub_08080368.inc", void sub_08080368()) +void sub_08080368(void) { + u32 tmp; + u32 index; + u16* ptr; + + if ((gDiggingCaveEntranceTransition.previousArea != gRoomControls.area) && + (gDiggingCaveEntranceTransition.previousArea != 0xff)) { + gUnk_02034480.unk_00 = 0; + } else { + ptr = gUnk_020246B0; + tmp = gUnk_02034480.unk_00 << 1; + index = 0; + while (index < tmp) { + sub_0807B9B8(ptr[1], ptr[0] & 0xfff, (ptr[0] >> 0xe)); + ptr += 2; + index += 2; + } + gUpdateVisibleTiles = 0; + } +} ASM_FUNC("asm/non_matching/scroll/sub_080803D0.inc", u32 sub_080803D0()) @@ -614,14 +633,46 @@ void sub_080809D4(void) { ASM_FUNC("asm/non_matching/scroll/UpdateDoorTransition.inc", void UpdateDoorTransition()) -ASM_FUNC("asm/non_matching/scroll/sub_08080B60.inc", void sub_08080B60(u8* param_1)) - -ASM_FUNC("asm/non_matching/scroll/sub_08080BC4.inc", void sub_08080BC4()) +ASM_FUNC("asm/non_matching/scroll/sub_08080B60.inc", void sub_08080B60(LayerStruct* param_1)) + +void sub_08080BC4(void) { + const s8* ptr; + s32 tmpX; + s32 tmpY; + + tmpX = (gRoomControls.scroll_x - gRoomControls.origin_x) & 0xf; + tmpY = ((gRoomControls.scroll_y - gRoomControls.origin_y) & 0xf) + 8; + if (gRoomControls.shake_duration != 0) { + gRoomControls.shake_duration--; + ptr = &gUnk_080169A4[gRoomControls.shake_magnitude * 0x10 + (gRoomControls.shake_duration & 0xe)]; + if (gMapBottom.bgSettings != NULL) { + gMapBottom.bgSettings->xOffset = ptr[0] + tmpX; + gMapBottom.bgSettings->yOffset = ptr[1] + tmpY; + } + if (gMapTop.bgSettings != NULL) { + gMapTop.bgSettings->xOffset = ptr[0] + tmpX; + gMapTop.bgSettings->yOffset = ptr[1] + tmpY; + } + gRoomControls.aff_x = ptr[0]; + gRoomControls.aff_y = ptr[1]; + } else { + if (gMapBottom.bgSettings != NULL) { + gMapBottom.bgSettings->xOffset = tmpX; + gMapBottom.bgSettings->yOffset = tmpY; + } + if (gMapTop.bgSettings != NULL) { + gMapTop.bgSettings->xOffset = tmpX; + gMapTop.bgSettings->yOffset = tmpY; + } + gRoomControls.aff_x = 0; + gRoomControls.aff_y = 0; + } +} void sub_08080C80(u32* param_1) { sub_080197D4(param_1); - sub_0807C8B0(gMapDataBottom, gRoomControls.width >> 4, gRoomControls.height >> 4); - sub_0807C8B0(gMapDataTop, gRoomControls.width >> 4, gRoomControls.height >> 4); + sub_0807C8B0(gMapBottom.mapData, gRoomControls.width >> 4, gRoomControls.height >> 4); + sub_0807C8B0(gMapTop.mapData, gRoomControls.width >> 4, gRoomControls.height >> 4); } ASM_FUNC("asm/non_matching/scroll/sub_08080CB4.inc", void sub_08080CB4(Entity* a)) |
