mirror of
https://github.com/zeldaret/tmc
synced 2026-07-05 21:49:13 -04:00
Merge pull request #363 from hatal175/manager22
This commit is contained in:
+2
-2
@@ -355,7 +355,7 @@ bool32 sub_08041170(Enemy50Entity* this) {
|
||||
} else {
|
||||
if ((sub_08049FDC(super, 1)) &&
|
||||
((sub_0806FD54(super) ||
|
||||
((0xf < (s16)gArea.unk_0a && (EntityInRectRadius(super, gUnk_020000B0, 0x70, 0x48))))))) {
|
||||
((0xf < (s16)gArea.lightLevel && (EntityInRectRadius(super, gUnk_020000B0, 0x70, 0x48))))))) {
|
||||
sub_08041134(this);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ bool32 sub_080411E8(Enemy50Entity* this) {
|
||||
}
|
||||
return TRUE;
|
||||
case 2:
|
||||
if ((s16)gArea.unk_0a < 0x10) {
|
||||
if ((s16)gArea.lightLevel < 0x10) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
+2
-2
@@ -320,7 +320,7 @@ bool32 sub_0803F5A8(GhiniEntity* this) {
|
||||
u32 result;
|
||||
if (sub_08049FDC(super, 1) == 0) {
|
||||
result = 0;
|
||||
} else if ((s16)gArea.unk_0a < 0x10) {
|
||||
} else if ((s16)gArea.lightLevel < 0x10) {
|
||||
result = sub_0806FD54(super);
|
||||
} else {
|
||||
result = 1;
|
||||
@@ -334,7 +334,7 @@ bool32 sub_0803F5D4(GhiniEntity* this) {
|
||||
} else {
|
||||
if ((sub_08049FDC(super, 1)) &&
|
||||
((sub_0806FD54(super) ||
|
||||
((0xf < (s16)gArea.unk_0a && (EntityInRectRadius(super, gUnk_020000B0, 0x70, 0x48))))))) {
|
||||
((0xf < (s16)gArea.lightLevel && (EntityInRectRadius(super, gUnk_020000B0, 0x70, 0x48))))))) {
|
||||
sub_0803F630(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1331,7 +1331,7 @@ void InitRoom(void) {
|
||||
gArea.localFlagOffset = gLocalFlagBanks[a_hdr->flag_bank];
|
||||
gArea.filler[0] = a_hdr->flag_bank;
|
||||
gArea.unk1A = 180;
|
||||
gArea.unk_0a = 256;
|
||||
gArea.lightLevel = 256;
|
||||
InitRoomTransition();
|
||||
InitAllRoomResInfo();
|
||||
}
|
||||
@@ -1412,7 +1412,7 @@ static void UpdateFakeScroll(void) {
|
||||
LinkedList* ll;
|
||||
Entity* e;
|
||||
|
||||
if ((gArea.filler3[1] & 1) == 0 || !gRoomVars.field_0x0)
|
||||
if ((gArea.unk_0c & 1) == 0 || !gRoomVars.field_0x0)
|
||||
return;
|
||||
|
||||
y = 0;
|
||||
|
||||
+194
-8
@@ -1,18 +1,204 @@
|
||||
|
||||
#include "manager.h"
|
||||
#include "area.h"
|
||||
#include "main.h"
|
||||
#include "screen.h"
|
||||
#include "player.h"
|
||||
#include "room.h"
|
||||
#include "coord.h"
|
||||
#include "functions.h"
|
||||
#include "common.h"
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/Manager22_Main.inc", void Manager22_Main())
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
s32 unk20;
|
||||
} Manager22;
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BA78.inc", void sub_0805BA78())
|
||||
extern void sub_0801E120(void);
|
||||
extern void sub_0801E154(u32);
|
||||
extern u32 CheckRectOnScreen(s32, s32, u32, u32);
|
||||
extern void sub_0801E160(u32, u32, u32);
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BAD4.inc", void sub_0805BAD4())
|
||||
u32 sub_0805BA78();
|
||||
void sub_0805BAD4();
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BB00.inc", void sub_0805BB00())
|
||||
void Manager22_Main(Manager22* this) {
|
||||
s32 sVar1;
|
||||
u32 uVar3;
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BB74.inc", void sub_0805BB74())
|
||||
if (gArea.unk_0b == 0) {
|
||||
sub_0801E104();
|
||||
gScreen.lcd.displayControl &= ~(DISPCNT_BG3_ON | DISPCNT_WIN0_ON);
|
||||
DeleteThisEntity();
|
||||
}
|
||||
if (this->manager.action == 0) {
|
||||
this->manager.action = 1;
|
||||
this->manager.unk_10 |= 0x20;
|
||||
this->manager.unk_0e = 17;
|
||||
this->unk20 = 0;
|
||||
SetDefaultPriority((Entity*)this, 6);
|
||||
sub_0801E120();
|
||||
sub_0801E154(this->manager.unk_0e);
|
||||
}
|
||||
if (gMain.substate == 2) {
|
||||
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
|
||||
sub_0805BA78();
|
||||
sub_0805BAD4();
|
||||
}
|
||||
if (gArea.unk_0b == 2) {
|
||||
gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON;
|
||||
} else {
|
||||
if (CheckRectOnScreen(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x,
|
||||
gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, 0, 0)) {
|
||||
gScreen.lcd.displayControl |= DISPCNT_WIN0_ON;
|
||||
} else {
|
||||
gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON;
|
||||
}
|
||||
uVar3 = this->manager.unk_0e;
|
||||
if (((gPlayerState.flags & PL_USE_LANTERN)) && (gArea.unk_0b)) {
|
||||
if (uVar3 < 0x48) {
|
||||
uVar3 += 4;
|
||||
sub_0801E154(uVar3);
|
||||
this->unk20 = 0;
|
||||
} else if ((gRoomTransition.frameCount & 3) == 0) {
|
||||
this->manager.unk_0f += 0x10;
|
||||
sVar1 = gSineTable[this->manager.unk_0f];
|
||||
this->unk20 = sVar1 >> 7;
|
||||
sub_0801E154(uVar3 + this->unk20);
|
||||
}
|
||||
} else {
|
||||
this->unk20 = 0;
|
||||
if (0x11 < uVar3) {
|
||||
uVar3 -= 4;
|
||||
if (uVar3 < 0x11) {
|
||||
uVar3 = 0x11;
|
||||
}
|
||||
sub_0801E154(uVar3);
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/UpdateLightLevel.inc", void UpdateLightLevel())
|
||||
this->manager.unk_0e = uVar3;
|
||||
sub_0801E160(gPlayerEntity.x.HALF.HI - gRoomControls.scroll_x,
|
||||
gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y - 9 + gPlayerEntity.z.HALF.HI,
|
||||
uVar3 + this->unk20);
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BC04.inc", void sub_0805BC04())
|
||||
#define ABS(x) ((unsigned)(x < 0 ? -(x) : x))
|
||||
|
||||
ASM_FUNC("asm/non_matching/manager22/sub_0805BC4C.inc", void sub_0805BC4C())
|
||||
u32 sub_0805BA78() {
|
||||
u32 uVar1;
|
||||
s32 iVar1;
|
||||
s32 iVar2;
|
||||
|
||||
iVar2 = (short)gArea.lightLevel;
|
||||
iVar1 = gRoomVars.lightLevel;
|
||||
|
||||
if (iVar1 < 0) {
|
||||
iVar1 = 0;
|
||||
}
|
||||
|
||||
if (0x100 < iVar1) {
|
||||
iVar1 = 0x100;
|
||||
}
|
||||
|
||||
if (iVar2 != iVar1) {
|
||||
if (ABS(iVar1 - iVar2) <= 4) {
|
||||
iVar2 = iVar1;
|
||||
} else {
|
||||
if (iVar1 < iVar2) {
|
||||
iVar2 = iVar2 - 4;
|
||||
} else {
|
||||
if (iVar1 > iVar2) {
|
||||
iVar2 = iVar2 + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
gArea.lightLevel = iVar2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern u16 gUnk_08108CA8[];
|
||||
|
||||
void sub_0805BAD4() {
|
||||
static const u16 gUnk_08108CA8[] = { 0x10, 0x10f, 0x20e, 0x30d, 0x40c, 0x50b, 0x60a, 0x709, 0x808,
|
||||
0x907, 0xa06, 0xb05, 0xc04, 0xd03, 0xe02, 0xf01, 0x1000, 0x00 };
|
||||
if (gArea.unk_0b) {
|
||||
gScreen.controls.alphaBlend = gUnk_08108CA8[(gArea.lightLevel << 0x10) >> 0x14];
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805BB00(s32 lightLevel, s32 param_2) {
|
||||
if (gArea.unk_0b == 0) {
|
||||
Manager* pManager = GetEmptyManager();
|
||||
if (pManager != 0) {
|
||||
pManager->type = 9;
|
||||
pManager->subtype = 34;
|
||||
AppendEntityToList((Entity*)pManager, 0);
|
||||
}
|
||||
}
|
||||
MemFill16(0xf, BG_SCREEN_ADDR(0x1E), BG_SCREEN_SIZE);
|
||||
gScreen.bg3.control = 0x1e0c;
|
||||
gScreen.controls.layerFXControl = 0x3e48;
|
||||
gRoomVars.lightLevel = lightLevel;
|
||||
if (param_2) {
|
||||
gArea.unk_0b = 1;
|
||||
} else {
|
||||
gArea.unk_0b = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805BB74(s32 lightLevel) {
|
||||
Manager22* manager;
|
||||
|
||||
if (lightLevel < 0) {
|
||||
lightLevel = gRoomVars.lightLevel;
|
||||
}
|
||||
gArea.lightLevel = lightLevel;
|
||||
gRoomVars.lightLevel = gArea.lightLevel;
|
||||
manager = (Manager22*)DeepFindEntityByID(9, 0x22);
|
||||
if (manager) {
|
||||
Manager22_Main(manager);
|
||||
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
|
||||
sub_0805BA78();
|
||||
sub_0805BAD4();
|
||||
}
|
||||
}
|
||||
|
||||
s32 UpdateLightLevel() {
|
||||
s32 iVar1;
|
||||
|
||||
iVar1 = 0;
|
||||
if (gArea.unk_0b && gRoomVars.lightLevel < (s16)gArea.lightLevel) {
|
||||
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
|
||||
iVar1 = sub_0805BA78();
|
||||
if (iVar1) {
|
||||
sub_0805BAD4();
|
||||
}
|
||||
}
|
||||
return iVar1;
|
||||
}
|
||||
|
||||
s32 sub_0805BC04(void) {
|
||||
s32 iVar1;
|
||||
|
||||
iVar1 = 0;
|
||||
if (gArea.unk_0b && gRoomVars.lightLevel > (short)gArea.lightLevel) {
|
||||
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
|
||||
iVar1 = sub_0805BA78();
|
||||
if (iVar1) {
|
||||
sub_0805BAD4();
|
||||
}
|
||||
}
|
||||
return iVar1;
|
||||
}
|
||||
|
||||
void sub_0805BC4C() {
|
||||
if (gArea.unk_0b != 0) {
|
||||
gArea.unk_0b = 0;
|
||||
gScreen.lcd.displayControl &= ~(DISPCNT_BG3_ON | DISPCNT_WIN0_ON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ void sub_08059220(ManagerF* this) {
|
||||
}
|
||||
if (!this->manager.action) {
|
||||
this->manager.action = 1;
|
||||
gArea.unk_0a = gRoomVars.lightLevel;
|
||||
gArea.lightLevel = gRoomVars.lightLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user