decompile MacroDecoration

This commit is contained in:
Tal Hayon 2022-02-27 16:48:19 +02:00
parent ee11972a67
commit fd5562dad6
5 changed files with 114 additions and 261 deletions

View File

@ -1,242 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start MacroDecoration
MacroDecoration: @ 0x08097DD4
push {lr}
ldr r2, _08097DE8 @ =gUnk_081233B8
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_08097DE8: .4byte gUnk_081233B8
thumb_func_start sub_08097DEC
sub_08097DEC: @ 0x08097DEC
push {r4, lr}
adds r4, r0, #0
movs r0, #1
strb r0, [r4, #0xc]
adds r0, r4, #0
bl UpdateSpriteForCollisionLayer
ldrb r0, [r4, #0xa]
cmp r0, #1
beq _08097E46
cmp r0, #1
bgt _08097E0A
cmp r0, #0
beq _08097E1C
b _08097EA2
_08097E0A:
cmp r0, #3
bgt _08097EA2
ldrb r0, [r4, #0xb]
strb r0, [r4, #0x1e]
ldrb r0, [r4, #0x18]
movs r1, #3
orrs r0, r1
strb r0, [r4, #0x18]
b _08097E9C
_08097E1C:
ldrh r2, [r4, #0x2e]
movs r1, #0x10
rsbs r1, r1, #0
adds r0, r1, #0
ands r0, r2
strh r0, [r4, #0x2e]
ldrh r0, [r4, #0x32]
ands r1, r0
strh r1, [r4, #0x32]
adds r0, r4, #0
bl sub_08097EB8
ldrb r0, [r4, #0xb]
cmp r0, #0
beq _08097EA2
adds r1, r0, #0
adds r1, #0xb
adds r0, r4, #0
bl ChangeObjPalette
b _08097EA2
_08097E46:
ldrb r0, [r4, #0xb]
strb r0, [r4, #0x1e]
lsls r0, r0, #0x18
lsrs r0, r0, #0x19
cmp r0, #1
beq _08097E76
cmp r0, #1
bgt _08097E5C
cmp r0, #0
beq _08097E68
b _08097E9C
_08097E5C:
cmp r0, #2
bne _08097E9C
adds r0, r4, #0
movs r1, #0xd
bl ChangeObjPalette
_08097E68:
ldrb r0, [r4, #0x1b]
movs r1, #0x3f
ands r1, r0
movs r0, #0x40
orrs r1, r0
strb r1, [r4, #0x1b]
b _08097E9C
_08097E76:
ldrb r1, [r4, #0x1b]
movs r0, #0x3f
ands r0, r1
movs r1, #0x80
orrs r0, r1
strb r0, [r4, #0x1b]
adds r2, r4, #0
adds r2, #0x29
ldrb r1, [r2]
movs r0, #8
rsbs r0, r0, #0
ands r0, r1
movs r1, #3
orrs r0, r1
strb r0, [r2]
adds r0, r4, #0
movs r1, #0xb
bl ChangeObjPalette
_08097E9C:
adds r0, r4, #0
bl sub_08097F34
_08097EA2:
pop {r4, pc}
thumb_func_start sub_08097EA4
sub_08097EA4: @ 0x08097EA4
push {lr}
adds r1, r0, #0
ldrb r0, [r1, #0xa]
cmp r0, #0
beq _08097EB4
adds r0, r1, #0
bl sub_08097F10
_08097EB4:
pop {pc}
.align 2, 0
thumb_func_start sub_08097EB8
sub_08097EB8: @ 0x08097EB8
push {r4, r5, r6, lr}
movs r2, #0x2e
ldrsh r1, [r0, r2]
ldr r3, _08097F04 @ =gRoomControls
ldrh r2, [r3, #6]
subs r1, r1, r2
asrs r5, r1, #4
movs r2, #0x3f
ands r5, r2
movs r1, #0x32
ldrsh r0, [r0, r1]
ldrh r1, [r3, #8]
subs r0, r0, r1
asrs r0, r0, #4
ands r0, r2
lsls r0, r0, #6
orrs r5, r0
ldr r4, _08097F08 @ =gUnk_081233C0
movs r2, #0
ldrsh r0, [r4, r2]
ldr r1, _08097F0C @ =0x00007FFF
cmp r0, r1
beq _08097F00
adds r6, r1, #0
_08097EE8:
ldrh r0, [r4, #2]
movs r2, #0
ldrsh r1, [r4, r2]
adds r1, r5, r1
movs r2, #1
bl SetTile
adds r4, #4
movs r1, #0
ldrsh r0, [r4, r1]
cmp r0, r6
bne _08097EE8
_08097F00:
pop {r4, r5, r6, pc}
.align 2, 0
_08097F04: .4byte gRoomControls
_08097F08: .4byte gUnk_081233C0
_08097F0C: .4byte 0x00007FFF
thumb_func_start sub_08097F10
sub_08097F10: @ 0x08097F10
push {r4, lr}
adds r4, r0, #0
ldr r0, _08097F30 @ =gRoomControls
movs r2, #0xc
ldrsh r1, [r0, r2]
ldrh r0, [r0, #8]
subs r1, r1, r0
adds r0, r4, #0
bl sub_08097F60
adds r1, r4, #0
adds r1, #0x70
ldrh r1, [r1]
subs r1, r1, r0
strh r1, [r4, #0x32]
pop {r4, pc}
.align 2, 0
_08097F30: .4byte gRoomControls
thumb_func_start sub_08097F34
sub_08097F34: @ 0x08097F34
push {r4, lr}
adds r4, r0, #0
movs r0, #0x32
ldrsh r1, [r4, r0]
ldr r0, _08097F5C @ =gRoomControls
ldrh r0, [r0, #8]
subs r1, r1, r0
adds r0, r4, #0
bl sub_08097F60
ldrh r1, [r4, #0x32]
adds r1, r1, r0
adds r0, r4, #0
adds r0, #0x70
strh r1, [r0]
adds r0, r4, #0
bl sub_08097F10
pop {r4, pc}
.align 2, 0
_08097F5C: .4byte gRoomControls
thumb_func_start sub_08097F60
sub_08097F60: @ 0x08097F60
push {lr}
ldrb r2, [r0, #0xa]
cmp r2, #1
bne _08097F74
ldrb r0, [r0, #0x1e]
lsrs r0, r0, #1
cmp r0, #1
bne _08097F7C
asrs r1, r1, #3
b _08097F7E
_08097F74:
cmp r2, #1
blt _08097F7E
cmp r2, #3
bgt _08097F7E
_08097F7C:
asrs r1, r1, #1
_08097F7E:
adds r0, r1, #0
pop {pc}
.align 2, 0

View File

@ -44855,11 +44855,6 @@
"size": 4,
"type": "animation"
},
{
"path": "macroDecorations/gUnk_081233C0.bin",
"start": 1192896,
"size": 80
},
{
"path": "animations/gSpriteAnimations_Object79_0.bin",
"start": 1192994,

View File

@ -1,12 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_081233B8:: @ 081233B8
.4byte sub_08097DEC
.4byte sub_08097EA4
gUnk_081233C0:: @ 081233C0
.incbin "macroDecorations/gUnk_081233C0.bin"

View File

@ -764,7 +764,7 @@ SECTIONS {
src/object/lilypadSmall.o(.text);
asm/object/object74.o(.text);
src/object/bell.o(.text);
asm/object/macroDecorations.o(.text);
src/object/macroDecorations.o(.text);
asm/object/object79.o(.text);
src/object/steam.o(.text);
src/object/pushableLever.o(.text);
@ -1510,7 +1510,7 @@ SECTIONS {
data/const/object/object74.o(.rodata);
data/const/object/bell.o(.rodata);
data/animations/object/bell.o(.rodata);
data/const/object/macroDecorations.o(.rodata);
src/object/macroDecorations.o(.rodata);
data/const/object/object79.o(.rodata);
data/animations/object/object79.o(.rodata);
src/object/steam.o(.rodata);

View File

@ -0,0 +1,112 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "room.h"
#include "asm.h"
typedef struct {
Entity base;
u8 filler[8];
s16 y2;
} MacroDecorationEntity;
void sub_08097DEC(MacroDecorationEntity*);
void sub_08097EA4(MacroDecorationEntity*);
void sub_08097EB8(MacroDecorationEntity*);
void sub_08097F34(MacroDecorationEntity*);
void sub_08097F10(MacroDecorationEntity*);
s32 sub_08097F60(MacroDecorationEntity*, s32);
void MacroDecoration(Entity* this) {
static void (*const actionFuncs[])(MacroDecorationEntity*) = {
sub_08097DEC,
sub_08097EA4,
};
actionFuncs[this->action]((MacroDecorationEntity*)this);
}
void sub_08097DEC(MacroDecorationEntity* this) {
u32 bVar1;
u32 uVar2;
super->action = 1;
UpdateSpriteForCollisionLayer(super);
switch (super->type) {
case 0:
super->x.HALF.HI &= 0xfff0;
super->y.HALF.HI &= 0xfff0;
sub_08097EB8(this);
if (super->type2 == 0) {
return;
}
ChangeObjPalette(super, super->type2 + 0xb);
return;
case 1:
bVar1 = super->frameIndex = super->type2;
bVar1 = (bVar1 << 0x18) >> 0x19;
switch ((s32)bVar1) {
case 2:
ChangeObjPalette(super, 0xd);
case 0:
super->spriteOrientation.flipY = 1;
break;
case 1:
super->spriteOrientation.flipY = 2;
super->spritePriority.b0 = 3;
ChangeObjPalette(super, 0xb);
break;
}
break;
case 2:
case 3:
super->frameIndex = super->type2;
super->spriteSettings.draw = 3;
break;
default:
return;
}
sub_08097F34(this);
}
void sub_08097EA4(MacroDecorationEntity* this) {
if (super->type) {
sub_08097F10(this);
}
}
void sub_08097EB8(MacroDecorationEntity* this) {
static const s16 tilePosArray[] = {
0xff7e, 0x4089, 0xff7f, 0x4022, 0xff80, 0x4022, 0xff81, 0x408a, 0xffbe, 0x4022, 0xffbf, 0x4022, 0xffc0, 0x4022,
0xffc1, 0x4022, 0xfffe, 0x4022, 0xffff, 0x4022, 0, 0x4022, 1, 0x4022, 2, 0x408b, 0x3e, 0x4022,
0x3f, 0x4022, 0x40, 0x4026, 0x41, 0x4022, 0x7e, 0x408c, 0x7f, 0x408c, 0x7fff, 0xffff,
};
const s16* tilePosPtr;
u16 tile = COORD_TO_TILE(super);
for (tilePosPtr = tilePosArray; *tilePosPtr != 0x7fff; tilePosPtr += 2) {
SetTile((u16)tilePosPtr[1], tile + tilePosPtr[0], 1);
}
}
void sub_08097F10(MacroDecorationEntity* this) {
super->y.HALF.HI = this->y2 - sub_08097F60(this, gRoomControls.scroll_y - gRoomControls.origin_y);
}
void sub_08097F34(MacroDecorationEntity* this) {
this->y2 = super->y.HALF.HI + sub_08097F60(this, super->y.HALF.HI - gRoomControls.origin_y);
sub_08097F10(this);
}
s32 sub_08097F60(MacroDecorationEntity* this, s32 arg2) {
switch (super->type) {
case 1:
if (super->frameIndex >> 1 == 1) {
arg2 >>= 3;
break;
}
case 2:
case 3:
arg2 >>= 1;
}
return arg2;
}