diff options
| author | Christopher Leggett <chris@leggett.dev> | 2022-07-25 21:33:19 -0400 |
|---|---|---|
| committer | Christopher Leggett <chris@leggett.dev> | 2022-07-25 21:33:19 -0400 |
| commit | 2ff5d54592edbbf65e3bdee8c68c903f6be1935a (patch) | |
| tree | fc3b1f81d4740cbb87421042e13a87f067b7946b /soh/src/code | |
| parent | cd01e8b7781d1b74ff7a77907666963691006d86 (diff) | |
| parent | 8bdc4458c73898e17c738c82eb83402b26968ef0 (diff) | |
Merge in develop-zhora
Diffstat (limited to 'soh/src/code')
| -rw-r--r-- | soh/src/code/fault_drawer.c | 5 | ||||
| -rw-r--r-- | soh/src/code/graph.c | 16 | ||||
| -rw-r--r-- | soh/src/code/main.c | 2 | ||||
| -rw-r--r-- | soh/src/code/z_en_item00.c | 52 | ||||
| -rw-r--r-- | soh/src/code/z_message_PAL.c | 17 | ||||
| -rw-r--r-- | soh/src/code/z_player_lib.c | 86 |
6 files changed, 144 insertions, 34 deletions
diff --git a/soh/src/code/fault_drawer.c b/soh/src/code/fault_drawer.c index 9759bfe72..8cd08248f 100644 --- a/soh/src/code/fault_drawer.c +++ b/soh/src/code/fault_drawer.c @@ -265,16 +265,14 @@ void* FaultDrawer_FormatStringFunc(void* arg, const char* str, u32 count) { return arg; } -void FaultDrawer_VPrintf(const char* str, char* args) { // va_list +void FaultDrawer_VPrintf(const char* str, va_list args) { // va_list _Printf(FaultDrawer_FormatStringFunc, (char*)&sFaultDrawerStruct, str, args); } void FaultDrawer_Printf(const char* fmt, ...) { va_list args; va_start(args, fmt); - FaultDrawer_VPrintf(fmt, args); - va_end(args); } @@ -284,7 +282,6 @@ void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) { FaultDrawer_SetCursor(x, y); FaultDrawer_VPrintf(fmt, args); - va_end(args); } diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index f4dcf56e8..cf0a53c76 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -481,6 +481,22 @@ static void RunFrame() uint64_t ticksA, ticksB; ticksA = GetPerfCounter(); +#ifdef __SWITCH__ + #define SAMPLES_HIGH 752 + #define SAMPLES_LOW 720 + + #define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 ) + #define NUM_AUDIO_CHANNELS 2 + int samples_left = AudioPlayer_Buffered(); + u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW; + + s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3]; + for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) { + AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples); + } + + AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE)); +#endif Graph_StartFrame(); // TODO: Workaround for rumble being too long. Implement os thread functions. diff --git a/soh/src/code/main.c b/soh/src/code/main.c index 372e3947c..fd02b016a 100644 --- a/soh/src/code/main.c +++ b/soh/src/code/main.c @@ -41,8 +41,6 @@ void main(int argc, char** argv) GameConsole_Init(); InitOTR(); BootCommands_Init(); - - BootCommands_ParseBootArgs(argc - 1, (char**)&argv[1]); Main(0); } diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index c2fddaab1..b31209d83 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -996,6 +996,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; GetItem_Draw(globalCtx, GID_RUPEE_PURPLE); + break; } else { Actor_SetScale(&this->actor, 0.03f); this->actor.shape.shadowScale = 6.0f; @@ -1231,27 +1232,40 @@ void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, s16 case GI_PRELUDE_OF_LIGHT: color_slot = 5; break; + case GI_STICK_UPGRADE_20: + case GI_STICK_UPGRADE_30: + color_slot = 6; + break; + case GI_NUT_UPGRADE_30: + case GI_NUT_UPGRADE_40: + color_slot = 7; + break; } - s16* colors[7][3] = { - { 34, 255, 76 }, // Minuet and Magic Upgrades Colors - { 177, 35, 35 }, // Bolero and Double Defense Colors - { 115, 251, 253 }, // Serenade Color - { 177, 122, 35 }, // Requiem Color - { 177, 28, 212 }, // Nocturne Color - { 255, 255, 92 }, // Prelude Color - { 255, 255, 255} // White Color placeholder + s16* colors[9][3] = { + { 34, 255, 76 }, // Minuet and Magic Upgrades Colors + { 177, 35, 35 }, // Bolero and Double Defense Colors + { 115, 251, 253 }, // Serenade Color + { 177, 122, 35 }, // Requiem Color + { 177, 28, 212 }, // Nocturne Color + { 255, 255, 92 }, // Prelude Color + { 31, 152, 49 }, // Stick Upgrade Color + { 222, 182, 20 }, // Nut Upgrade Color + { 255, 255, 255 } // White Color placeholder }; - s16* colorsEnv[7][3] = { - { 30, 110, 30 }, // Minuet and Magic Upgrades Colors - { 90, 10, 10 }, // Bolero and Double Defense Colors - { 35, 35, 177 }, // Serenade Color - { 70, 20, 10 }, // Requiem Color - { 100, 20, 140 }, // Nocturne Color - { 100, 100, 10 }, // Prelude Color - { 154, 154, 154 } // White Color placeholder + s16* colorsEnv[9][3] = { + { 30, 110, 30 }, // Minuet and Magic Upgrades Colors + { 90, 10, 10 }, // Bolero and Double Defense Colors + { 35, 35, 177 }, // Serenade Color + { 70, 20, 10 }, // Requiem Color + { 100, 20, 140 }, // Nocturne Color + { 100, 100, 10 }, // Prelude Color + { 5, 50, 10 }, // Stick Upgrade Color + { 150, 100, 5 }, // Nut Upgrade Color + { 154, 154, 154 } // White Color placeholder }; + static Vec3f velocity = { 0.0f, 0.2f, 0.0f }; static Vec3f accel = { 0.0f, 0.05f, 0.0f }; Color_RGBA8 primColor = { colors[color_slot][0], colors[color_slot][1], colors[color_slot][2], 0 }; @@ -1304,7 +1318,8 @@ void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) { f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); s32 randoGetItemId = Randomizer_GetRandomizedItemId(this->getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); - if (randoGetItemId >= GI_MINUET_OF_FOREST && randoGetItemId <= GI_DOUBLE_DEFENSE) { + if ((randoGetItemId >= GI_MINUET_OF_FOREST && randoGetItemId <= GI_DOUBLE_DEFENSE) || + (randoGetItemId >= GI_STICK_UPGRADE_20 && randoGetItemId <= GI_NUT_UPGRADE_40)) { EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItemId); } GetItem_Draw(globalCtx, Randomizer_GetItemModelFromId(randoGetItemId)); @@ -1364,7 +1379,8 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); s32 randoGetItemId = Randomizer_GetRandomizedItemId(GI_HEART_PIECE, this->actor.id, this->ogParams, globalCtx->sceneNum); - if (randoGetItemId >= GI_MINUET_OF_FOREST && randoGetItemId <= GI_DOUBLE_DEFENSE) { + if ((randoGetItemId >= GI_MINUET_OF_FOREST && randoGetItemId <= GI_DOUBLE_DEFENSE) || + (randoGetItemId >= GI_STICK_UPGRADE_20 && randoGetItemId <= GI_NUT_UPGRADE_40)) { EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItemId); } GetItem_Draw(globalCtx, Randomizer_GetItemModelFromId(randoGetItemId)); diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 3da2a0fc8..fba12b995 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -111,7 +111,7 @@ void Message_ResetOcarinaNoteState(void) { sOcarinaNoteCEnvR = 10; sOcarinaNoteCEnvG = 10; sOcarinaNoteCEnvB = 10; - if (CVar_GetS32("gHudColors", 1) == 0) { + if (CVar_GetS32("gHudColors", 1) == 0) { sOcarinaNoteAPrimR = 80; sOcarinaNoteAPrimG = 150; sOcarinaNoteAPrimB = 255; @@ -240,8 +240,6 @@ void Message_DrawTextChar(GlobalContext* globalCtx, void* textureImage, Gfx** p) s16 x = msgCtx->textPosX; s16 y = msgCtx->textPosY; - gSPInvalidateTexCache(gfx++, textureImage); - gDPPipeSync(gfx++); sCharTexSize = (R_TEXT_CHAR_SCALE / 100.0f) * 16.0f; @@ -1229,6 +1227,8 @@ void Message_Decode(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; Font* font = &globalCtx->msgCtx.font; + gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL); + globalCtx->msgCtx.textDelayTimer = 0; globalCtx->msgCtx.textUnskippable = globalCtx->msgCtx.textDelay = globalCtx->msgCtx.textDelayTimer = 0; sTextFade = false; @@ -1624,6 +1624,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } sMessageHasSetSfx = D_8014B2F4 = sTextboxSkipped = sTextIsCredits = 0; + gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL); if (textId >= 0x0500 && textId < 0x0600) { // text ids 0500 to 0600 are reserved for credits sTextIsCredits = true; @@ -1731,7 +1732,7 @@ void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* actor) { // so we need to switch the order of these lines if (gSaveContext.n64ddFlag && textId == 0x2053) { msgCtx->talkActor = actor; - Message_OpenText(globalCtx, textId); + Message_OpenText(globalCtx, textId); } else { Message_OpenText(globalCtx, textId); msgCtx->talkActor = actor; @@ -2052,7 +2053,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if(CBtnB_2 > 255){CBtnB_2=255;}; s16 sOcarinaNoteCPrimColors_CUSTOM[][3] = { { CBtnR, CBtnG, CBtnB }, //Unified - { CBtnR_2, CBtnG_2, CBtnB_2 }, + { CBtnR_2, CBtnG_2, CBtnB_2 }, { CBtnRL, CBtnGL, CBtnBL }, //Left { CBtnRD, CBtnGD, CBtnBD }, //Down { CBtnRR, CBtnGR, CBtnBR }, //Right @@ -2642,15 +2643,15 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Message_ContinueTextbox(globalCtx, msgCtx->lastPlayedSong + 0x893); // You played [song name] Message_Decode(globalCtx); msgCtx->msgMode = MSGMODE_DISPLAY_SONG_PLAYED_TEXT; - - if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME + + if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) { msgCtx->stateTimer = 20; } else { msgCtx->stateTimer = 1; } - + Message_DrawText(globalCtx, &gfx); break; case MSGMODE_DISPLAY_SONG_PLAYED_TEXT: diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 239a1e1a9..470cec354 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -763,7 +763,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, color->r = CVar_GetS32("gTunic_Zora_R", sTunicColors[PLAYER_TUNIC_ZORA].r); color->g = CVar_GetS32("gTunic_Zora_G", sTunicColors[PLAYER_TUNIC_ZORA].g); color->b = CVar_GetS32("gTunic_Zora_B", sTunicColors[PLAYER_TUNIC_ZORA].b); - } else if (!CVar_GetS32("gUseTunicsCol",0)){ + } else if (!CVar_GetS32("gUseTunicsCol",0)) { if (tunic >= 3) { color->r = sOriginalTunicColors[0].r; color->g = sOriginalTunicColors[0].g; @@ -1712,7 +1712,6 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, // Link is idle so revert to 0 EquipedStance = 0; } - if (SelectedMode == 16) { // Apply Random function s16 SwitchAtFrame = 0; @@ -1749,6 +1748,89 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, anim = PauseMenuAnimSet[SelectedAnim][EquipedStance]; } FrameCountSinceLastAnim++; + } else if (SelectedMode == 17) { + // Apply Random function + s16 SwitchAtFrame = 0; + s16 CurAnimDuration = 0; + s16 LastAnim; + if (FrameCountSinceLastAnim == 0) { + // When opening Kaleido this will be passed one time + SelectedAnim = (rand() % (6 - 1 + 1)) + 1; + if (SelectedAnim == 0) { + // prevent loading 0 that would result to a crash. + SelectedAnim = 1; + } + } else if (FrameCountSinceLastAnim >= 1) { + SwitchAtFrame = Animation_GetLastFrame(PauseMenuAnimSet[SelectedAnim][EquipedStance]); + CurAnimDuration = Animation_GetLastFrame(PauseMenuAnimSet[SelectedAnim][EquipedStance]); + if (SwitchAtFrame < MinFrameCount) { + // Animation frame count is lower than minimal wait time then we wait for another round. + // This will be looped to always add current animation time if that still lower than minimum time + while (SwitchAtFrame < MinFrameCount) { + SwitchAtFrame = SwitchAtFrame + CurAnimDuration; + } + } else if (CurAnimDuration >= MinFrameCount) { + // Since we have more (or same) animation time than min duration we set the wait time to animation + // time. + SwitchAtFrame = CurAnimDuration; + } + if (FrameCountSinceLastAnim >= SwitchAtFrame) { + LastAnim = SelectedAnim; + if (LastAnim==1) { + if ((CUR_EQUIP_VALUE(EQUIP_SWORD)!=PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)!= PLAYER_SHIELD_NONE)) { // if the player has a sword and shield equipped + if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_SHIELD) == PLAYER_SHIELD_DEKU)) { // if he's an adult or a kid with the deku shield + SelectedAnim = (rand() % (6 - 2 + 1)) + 2; // select any 5 animations that aren't the default standing anim + } else { //else if he's a child with a shield that isn't the deku shield + s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations + if (randval==4) { //if its the shield anim + SelectedAnim==6; // set to yawn anim + } else { + SelectedAnim=randval; + } + } + } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) != PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)==PLAYER_SHIELD_NONE)) { // if the player has a sword equipped but no shield + s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations + if (randval==4) { //if its the shield anim + SelectedAnim==6; // set to yawn anim + } else { + SelectedAnim=randval; + } + } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) == PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)!=PLAYER_SHIELD_NONE)) { //if the player has a shield equipped but no sword + if ((LINK_AGE_IN_YEARS == YEARS_ADULT) || (CUR_EQUIP_VALUE(EQUIP_SHIELD) == PLAYER_SHIELD_DEKU)) {// if he's an adult or a kid with the deku shield + s16 randval = (rand() % (5 - 2 + 1)) + 2; // 4 animations + if (randval==5) { //if its the sword anim + SelectedAnim==6; // set to yawn anim + } else { + SelectedAnim=randval; + } + } else { + s16 randval = (rand() % (4 - 2 + 1)) + 2; // 3 animations + if (randval==4) { //if its the shield anim + SelectedAnim==6; // set to yawn anim + } else { + SelectedAnim=randval; + } + } + } else if ((CUR_EQUIP_VALUE(EQUIP_SWORD) == PLAYER_SWORD_NONE) && (CUR_EQUIP_VALUE(EQUIP_SHIELD)==PLAYER_SHIELD_NONE)) { // if the player has no sword or shield equipped + s16 randval = (rand() % (4 - 2 + 1)) + 2; // 3 animations + if (randval==4) { //if its the shield anim + SelectedAnim==6; // set to yawn anim + } else { + SelectedAnim=randval; + } + } + } else { + SelectedAnim = 1; + } + if (SelectedAnim == 0) { + // prevent loading 0 that would result to a crash. Also makes sure default idle is every other anim + SelectedAnim = 1; + } + FrameCountSinceLastAnim = 1; + } + anim = PauseMenuAnimSet[SelectedAnim][EquipedStance]; + } + FrameCountSinceLastAnim++; } else if (SelectedMode == 15) { // When opening Kaleido this will be passed one time if (FrameCountSinceLastAnim < 1) { |
