Added item_entity struct and related stuff. More matching functions

This commit is contained in:
Jdog 2020-08-11 18:59:46 -07:00
parent 447e6261e1
commit 224aa7dfdd
7 changed files with 96 additions and 22 deletions

View File

@ -48,6 +48,62 @@ typedef struct {
/* 0x168 */ s32 unk_168; /* 0x168 */ s32 unk_168;
} game_status; } game_status;
typedef enum eItemEntityState {
CollisionWithPlayer=3,
FellBelowWorld=2,
Init=0,
Initialized=1
} eItemEntityState;
typedef struct {
/* 0x00 */ f32 verticalVelocity;
/* 0x04 */ f32 gravity; /* 2 = normal, 1 = low gravity, higher values never 'settle' */
/* 0x08 */ f32 field_0x8;
/* 0x0C */ f32 constVelocity; /* ? */
/* 0x10 */ f32 velx;
/* 0x14 */ f32 velz;
/* 0x18 */ f32 moveAngle;
/* 0x1C */ f32 field_0x1c;
/* 0x20 */ f32 field_0x20;
} item_entity_physics_data;
typedef struct {
/* 0x00 */ s32 flags;
/* 0x04 */ s16 boundVar; /* see make_item_entity */
/* 0x06 */ s16 field_0x6;
/* 0x08 */ f32 position[3];
/* 0x14 */ struct item_entity_physics_data* physicsData;
/* 0x24 */ s16 itemID; /* into item table, also worldIconID */
/* 0x1A */ eItemEntityState state;
/* 0x1B */ s8 type;
/* 0x1C */ s8 pickupDelay; /* num frames before item can be picked up */
/* 0x1D */ s8 field_0x1d;
/* 0x1E */ s16 wsFaceAngle; /* < 0 means none */
/* 0x20 */ s16 shadowIndex;
/* 0x22 */ char unk_22[2];
/* 0x24 */ u32* readPos;
/* 0x28 */ u32 savedReadPos;
/* 0x2C */ s8 field_0x2c;
/* 0x2D */ s8 field_0x2d;
/* 0x2E */ s8 unkCounter;
/* 0x2F */ s8 field_0x2f;
/* 0x30 */ f32 scale;
/* 0x34 */ s16 field_0x34;
/* 0x36 */ s16 field_0x36;
/* 0x38 */ s16 field_0x38;
/* 0x3A */ char unk_3a[2];
/* 0x3C */ s32 field_0x3c; /* coin related? timer? state? */
/* 0x40 */ s32 field_0x40; /* coin sound related? */
/* 0x44 */ char unk_44[4];
/* 0x48 */ s32 field_0x48; /* coin sound related? */
/* 0x4C */ s32 field_0x4c;
/* 0x50 */ s32 field_0x50;
/* 0x54 */ char unk_54[2];
/* 0x56 */ s16 field_0x56;
/* 0x58 */ char unk_58[2];
/* 0x5A */ s16 field_0x5a;
} item_entity;
typedef struct { typedef struct {
/* 0x00 */ s32 nameString; /* 0x00 */ s32 nameString;
/* 0x04 */ s16 iconID; /* 0x04 */ s16 iconID;

View File

@ -13,4 +13,6 @@ f32 get_float_variable(script_context* script, s32 pos);
f32 sin_deg(f32 x); f32 sin_deg(f32 x);
f32 cos_deg(f32 x); f32 cos_deg(f32 x);
s32 play_sound_at_position(s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ);
#endif #endif

View File

@ -13,12 +13,15 @@ extern s16* D_80151328;
extern s16 D_8010CD10; extern s16 D_8010CD10;
extern s16 D_8010CD12; extern s16 D_8010CD12;
extern u16 mapTransitionAlpha; extern u16 gMapTransitionAlpha;
extern u16 D_800A0942; extern u16 D_800A0942;
extern s16 D_800A0944; extern s16 D_800A0944;
extern s16 D_80151308; extern s16 D_80151308;
extern s16 D_8010F304[]; // Key Items
extern s16 D_8010F444[]; // Items
extern s16 gCurrentDoorSoundsSet; extern s16 gCurrentDoorSoundsSet;

View File

@ -25,7 +25,7 @@ void func_800360FC(void) {
void func_80036130(void) { void func_80036130(void) {
game_status* gameStatus = *gGameStatusPtr; game_status* gameStatus = *gGameStatusPtr;
mapTransitionAlpha = 0x00; gMapTransitionAlpha = 0x00;
D_800A0942 = 0x14; D_800A0942 = 0x14;
D_800A0944 = 0x00; D_800A0944 = 0x00;
@ -52,7 +52,7 @@ s32 func_800363FC(void) {
s32 func_80036430(void) { s32 func_80036430(void) {
player_status* pPlayerStatus = &gPlayerStatus; player_status* pPlayerStatus = &gPlayerStatus;
mapTransitionAlpha = 0xFF; gMapTransitionAlpha = 0xFF;
D_800A0942 = 0x14; D_800A0942 = 0x14;
D_800A0944 = 0x01; D_800A0944 = 0x01;

View File

@ -44,7 +44,7 @@ INCLUDE_ASM(code_de740_len_23f0, play_sound_at_player);
INCLUDE_ASM(code_de740_len_23f0, play_sound_at_npc); INCLUDE_ASM(code_de740_len_23f0, play_sound_at_npc);
INCLUDE_ASM(code_de740_len_23f0, play_sound_at_position); s32 INCLUDE_ASM(code_de740_len_23f0, play_sound_at_position, s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ);
INCLUDE_ASM(code_de740_len_23f0, func_80149E04); INCLUDE_ASM(code_de740_len_23f0, func_80149E04);

View File

@ -46,8 +46,6 @@ s32 func_802D617C(script_context* script, s32 initialCall) {
return 2; return 2;
} }
INCLUDE_ASM(code_fa4c0_len_3bf0, PlaySoundAt);
/*
s32 PlaySoundAt(script_context* script, s32 initialCall) { s32 PlaySoundAt(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos; s32* ptrReadPos = script->ptrReadPos;
s32 soundID = get_variable(script, *ptrReadPos++); s32 soundID = get_variable(script, *ptrReadPos++);
@ -56,10 +54,9 @@ s32 PlaySoundAt(script_context* script, s32 initialCall) {
s32 y = get_variable(script, *ptrReadPos++); s32 y = get_variable(script, *ptrReadPos++);
s32 z = get_variable(script, *ptrReadPos++); s32 z = get_variable(script, *ptrReadPos++);
play_sound_at_position(soundID, value2, x, y, z); play_sound_at_position(soundID, value2, (f32) x, (f32) y, (f32) z);
return 2; return 2;
} }
*/
s32 StopSound(script_context* script, s32 initialCall) { s32 StopSound(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos; s32* ptrReadPos = script->ptrReadPos;
@ -91,9 +88,24 @@ s32 func_802D6340(script_context* script, s32 initialCall) {
INCLUDE_ASM(code_fa4c0_len_3bf0, PlaySoundAtF); INCLUDE_ASM(code_fa4c0_len_3bf0, PlaySoundAtF);
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveKeyItemAt); s32 RemoveKeyItemAt(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos;
s32 index = get_variable(script, *ptrReadPos++);
s16* ptrTemp = D_8010F304;
ptrTemp[index] = 0;
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveItemAt); return 2;
}
s32 RemoveItemAt(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos;
s32 index = get_variable(script, *ptrReadPos++);
s16* ptrTemp = D_8010F444;
ptrTemp[index] = 0;
sort_items();
return 2;
}
INCLUDE_ASM(code_fa4c0_len_3bf0, AddKeyItem); INCLUDE_ASM(code_fa4c0_len_3bf0, AddKeyItem);
@ -142,25 +154,24 @@ s32 AddBadge(script_context* script, s32 initialCall) {
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveBadge); INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveBadge);
INCLUDE_ASM(code_fa4c0_len_3bf0, SetItemPos);
/*
s32 SetItemPos(script_context* script, s32 initialCall) { s32 SetItemPos(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos; s32* ptrReadPos = script->ptrReadPos;
s32 itemEntityIndex, value2, value3, value4; item_entity* ptrItemEntity;
s32* ptrItemEntity; s32 itemEntityIndex;
s32 x, y, z;
itemEntityIndex = get_variable(script, *ptrReadPos++); itemEntityIndex = get_variable(script, *ptrReadPos++);
value2 = get_variable(script, *ptrReadPos++); x = get_variable(script, *ptrReadPos++);
value3 = get_variable(script, *ptrReadPos++); y = get_variable(script, *ptrReadPos++);
value4 = get_variable(script, *ptrReadPos++); z = get_variable(script, *ptrReadPos++);
ptrItemEntity = get_item_entity(itemEntityIndex); ptrItemEntity = get_item_entity(itemEntityIndex);
*(ptrItemEntity + 0x08) = (f64) value2; ptrItemEntity->position[0] = (f32) x;
*(ptrItemEntity + 0x0C) = (f64) value3; ptrItemEntity->position[1] = (f32) y;
*(ptrItemEntity + 0x10) = (f64) value4; ptrItemEntity->position[2] = (f32) z;
return 2; return 2;
} }
*/
INCLUDE_ASM(code_fa4c0_len_3bf0, SetItemFlags); INCLUDE_ASM(code_fa4c0_len_3bf0, SetItemFlags);

View File

@ -4,7 +4,7 @@ gPlayerData = 0x8010F290;
gPlayerStatus = 0x8010EFC8; gPlayerStatus = 0x8010EFC8;
gItemTable = 0x800878E0; gItemTable = 0x800878E0;
mapTransitionAlpha = 0x800A0940; gMapTransitionAlpha = 0x800A0940;
D_800A0942 = 0x800A0942; D_800A0942 = 0x800A0942;
D_800A0944 = 0x800A0944; D_800A0944 = 0x800A0944;
@ -29,6 +29,8 @@ D_8009A5D8 = 0x8009A5D8;
D_8009A650 = 0x8009A650; D_8009A650 = 0x8009A650;
D_800DC500 = 0x800DC500; D_800DC500 = 0x800DC500;
D_8010F6D0 = 0x8010F6D0; D_8010F6D0 = 0x8010F6D0;
D_8010F304 = 0x8010F304;
D_8010F444 = 0x8010F444;
D_802C3000 = 0x802C3000; D_802C3000 = 0x802C3000;
D_802DBD40 = 0x802DBD40; D_802DBD40 = 0x802DBD40;
D_802E0D90 = 0x802E0D90; D_802E0D90 = 0x802E0D90;