move entity update functions

This commit is contained in:
theo3 2021-11-11 21:18:48 -08:00
parent 313cc336f2
commit fddb4abd53
37 changed files with 430 additions and 415 deletions

View File

@ -110,9 +110,14 @@ else
NODEP := 1
endif
#$(C_BUILDDIR)/need_interworking_file_name.o: CFLAGS += -mthumb-interwork
$(C_BUILDDIR)/interrupts.o: CFLAGS += -mthumb-interwork
$(C_BUILDDIR)/collision.o: CFLAGS += -mthumb-interwork
interwork := $(C_BUILDDIR)/interrupts.o \
$(C_BUILDDIR)/collision.o \
$(C_BUILDDIR)/playerItem.o \
$(C_BUILDDIR)/object.o \
$(C_BUILDDIR)/manager.o \
$(C_BUILDDIR)/npc.o
$(interwork): CFLAGS += -mthumb-interwork
$(C_BUILDDIR)/gba/m4a.o: CFLAGS = -O2 -mthumb-interwork -Wimplicit -Wparentheses -Werror -Wno-multichar
$(C_BUILDDIR)/eeprom.o: CFLAGS = -O1 -mthumb-interwork -Wimplicit -Wparentheses -Werror -Wno-multichar

View File

@ -4,34 +4,6 @@
.section .rodata
.align 2
gUnk_080B3740:: @ 080B3740
.incbin "baserom.gba", 0x0B3740, 0x0000004
gUnk_080B3744:: @ 080B3744
.4byte sub_08018308
.4byte CollisionNoOp
.4byte CollisionNoOp
.4byte CollisionGroundItem
.4byte sub_08017B58
.4byte sub_08017EB0
.4byte sub_08017F3C
.4byte sub_08017F40
.4byte sub_0801802C
.4byte sub_08017DD4
.4byte sub_080180E8
.4byte sub_08017BBC
.4byte sub_08017C40
.4byte sub_08017D6C
.4byte sub_08017D28
.4byte sub_08018168
.4byte sub_08018228
.4byte sub_08018250
.4byte sub_08018288
.4byte sub_080182A8
.4byte sub_08017B1C
.4byte sub_08017CBC
.4byte sub_08017E88
gUnk_080B37A0:: @ 080B37A0
.ifdef EU
@ TODO only small differences

View File

