MAD quick matches (#1287)

small quick wins
This commit is contained in:
Luciano Ciccariello 2024-06-08 23:02:00 +01:00 committed by GitHub
parent a9f85a4f85
commit 3c5d5a4c91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 126 additions and 66 deletions

View File

@ -75,9 +75,7 @@ segments:
- [0xD874, .rodata, entity_relic_orb]
- [0xD8AC, rodata]
- [0xD8C8, c]
- [0xE964, c, random]
- [0xE994, c, update]
- [0xEC90, c, CollectGold]
- [0xE964, c, st_update]
- [0xEDB8, c, collision]
- [0x10544, c, create_entity]
- [0x110A8, c, e_red_door]

View File

@ -57,8 +57,6 @@ MoveEntity = 0x801920F0;
FallEntity = 0x80192120;
InitializeEntity = 0x80192CAC;
EntityDummy = 0x80192DA8;
CollectHeart = 0x8019362C;
CollectGold = 0x801936E0;
EntityPrizeDrop = 0x801939E0;
EntityExplosion = 0x80194218;
EntityEquipItemDrop = 0x801943EC;
@ -91,3 +89,4 @@ g_ESoulStealOrbAnim = 0x801810D8;
g_ESoulStealOrbSprt = 0x80181078;
g_ExplosionYVelocities = 0x80180E18;
g_ExplosionAnimations = 0x80180EC4;
UpdateStageEntities = 0x8018EC90;

View File

@ -1,4 +1,4 @@
g_CastleFlags = 0x8003BDEC;
g_CastleFlags = 0x8003BDE8;
g_api = 0x8003C670;
g_Player = 0x80072684;
g_Camera = 0x80072B3C;

View File

@ -14,11 +14,7 @@ void EntityRoomForeground(Entity*);
void EntityStageNamePopup(Entity*);
void EntityEquipItemDrop(Entity*);
void EntityRelicOrb(Entity*);
#ifndef MAD_H
void EntityHeartDrop(Entity*);
#else
void EntityHeartDrop(Entity* entity, u32 arg1);
#endif
void EntityEnemyBlood(Entity*);
void EntityMessageBox(Entity*);
void EntityDummy(Entity*);

View File

@ -469,7 +469,19 @@ void func_801934D0(u16 arg0) {
}
}
INCLUDE_ASM("asm/us/st/mad/nonmatchings/11D3C", CollectHeart);
void CollectHeart(u16 arg0) {
HeartCounts counts;
HeartCounts unknown;
counts = D_8018D830;
unknown = D_8018D834;
g_api.PlaySfx(0x670);
g_Status.hearts += counts.count[arg0];
if (g_Status.hearts > g_Status.heartsMax) {
g_Status.hearts = g_Status.heartsMax;
}
DestroyEntity(g_CurrentEntity);
}
#include "../collect_gold.h"

View File

