more code_0800ECAC

This commit is contained in:
Zhengwen Jiang 2023-10-28 00:52:11 -05:00 committed by Egor Ananyin
parent 1c3c68a08d
commit b59e6750b9
9 changed files with 668 additions and 1591 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnk_082DDE84:: @ 082DDE84
.incbin "baserom.gba", 0x2DDE84, 0x000006C
gUnk_082DDEF0:: @ 082DDEF0
.incbin "baserom.gba", 0x2DDEF0, 0x000006C
gUnk_082DDF5C:: @ 082DDF5C
.incbin "baserom.gba", 0x2DDF5C, 0x000006C
gUnk_082DDFC8:: @ 082DDFC8
.incbin "baserom.gba", 0x2DDFC8, 0x000006C
gUnk_082DE034:: @ 082DE034
.incbin "baserom.gba", 0x2DE034, 0x0000040
gUnk_082DE074:: @ 082DE074
.incbin "baserom.gba", 0x2DE074, 0x0000020

View File

@ -29,6 +29,8 @@
#define KIRBY_ABILITY_MISSILE 25
#define KIRBY_ABILITY_MASTER 26
#define KIRBY_ABILITY_COUNT (KIRBY_ABILITY_MASTER + 1)
// for both inhale and copy essence
#define KIRBY_ABILITY_CHANGE_RANDOM 0x20 // generate a random ability
#define KIRBY_ABILITY_CHANGE_UNKNOWN 0x40

View File

@ -246,7 +246,7 @@
#define ObjType38To52(obj) ((obj)->type == OBJ_MR_FROSTY || (obj)->type == OBJ_BONKERS || (obj)->type == OBJ_PHAN_PHAN \
|| (obj)->type == OBJ_BATAFIRE || (obj)->type == OBJ_BOX_BOXER || (obj)->type == OBJ_BOXY \
|| (obj)->type == OBJ_MASTER_HAND || (obj)->type == OBJ_BOMBAR || (obj)->type == OBJ_EMPTY_40 \
|| (obj)->type == OBJ_EMPTY_41 || (obj)->type == OBJ_EMPTY_42 || ObjType43To52((obj)))
|| (obj)->type == OBJ_EMPTY_41 || (obj)->type == OBJ_EMPTY_42 || ObjType43To52(obj))
#define ObjType43To52(obj) ((obj)->type == OBJ_EMPTY_43 \
|| (obj)->type == OBJ_EMPTY_44 || (obj)->type == OBJ_KRACKO || (obj)->type == OBJ_KING_GOLEM \
@ -261,7 +261,7 @@
|| (obj)->type == OBJ_EMPTY_59 || (obj)->type == OBJ_EMPTY_5A || (obj)->type == OBJ_EMPTY_5B \
|| (obj)->type == OBJ_EMPTY_5C)
#define ObjType53To64(obj) (ObjType53To5C((obj)) || (obj)->type == OBJ_EMPTY_5D || (obj)->type == OBJ_SMALL_FOOD \
#define ObjType53To64(obj) (ObjType53To5C(obj) || (obj)->type == OBJ_EMPTY_5D || (obj)->type == OBJ_SMALL_FOOD \
|| (obj)->type == OBJ_POP_SODA || (obj)->type == OBJ_MEAT || (obj)->type == OBJ_TOMATO \
|| (obj)->type == OBJ_BATTERY || (obj)->type == OBJ_1UP || (obj)->type == OBJ_INVINCIBLE_CANDY)
@ -287,7 +287,7 @@
|| (obj)->type == OBJ_ABILITY_STATUE_3 || (obj)->type == OBJ_ABILITY_STATUE_4 || (obj)->type == OBJ_ABILITY_STATUE_RANDOM \
|| (obj)->type == OBJ_DOOR_TO_HUB || (obj)->type == OBJ_MASTER_SWORD_STAND || (obj)->type == OBJ_AREA_DOOR)
#define ObjType6Dto9A(obj) (ObjType6Dto99((obj)) || (obj)->type == OBJ_EMPTY_9A)
#define ObjType6Dto9A(obj) (ObjType6Dto99(obj) || (obj)->type == OBJ_EMPTY_9A)
#define ObjIsTitanArm(obj) ((obj)->type == OBJ_TITAN_ARM_1 || (obj)->type == OBJ_TITAN_ARM_2 || (obj)->type == OBJ_TITAN_ARM_3 || (obj)->type == OBJ_TITAN_ARM_4)

View File

