diff --git a/README.md b/README.md index 916efb90e..c6c27e4a4 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ There are a few tricks to make the process more streamlined: ## Resources -* Project Documentation [Style Guide](https://github.com/Xeeynamo/sotn-decomp/docs/STYLE.md) +* Project Documentation [Style Guide](https://github.com/Xeeynamo/sotn-decomp/blob/master/docs/STYLE.md) * List of resource for sotn (speedrun oriented, but still very useful). * PS1’s CPU R3000 instruction [manual](https://cgi.cse.unsw.edu.au/~cs3231/doc/R3000.pdf) and [cheat sheet](https://vhouten.home.xs4all.nl/mipsel/r3000-isa.html) * [SOTN map viewer written in C](https://github.com/KernelEquinox/SotN-Editor) diff --git a/include/dra.h b/include/dra.h index 06a1b2644..44ce81d47 100644 --- a/include/dra.h +++ b/include/dra.h @@ -601,7 +601,7 @@ extern Entity D_800762D8[]; // g_EntityArray[64] extern Unkstruct8 g_CurrentRoomTileLayout; extern Entity D_8007A958[]; extern Entity D_8007D858[]; -extern u16 g_zEntityCenter; +extern MultiType g_zEntityCenter; extern s32 g_entityDestroyed[]; extern Entity D_8007EF1C; extern s32 D_8007EFDC; @@ -620,11 +620,19 @@ extern u32 D_80097364; extern s32 D_800973B4; extern POLY_GT4 D_800973B8[]; extern s32 D_800973EC; // flag to check if the menu is shown +extern s32 D_800973F8; extern s32 D_800973FC; +extern s32 D_80097400[]; +extern s32 D_8009740C[]; extern s32 D_80097410; extern s32 D_80097414; +extern s32 D_80097418; +extern s32 D_8009741C; extern s32 D_80097420; +extern s32 D_80097424; +extern s32 D_80097448; extern s32 D_8009744C; +extern s32 D_80097450; extern Pad g_pads[]; extern u16 D_80097494; // related to g_menuRelicsCursorIndex extern u16 D_80097496; @@ -739,6 +747,7 @@ extern RECT D_800ACDF0; extern Unkstruct_800ACEC6 D_800ACEC6; extern u8 D_800ACF4C[]; extern s16 D_800ACF60[]; +extern s32 D_800ACFB4; extern s32* D_800AE294; // might not really be a pointer extern s16 D_800AFDA6; extern const char* c_strEquip; @@ -905,6 +914,7 @@ extern u8 D_8013B680; extern s8 D_8013B684; extern s8 D_8013B690; extern s32 D_8013B694; +extern s32 D_8016FCC0[]; extern void (*D_8013C00C)(void); extern void (*D_80170000)(void); extern ImgSrc* g_imgUnk8013C200; @@ -1007,6 +1017,7 @@ void func_801073C0(void); void func_801092E8(s32); void SetPolyRect(POLY_GT4* poly, s32 x, s32 y, s32 width, s32 height); void func_8010D584(s16 arg0); +void func_8010DDA0(s32, s32*); void func_8010DFF0(s32, s32); void func_8010E0A8(void); void func_8010E0B8(void); diff --git a/include/sfx.h b/include/sfx.h index b36997c4d..971e01309 100644 --- a/include/sfx.h +++ b/include/sfx.h @@ -1,4 +1,4 @@ -/* +/** * File: sfx.h * Description: SOTN Sound Effects * @@ -21,10 +21,26 @@ * AL = Alucard * MA = Maria * RI = Richter + * WO = Form of Wolf + * BT = Form of Bat */ #define NA_SE_BREAK_CANDLE 0x634 #define NA_SE_SECRET_STAIRS 0x644 #define NA_SE_PL_COLLECT_HEART 0x67A #define NA_SE_BREAK_GLASS 0x68B -#define NA_SE_PL_COLLECT_GOLD 0x6A9 \ No newline at end of file +#define NA_SE_PL_COLLECT_GOLD 0x6A9 +#define NA_SE_PL_WARP 0x636 +#define NA_SE_EN_OPEN_DOOR 0x642 +#define NA_SE_EN_COG_CLICK 0x642 +#define NA_SE_SY_MOVE_MENU_CURSOR 0x67B +#define NA_SE_PL_IT_PICKUP 0x67C +#define NA_SE_PL_MP_FULL 0x67D +#define NA_SE_PL_BT_FIREBALL 0x680 +#define NA_SE_PL_MAX_HP_MP_INCREASED 0x687 +#define NA_SE_EV_CLOCK_TICK 0x6A1 +#define NA_SE_VO_AL_SOUL_STEAL 0x6F4 +#define NA_SE_VO_AL_DYING 0x6F4 +#define NA_SE_VO_AL_WHAT 0x704 +#define NA_SE_VO_AL_DARK_METAMORPHOSIS 0x705 +#define NA_SE_VO_WO_BARK 0x706 \ No newline at end of file diff --git a/src/dra/42398.c b/src/dra/42398.c index 16b270ba8..d56f0c2e5 100644 --- a/src/dra/42398.c +++ b/src/dra/42398.c @@ -839,7 +839,7 @@ s32 func_800E9B18(s32 arg0, s32 arg1) { } void GetSavePalette(u16* dst, s32 palIdx) { - const ColorCount = 16; + const s32 ColorCount = 16; s32 i; u16* src = g_saveIconPalette[0]; @@ -850,7 +850,7 @@ void GetSavePalette(u16* dst, s32 palIdx) { } void GetSaveIcon(u8* dst, s32 iconIdx) { - const IconSize = 384; + const s32 IconSize = 384; s32 i; u8* src; @@ -1544,7 +1544,48 @@ void func_800F223C(void) { INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F2288); -INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F2404); +void func_800F2404(s32 arg0) { + s32* temp; + s32* ptr; + s32 count; + + if (arg0 == 0) { + D_80097410 = 0; + D_800973F8 = 0; + D_800973FC = 0; + } + + temp = &D_80097400; + *temp = 0; + D_8003C704 = 0; + D_80097418 = 0; + D_8009741C = 0; + D_8009740C[0] = 0x80; + + if (D_80097410 != 0) { + FreePolygons(D_80097414); + } + + D_80097410 = 0; + D_80097414 = 0; + g_zEntityCenter.typeInt = 148; + count = 7; + + ptr = &D_80097400[17]; + + while (count >= 0) { + *ptr = 0; + count -= 1; + ptr -= 1; + } + + D_80097420 = 0; + D_80097424 = 0; + D_80097448 = 0; + D_8009744C = 0; + D_80097450 = 0; + func_800E346C(); +} #ifndef NON_EQUIVALENT INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F24F4); @@ -3727,7 +3768,7 @@ void func_8010E4D0(void) { func_80111CC0(); player->palette = 0x8100; - player->zPriority = g_zEntityCenter; + player->zPriority = g_zEntityCenter.typeShort; if ((u32)(D_80072F92 - 1) < 2U) { func_8010DA48(0xC7); @@ -4125,7 +4166,7 @@ void func_80113EE0(void) { *D_80072F64 = 0; D_80072F66 = 0; player->unk1E = 0; - player->zPriority = g_zEntityCenter; + player->zPriority = g_zEntityCenter.typeShort; if (g_EntityArray[UNK_ENTITY_10].objectId == 0x22) { func_8010FAF4(); } @@ -4397,7 +4438,48 @@ void func_8011A4C8(void) {} INCLUDE_ASM("asm/dra/nonmatchings/42398", func_8011A4D0); -INCLUDE_ASM("asm/dra/nonmatchings/42398", func_8011A870); +void func_8011A870(void) { + Entity* entity = g_CurrentEntity = &g_EntityArray[UNK_ENTITY_4]; + u16 objectId; + s32 i = 4; + +loop_1: // !FAKE: this should be a for loop + objectId = entity->objectId; + + if (objectId != 0) { + if (entity->step == ENTITY_STEP_0) { + if ((u32)(entity->objectId - 0xD0) < 0x10) { + entity->pfnUpdate = D_8016FCC0[objectId]; + } else { + goto label; + } + } + + if (entity->pfnUpdate != NULL) { + entity->pfnUpdate(entity); + entity = g_CurrentEntity; + if (entity->objectId != 0) { + if ((!(entity->unk34 & 0x04000000)) && + (((u32)((((u16)entity->posX.Data.high) + 0x20) & 0xFFFF) >= + 0x141) || + ((u32)((((u16)entity->posY.Data.high) + 0x10) & 0xFFFF) >= + 0x111))) { + func_80106590(entity); + goto label; + } else if (entity->unk34 & 0x100000) { + func_8010DDA0(0, &D_800ACFB4); + } + } + } + } +label: + i++; + g_CurrentEntity++; + entity++; + + if (i < 8) + goto loop_1; +} INCLUDE_ASM("asm/dra/nonmatchings/42398", func_8011A9D8); @@ -4989,7 +5071,15 @@ u16 func_80132E38(void) { return D_801396F4; } -INCLUDE_ASM("asm/dra/nonmatchings/42398", func_80132E90); +void func_80132E90(u32 arg0, s8* arg1) { + u16 temp; + u16 temp2; + + arg1[2] = (((arg0 % 75) / 10) * 0x10) + ((arg0 % 75) % 10); + arg1[1] = ((((arg0 / 75) % 60) / 10) * 0x10) + (((arg0 / 75) % 60) % 10); + temp = ((arg0 / 75) / 60) % 10; + arg1[0] = (temp2 = (((arg0 / 75) / 60) / 10) * 0x10) + temp; +} INCLUDE_ASM("asm/dra/nonmatchings/42398", func_80132F60); void func_80132F60(); diff --git a/src/st/dre/11A64.c b/src/st/dre/11A64.c index 1c5f65122..15d12ae67 100644 --- a/src/st/dre/11A64.c +++ b/src/st/dre/11A64.c @@ -29,7 +29,6 @@ Entity* func_8019AC18(Entity*, Entity*); void func_8019E5E0(Entity* entity); extern s16 D_80180D80[]; -extern s32 D_8009740C[]; extern LayoutObject* D_801A32C4; extern LayoutObject* D_801A32C8; extern u16 D_8007308E; @@ -112,7 +111,7 @@ void EntityBreakable(Entity* entity) { } } else { InitializeEntity(g_eBreakableInit); - entity->zPriority = g_zEntityCenter - 20; + entity->zPriority = g_zEntityCenter.typeShort - 20; entity->blendMode = g_eBreakableBlendModes[temp_s0]; entity->hitboxHeight = g_eBreakableHitboxes[temp_s0]; entity->animationSet = g_eBreakableAnimationSets[temp_s0]; @@ -687,7 +686,7 @@ void InitializeEntity(const u16 arg0[]) { g_CurrentEntity->unk2E = 0; g_CurrentEntity->step++; if (g_CurrentEntity->zPriority == 0) { - g_CurrentEntity->zPriority = g_zEntityCenter - 0xC; + g_CurrentEntity->zPriority = g_zEntityCenter.typeShort - 0xC; } } diff --git a/src/st/no3/377D4.c b/src/st/no3/377D4.c index 724203b2a..eff045231 100644 --- a/src/st/no3/377D4.c +++ b/src/st/no3/377D4.c @@ -81,7 +81,7 @@ void EntityBreakable(Entity* entity) { } } else { InitializeEntity(g_eBreakableInit); - entity->zPriority = g_zEntityCenter - 0x14; + entity->zPriority = g_zEntityCenter.typeShort - 0x14; entity->blendMode = g_eBreakableBlendModes[breakableType]; entity->hitboxHeight = g_eBreakableHitboxes[breakableType]; entity->animationSet = g_eBreakableAnimationSets[breakableType]; @@ -595,7 +595,7 @@ void InitializeEntity(const u16 arg0[]) { g_CurrentEntity->unk2E = 0; g_CurrentEntity->step++; if (g_CurrentEntity->zPriority == 0) { - g_CurrentEntity->zPriority = g_zEntityCenter - 0xC; + g_CurrentEntity->zPriority = g_zEntityCenter.typeShort - 0xC; } } diff --git a/src/st/np3/3246C.c b/src/st/np3/3246C.c index 88ce78f2a..2a316cd27 100644 --- a/src/st/np3/3246C.c +++ b/src/st/np3/3246C.c @@ -65,7 +65,7 @@ void EntityBreakable(Entity* entity) { } } else { InitializeEntity(g_eBreakableInit); - entity->zPriority = g_zEntityCenter - 0x14; + entity->zPriority = g_zEntityCenter.typeShort - 0x14; entity->blendMode = g_eBreakableBlendModes[breakableType]; entity->hitboxHeight = g_eBreakableHitboxes[breakableType]; entity->animationSet = g_eBreakableAnimationSets[breakableType]; @@ -441,7 +441,7 @@ void InitializeEntity(const u16 arg0[]) { g_CurrentEntity->unk2E = 0; g_CurrentEntity->step++; if (g_CurrentEntity->zPriority == 0) { - g_CurrentEntity->zPriority = g_zEntityCenter - 0xC; + g_CurrentEntity->zPriority = g_zEntityCenter.typeShort - 0xC; } } diff --git a/src/st/nz0/394D4.c b/src/st/nz0/394D4.c index 52e66e788..f333ecd0f 100644 --- a/src/st/nz0/394D4.c +++ b/src/st/nz0/394D4.c @@ -460,7 +460,7 @@ void InitializeEntity(const u16 arg0[]) { g_CurrentEntity->unk2E = 0; g_CurrentEntity->step++; if (g_CurrentEntity->zPriority == 0) { - g_CurrentEntity->zPriority = g_zEntityCenter - 0xC; + g_CurrentEntity->zPriority = g_zEntityCenter.typeShort - 0xC; } } diff --git a/src/st/sel/2C048.c b/src/st/sel/2C048.c index 4e50836b8..b973fab9a 100644 --- a/src/st/sel/2C048.c +++ b/src/st/sel/2C048.c @@ -173,7 +173,7 @@ void PrintFileSelectPlaceName(s32 arg0, s32 arg1, s32 y) { const s32 row1y = 0; const s32 row2y = 8; const s32 tge = 1; - volatile u32 pad; // FAKE + volatile u32 pad; // !FAKE: s32* new_var2 = &D_801BC958[arg0 * 0xEA]; s32 idx = new_var2[arg1] * 2; diff --git a/src/st/wrp/6FD0.c b/src/st/wrp/6FD0.c index 36a65b806..a2b2520d2 100644 --- a/src/st/wrp/6FD0.c +++ b/src/st/wrp/6FD0.c @@ -2625,7 +2625,7 @@ void EntityBreakable(Entity* entity) { } } else { InitializeEntity(g_eBreakableInit); - entity->zPriority = g_zEntityCenter - 0x14; + entity->zPriority = g_zEntityCenter.typeShort - 0x14; entity->blendMode = g_eBreakableBlendModes[breakableType]; entity->hitboxHeight = g_eBreakableHitboxes[breakableType]; entity->animationSet = g_eBreakableAnimationSets[breakableType]; @@ -3269,7 +3269,7 @@ void InitializeEntity(const u16 arg0[]) { g_CurrentEntity->unk2E = 0; g_CurrentEntity->step++; if (g_CurrentEntity->zPriority == 0) { - g_CurrentEntity->zPriority = g_zEntityCenter - 0xC; + g_CurrentEntity->zPriority = g_zEntityCenter.typeShort - 0xC; } }