Decompile Object12

This commit is contained in:
octorock
2022-03-10 21:33:42 +01:00
parent f72e27b08a
commit a24178a56e
7 changed files with 183 additions and 273 deletions
+98
View File
@@ -0,0 +1,98 @@
/**
* @file object12.c
* @ingroup Objects
*
* @brief Object12 object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
#include "screen.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[30];
/*0x86*/ u16 unk_86;
} Object12Entity;
void Object12_Init(Object12Entity*);
void Object12_Action1(Object12Entity*);
void Object12_Action2(Object12Entity*);
void Object12_Action3(Object12Entity*);
void Object12_Action4(Object12Entity*);
void sub_080850FC(Object12Entity*);
void Object12(Object12Entity* this) {
static void (*const Object12_Actions[])(Object12Entity*) = {
Object12_Init, Object12_Action1, Object12_Action2, Object12_Action3, Object12_Action4,
};
Object12_Actions[super->action](this);
}
void Object12_Init(Object12Entity* this) {
if (super->type == 0) {
if (CheckFlags(this->unk_86)) {
DeleteThisEntity();
}
super->action = 1;
super->spritePriority.b0 = 7;
sub_080850FC(this);
} else {
super->action = 2;
super->actionDelay = 0xf0;
super->speed = 0x80;
super->direction = 0x18;
}
super->frameIndex = 0;
}
void Object12_Action1(Object12Entity* this) {
}
NONMATCH("asm/non_matching/object12/Object12_Action2.inc", void Object12_Action2(Object12Entity* this)) {
u32 tmp;
if (--super->actionDelay == 0) {
super->action = 3;
super->actionDelay = 0x1e;
super->spriteOffsetY = 4;
gScreen.lcd.displayControl |= 0x2000;
gScreen.controls.windowInsideControl = 0x1f;
gScreen.controls.windowOutsideControl = 0xf;
tmp = super->x.HALF.HI - gRoomControls.scroll_x;
gScreen.controls.window0HorizontalDimensions = (((tmp - 0x18) & 0xff) << 8) | ((tmp + 0x18) & 0xff);
tmp = super->y.HALF.HI - gRoomControls.scroll_y;
gScreen.controls.window0VerticalDimensions = (((tmp - 0x18) & 0xff) << 8) | ((tmp + 0x18) & 0xff);
}
}
END_NONMATCH
void Object12_Action3(Object12Entity* this) {
if (--super->actionDelay == 0) {
super->action = 4;
super->actionDelay = 0x60;
}
}
void Object12_Action4(Object12Entity* this) {
LinearMoveUpdate(super);
if (--super->actionDelay == 0) {
gScreen.lcd.displayControl &= 0xdfff;
DeleteEntity(super);
}
}
void sub_080850FC(Object12Entity* this) {
u32 position = COORD_TO_TILE(super);
u32 layer = super->collisionLayer;
SetTile(0x403d, position - 0x41, layer);
SetTile(0x403d, position - 0x40, layer);
SetTile(0x403d, position - 0x3f, layer);
SetTile(0x403d, position - 1, layer);
SetTile(0x403d, position, layer);
SetTile(0x403d, position + 1, layer);
SetTile(0x403d, position + 0x3f, layer);
SetTile(0x403d, position + 0x40, layer);
SetTile(0x403d, position + 0x41, layer);
}
+11 -9
View File
@@ -19,14 +19,17 @@ typedef struct {
/*0x68*/ u16 unk_68;
} Object3DEntity;
void Object3D_Init(Object3DEntity*);
void Object3D_Action1(Object3DEntity*);
void Object3D_Action2(Object3DEntity*);
void sub_0808D030(void);
void Object3D(Object3DEntity* this) {
static void (*const Object3D_Actions[])(Object3DEntity*) = {Object3D_Init, Object3D_Action1, Object3D_Action2, };
static void (*const Object3D_Actions[])(Object3DEntity*) = {
Object3D_Init,
Object3D_Action1,
Object3D_Action2,
};
Object3D_Actions[super->action](this);
}
@@ -37,15 +40,14 @@ void Object3D_Init(Object3DEntity* this) {
this->unk_68 = 0x80;
super->updatePriority = 6;
sub_0801E1B8(0x1f17, 0);
sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI,
this->unk_68);
sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI, this->unk_68);
}
void Object3D_Action1(Object3DEntity* this) {
#ifdef EU
static const u16 gUnk_081216C8[] = { 206, 19, 333, 208, 16, 333, 207, 1, 333, 0};
static const u16 gUnk_081216C8[] = { 206, 19, 333, 208, 16, 333, 207, 1, 333, 0 };
#else
static const u16 gUnk_081216C8[] = { 206, 19, 334, 208, 16, 334, 207, 1, 334, 0};
static const u16 gUnk_081216C8[] = { 206, 19, 334, 208, 16, 334, 207, 1, 334, 0 };
#endif
const u16* ptr;
this->unk_68 -= 2;
@@ -57,7 +59,7 @@ void Object3D_Action1(Object3DEntity* this) {
ResetPaletteTable(0);
ResetPalettes();
gGFXSlots.unk0 = 1;
ptr = &gUnk_081216C8[super->type* 3];
ptr = &gUnk_081216C8[super->type * 3];
LoadFixedGFX(super, ptr[0]);
LoadObjPalette(super, ptr[1]);
super->spriteIndex = ptr[2];
@@ -68,7 +70,7 @@ void Object3D_Action1(Object3DEntity* this) {
super->spriteSettings.draw = 2;
super->spriteOrientation.flipY = 0;
super->spriteRendering.b3 = 0;
super->spritePriority. b0 = 0;
super->spritePriority.b0 = 0;
super->actionDelay = 0x1e;
super->field_0xf = 0xff;
super->spriteRendering.b0 = 3;
@@ -104,7 +106,7 @@ void Object3D_Action2(Object3DEntity* this) {
}
sub_0801E1EC(super->x.HALF.HI, super->y.HALF.HI, this->unk_68);
if (0x80 < super->field_0xf) {
super->field_0xf-= 8;
super->field_0xf -= 8;
}
sub_0805EC9C(super, super->field_0xf, super->field_0xf, 0);
} else {
+2 -1
View File
@@ -26,7 +26,8 @@ void Object4B_Action7(Object4BEntity*);
void Object4B(Object4BEntity* this) {
static void (*const Object4B_Actions[])(Object4BEntity*) = {
Object4B_Init, Object4B_Action1, Object4B_Action2, Object4B_Action3, Object4B_Action4, Object4B_Action5, Object4B_Action6, Object4B_Action7,
Object4B_Init, Object4B_Action1, Object4B_Action2, Object4B_Action3,
Object4B_Action4, Object4B_Action5, Object4B_Action6, Object4B_Action7,
};
Object4B_Actions[super->action](this);
}