@ -418,7 +418,7 @@ struct Unk_02038590 {
u8 unk3E; // something related to kirby ability
u8 unk3F;
struct Kirby *unk40;
u32 unk44;
struct Kirby *unk44;
struct Object2 *unk48;
struct Unk_02038590_4C unk4C[4];
s32 unk7C;

View File

@ -183,6 +183,7 @@ void sub_08036314(struct ObjectBase *);
void sub_08036378(void);
u8 sub_0803925C(struct ObjectBase*, struct ObjectBase*);
u8 sub_08039430(struct ObjectBase *, s32, s32, s16, s16, u16, u16);
void *sub_08039490(struct ObjectBase *); // TODO: may return struct Object2 ** or struct ObjectBase **
struct Object2 **sub_080394C8(struct ObjectBase *);
bool32 sub_080395D4(void);
void sub_08039600(u16);

View File

@ -412,7 +412,8 @@ SECTIONS {
data/data_1.o(.rodata);
src/warp_star.o(.rodata);
src/code_0800E0E4.o(.rodata);
data/data_7.o(.rodata);
src/code_0800ECAC.o(.rodata);
src/code_0800ECAC_2.o(.rodata);
src/multi_08019F28.o(.rodata);
data/data_15.o(.rodata);
src/shard.o(.rodata);

View File

@ -5,8 +5,217 @@
#include "random.h"
#include "constants/kirby.h"
void sub_08010944(struct Unk_02038590 *);
void sub_08010A34(struct Unk_02038590 *);
void sub_08010AC8(struct Unk_02038590 *);
void sub_08010B80(struct Unk_02038590 *);
void sub_08010C34(struct Unk_02038590 *);
void sub_08010CE8(struct Unk_02038590 *);
void sub_08010E3C(struct Unk_02038590 *);
void sub_08010F90(struct Unk_02038590 *);
void sub_08011044(struct Unk_02038590 *);
void sub_0801119C(struct Unk_02038590 *);
void sub_08011250(struct Unk_02038590 *);
void sub_08011324(struct Unk_02038590 *);
void sub_0801149C(struct Unk_02038590 *);
void sub_08011558(struct Unk_02038590 *);
void sub_080115FC(struct Unk_02038590 *);
void sub_08011754(struct Unk_02038590 *);
void sub_08011A28(struct Unk_02038590 *);
void sub_08011AD8(struct Unk_02038590 *);
void sub_08011C2C(struct Unk_02038590 *);
void sub_08011CE0(struct Unk_02038590 *);
void sub_08011D94(struct Unk_02038590 *);
void sub_08011F00(struct Unk_02038590 *);
void sub_08011FB4(struct Unk_02038590 *);
void sub_08012048(struct Unk_02038590 *);
void sub_080120FC(struct Unk_02038590 *);
void sub_08012190(struct Unk_02038590 *);
void sub_0801232C(struct Unk_02038590 *);
void sub_080123E0(struct Unk_02038590 *);
bool16 sub_080124E0(struct Unk_02038590 *);
bool16 sub_080126CC(struct Unk_02038590 *);
bool16 sub_08012884(struct Unk_02038590 *);
bool16 sub_08012980(struct Unk_02038590 *);
bool16 sub_08012A88(struct Unk_02038590 *);
bool16 sub_08012BC8(struct Unk_02038590 *);
bool16 sub_08012C5C(struct Unk_02038590 *);
bool16 sub_08012DD4(struct Unk_02038590 *);
bool16 sub_08012EAC(struct Unk_02038590 *);
bool16 sub_08012FD8(struct Unk_02038590 *);
bool16 sub_08013174(struct Unk_02038590 *);
bool16 sub_08013318(struct Unk_02038590 *);
bool16 sub_08013518(struct Unk_02038590 *);
bool16 sub_08013720(struct Unk_02038590 *);
void sub_0801519C(struct Unk_02038590 *);
void sub_080160B8(struct Unk_02038590 *);
void sub_08017274(struct Unk_02038590 *);
void sub_0801737C(struct Unk_02038590 *);
void sub_0801745C(struct Unk_02038590 *);
void sub_080175D0(struct Unk_02038590 *);
void sub_08017684(struct Unk_02038590 *);
bool16 sub_08018368(struct Unk_02038590 *);
void sub_0801836C(struct Unk_02038590 *);
void sub_08018374(struct Unk_02038590 *);
bool16 (*const gUnk_082DDE84[])(struct Unk_02038590 *) = {
[KIRBY_ABILITY_NORMAL] = sub_080124E0,
[KIRBY_ABILITY_FIRE] = sub_080126CC,
[KIRBY_ABILITY_ICE] = sub_080126CC,
[KIRBY_ABILITY_BURNING] = sub_08012884,
[KIRBY_ABILITY_WHEEL] = sub_08012980,
[KIRBY_ABILITY_PARASOL] = sub_08012A88,
[KIRBY_ABILITY_CUTTER] = sub_08012BC8,
[KIRBY_ABILITY_BEAM] = sub_08012C5C,
[KIRBY_ABILITY_STONE] = sub_08012DD4,
[KIRBY_ABILITY_BOMB] = sub_080124E0,
[KIRBY_ABILITY_THROW] = sub_08013318,
[KIRBY_ABILITY_SLEEP] = sub_080124E0,
[KIRBY_ABILITY_COOK] = sub_080124E0,
[KIRBY_ABILITY_LASER] = sub_08012BC8,
[KIRBY_ABILITY_UFO] = sub_08012BC8,
[KIRBY_ABILITY_SPARK] = sub_08012EAC,
[KIRBY_ABILITY_TORNADO] = sub_08013720,
[KIRBY_ABILITY_HAMMER] = sub_08013174,
[KIRBY_ABILITY_SWORD] = sub_08012EAC,
[KIRBY_ABILITY_CUPID] = sub_08012FD8,
[KIRBY_ABILITY_FIGHTER] = sub_080124E0,
[KIRBY_ABILITY_MAGIC] = sub_080124E0,
[KIRBY_ABILITY_SMASH] = sub_080124E0,
[KIRBY_ABILITY_MINI] = sub_08018368,
[KIRBY_ABILITY_CRASH] = sub_080124E0,
[KIRBY_ABILITY_MISSILE] = sub_08013518,
[KIRBY_ABILITY_MASTER] = sub_08013174,
};
void (*const gUnk_082DDEF0[])(struct Unk_02038590 *) = {
[KIRBY_ABILITY_NORMAL] = sub_08010AC8,
[KIRBY_ABILITY_FIRE] = sub_08010B80,
[KIRBY_ABILITY_ICE] = sub_08010C34,
[KIRBY_ABILITY_BURNING] = sub_08010CE8,
[KIRBY_ABILITY_WHEEL] = sub_08010E3C,
[KIRBY_ABILITY_PARASOL] = sub_08010F90,
[KIRBY_ABILITY_CUTTER] = sub_08011044,
[KIRBY_ABILITY_BEAM] = sub_0801119C,
[KIRBY_ABILITY_STONE] = sub_08011250,
[KIRBY_ABILITY_BOMB] = sub_08011324,
[KIRBY_ABILITY_THROW] = sub_0801149C,
[KIRBY_ABILITY_SLEEP] = sub_0801836C,
[KIRBY_ABILITY_COOK] = sub_08011558,
[KIRBY_ABILITY_LASER] = sub_080115FC,
[KIRBY_ABILITY_UFO] = sub_08011754,
[KIRBY_ABILITY_SPARK] = sub_08011A28,
[KIRBY_ABILITY_TORNADO] = sub_08011AD8,
[KIRBY_ABILITY_HAMMER] = sub_08011C2C,
[KIRBY_ABILITY_SWORD] = sub_08011CE0,
[KIRBY_ABILITY_CUPID] = sub_08011D94,
[KIRBY_ABILITY_FIGHTER] = sub_08011F00,
[KIRBY_ABILITY_MAGIC] = sub_08011FB4,
[KIRBY_ABILITY_SMASH] = sub_08012048,
[KIRBY_ABILITY_MINI] = sub_08018374,
[KIRBY_ABILITY_CRASH] = sub_080120FC,
[KIRBY_ABILITY_MISSILE] = sub_08012190,
[KIRBY_ABILITY_MASTER] = sub_0801232C,
};
void (*const gUnk_082DDF5C[])(struct Unk_02038590 *) = {
[KIRBY_ABILITY_NORMAL] = sub_080123E0,
[KIRBY_ABILITY_FIRE] = sub_080123E0,
[KIRBY_ABILITY_ICE] = sub_080123E0,
[KIRBY_ABILITY_BURNING] = sub_080123E0,
[KIRBY_ABILITY_WHEEL] = sub_080123E0,
[KIRBY_ABILITY_PARASOL] = sub_08010F90,
[KIRBY_ABILITY_CUTTER] = sub_080123E0,
[KIRBY_ABILITY_BEAM] = sub_080123E0,
[KIRBY_ABILITY_STONE] = sub_080123E0,
[KIRBY_ABILITY_BOMB] = sub_080123E0,
[KIRBY_ABILITY_THROW] = sub_080123E0,
[KIRBY_ABILITY_SLEEP] = sub_0801836C,
[KIRBY_ABILITY_COOK] = sub_080123E0,
[KIRBY_ABILITY_LASER] = sub_080123E0,
[KIRBY_ABILITY_UFO] = sub_08011754,
[KIRBY_ABILITY_SPARK] = sub_080123E0,
[KIRBY_ABILITY_TORNADO] = sub_080123E0,
[KIRBY_ABILITY_HAMMER] = sub_08011C2C,
[KIRBY_ABILITY_SWORD] = sub_08011CE0,
[KIRBY_ABILITY_CUPID] = sub_080123E0,
[KIRBY_ABILITY_FIGHTER] = sub_080123E0,
[KIRBY_ABILITY_MAGIC] = sub_080123E0,
[KIRBY_ABILITY_SMASH] = sub_080123E0,
[KIRBY_ABILITY_MINI] = sub_08018374,
[KIRBY_ABILITY_CRASH] = sub_080123E0,
[KIRBY_ABILITY_MISSILE] = sub_080123E0,
[KIRBY_ABILITY_MASTER] = sub_0801232C,
};
const u32 gUnk_082DDFC8[] = {
[KIRBY_ABILITY_NORMAL] = 0x20000042,
[KIRBY_ABILITY_FIRE] = 0x20000103,
[KIRBY_ABILITY_ICE] = 0x20000203,
[KIRBY_ABILITY_BURNING] = 0x30001103,
[KIRBY_ABILITY_WHEEL] = 0x30000043,
[KIRBY_ABILITY_PARASOL] = 0x20000043,
[KIRBY_ABILITY_CUTTER] = 0x20002003,
[KIRBY_ABILITY_BEAM] = 0x20000403,
[KIRBY_ABILITY_STONE] = 0x30005003,
[KIRBY_ABILITY_BOMB] = 0x20000103,
[KIRBY_ABILITY_THROW] = 0x20001003,
[KIRBY_ABILITY_SLEEP] = 0x20000082,
[KIRBY_ABILITY_COOK] = 0x20008003,
[KIRBY_ABILITY_LASER] = 0x20000103,
[KIRBY_ABILITY_UFO] = 0x20000103,
[KIRBY_ABILITY_SPARK] = 0x20000403,
[KIRBY_ABILITY_TORNADO] = 0x30000043,
[KIRBY_ABILITY_HAMMER] = 0x30005003,
[KIRBY_ABILITY_SWORD] = 0x30002003,
[KIRBY_ABILITY_CUPID] = 0x2003,
[KIRBY_ABILITY_FIGHTER] = 0x30000043,
[KIRBY_ABILITY_MAGIC] = 0x20000082,
[KIRBY_ABILITY_SMASH] = 0x30000043,
[KIRBY_ABILITY_MINI] = 0x20000082,
[KIRBY_ABILITY_CRASH] = 0x10003,
[KIRBY_ABILITY_MISSILE] = 0x30001043,
[KIRBY_ABILITY_MASTER] = 0x30007103,
};
const u8 gUnk_082DE034[] = {
KIRBY_ABILITY_FIRE, KIRBY_ABILITY_FIRE, KIRBY_ABILITY_FIRE, KIRBY_ABILITY_FIRE,
KIRBY_ABILITY_ICE, KIRBY_ABILITY_ICE, KIRBY_ABILITY_ICE,
KIRBY_ABILITY_CUTTER, KIRBY_ABILITY_CUTTER, KIRBY_ABILITY_CUTTER,
KIRBY_ABILITY_BEAM, KIRBY_ABILITY_BEAM, KIRBY_ABILITY_BEAM,
KIRBY_ABILITY_SWORD, KIRBY_ABILITY_SWORD, KIRBY_ABILITY_SWORD,
KIRBY_ABILITY_CUTTER, KIRBY_ABILITY_CUTTER, KIRBY_ABILITY_CUTTER,
KIRBY_ABILITY_CUPID, KIRBY_ABILITY_CUPID, KIRBY_ABILITY_CUPID, KIRBY_ABILITY_CUPID,
KIRBY_ABILITY_MISSILE, KIRBY_ABILITY_MISSILE, KIRBY_ABILITY_MISSILE,
KIRBY_ABILITY_BURNING, KIRBY_ABILITY_BURNING, KIRBY_ABILITY_BURNING,
KIRBY_ABILITY_PARASOL, KIRBY_ABILITY_PARASOL, KIRBY_ABILITY_PARASOL,
KIRBY_ABILITY_WHEEL, KIRBY_ABILITY_WHEEL, KIRBY_ABILITY_WHEEL,
KIRBY_ABILITY_PARASOL, KIRBY_ABILITY_PARASOL, KIRBY_ABILITY_PARASOL, KIRBY_ABILITY_PARASOL,
KIRBY_ABILITY_BOMB, KIRBY_ABILITY_BOMB, KIRBY_ABILITY_BOMB,
KIRBY_ABILITY_LASER, KIRBY_ABILITY_LASER, KIRBY_ABILITY_LASER,
KIRBY_ABILITY_SPARK, KIRBY_ABILITY_SPARK, KIRBY_ABILITY_SPARK,
KIRBY_ABILITY_HAMMER, KIRBY_ABILITY_HAMMER,
KIRBY_ABILITY_SMASH,
KIRBY_ABILITY_TORNADO, KIRBY_ABILITY_TORNADO, KIRBY_ABILITY_TORNADO,
KIRBY_ABILITY_FIGHTER, KIRBY_ABILITY_FIGHTER, KIRBY_ABILITY_FIGHTER,
KIRBY_ABILITY_UFO,
KIRBY_ABILITY_STONE, KIRBY_ABILITY_STONE,
KIRBY_ABILITY_THROW,
KIRBY_ABILITY_COOK,
KIRBY_ABILITY_MAGIC,
KIRBY_ABILITY_CRASH,
};
const u16 gUnk_082DE074[][2] = {
{ 0x12C, 0x144 },
{ 0x2BC, 0x2C6 },
{ 0x190, 0x1A1 },
{ 0x320, 0x336 },
{ 0xC8, 0xDB },
{ 0x1F4, 0x204 },
{ 0x258, 0x2E2 },
{ 0x72, 0x81 },
};
struct Kirby *sub_0800FE50(struct ObjectBase *objBase, s16 *a2) {
u16 i;
@ -157,3 +366,435 @@ void sub_08010294(struct Unk_02038590 *a1) {
}
}
}
bool32 sub_080103BC(struct Unk_02038590 *a1) {
u16 i;
bool32 r7;
s16 stack;
if (!(a1->flags & 4))
return (a1->flags >> 4) & 1;
for (i = 0; i < 0x10; ++i) {
if (gUnk_0835105C[i] == a1->unk14->currentRoom)
break;
}
if (i < 0x10)
return FALSE;
if (a1->flags & 0x10) {
r7 = FALSE;
if (!a1->unk44
|| a1->unk14->currentRoom != a1->unk44->base.base.base.roomId) {
r7 = TRUE;
} else {
s16 dx = a1->unk40->base.base.base.x >> 8 > a1->unk44->base.base.base.x >> 8
? (a1->unk40->base.base.base.x >> 8) - (a1->unk44->base.base.base.x >> 8)
: (a1->unk44->base.base.base.x >> 8) - (a1->unk40->base.base.base.x >> 8);
s16 dy = a1->unk40->base.base.base.y >> 8 > a1->unk44->base.base.base.y >> 8
? (a1->unk40->base.base.base.y >> 8) - (a1->unk44->base.base.base.y >> 8)
: (a1->unk44->base.base.base.y >> 8) - (a1->unk40->base.base.base.y >> 8);
s16 max = dy < dx ? dx : dy;
if (max < 0x50) {
if (a1->unkA2 < 0x12C0) a1->unkA2 -= max - 0x50;
if (a1->unkA2 > 0x12C0) a1->unkA2 = 0x12C0;
} else {
if (a1->unkA2 > 0x10)
a1->unkA2 -= 0x10;
else
a1->unkA2 = 0;
}
if (!a1->unkA2)
r7 = TRUE;
if (a1->unk40->base.base.base.xspeed == 0
&& a1->unk40->base.base.base.yspeed == 0)
++a1->unkA4;
else
a1->unkA4 = 0;
if (a1->unkA4 > 600)
r7 = TRUE;
}
if (r7) {
a1->flags &= ~0x10;
a1->unk44 = NULL;
a1->unkA2 = 0;
a1->unkA4 = 0;
}
return (a1->flags >> 4) & 1;
} else {
struct Kirby *kirby = sub_0800FE50(&a1->unk40->base.base.base, &stack);
if (kirby && stack < 0x50) {
if (a1->unkA2 < 0x12C0) a1->unkA2 -= stack - 0x50;
if (a1->unkA2 > 0x12C0) a1->unkA2 = 0x12C0;
} else {
if (a1->unkA2 > 0x10)
a1->unkA2 -= 0x10;
else
a1->unkA2 = 0;
}
if (a1->unkA2 > 0xB40 && kirby) {
a1->flags |= 0x10;
a1->unk44 = kirby;
a1->unkA4 = 0;
}
return (a1->flags >> 4) & 1;
}
}
// https://decomp.me/scratch/Q0OQa
struct Object2 *sub_08010590(struct Unk_02038590 *a1, s32 a2, s32 a3) {
s32 dx, dy;
struct Object2 **r7 = sub_08039490(&a1->unk40->base.base.base);
struct Object2 *sp = NULL;
s32 x = a1->unk40->base.base.base.x;
s32 y = a1->unk40->base.base.base.y;
for (; *r7; ++r7) {
struct Object2 *r3 = *r7;
struct Object2 *r5 = *r7;
if (r3->base.flags & 0x10000000 || !(r3->base.flags & 0x8000)) {
if (ObjType0To37(r3) || ObjType38To52(r3) || ObjType43To52(r3) || ObjType53To5C(r3) || r3->type == OBJ_EMPTY_5D) {
switch (r3->type) {
case OBJ_JACK:
case OBJ_COOKIN:
case OBJ_MINNY:
case OBJ_PRANK:
case OBJ_MIRRA:
continue;
case OBJ_MR_FROSTY:
case OBJ_BONKERS:
case OBJ_PHAN_PHAN:
case OBJ_BATAFIRE:
case OBJ_BOX_BOXER:
case OBJ_BOXY:
case OBJ_MASTER_HAND:
case OBJ_BOMBAR:
if (r5->unk80 <= 0)
continue;
break;
default:
case OBJ_BIG_WADDLE_DEE:
case OBJ_WADDLE_DOO:
case OBJ_FLAMER:
case OBJ_HOT_HEAD:
case OBJ_LASER_BALL:
case OBJ_PENGY:
case OBJ_ROCKY:
case OBJ_SIR_KIBBLE:
case OBJ_SPARKY:
case OBJ_SWORD_KNIGHT:
case OBJ_UFO:
case OBJ_TWISTER:
case OBJ_WHEELIE:
case OBJ_NODDY:
case OBJ_GOLEM_1:
case OBJ_GOLEM_2:
case OBJ_GOLEM_3:
case OBJ_FOLEY_1:
case OBJ_SHOOTY:
case OBJ_SCARFY_FALLING:
case OBJ_BOXIN:
case OBJ_BOMBER:
case OBJ_HEAVY_KNIGHT:
case OBJ_GIANT_ROCKY:
case OBJ_METAL_GUARDIAN:
case OBJ_EMPTY_2C:
case OBJ_BATTY:
case OBJ_FOLEY_2:
case OBJ_BANG_BANG:
case OBJ_DARK_MIND_BOMB:
case OBJ_EMPTY_31:
case OBJ_DROPPY:
case OBJ_SHOTZO_1:
case OBJ_SHADOW_KIRBY:
case OBJ_WADDLE_DEE_2:
break;
}
} else {
if (ObjType5ETo6C(r3))
continue;
if (ObjType6Dto9A(r3)) {
#ifndef NONMATCHING
asm("":::"memory");
#endif
if (r3->type != OBJ_CANNON_FUSE && r3->type != OBJ_STAR_PLATFORM)
continue;
} else {
#ifndef NONMATCHING
asm("":::"memory");
#endif
if (r3->type != OBJ_ABILITY_STAR_1) {
if (r3->type == OBJ_ABILITY_STAR_2)
continue;
} else {
if (r3->base.parent == a1->unk40) {
if (((struct Kirby *)r3->base.parent)->ability != KIRBY_ABILITY_NORMAL)
continue;
if (r3->base.counter > 60)
goto label; // TODO
continue;
} else {
if (r3->base.counter <= 120)
continue;
}
}
}
}
label:
dx = x > r3->base.x ? x - r3->base.x : r3->base.x - x;
dy = y > r3->base.y ? y - r3->base.y : r3->base.y - y;
if (ObjType38To52(r5)) {
dx >>= 2;
dy >>= 1;
if (a2 >= dx && a3 >= dy)
sp = r5;
} else {
if (a2 >= dx && a3 >= dy) {
struct Unk_02038590_4C *r6 = NULL;
bool32 b = FALSE;
u16 i;
for (i = 0; i < 4; ++i) {
if (a1->unk4C[i].unk4 == r3) {
b = TRUE;
if (a1->unk4C[i].unk0)
break;
} else {
if (!a1->unk4C[i].unk4)
r6 = &a1->unk4C[i];
}
}
if (i == 4) {
if (!b && r6) {
r6->unk0 = 0;
r6->unk4 = r3;
r6->unkA = r3->unk80;
r6->unk8 = (Rand16() & 0xFF) + 0x12C;
}
return r3;
}
}
}
}
}
return sp;
}
bool32 sub_08010818(struct Unk_02038590 *a1, struct Object2 *obj2) {
s16 var;
switch (a1->unkDC) {
case 7:
case 8:
case 0xA:
return TRUE;
}
if (a1->unk40->base.base.base.xspeed) {
if (a1->unk40->base.base.base.flags & 1) {
if (a1->unk40->base.base.base.x <= obj2->base.x)
return FALSE;
} else {
if (a1->unk40->base.base.base.x >= obj2->base.x)
return FALSE;
}
var = (a1->unk40->base.base.base.y - obj2->base.y) >> 8;
if (var + 7 >= 0 && var + 7 <= 0x1E) {
if (a1->unkDC != 7) {
a1->unkDE = (Rand16() & 1) + 3;
a1->unk0[3] = sub_080160B8;
}
return TRUE;
}
}
return FALSE;
}
void sub_080108B8(struct Unk_02038590 *a1) {
u32 ability = a1->unk40->ability;
if (ability == KIRBY_ABILITY_UFO) {
if (a1->unk40->base.base.base.unk58 & 2)
gUnk_082DDF5C[KIRBY_ABILITY_UFO](a1);
else
gUnk_082DDEF0[KIRBY_ABILITY_UFO](a1);
} else if (a1->unk40->base.base.base.flags & 0x40) {
sub_08010944(a1);
} else if (a1->unk40->base.base.base.flags & 0x80) {
sub_08010A34(a1);
} else {
if (a1->unk40->base.base.base.unk58 & 2)
gUnk_082DDF5C[ability](a1);
else
gUnk_082DDEF0[ability](a1);
}
}
static inline bool32 IsOneOfTheCurrentRooms(u16 roomId) {
u16 i;
for (i = 0; i < gUnk_0203AD30; ++i) {
if (roomId == gCurLevelInfo[i].currentRoom)
return TRUE;
}
return FALSE;
}
void sub_08010944(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x3000, 0x1800);
if (a1->unk48) {
if (!IsOneOfTheCurrentRooms(a1->unk14->currentRoom))
return;
if (~(a1->unk48->base.unk5C & ~7) & 0x40 && (a1->unk48->base.unk5C & 7) < 3) {
if (a1->unkDC != 0xC) {
a1->unkDE = a1->unk40->base.base.base.x >= a1->unk48->base.x;
a1->unk0[3] = sub_08017274;
}
} else {
u32 ability = a1->unk40->ability;
bool32 b = FALSE;
if (ability < KIRBY_ABILITY_COUNT) {
// TODO: better match
const u32 *table = gUnk_082DDFC8;
const u32 *r2 = &table[ability];
u32 inter = a1->unk48->base.unk5C & ~7;
u32 var = 0x3FFFF8 & ~inter;
if (var & *r2
&& (*r2 & 7) >= (a1->unk48->base.unk5C & 7))
b = TRUE;
}
if (b)
a1->unk0[3] = sub_0801519C;
}
}
}
void sub_08010A34(struct Unk_02038590 *a1) {
if ((a1->unk40->unkDD & 0x1F) != KIRBY_ABILITY_NORMAL
&& (a1->unk40->unkDD & 0x1F) < KIRBY_ABILITY_COUNT
&& (Rand16() & 0xFF) < 0xC0) {
if (a1->unkDC != 0xF)
a1->unk0[3] = sub_080175D0;
} else {
a1->unk48 = sub_08010590(a1, 0x3000, 0x1800);
if (a1->unk48 && a1->unkDC != 0xD) {
a1->unkDE = a1->unk40->base.base.base.x >= a1->unk48->base.x;
a1->unk0[3] = sub_0801737C;
}
}
}
void sub_08010AC8(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x3000, 0x1800);
if (a1->unk48) {
if (IsOneOfTheCurrentRooms(a1->unk14->currentRoom)) {
if (~(a1->unk48->base.unk5C & ~7) & 0x20 && (a1->unk48->base.unk5C & 7) < 4) {
bool32 b = a1->unk40->base.base.base.x >= a1->unk48->base.x;
if (a1->unkDC != 0xE) {
a1->unkDE = b;
a1->unkE0 = 0;
a1->unk0[3] = sub_0801745C;
}
return;
}
}
sub_08010818(a1, a1->unk48);
}
}
void sub_08010B80(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x3000, 0x1000);
if (a1->unk48) {
if (IsOneOfTheCurrentRooms(a1->unk14->currentRoom)) {
if (~(a1->unk48->base.unk5C & ~7) & 0x100 && (a1->unk48->base.unk5C & 7) < 4) {
bool32 b = a1->unk40->base.base.base.x >= a1->unk48->base.x;
if (a1->unkDC != 0x10) {
a1->unkDE = b;
a1->unk0[3] = sub_08017684;
}
return;
}
}
sub_08010818(a1, a1->unk48);
}
}
void sub_08010C34(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x3000, 0x1000);
if (a1->unk48) {
if (IsOneOfTheCurrentRooms(a1->unk14->currentRoom)) {
if (~(a1->unk48->base.unk5C & ~7) & 0x200 && (a1->unk48->base.unk5C & 7) < 4) {
bool32 b = a1->unk40->base.base.base.x >= a1->unk48->base.x;
if (a1->unkDC != 0x10) {
a1->unkDE = b;
a1->unk0[3] = sub_08017684;
}
return;
}
}
sub_08010818(a1, a1->unk48);
}
}
void sub_08010CE8(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x5000, 0x1000);
if (a1->unk48) {
if (IsOneOfTheCurrentRooms(a1->unk14->currentRoom)) {
if (~(a1->unk48->base.unk5C & ~7) & 0x1100 && (a1->unk48->base.unk5C & 7) < 4) {
bool32 r2 = a1->unk40->base.base.base.x >= a1->unk48->base.x;
bool16 b = r2;
s16 r0 = (a1->unk40->base.base.base.x - a1->unk48->base.x) >> 0xC;
u16 r5 = abs(r0);
u32 r8 = a1->unk14->roomWidth >> 4;
s16 r7 = b == TRUE ? -1 : 1;
u16 r4 = r7 + (a1->unk40->base.base.base.x >> 12);
u16 sb = a1->unk40->base.base.base.y >> 12;
for (; r5-- && r4 < r8; r4 += r7) {
if (!(gUnk_082D88B8[sub_080024F0(a1->unk14, r4, sb)] & 1))
return;
}
if (a1->unkDC != 0x10) {
a1->unkDE = b;
a1->unk0[3] = sub_08017684;
}
return;
}
}
sub_08010818(a1, a1->unk48);
}
}
void sub_08010E3C(struct Unk_02038590 *a1) {
a1->unk48 = sub_08010590(a1, 0x5000, 0x1000);
if (a1->unk48) {
if (IsOneOfTheCurrentRooms(a1->unk14->currentRoom)) {
if (~(a1->unk48->base.unk5C & ~7) & 0x40 && (a1->unk48->base.unk5C & 7) < 4) {
bool32 r2 = a1->unk40->base.base.base.x >= a1->unk48->base.x;
bool16 b = r2;
s16 r0 = (a1->unk40->base.base.base.x - a1->unk48->base.x) >> 0xC;
u16 r5 = abs(r0);
u32 r8 = a1->unk14->roomWidth >> 4;
s16 r7 = b == TRUE ? -1 : 1;
u16 r4 = r7 + (a1->unk40->base.base.base.x >> 12);
u16 sb = a1->unk40->base.base.base.y >> 12;
for (; r5-- && r4 < r8; r4 += r7) {
if (!(gUnk_082D88B8[sub_080024F0(a1->unk14, r4, sb)] & 1))
return;
}
if (a1->unkDC != 0x10) {
a1->unkDE = b;
a1->unk0[3] = sub_08017684;
}
return;
}
}
sub_08010818(a1, a1->unk48);
}
}