@ -1,54 +1,36 @@
#include "mad.h"
// v1 -> a0 reg swap
// branching
// signature conflict
// DECOMP_ME_WIP EntityHeartDrop https://decomp.me/scratch/h3CVU
#ifndef NON_EQUIVALENT
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", EntityHeartDrop);
#else
void EntityHeartDrop(Entity* entity, u32 arg1) {
u16 temp_v0_2;
u16 temp_v1;
u16 var_v1;
u32 temp_a0;
void EntityHeartDrop(Entity* self) {
u16 index;
PfnEntityUpdate update;
if (entity->step == 0) {
temp_v0_2 = entity->params;
temp_a0 = temp_v0_2 & 0xFFFF;
var_v1 = temp_v0_2;
entity->ext.generic.unkB4 = var_v1;
if ((D_8003BEE8[temp_a0 >> 3] >> (var_v1 & 7)) & 1) {
DestroyEntity(entity);
if (self->step == 0) {
index = self->ext.heartDrop.unkB4 = self->params;
if ((g_CastleFlags[(index >> 3) + 0x100] >> (index & 7)) & 1) {
DestroyEntity(self);
return;
}
var_v1 = D_80180F5C[temp_a0];
if (var_v1 < 0x80) {
entity->ext.generic.uunkB8.unkFuncB8 = EntityPrizeDrop;
index = D_80180F5C[index];
if (index < 128) {
self->ext.heartDrop.update = EntityPrizeDrop;
} else {
entity->ext.generic.uunkB8.unkFuncB8 = EntityEquipItemDrop;
var_v1 -= 0x80;
self->ext.heartDrop.update = EntityEquipItemDrop;
index -= 128;
}
entity->params = var_v1 + 0x8000;
return;
}
temp_v1 = entity->ext.generic.unkB4;
if (entity->step < 5) {
arg1 = temp_v1 / 8;
if (entity->unk48 != 0) {
D_8003BEE8[arg1] |= (1 << (temp_v1 & 7));
entity->step = 5;
self->params = index + 0x8000;
} else {
index = self->ext.generic.unkB4;
if (self->step < 5) {
if (self->hitFlags) {
g_CastleFlags[(index >> 3) + 0x100] |= 1 << (index & 7);
self->step = 5;
}
}
}
entity->ext.generic.uunkB8.unkFuncB8(entity, arg1, entity);
update = self->ext.heartDrop.update;
update(self);
}
#endif
#include "../check_coll_offsets.h"
@ -289,7 +271,46 @@ void func_801965E4(Entity* entity) {
}
}
INCLUDE_ASM("asm/us/st/mad/nonmatchings/15520", func_801966B0);
void func_801966B0(u16* sensors) {
switch (g_CurrentEntity->step_s) {
case 0:
g_CurrentEntity->animCurFrame = 0;
g_CurrentEntity->hitboxState = 0;
g_CurrentEntity->zPriority -= 0x10;
g_CurrentEntity->drawFlags |= DRAW_HIDE;
g_CurrentEntity->unk6C = 0;
g_CurrentEntity->step_s++;
break;
case 1:
if (func_80192190(sensors) & 1) {
g_CurrentEntity->animCurFrame = 1;
g_CurrentEntity->step_s++;
}
break;
case 2:
g_CurrentEntity->unk6C += 2;
if (g_CurrentEntity->unk6C == 0xC0) {
g_CurrentEntity->drawFlags = 0;
g_CurrentEntity->drawMode = DRAW_DEFAULT;
g_CurrentEntity->hitEffect = g_CurrentEntity->palette;
g_CurrentEntity->step_s++;
D_80199DE8 = 64;
}
break;
case 3:
if (D_80199DE8 & 1) {
g_CurrentEntity->palette = g_CurrentEntity->hitEffect;
} else {
g_CurrentEntity->palette = PAL_OVL(0x19F);
}
if (!--D_80199DE8) {
g_CurrentEntity->hitboxState = 3;
g_CurrentEntity->palette = g_CurrentEntity->hitEffect;
func_80192BD0(1);
}
break;
}
}
void func_8019686C(u16 entityId, Entity* src, Entity* dst) {
DestroyEntity(dst);
@ -311,8 +332,6 @@ void func_8019686C(u16 entityId, Entity* src, Entity* dst) {
}
}
// DECOMP_ME_WIP func_80196934 https://decomp.me/scratch/fA367 TODO: 0x80 entity
// member unconfirmed
void func_80196934(void) {
Entity* entity;
s16 temp_s3;

View File

@ -1,3 +0,0 @@
#include "mad.h"
INCLUDE_ASM("asm/us/st/mad/nonmatchings/CollectGold", func_8018EC90);

View File

@ -284,7 +284,7 @@ void HitDetection(void) {
if (miscVar1) {
miscVar1--;
miscVar3 = 1 << (miscVar1 & 7);
g_CastleFlags[(miscVar1 >> 3) + 0x11C] |= miscVar3;
g_CastleFlags[(miscVar1 >> 3) + 0x120] |= miscVar3;
}
if ((g_Status.relics[RELIC_FAERIE_SCROLL] & 2) &&
!(entFrom5C->flags & FLAG_UNK_01000000)) {
@ -492,7 +492,7 @@ void HitDetection(void) {
miscVar1--;
flaggy_flags = (1 << (miscVar1 & 7));
g_CastleFlags[(miscVar1 >> 3) +
0x13C] |= flaggy_flags;
0x140] |= flaggy_flags;
}
} else {
miscVar3 -= sp3C->rareItemDropRate;

View File

@ -32,6 +32,10 @@ typedef enum {
E_ID_15
} EntityIDs;
typedef struct {
s8 count[2];
} HeartCounts;
void CreateEntitiesToTheRight(s16);
void CreateEntitiesToTheLeft(s16);
void CreateEntitiesAbove(s16);
@ -45,9 +49,11 @@ void func_8019344C(void);
void EntityUnkId14(Entity* entity);
void EntityUnkId15(Entity* entity);
// DRA - all the exclusive global variables
extern s32 D_80096ED0_mad;
// ST/MAD
extern u16 g_InitializeData0[];
extern u16 UNK_Invincibility0[];
extern u16 g_eInitGeneric2[];
extern ObjInit2 D_8018056C[];
extern u16 D_80180D1C[];
@ -90,4 +96,9 @@ extern u8 g_ESoulStealOrbAnim[];
// *** EntitySoulStealOrb properties END ***
extern HeartCounts D_8018D830;
extern HeartCounts D_8018D834;
extern s16 D_80199DE8;
#endif

View File

@ -1,3 +0,0 @@
#include <game.h>
#include "../random.h"

34
src/st/mad/st_update.c Normal file
View File

@ -0,0 +1,34 @@
#include "mad.h"
#include "../random.h"
#include "../update.h"
void UpdateStageEntities(void) {
Entity* entity;
s16 iFramePalette;
for (entity = &g_Entities[STAGE_ENTITY_START];
entity < &g_Entities[TOTAL_ENTITY_COUNT]; entity++) {
if (!entity->pfnUpdate)
continue;
if (entity->step) {
if (D_80096ED0_mad && !(entity->flags & FLAG_UNK_10000))
continue;
if (entity->flags & 0xF) {
iFramePalette = entity->nFramesInvincibility << 1;
iFramePalette += entity->flags & 1;
entity->palette = UNK_Invincibility0[iFramePalette];
if ((--entity->flags & 0xF) == 0) {
entity->palette = entity->hitEffect;
entity->hitEffect = 0;
}
}
}
g_CurrentEntity = entity;
entity->pfnUpdate(entity);
entity->unk44 = 0;
entity->hitFlags = 0;
}
}

View File

@ -1,3 +0,0 @@
#include <game.h>
#include "../update.h"