@ -209,23 +209,29 @@ enum {
#define Direction8FromAnimationState(expr) (((expr) << 2)
Entity* GetEmptyEntity(void);
extern Entity* CreateEnemy(u32 id, u32 type);
extern Entity* CreateNPC(u32 id, u32 type, u32 type2);
extern Entity* CreateObject(u32 id, u32 type, u32 type2);
extern Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
extern Entity* CreateFx(Entity* parent, u32 type, u32 type2);
void DrawEntity(Entity*);
Entity* CreateEnemy(u32 id, u32 type);
Entity* CreateNPC(u32 id, u32 type, u32 type2);
Entity* CreateObject(u32 id, u32 type, u32 type2);
Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
Entity* CreateFx(Entity* parent, u32 type, u32 type2);
extern void InitializeAnimation(Entity*, u32);
extern void InitAnimationForceUpdate(Entity*, u32);
extern void UpdateAnimationSingleFrame(Entity*);
extern void UpdateSpriteForCollisionLayer(Entity*);
extern void GetNextFrame(Entity*);
extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
extern void SetExtraSpriteFrame(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
void InitializeAnimation(Entity*, u32);
void InitAnimationForceUpdate(Entity*, u32);
void UpdateAnimationSingleFrame(Entity*);
void UpdateSpriteForCollisionLayer(Entity*);
void GetNextFrame(Entity*);
u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
void SetExtraSpriteFrame(Entity*, u32, u32);
void SetSpriteSubEntryOffsetData1(Entity*, u32, u32);
void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
extern u32 GetFacingDirection(Entity*, Entity*);
u32 GetFacingDirection(Entity*, Entity*);
/**
* @brief Check if entity should sleep this frame.
*/
bool32 CheckDontUpdate(Entity* this);
/**
* @brief Delete the entity currently in execution.

View File

@ -173,6 +173,8 @@ typedef struct MusicPlayer {
extern const MusicPlayer gMusicPlayers[];
extern const Song gSongTable[];
void m4aSoundMain(void);
void m4aSoundVSync(void);
void m4aSoundInit(void);
void m4aSongNumStart(u16 n);
void m4aSongNumStartOrContinue(u16 n);

View File

@ -11,29 +11,19 @@ typedef struct {
} LcdControls;
typedef struct {
u16 bg0Control;
u16 bg0xOffset;
u16 bg0yOffset;
u16 bg0Updated;
void* bg0Tilemap;
u16 bg1Control;
u16 bg1xOffset;
u16 bg1yOffset;
u16 bg1Updated;
void* bg1Tilemap;
u16 control;
u16 xOffset;
u16 yOffset;
u16 updated;
void* tilemap;
} BgSettings;
typedef struct {
u16 bg2Control;
u16 bg2xOffset;
u16 bg2yOffset;
u16 bg2Updated;
void* bg2Tilemap;
u16 bg3Control;
s16 bg3xOffset;
s16 bg3yOffset;
u16 bg3Updated;
void* bg3Tilemap;
u16 control;
s16 xOffset;
s16 yOffset;
u16 updated;
void* tilemap;
} BgAffSettings;
typedef struct {
@ -67,8 +57,10 @@ typedef struct {
typedef struct {
/*0x00*/ LcdControls lcd;
/*0x08*/ BgSettings bg;
/*0x20*/ BgAffSettings affine;
/*0x08*/ BgSettings bg0;
/*0x14*/ BgSettings bg1;
/*0x20*/ BgAffSettings bg2;
/*0x2c*/ BgAffSettings bg3;
/*0x38*/ BgControls controls;
/*0x6c*/ u8 _6c;
/*0x6d*/ u8 _6d;

View File

@ -332,6 +332,10 @@ SECTIONS {
/* C source compiled with interworking */
src/interrupts.o(.text);
src/playerItem.o(.text);
src/object.o(.text);
src/manager.o(.text);
src/npc.o(.text);
src/collision.o(.text);
/* C source compiled without interworking */
asm/code_08018500.o(.text);
@ -972,10 +976,12 @@ SECTIONS {
asm/intr.o(.text);
/* data */
data/data_080B2A70.o(.rodata);
src/interrupts.o(.rodata);
src/playerItem.o(.rodata);
src/object.o(.rodata);
src/manager.o(.rodata);
src/npc.o(.rodata);
src/collision.o(.rodata);
data/data_080B3740.o(.rodata);
data/const/playerItem/playerItem11.o(.rodata);
data/const/playerItem/playerItemBow.o(.rodata);

View File

@ -274,7 +274,7 @@ void sub_08017940(Entity* org, Entity* tgt) {
r1 = 0;
r1 = (u32)(org == &gPlayerEntity ? gPlayerEntity.knockbackDuration
: (tgt == &gPlayerEntity ? tgt->knockbackDuration : 0)) >>
: (tgt == &gPlayerEntity ? tgt->knockbackDuration : 0)) >>
3;
// Anything requiring the evaluation of r1 could be written here.
@ -284,7 +284,7 @@ void sub_08017940(Entity* org, Entity* tgt) {
}
void sub_080179EC(Entity* a1, Entity* a2) {
u8* p = gUnk_080B3740;
const u8* p = (const u8[]){ FX_27, FX_32, FX_33, FX_34 };
u32 rand = Random();
Entity* e = CreateFx(a2, p[rand & 3], 0);
if (e != NULL) {
@ -310,13 +310,44 @@ Entity* sub_08017A90(Entity* a1, Entity* parent) {
return NULL;
}
u32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction) {
typedef s32 (*CollisionHandler)(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings);
const CollisionHandler gUnk_080B3744[] = {
sub_08018308, CollisionNoOp, CollisionNoOp, CollisionGroundItem, sub_08017B58, sub_08017EB0,
sub_08017F3C, sub_08017F40, sub_0801802C, sub_08017DD4, sub_080180E8, sub_08017BBC,
sub_08017C40, sub_08017D6C, sub_08017D28, sub_08018168, sub_08018228, sub_08018250,
sub_08018288, sub_080182A8, sub_08017B1C, sub_08017CBC, sub_08017E88,
};
s32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return 0;
}
// origin: player or sword
// target: item
s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction) {
s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
COLLISION_OFF(tgt);
tgt->bitfield = org->hurtType | 0x80;
if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt))
@ -324,7 +355,7 @@ s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction) {
return 2;
}
s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.field_0x1d[1] & 0x60) != 0) {
COLLISION_OFF(tgt);
} else {
@ -335,7 +366,7 @@ s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((tgt->field_0x3a & 4) != 0) {
if (tgt->field_0x1d) {
s32 x = tgt->field_0x1d = tgt->field_0x1d - gPlayerState.field_0x1d[0];
@ -354,7 +385,7 @@ s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (0x1 | 0x80 | 0x400 | 0x1000)) == 0) {
Entity* e = CreateObject(66, 1, 0);
if (e != NULL) {
@ -373,7 +404,7 @@ s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if ((gPlayerState.flags & (0x1 | 0x80 | 0x800 | 0x1000)) == 0 && gPlayerState.playerAction == 0) {
if (org->action == 1 || org->action == 24) {
tgt->damage = 4;
@ -390,7 +421,8 @@ s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
NONMATCH("asm/non_matching/collision/sub_08017CBC.inc", s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction)) {
NONMATCH("asm/non_matching/collision/sub_08017CBC.inc",
s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)) {
if (((-(((direction ^ 0x10) - 0xc) & 0x1f) + tgt->direction) & 0x1f) < 0x19) {
org->iframes = -12;
tgt->iframes = -12;
@ -407,7 +439,7 @@ NONMATCH("asm/non_matching/collision/sub_08017CBC.inc", s32 sub_08017CBC(Entity*
}
END_NONMATCH
s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
gPlayerState.field_0x1a[0] = 1;
org->field_0x7a.HWORD = 600;
org->knockbackDuration = 12;
@ -418,7 +450,7 @@ s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 x;
u32 y;
ColSettings* p;
@ -436,7 +468,7 @@ s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction) {
return sub_08018308(org, tgt, direction, p);
}
int sub_08017DD4(Entity* org, Entity* tgt, u32 direction) {
int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->bitfield = 0;
if (tgt->damage & 0x80)
tgt->damage &= ~0x80;
@ -459,7 +491,7 @@ int sub_08017DD4(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->knockbackDuration = 2;
org->field_0x46 = 640;
if (tgt->iframes == 0)
@ -467,7 +499,7 @@ s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->damage == 0)
return 0;
if (org == &gPlayerEntity) {
@ -489,14 +521,20 @@ s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
return 1;
}
s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->field_0x43 == 0) {
if (org == &gPlayerEntity) {
if (sub_08079F8C() && (gPlayerState.flags & 0x80) == 0 && !gPlayerState.swimState) {
if (sub_08079F8C() &&
#ifdef EU
(gPlayerState.flags & 0x81) == 0 &&
#else
(gPlayerState.flags & 0x80) == 0 &&
#endif
!gPlayerState.swimState) {
gPlayerState.field_0x1a[0] |= 0x80u;
gPlayerState.field_0xa |= 0x80u;
gPlayerState.flags |= 0x10u;
@ -525,7 +563,8 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction) {
}
// inverted branch
NONMATCH("asm/non_matching/collision/sub_0801802C.inc", s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction)) {
NONMATCH("asm/non_matching/collision/sub_0801802C.inc",
s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings)) {
int kind;
ColSettings* p;
u32 x;
@ -558,7 +597,7 @@ void sub_080180BC(Entity* org, Entity* tgt) {
tgt->subAction = -1;
}
s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction) {
s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 v3;
u32 x;
@ -577,10 +616,16 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction) {
return sub_08018308(org, tgt, v3, &gCollisionMtx[org->hurtType + x]);
}
s32 sub_08018168(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->field_0x43 == 0) {
if (org == &gPlayerEntity) {
if (((sub_08079F8C() != 0) && ((gPlayerState.flags & 0x40080) == 0)) && (gPlayerState.swimState == 0)) {
if (((sub_08079F8C() != 0) &&
#ifdef EU
((gPlayerState.flags & 0x81) == 0)) &&
#else
((gPlayerState.flags & 0x40080) == 0)) &&
#endif
(gPlayerState.swimState == 0)) {
gPlayerState.field_0x1a[0] |= 0x80;
gPlayerState.field_0xa |= 0x80;
gPlayerState.flags |= 0x100;
@ -602,13 +647,13 @@ s32 sub_08018168(Entity* org, Entity* tgt, u32 direction) {
return 0;
}
s32 sub_08018228(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity && sub_08079F8C())
sub_08004484(tgt, org);
return 0;
}
s32 sub_08018250(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
org->iframes = -1;
if (org->direction == 0) {
tgt->iframes = 16;
@ -619,7 +664,7 @@ s32 sub_08018250(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_08018288(Entity* org, Entity* tgt, u32 direction) {
s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity)
sub_0807AFE8();
else
@ -627,7 +672,7 @@ s32 sub_08018288(Entity* org, Entity* tgt, u32 direction) {
return 1;
}
s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction) {
s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->field_0x43 == 0) {
if (org->iframes == 0)
org->iframes = -1;

View File

@ -18,12 +18,12 @@ void sub_0805FA04(void) {
MemClear(&gBG0Buffer, sizeof(gBG0Buffer));
MemClear(&gBG3Buffer, sizeof(gBG3Buffer));
gScreen.lcd.displayControl = 0x940;
gScreen.bg.bg0xOffset = 0;
gScreen.bg.bg0yOffset = 0;
gScreen.affine.bg3xOffset = 0;
gScreen.affine.bg3yOffset = 0;
gScreen.affine.bg3Control = 0x1e0f;
gScreen.affine.bg3Updated = 1;
gScreen.bg0.xOffset = 0;
gScreen.bg0.yOffset = 0;
gScreen.bg3.xOffset = 0;
gScreen.bg3.yOffset = 0;
gScreen.bg3.control = 0x1e0f;
gScreen.bg3.updated = 1;
MessageInitialize();
MemClear((void*)&gUnk_02032EC0, sizeof(UI));
MemClear((void*)&gMenu, sizeof(Menu));
@ -48,11 +48,11 @@ void sub_0805FA98(void) {
case 0x200:
gMenu.focusCoords[0] ^= 1;
if (gMenu.focusCoords[0] == 0) {
gScreen.bg.bg0Control = 0x1f0c;
gScreen.affine.bg3Control = 0x1e0f;
gScreen.bg0.control = 0x1f0c;
gScreen.bg3.control = 0x1e0f;
} else {
gScreen.bg.bg0Control = 0x1f0f;
gScreen.affine.bg3Control = 0x1e0c;
gScreen.bg0.control = 0x1f0f;
gScreen.bg3.control = 0x1e0c;
}
break;
case 0x100:
@ -87,7 +87,7 @@ void sub_0805FA98(void) {
}
}
gMenu.focusCoords[1] = (gMenu.focusCoords[1] + 3) % 3;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.updated = 1;
}
void sub_0805FBC4() {

View File

@ -49,12 +49,12 @@ void sub_080A2E40(void) {
MemCopy(&gUnk_08A05751, &gBG1Buffer, 0x800);
MemCopy(&gUnk_08A05751[0x800], &gBG2Buffer, 0x800);
gScreen.lcd.displayControl = 0x1f00;
gScreen.bg.bg1Control = 0x1c81;
gScreen.affine.bg2Control = 0x1d82;
gScreen.affine.bg3Control = 0x1e0b;
gScreen.bg.bg1Updated = 1;
gScreen.affine.bg2Updated = 1;
gScreen.affine.bg3Updated = 1;
gScreen.bg1.control = 0x1c81;
gScreen.bg2.control = 0x1d82;
gScreen.bg3.control = 0x1e0b;
gScreen.bg1.updated = 1;
gScreen.bg2.updated = 1;
gScreen.bg3.updated = 1;
gScreen.controls.layerFXControl = 0x1044;
gScreen.controls.alphaBlend = 0xb04;
{

View File

@ -62,8 +62,8 @@ void sub_0802A2FC(Entity* this) {
}
void sub_0802A334(Entity* this) {
u32 x = (this->x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1xOffset) >> 3;
u32 y = (this->y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg1yOffset) >> 3;
u32 x = (this->x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg1.xOffset) >> 3;
u32 y = (this->y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg1.yOffset) >> 3;
if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
this->collisionLayer = 2;
} else {
@ -73,8 +73,8 @@ void sub_0802A334(Entity* this) {
}
void sub_0802A39C(Entity* this) {
u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1xOffset) >> 3;
u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg1yOffset - 10) >> 3;
u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg1.xOffset) >> 3;
u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg1.yOffset - 10) >> 3;
if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
COLLISION_OFF(this);
} else {

View File

@ -38,9 +38,9 @@ void DoFade(u32 fadeType, u32 fadeSpeed) {
}
if ((fadeType & 8) != 0) {
gUnk_03000000.spritesOffset = 1;
gScreen.bg.bg1Control |= 0x40;
gScreen.affine.bg2Control |= 0x40;
gScreen.affine.bg3Control |= 0x40;
gScreen.bg1.control |= 0x40;
gScreen.bg2.control |= 0x40;
gScreen.bg3.control |= 0x40;
}
if ((fadeType & 0x10) != 0) {
sub_0801E1B8(gFadeControl.field_0x16, gFadeControl.field_0x18);

View File

@ -109,19 +109,19 @@ void CreateDialogBox(u32 arg0, u32 arg1) {
if (sfx) {
SoundReq(sfx);
}
gScreen.bg.bg0Updated = 1;
gScreen.bg0.updated = 1;
}
void sub_08050384(void) {
RecoverUI(0, 0);
MemClear(&gBG0Buffer, sizeof(gBG0Buffer));
gScreen.bg.bg0Updated = 1;
gScreen.bg0.updated = 1;
}
void sub_080503A8(u32 gfxGroup) {
LoadGfxGroup(gfxGroup);
gScreen.bg.bg1Updated = 1;
gScreen.affine.bg2Updated = 1;
gScreen.bg1.updated = 1;
gScreen.bg2.updated = 1;
}
void SetFileSelectState(FileSelectState mode) {
@ -162,12 +162,12 @@ void HandleChooseFileScreen(void) {
sScreenHandlers[gMain.funcIndex]();
if (gUnk_02032EC0.lastState != gUnk_02032EC0.state) {
gUnk_02032EC0.lastState = gUnk_02032EC0.state;
gScreen.bg.bg0xOffset = 0;
gScreen.bg.bg0yOffset = 0;
gScreen.bg.bg1xOffset = 0;
gScreen.bg.bg1yOffset = 0;
gScreen.affine.bg2xOffset = 0;
gScreen.affine.bg2yOffset = 0;
gScreen.bg0.xOffset = 0;
gScreen.bg0.yOffset = 0;
gScreen.bg1.xOffset = 0;
gScreen.bg1.yOffset = 0;
gScreen.bg2.xOffset = 0;
gScreen.bg2.yOffset = 0;
MemClear(&gChooseFileState, sizeof(gChooseFileState));
}
@ -220,7 +220,7 @@ static void HandleFileScreenEnter(void) {
sub_080A70AC(&gUnk_080FC8D0);
HideButtonR();
gScreen.lcd.displayControl |= DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON;
gScreen.affine.bg3Control = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(30);
gScreen.bg3.control = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(30);
gScreen.controls.layerFXControl = BLDCNT_TGT1_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_EFFECT_BLEND;
gScreen.controls.alphaBlend = BLDALPHA_BLEND(15, 10);
gUnk_02024490.unk0 = 1;
@ -525,7 +525,7 @@ void sub_08050AFC(u32 idx) {
if (gUnk_02019EE0.saveStatus[idx] == SAVE_VALID) {
sub_08050B3C(&gBG1Buffer[0x14E]);
}
gScreen.bg.bg1Updated = 1;
gScreen.bg1.updated = 1;
}
typedef struct {
@ -859,8 +859,8 @@ void sub_08051090(void) {
sub_08050790();
sub_0805070C();
sub_08051458();
gScreen.bg.bg1yOffset = 0xff;
gScreen.affine.bg2yOffset = 0xff;
gScreen.bg1.yOffset = 0xff;
gScreen.bg2.yOffset = 0xff;
sub_080A7114(1);
}

View File

@ -248,7 +248,7 @@ NONMATCH("asm/non_matching/game/sub_08052418.inc", void sub_08052418(int param_1
// temp._0 = gBG1Buffer[gUnk_080FCAA4._8[param_1]][gUnk_080FCAA4._0[gSaveHeader->gameLanguage + i]] * 2;
temp._13 = ((temp._13 & 0xfe) | gUnk_080FCAA4._8[i + 1]) & 1;
sub_0805F46C(gUnk_080FCAA4._a[param_1], &temp);
gScreen.bg.bg1xOffset = 1;
gScreen.bg1.xOffset = 1;
}
END_NONMATCH

View File

@ -7,11 +7,11 @@
#include "textbox.h"
#include "functions.h"
#include "object.h"
#include "manager.h"
#include "utils.h"
#include "npc.h"
#include "effects.h"
#include "screen.h"
#include "gba/m4a.h"
extern u8 gUnk_03003DE0;
extern u8 gUnk_03000C30;
@ -22,18 +22,19 @@ extern u8 gUpdateVisibleTiles;
extern u8 gUnk_03003DF0[];
extern u8 gUnk_03003BE0;
extern Entity* gUnk_03004040[3];
extern u8 gUnk_020342F8;
extern u16 gUnk_080B2CD8[];
extern u32 gUnk_03000FBC;
extern void sub_080ADD70();
extern void sub_0801C25C();
extern void UpdateDisplayControls();
extern void LoadResources();
extern void FadeMain();
extern u32 CheckDontUpdate();
extern void HandlePlayerLife();
extern void DoPlayerAction();
extern void sub_080171F0();
extern void sub_08078FB0();
extern u32 CheckDontUpdate();
extern void DrawEntity();
extern void sub_0807A050();
extern u32 sub_08079B24();
@ -44,43 +45,8 @@ extern void sub_08078180(void);
extern void sub_0807B0C8(void);
extern void sub_0807A8D8(Entity*);
extern void sub_08077FEC(u32);
extern void ItemInit(Entity*);
extern void InitObject(Entity*);
extern u32 ReadBit(void*, u32);
extern void InitNPC(Entity*);
extern void m4aSoundMain();
extern void m4aSoundVSync();
typedef struct {
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u8 unk4;
u8 unk5;
u16 unk6;
} ItemFrame;
extern ItemFrame gUnk_08126DA8[];
extern ItemFrame* gUnk_08126ED8[3];
typedef struct {
u16 unk0;
u16 unk1;
u16 x;
u16 y;
} NPCStruct;
extern NPCStruct gUnk_02031EC0[100];
// todo: merge with screen.h
typedef struct {
u16 dest;
u16 _2;
u16 _4;
u16 _6;
u8* src;
} DmaSettings;
extern u16 gDmaPresets[];
void gIntrMain(void);
struct {
u8 update;
@ -95,18 +61,10 @@ struct {
u32 size;
} extern gUnk_02022730;
void sub_08016CA8(DmaSettings* s);
void sub_08016CA8(BgSettings* bg);
void sub_08016BF8(void);
void DispCtrlSet(void);
extern u16 gUnk_080B2CD8[];
extern u32 gUnk_03000FBC;
void gIntrMain(void);
typedef void (*fp)(void);
void DummyIntr(void) {
/* .. */
}
@ -157,18 +115,18 @@ void UpdateDisplayControls(void) {
gUnk_03000000.update = 0;
DmaCopy32(3, &gUnk_03000000.oam, 0x07000000, 0x400);
}
sub_08016CA8((DmaSettings*)&gScreen.bg.bg0Control);
sub_08016CA8((DmaSettings*)&gScreen.bg.bg1Control);
sub_08016CA8((DmaSettings*)&gScreen.affine.bg2Control);
sub_08016CA8((DmaSettings*)&gScreen.affine.bg3Control);
sub_08016CA8(&gScreen.bg0);
sub_08016CA8(&gScreen.bg1);
sub_08016CA8((BgSettings*)&gScreen.bg2);
sub_08016CA8((BgSettings*)&gScreen.bg3);
}
void sub_08016CA8(DmaSettings* s) {
if (s->_6 && s->src != 0) {
void sub_08016CA8(BgSettings* bg) {
if (bg->updated && bg->tilemap != NULL) {
u32 dest;
s->_6 = 0;
dest = s->dest;
DmaCopy32(3, s->src, ((dest << 3) & 0xF800) + 0x06000000, gUnk_080B2CD8[dest >> 14]);
bg->updated = 0;
dest = bg->control;
DmaCopy32(3, bg->tilemap, ((dest << 3) & 0xF800) + 0x06000000, gUnk_080B2CD8[dest >> 14]);
}
}
@ -322,7 +280,7 @@ void HandlePlayerLife(Entity* this) {
} else if ((gSave.stats.effectTimer == 0) || --gSave.stats.effectTimer == 0) {
gSave.stats.effect = 0;
} else if ((gSave.stats.effectTimer & 0x3f) == 0) {
CreateFx(this, FX_AURA_BASE + gSave.stats.effect, 0);
CreateFx(this, (FX_RED_AURA - 1) + gSave.stats.effect, 0);
}
}
#endif
@ -373,91 +331,3 @@ void sub_080171F0(void) {
sub_08077FEC(gPlayerEntity.action);
}
}
void ItemUpdate(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0 && this->subAction == 0)
ItemInit(this);
if (!CheckDontUpdate(this)) {
gPlayerItemFunctions[this->id](this);
this->bitfield &= ~0x80;
if (this->iframes != 0) {
if (this->iframes > 0)
this->iframes--;
else
this->iframes++;
}
}
DrawEntity(this);
}
// tiny regalloc
NONMATCH("asm/non_matching/arm_proxy/ItemInit.inc", void ItemInit(Entity* this)) {
ItemFrame* entry;
entry = &gUnk_08126DA8[this->id];
if (entry->unk0 == 0xff) {
u32 temp = entry->unk2;
ItemFrame* temp2 = gUnk_08126ED8[entry->unk1];
entry = &temp2[this->field_0x68.HALF.LO - temp];
}
this->palette.raw = ((entry->unk0 & 0xf) << 4) | entry->unk0;
this->damage = entry->unk1;
this->hurtType = entry->unk3;
this->hitType = entry->unk4;
this->spriteIndex = entry->unk5;
if (entry->unk6 == 0)
this->spriteVramOffset = gPlayerEntity.spriteVramOffset;
else
this->spriteVramOffset = entry->unk6 & 0x3ff;
if (this->animationState == 0)
this->animationState = gPlayerEntity.animationState & 6;
this->collisionLayer = gPlayerEntity.collisionLayer;
this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
this->spritePriority.b0 = gPlayerEntity.spritePriority.b0;
this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
this->currentHealth = 1;
this->flags |= ENT_DID_INIT;
}
END_NONMATCH
void ObjectUpdate(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0)
InitObject(this);
if (this->iframes != 0)
this->iframes++;
if (!CheckDontUpdate(this)) {
gObjectFunctions[this->id](this);
this->bitfield &= ~0x80;
}
DrawEntity(this);
}
void ManagerUpdate(Entity* this) {
if (!CheckDontUpdate(this))
gManagerFunctions[this->id](this);
}
// regalloc
NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
if ((this->currentHealth & 0x7f) && !ReadBit(&gUnk_020342F8, this->currentHealth - 1))
DeleteThisEntity();
if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
InitNPC(this);
if (!CheckDontUpdate(this))
gNPCFunctions[this->id][0](this);
if (this->next != NULL) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
if ((this->currentHealth & 0x7f) != 0) {
u32 temp = this->currentHealth & 0x7f;
gUnk_02031EC0[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.roomOriginX;
gUnk_02031EC0[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.roomOriginY;
}
DrawEntity(this);
}
}
END_NONMATCH

View File

@ -101,7 +101,7 @@ static void HandleNintendoCapcomLogos(void) {
}
LoadPaletteGroup(paletteGroup);
gScreen.lcd.displayControl |= DISPCNT_BG2_ON;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.updated = 1;
DoFade(6, 8);
advance = ADVANCE_NONE;
#if defined(DEMO_USA)
@ -158,17 +158,17 @@ static void HandleTitlescreen(void) {
// Blend first and second layer
gScreen.controls.layerFXControl = BLDCNT_TGT1_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_EFFECT_BLEND;
gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9);
gScreen.bg.bg1Control = 0x1c09;
gScreen.affine.bg2Control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.affine.bg3Control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3);
gScreen.bg1.control = 0x1c09;
gScreen.bg2.control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3);
gScreen.lcd.displayControl |= DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON;
gScreen.bg.bg1yOffset = 0xff60;
gScreen.bg1.yOffset = 0xff60;
} else {
gScreen.controls.layerFXControl = BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND;
gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9);
gScreen.bg.bg0Control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.bg.bg1Control = 0x1E03;
gScreen.affine.bg2Control = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_256COLOR |
gScreen.bg0.control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.bg1.control = 0x1E03;
gScreen.bg2.control = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_256COLOR |
BGCNT_SCREENBASE(28) | BGCNT_WRAP | BGCNT_TXT512x256;
gScreen.lcd.displayControl |= DISPCNT_MODE_1;
gScreen.lcd.displayControl |= DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_ON;
@ -278,13 +278,13 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) {
case 0:
if (!gFadeControl.active) {
if ((gIntroState.counter & 1) == 0) {
gScreen.bg.bg1yOffset++;
gScreen.bg1.yOffset++;
}
if (GetAdvanceState() == ADVANCE_KEY_PRESSED || gScreen.bg.bg1yOffset == 0) {
if (GetAdvanceState() == ADVANCE_KEY_PRESSED || gScreen.bg1.yOffset == 0) {
gIntroState.subState++;
gScreen.bg.bg1yOffset = 0;
gScreen.bg.bg1Control = 0xc09;
gScreen.bg1.yOffset = 0;
gScreen.bg1.control = 0xc09;
gFadeControl.mask = 0x00000040;
DoFade(6, 0x10);
SoundReq(SFX_F8);

View File

@ -12,3 +12,8 @@ void (*const gManagerFunctions[])() = {
Manager31_Main, Manager32_Main, Manager33_Main, Manager34_Main, Manager35_Main, Manager36_Main, Manager37_Main,
Manager38_Main, Manager39_Main
};
void ManagerUpdate(Entity* this) {
if (!CheckDontUpdate(this))
gManagerFunctions[this->id](this);
}

View File

@ -32,7 +32,7 @@ void sub_080570B8(Entity* this) {
this->height.WORD = 0;
pbVar1 = ((u8*)&this->hVelocity + 1);
if (*pbVar1 == 3) {
gScreen.affine.bg3Updated = 1;
gScreen.bg3.updated = 1;
} else {
gUnk_08107C48[*pbVar1](this);
}
@ -50,7 +50,7 @@ void sub_08057118(Entity* this) {
((u8*)&this->hVelocity)[1] = 0;
((u8*)&this->hVelocity)[2] = 0;
this->action = 1;
gScreen.affine.bg3Control = 0x1e04;
gScreen.bg3.control = 0x1e04;
gScreen.lcd.displayControl |= 0x800;
gScreen.controls.layerFXControl = 0x3648;
gScreen.controls.alphaBlend = 0x1000;

View File

@ -97,8 +97,8 @@ void sub_08059690(Manager10* this) {
void sub_080596E0(Manager10* this) {
if ((gScreenTransition.frameCount & 7) == 0) {
gScreen.bg.bg1xOffset += 8;
gScreen.bg.bg1xOffset &= 0x1F;
gScreen.bg1.xOffset += 8;
gScreen.bg1.xOffset &= 0x1F;
}
if (sub_0805986C()) {
if (this->unk_21 == 0 && this->unk_22 != 2) {
@ -142,7 +142,7 @@ void sub_080596E0(Manager10* this) {
LoadResourceAsync(gBG3Buffer, 0x600e800, 0x800);
break;
case 5:
gUnk_0200B650 = &gScreen.bg.bg1Control;
gUnk_0200B650 = &gScreen.bg1.control;
gScreen.lcd.displayControl |= 0x200;
break;
}

View File

@ -397,9 +397,9 @@ void sub_0805A8EC(Manager15* this) {
void sub_0805A94C(Manager15* this) {
int tmp1, tmp2;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY - this->unk_26 + this->unk_36;
tmp1 = -gScreen.affine.bg3xOffset;
gScreen.bg3.xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
gScreen.bg3.yOffset = gRoomControls.roomScrollY - this->unk_26 + this->unk_36;
tmp1 = -gScreen.bg3.xOffset;
tmp2 = tmp1 + 0x100;
if (tmp1 < 0)
tmp1 = 0;
@ -410,7 +410,7 @@ void sub_0805A94C(Manager15* this) {
if (tmp2 > 0xF0)
tmp2 = 0xF0;
gScreen.controls.window1HorizontalDimensions = (tmp1 << 8 | tmp2);
tmp1 = -gScreen.affine.bg3yOffset;
tmp1 = -gScreen.bg3.yOffset;
tmp2 = tmp1 + 0x100;
if (tmp1 < 0)
tmp1 = 0;
@ -426,8 +426,8 @@ void sub_0805A94C(Manager15* this) {
void sub_0805A9CC(Manager15* this) {
int tmp1, tmp2;
void* tmp3;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
tmp1 = -gScreen.affine.bg3xOffset;
gScreen.bg3.xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
tmp1 = -gScreen.bg3.xOffset;
tmp2 = tmp1 + 0x100;
if (tmp1 < 0)
tmp1 = 0;
@ -439,14 +439,14 @@ void sub_0805A9CC(Manager15* this) {
tmp2 = 0xF0;
gScreen.controls.window1HorizontalDimensions = tmp1 << 8 | tmp2;
tmp1 = gRoomControls.roomScrollY - this->unk_26 + this->unk_36;
gScreen.affine.bg3yOffset = tmp1 & 0x3F;
gScreen.bg3.yOffset = tmp1 & 0x3F;
tmp3 = (&gBG3Buffer[((tmp1 / 0x40) << 8)]);
gScreen.affine.bg3Tilemap = (u32*)tmp3;
gScreen.bg3.tilemap = (u32*)tmp3;
gScreen.controls.window1VerticalDimensions = 0xa0;
if (this->unk_28 == tmp3)
return;
this->unk_28 = tmp3;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.updated = 1;
}
extern struct { u8 unk_00[0x20]; } gUnk_085A97A0[];
@ -483,11 +483,11 @@ void sub_0805AAF0(u32 unk0) {
sub_0805AADC(unk0);
gScreen.controls.layerFXControl = 0x3E48;
gScreen.controls.alphaBlend = 0x1008;
gScreen.affine.bg3Control = 0x1E04;
gScreen.affine.bg3Tilemap = &gBG3Buffer;
gScreen.affine.bg3xOffset = 0;
gScreen.affine.bg3yOffset = 0;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.control = 0x1E04;
gScreen.bg3.tilemap = &gBG3Buffer;
gScreen.bg3.xOffset = 0;
gScreen.bg3.yOffset = 0;
gScreen.bg3.updated = 1;
gScreen.controls.windowInsideControl = 0x3F3F;
gScreen.controls.windowOutsideControl = 0x37;
gScreen.controls.window1HorizontalDimensions = 0xF0;

View File

@ -40,19 +40,19 @@ void Manager18_Main(Manager18* this) {
}
gRoomControls.bg3OffsetX.WORD -= 0x2000;
gRoomControls.bg3OffsetY.WORD -= 0x1000;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}
}
}
void sub_0805AEDC(Manager18* this) {
gScreen.affine.bg3Control = 0x1e05;
gScreen.bg3.control = 0x1e05;
gScreen.lcd.displayControl |= 0x800;
gScreen.controls.layerFXControl = 0x3648;
gScreen.controls.alphaBlend = (this != NULL) ? this->field_0x20 : 0x1000;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
if (this != NULL) {
Manager18_Main(this);
}

View File

@ -23,15 +23,15 @@ void Manager19_Main(Manager* this) {
}
} else {
gRoomControls.bg3OffsetX.WORD = gRoomControls.bg3OffsetX.WORD - 0x2000;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}
}
}
void sub_0805AFFC(Manager* this) {
gScreen.affine.bg3Control = 0x1e03;
gScreen.bg3.control = 0x1e03;
gScreen.lcd.displayControl |= 0x800;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}

View File

@ -199,9 +199,9 @@ void sub_0805B2B0(Manager1A* this) {
}
gScreen.lcd.displayControl |= 0x800;
gRoomControls.bg3OffsetX.HALF.HI = gRoomControls.roomScrollX + this->unk_34 + tmp;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + this->unk_34 + tmp;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + this->unk_34 + tmp;
gRoomControls.bg3OffsetY.HALF.HI = gRoomControls.roomScrollY + this->unk_36 + tmp2;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + this->unk_36 + tmp2;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + this->unk_36 + tmp2;
}
void sub_0805B328(Manager1A* this) {
@ -210,10 +210,10 @@ void sub_0805B328(Manager1A* this) {
return;
tmp = &gUnk_08108764[this->manager.unk_0a];
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp->unk_0c->unk_00], 0x0600F000, 0x800);
gScreen.affine.bg3Control = 0x1E07;
gScreen.bg3.control = 0x1E07;
gScreen.lcd.displayControl |= 0x800;
gScreen.affine.bg3xOffset = gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.bg3OffsetY.HALF.HI;
gScreen.controls.layerFXControl &= ~0x8;
}

View File

@ -46,14 +46,14 @@ void Manager1B_Main(Manager1B* this) {
}
void sub_0805B448(Manager1B* this) {
gScreen.affine.bg3xOffset = (gRoomControls.roomScrollX - gRoomControls.roomOriginX) >> 2;
gScreen.affine.bg3yOffset = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) >> 1) + this->field_0x20;
gScreen.bg3.xOffset = (gRoomControls.roomScrollX - gRoomControls.roomOriginX) >> 2;
gScreen.bg3.yOffset = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) >> 1) + this->field_0x20;
}
void sub_0805B474(Manager1B* this) {
s32 tmp = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) * 0x60) / (gRoomControls.height - 0xa0);
gScreen.affine.bg3yOffset = gRoomControls.roomOriginY + tmp;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX - ((gRoomControls.width - 0x100) / 2);
gScreen.bg3.yOffset = gRoomControls.roomOriginY + tmp;
gScreen.bg3.xOffset = gRoomControls.roomScrollX - ((gRoomControls.width - 0x100) / 2);
}
void sub_0805B4B4(Manager1B* this) {
@ -69,14 +69,14 @@ void sub_0805B4D0(u32 param_1) {
u32 uVar2;
LoadGfxGroup(gUnk_08108C5C[param_1]);
gScreen.affine.bg3Control = 0x1e07;
gScreen.bg3.control = 0x1e07;
gScreen.lcd.displayControl |= 0x800;
gScreen.affine.bg3xOffset = (gRoomControls.roomScrollX - gRoomControls.roomOriginX) >> 2;
gScreen.bg3.xOffset = (gRoomControls.roomScrollX - gRoomControls.roomOriginX) >> 2;
uVar2 = (gRoomControls.roomScrollY - gRoomControls.roomOriginY) >> 1;
iVar1 = 0x100 - gRoomControls.height;
if (iVar1 < 0) {
iVar1 = 0;
}
gScreen.affine.bg3yOffset = uVar2 + iVar1 + gUnk_08108C44[param_1];
gScreen.bg3.yOffset = uVar2 + iVar1 + gUnk_08108C44[param_1];
}

View File

@ -14,19 +14,19 @@ void sub_0805B5E0(Manager* this) {
this->action = 1;
gScreen.lcd.displayControl |= 0x800;
gScreen.affine.bg3Control = gUnk_08108C88[this->unk_0a];
gScreen.bg3.control = gUnk_08108C88[this->unk_0a];
gRoomControls.bg3OffsetY.WORD = 0;
gRoomControls.bg3OffsetX.WORD = 0;
switch (this->unk_0a) {
case 0:
default:
gScreen.affine.bg3yOffset = 0;
gScreen.affine.bg3xOffset = 0;
gScreen.bg3.yOffset = 0;
gScreen.bg3.xOffset = 0;
break;
case 1:
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
break;
}
}
@ -34,7 +34,7 @@ void sub_0805B5E0(Manager* this) {
void sub_0805B638(Manager* this) {
if (this->unk_0a == 1) {
gRoomControls.bg3OffsetX.WORD = gRoomControls.bg3OffsetX.WORD + 0x2000;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}
}

View File

@ -21,8 +21,8 @@ extern u32 gUnk_0200B650;
void Manager2_Main(Manager2* this) {
if (this->manager.action == 0) {
this->manager.action = 1;
gScreen.affine.bg3Updated = 0;
gScreen.bg.bg1Updated = 0;
gScreen.bg3.updated = 0;
gScreen.bg1.updated = 0;
sub_08052D74(this, sub_080576A0, 0);
}
sub_0805754C(this);
@ -33,19 +33,19 @@ void sub_0805754C(Manager2* this) {
bgOffset = (gRoomControls.roomScrollY - gRoomControls.roomOriginY);
bgOffset += bgOffset >> 3;
gScreen.affine.bg3yOffset = bgOffset & 0x3f;
gScreen.affine.bg3Tilemap = gMapDataTopSpecial + (bgOffset / 0x40) * 0x200;
if (this->field_0x38 != gScreen.affine.bg3Tilemap) {
this->field_0x38 = gScreen.affine.bg3Tilemap;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.yOffset = bgOffset & 0x3f;
gScreen.bg3.tilemap = gMapDataTopSpecial + (bgOffset / 0x40) * 0x200;
if (this->field_0x38 != gScreen.bg3.tilemap) {
this->field_0x38 = gScreen.bg3.tilemap;
gScreen.bg3.updated = 1;
}
bgOffset = (gRoomControls.roomScrollY - gRoomControls.roomOriginY);
bgOffset += bgOffset >> 2;
gScreen.bg.bg1yOffset = bgOffset & 0x3f;
gScreen.bg.bg1Tilemap = gMapDataTopSpecial + 0x2000 + (bgOffset / 0x40) * 0x200;
if (this->field_0x3c != gScreen.bg.bg1Tilemap) {
this->field_0x3c = gScreen.bg.bg1Tilemap;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.yOffset = bgOffset & 0x3f;
gScreen.bg1.tilemap = gMapDataTopSpecial + 0x2000 + (bgOffset / 0x40) * 0x200;
if (this->field_0x3c != gScreen.bg1.tilemap) {
this->field_0x3c = gScreen.bg1.tilemap;
gScreen.bg1.updated = 1;
}
}
@ -59,27 +59,27 @@ void sub_080575C8(u32 param) {
bgOffset = (gRoomControls.roomScrollY - gRoomControls.roomOriginY);
bgOffset += bgOffset >> 3;
gScreen.affine.bg3yOffset = bgOffset & 0x3f;
gScreen.affine.bg3xOffset = 0;
gScreen.affine.bg3Tilemap = &gMapDataTopSpecial[(bgOffset / 0x40) * 0x200];
gScreen.affine.bg3Control = 0x1d49;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.yOffset = bgOffset & 0x3f;
gScreen.bg3.xOffset = 0;
gScreen.bg3.tilemap = &gMapDataTopSpecial[(bgOffset / 0x40) * 0x200];
gScreen.bg3.control = 0x1d49;
gScreen.bg3.updated = 1;
bgOffset = (gRoomControls.roomScrollY - gRoomControls.roomOriginY);
bgOffset += bgOffset >> 2;
gScreen.bg.bg1yOffset = bgOffset & 0x3f;
gScreen.bg.bg1xOffset = 0;
gScreen.bg.bg1Tilemap = &gMapDataTopSpecial[0x2000 + (bgOffset / 0x40) * 0x200];
gScreen.bg.bg1Control = 0x1e49;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.yOffset = bgOffset & 0x3f;
gScreen.bg1.xOffset = 0;
gScreen.bg1.tilemap = &gMapDataTopSpecial[0x2000 + (bgOffset / 0x40) * 0x200];
gScreen.bg1.control = 0x1e49;
gScreen.bg1.updated = 1;
gScreen.controls.layerFXControl = 0x3c48;
gScreen.controls.alphaBlend = 0x609;
gScreen.lcd.displayControl |= 0xa00;
}
void sub_08057688(void) {
gScreen.affine.bg3Control = 0x1d48;
gScreen.bg.bg1Control = 0x1e48;
gScreen.bg3.control = 0x1d48;
gScreen.bg1.control = 0x1e48;
}
void sub_080576A0(Manager2* this) {

View File

@ -25,16 +25,16 @@ void Manager2F_Main(Manager* this) {
} else {
gRoomControls.bg3OffsetX.WORD -= 0x4000;
gRoomControls.bg3OffsetY.WORD -= 0x2000;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}
}
}
void sub_0805D470(Manager* this) {
LoadGfxGroup(0x4c);
gScreen.affine.bg3Control = 0x1e07;
gScreen.bg3.control = 0x1e07;
gScreen.lcd.displayControl |= 0x800;
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
gScreen.bg3.xOffset = gRoomControls.roomScrollX + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = gRoomControls.roomScrollY + gRoomControls.bg3OffsetY.HALF.HI;
}

View File

@ -65,7 +65,7 @@ void sub_0805D7DC(Manager32* this) {
}
LoadGfxGroup(gUnk_08108D74[index]);
gScreen.affine.bg3Control = 0x1e04;
gScreen.bg3.control = 0x1e04;
}
void sub_0805D860(Manager32* this) {
@ -152,8 +152,8 @@ void sub_0805D9D8(Manager32* this) {
// TODO find out the actual type of the parent of this manager.
Manager* pMVar1 = this->manager.parent;
if (pMVar1 != NULL) {
gScreen.affine.bg3xOffset = 0x80 - (*(s16*)&pMVar1[1].unk_0e - gRoomControls.roomScrollX);
gScreen.affine.bg3yOffset = 0x8c - (*(s16*)(pMVar1[1].unk_11 + 1) - gRoomControls.roomScrollY);
gScreen.bg3.xOffset = 0x80 - (*(s16*)&pMVar1[1].unk_0e - gRoomControls.roomScrollX);
gScreen.bg3.yOffset = 0x8c - (*(s16*)(pMVar1[1].unk_11 + 1) - gRoomControls.roomScrollY);
}
}
@ -161,7 +161,7 @@ void sub_0805DA08(u32 x, u32 y, u32 param_3) {
u32 i;
struct BgAffineDstData* affineDstData = &gUnk_02017AA0[gUnk_03003DE4[0] * 0xa0];
for (i = 0; i < 0xa0; ++i, y += 0x17) {
affineDstData->pa = ((gSineTable[(param_3 + i + y) & 0xff] * x) >> 8) + gScreen.affine.bg3xOffset;
affineDstData->pa = ((gSineTable[(param_3 + i + y) & 0xff] * x) >> 8) + gScreen.bg3.xOffset;
affineDstData = (struct BgAffineDstData*)&affineDstData->pb;
}
sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4[0] * 0xa0], 0x400001c, 0xa2600001);

View File

@ -69,7 +69,7 @@ void sub_0805E18C(Manager39* this) {
void sub_0805E1D8(Manager39* this) {
MemClear(&gUnk_02034DF0, 0x80);
gScreen.bg.bg0Updated = 1;
gScreen.bg0.updated = 1;
DeleteThisEntity();
}
@ -89,5 +89,5 @@ void sub_0805E1F8(u32 unk0, u32 unk1) {
if (!unk1)
tmp2 = gUnk_08108E30;
sub_0805F46C(&tmp, tmp2);
gScreen.bg.bg0Updated = 1;
gScreen.bg0.updated = 1;
}

View File

@ -23,8 +23,8 @@ void Manager8_Main(Manager8* this) {
sub_08057F20(this);
if (!this->manager.action) {
this->manager.action = 1;
gScreen.bg.bg1Updated = 0;
gScreen.affine.bg3Updated = 0;
gScreen.bg1.updated = 0;
gScreen.bg3.updated = 0;
sub_08052D74(this, sub_08057EFC, 0);
}
}
@ -45,25 +45,25 @@ void sub_08057F20(Manager8* this) {
u32 tmp;
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX;
tmp = tmp + (tmp >> 3) + ((0x400 - gRoomControls.width) / 2);
gScreen.affine.bg3xOffset = tmp & 0xF;
gScreen.affine.bg3yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 2);
gScreen.affine.bg3Tilemap = gBG3Buffer;
gScreen.bg3.xOffset = tmp & 0xF;
gScreen.bg3.yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 2);
gScreen.bg3.tilemap = gBG3Buffer;
sub_08058004(tmp, gUnk_02006F00, gBG3Buffer);
tmp = ((tmp >> 4) << 1);
if (this->unk_38 != tmp) {
this->unk_38 = tmp;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.updated = 1;
}
tmp = (gRoomControls.roomScrollX - gRoomControls.roomOriginX);
tmp = tmp + (tmp >> 2) + ((0x400 - gRoomControls.width) / 2);
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1);
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x400;
gScreen.bg1.xOffset = tmp & 0xF;
gScreen.bg1.yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1);
gScreen.bg1.tilemap = gBG3Buffer + 0x400;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x400);
tmp = ((tmp >> 4) << 1);
if (this->unk_3c != tmp) {
this->unk_3c = tmp;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.updated = 1;
}
}
@ -115,19 +115,19 @@ void sub_080580B0(u32 unk1) {
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX; // r7
tmp = tmp + (tmp >> 3) + (0x400 - gRoomControls.width) / 2;
sub_08058004(tmp, gUnk_02006F00, gBG3Buffer);
gScreen.affine.bg3xOffset = tmp & 0xF;
gScreen.affine.bg3yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.affine.bg3Control = 0x1D09;
gScreen.affine.bg3Tilemap = gBG3Buffer;
gScreen.affine.bg3Updated = 1;
gScreen.bg3.xOffset = tmp & 0xF;
gScreen.bg3.yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg3.control = 0x1D09;
gScreen.bg3.tilemap = gBG3Buffer;
gScreen.bg3.updated = 1;
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX; // r7
tmp = tmp + (tmp >> 2) + (0x400 - gRoomControls.width) / 2;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x400);
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg.bg1Control = 0x1E09;
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x400;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.xOffset = tmp & 0xF;
gScreen.bg1.yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg1.control = 0x1E09;
gScreen.bg1.tilemap = gBG3Buffer + 0x400;
gScreen.bg1.updated = 1;
gScreen.controls.layerFXControl = 0x3C48;
gScreen.controls.alphaBlend = 0x609;
gScreen.lcd.displayControl |= 0xa00;

View File

@ -24,7 +24,7 @@ void Manager9_Main(Manager9* this) {
sub_08058210(this);
if (!this->manager.action) {
this->manager.action = 1;
gScreen.bg.bg1Updated = 0;
gScreen.bg1.updated = 0;
sub_08052D74(this, sub_08058204, NULL);
}
}
@ -39,7 +39,7 @@ void sub_08058210(Manager9* this) {
return;
this->unk_3c = tmp;
sub_080582A0(tmp, gUnk_02006F00, gBG3Buffer);
gScreen.bg.bg1Updated = 1;
gScreen.bg1.updated = 1;
}
u32 sub_08058244(int i) {
@ -48,9 +48,9 @@ u32 sub_08058244(int i) {
u32 tmp3;
s32 tmp4;
tmp = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) * 0x20) / (gRoomControls.height - 0xa0);
gScreen.bg.bg1yOffset = gRoomControls.roomOriginY + tmp;
gScreen.bg1.yOffset = gRoomControls.roomOriginY + tmp;
tmp = (((gRoomControls.roomScrollX - gRoomControls.roomOriginX) * gUnk_081081EC[i]) / (gRoomControls.width - 0xf0));
gScreen.bg.bg1xOffset = tmp & 0xf;
gScreen.bg1.xOffset = tmp & 0xf;
return tmp;
}
@ -90,8 +90,8 @@ void sub_08058324(u32 unk) {
LoadGfxGroup(unk + 0x36);
sub_080582D0();
sub_080582A0(sub_08058244(unk), gUnk_02006F00, gBG3Buffer);
gScreen.bg.bg1Control = 0x1D47;
gScreen.bg.bg1Tilemap = gBG3Buffer;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.control = 0x1D47;
gScreen.bg1.tilemap = gBG3Buffer;
gScreen.bg1.updated = 1;
gScreen.lcd.displayControl |= 0x200;
}

View File

@ -287,10 +287,10 @@ void sub_08058D34() {
tmp = gScreen.lcd.displayControl;
tmp2 = 0;
gScreen.lcd.displayControl |= 1;
gScreen.affine.bg2Control = 0xBC82;
gScreen.bg.bg1Control = 0x5E86;
gScreen.bg.bg1xOffset = 0;
gScreen.bg.bg1yOffset = tmp2;
gScreen.bg2.control = 0xBC82;
gScreen.bg1.control = 0x5E86;
gScreen.bg1.xOffset = 0;
gScreen.bg1.yOffset = tmp2;
gScreen.controls.layerFXControl = 0x3456;
gScreen.controls.alphaBlend = 0x909;
gArea.musicIndex = gArea.pMusicIndex;

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
#include "room.h"
#include "npc.h"
//clang-format off
@ -135,3 +136,36 @@ void (*const gNPCFunctions[][3])(Entity* ent) = {
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
extern u8 gUnk_020342F8;
typedef struct {
u16 unk0;
u16 unk1;
u16 x;
u16 y;
} NPCStruct;
extern NPCStruct gUnk_02031EC0[100];
void InitNPC(Entity*);
u32 ReadBit(void*, u32);
// regalloc
NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
if ((this->currentHealth & 0x7f) && !ReadBit(&gUnk_020342F8, this->currentHealth - 1))
DeleteThisEntity();
if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
InitNPC(this);
if (!CheckDontUpdate(this))
gNPCFunctions[this->id][0](this);
if (this->next != NULL) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
if ((this->currentHealth & 0x7f) != 0) {
u32 temp = this->currentHealth & 0x7f;
gUnk_02031EC0[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.roomOriginX;
gUnk_02031EC0[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.roomOriginY;
}
DrawEntity(this);
}
}
END_NONMATCH

View File

@ -96,9 +96,9 @@ void sub_0806D0B0(Entity* this) {
if (this != NULL) {
sub_0806D164(this);
}
gScreen.bg.bg1Control = 0x1d47;
gScreen.bg.bg1Tilemap = &gMapDataTopSpecial;
gScreen.bg.bg1Updated = 1;
gScreen.bg1.control = 0x1d47;
gScreen.bg1.tilemap = &gMapDataTopSpecial;
gScreen.bg1.updated = 1;
}
void sub_0806D0F8(void) {

View File

@ -32,6 +32,6 @@ void sub_0806EABC(Entity* this, u32 param) {
sub_08050384();
sub_08057044(param, &gUnk_020227E8, 0x202020);
sub_0805F46C(0x3302, &gUnk_081146B8);
gScreen.bg.bg0Updated = 1;
gScreen.bg0.updated = 1;
}
#endif

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
#include "manager.h"
#include "object.h"
void (*const gObjectFunctions[])(Entity*) = {
@ -198,3 +199,17 @@ void (*const gObjectFunctions[])(Entity*) = {
[ENEMY_ITEM] = EnemyItem,
[OBJECT_C1] = ObjectC1,
};
void InitObject(Entity*);
void ObjectUpdate(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0)
InitObject(this);
if (this->iframes != 0)
this->iframes++;
if (!CheckDontUpdate(this)) {
gObjectFunctions[this->id](this);
this->bitfield &= ~0x80;
}
DrawEntity(this);
}

View File

@ -23,7 +23,6 @@ extern void PlayerItem15();
extern void PlayerItemNulled2();
void (*const gPlayerItemFunctions[])() = {
DeleteEntity,
PlayerItemSword,
PlayerItemBomb,
@ -50,3 +49,67 @@ void (*const gPlayerItemFunctions[])() = {
PlayerItemNulled2,
PlayerItemCellOverwriteSet
};
typedef struct {
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u8 unk4;
u8 unk5;
u16 unk6;
} ItemFrame;
extern ItemFrame gUnk_08126DA8[];
extern ItemFrame* gUnk_08126ED8[3];
void ItemInit(Entity*);
void ItemUpdate(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0 && this->subAction == 0)
ItemInit(this);
if (!CheckDontUpdate(this)) {
gPlayerItemFunctions[this->id](this);
this->bitfield &= ~0x80;
if (this->iframes != 0) {
if (this->iframes > 0)
this->iframes--;
else
this->iframes++;
}
}
DrawEntity(this);
}
// tiny regalloc
NONMATCH("asm/non_matching/arm_proxy/ItemInit.inc", void ItemInit(Entity* this)) {
ItemFrame* entry;
entry = &gUnk_08126DA8[this->id];
if (entry->unk0 == 0xff) {
u32 temp = entry->unk2;
ItemFrame* temp2 = gUnk_08126ED8[entry->unk1];
entry = &temp2[this->field_0x68.HALF.LO - temp];
}
this->palette.raw = ((entry->unk0 & 0xf) << 4) | entry->unk0;
this->damage = entry->unk1;
this->hurtType = entry->unk3;
this->hitType = entry->unk4;
this->spriteIndex = entry->unk5;
if (entry->unk6 == 0)
this->spriteVramOffset = gPlayerEntity.spriteVramOffset;
else
this->spriteVramOffset = entry->unk6 & 0x3ff;
if (this->animationState == 0)
this->animationState = gPlayerEntity.animationState & 6;
this->collisionLayer = gPlayerEntity.collisionLayer;
this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3;
this->spritePriority.b0 = gPlayerEntity.spritePriority.b0;
this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
this->currentHealth = 1;
this->flags |= ENT_DID_INIT;
}
END_NONMATCH

View File

@ -46,12 +46,12 @@ void sub_080A3BD0(void) {
LoadGfxGroup(iVar1 + 0x76);
gScreen.lcd.displayControl |= 0x1e00;
gScreen.bg.bg1Control = 0x1c01;
gScreen.affine.bg2Control = 0x1d02;
gScreen.affine.bg3Control = 0x1e0b;
gScreen.bg.bg1Updated = 1;
gScreen.affine.bg2Updated = 1;
gScreen.affine.bg3Updated = 1;
gScreen.bg1.control = 0x1c01;
gScreen.bg2.control = 0x1d02;
gScreen.bg3.control = 0x1e0b;
gScreen.bg1.updated = 1;
gScreen.bg2.updated = 1;
gScreen.bg3.updated = 1;
sub_080A4528();
sub_080A4398();
sub_0801E738(0);