View File

@ -600,8 +600,24 @@ static void sub_0809AF38(struct Object2 *r4, struct ObjectBase *r5) {
if (!r7)
PlaySfx(&r4->base, 380);
if (r4->type == OBJ_KING_GOLEM || r4->type == OBJ_MEGA_TITAN || r4->type == OBJ_TITAN_HEAD
|| r4->type == OBJ_MOLEY || r4->type == OBJ_GOBBLER || r4->type > OBJ_CRAZY_HAND_2
|| r4->type > OBJ_DARK_MIND_FORM_1 || r4->type == OBJ_WIZ) { // ... some weird macro expansion
|| r4->type == OBJ_MOLEY || r4->type == OBJ_GOBBLER
|| !(ObjType0To37(r4) || r4->type == OBJ_MR_FROSTY || r4->type == OBJ_BONKERS || r4->type == OBJ_PHAN_PHAN
|| r4->type == OBJ_BATAFIRE || r4->type == OBJ_BOX_BOXER || r4->type == OBJ_BOXY
|| r4->type == OBJ_MASTER_HAND || r4->type == OBJ_BOMBAR || r4->type == OBJ_EMPTY_40
|| r4->type == OBJ_EMPTY_41 || r4->type == OBJ_EMPTY_42 || r4->type == OBJ_EMPTY_43
|| r4->type == OBJ_EMPTY_44 || r4->type == OBJ_KRACKO || r4->type == OBJ_KING_GOLEM
|| r4->type == OBJ_CRAZY_HAND_1 || r4->type == OBJ_GOBBLER || r4->type == OBJ_WIZ
|| r4->type == OBJ_MOLEY || r4->type == OBJ_MEGA_TITAN || r4->type == OBJ_TITAN_HEAD
|| r4->type == OBJ_CRAZY_HAND_2)
|| !(ObjType0To37(r4) || r4->type == OBJ_MR_FROSTY || r4->type == OBJ_BONKERS || r4->type == OBJ_PHAN_PHAN
|| r4->type == OBJ_BATAFIRE || r4->type == OBJ_BOX_BOXER || r4->type == OBJ_BOXY
|| r4->type == OBJ_MASTER_HAND || r4->type == OBJ_BOMBAR || r4->type == OBJ_EMPTY_40
|| r4->type == OBJ_EMPTY_41 || r4->type == OBJ_EMPTY_42 || r4->type == OBJ_EMPTY_43
|| r4->type == OBJ_EMPTY_44 || r4->type == OBJ_KRACKO || r4->type == OBJ_KING_GOLEM
|| r4->type == OBJ_CRAZY_HAND_1 || r4->type == OBJ_GOBBLER || r4->type == OBJ_WIZ
|| r4->type == OBJ_MOLEY || r4->type == OBJ_MEGA_TITAN || r4->type == OBJ_TITAN_HEAD
|| r4->type == OBJ_CRAZY_HAND_2 || r4->type == OBJ_DARK_META_KNIGHT || r4->type == OBJ_DARK_MIND_FORM_1)
|| r4->type == OBJ_WIZ) {
gUnk_08351648[r4->type].unk10(r4);
} else {
r4->base.flags |= 0x200;