diff --git a/README.md b/README.md index 2b637d0..b0dfb81 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,7 @@ That will generate the rom at `/build/portal64.z64`
## Current New Feature TODO List +- [ ] crashed when dying in test chamber 05 when hit by pellet in mid air while touching a portal - [ ] rumble pak support - [ ] pausing while glados is speaking can end her speech early - [x] polish up subtitles diff --git a/assets/test_chambers/test_chamber_02/test_chamber_02.blend b/assets/test_chambers/test_chamber_02/test_chamber_02.blend index 91ec43d..d8fa05d 100644 Binary files a/assets/test_chambers/test_chamber_02/test_chamber_02.blend and b/assets/test_chambers/test_chamber_02/test_chamber_02.blend differ diff --git a/src/audio/soundplayer.c b/src/audio/soundplayer.c index ebb97dd..e11be42 100644 --- a/src/audio/soundplayer.c +++ b/src/audio/soundplayer.c @@ -269,7 +269,7 @@ float soundClipDuration(int soundClipId, float pitch) { return soundPlayerEstimateLength(alSound, pitch); } -void soundPlayerGameVolumeUpdate(enum SoundType type) { +void soundPlayerGameVolumeUpdate() { int index = 0; while (index < gActiveSoundCount) { struct ActiveSound* sound = &gActiveSounds[index]; @@ -279,7 +279,7 @@ void soundPlayerGameVolumeUpdate(enum SoundType type) { } float newVolume = sound->originalVolume * gSaveData.audio.soundVolume/0xFFFF; - if (type == SoundTypeMusic){ + if (sound->soundType == SoundTypeMusic){ newVolume = newVolume* gSaveData.audio.musicVolume/0xFFFF; } diff --git a/src/controls/controller.c b/src/controls/controller.c index 953fe9e..39ff262 100644 --- a/src/controls/controller.c +++ b/src/controls/controller.c @@ -40,6 +40,7 @@ static OSContPad gControllerData[MAX_PLAYERS]; static u16 gControllerLastButton[MAX_PLAYERS]; static enum ControllerDirection gControllerLastDirection[MAX_PLAYERS]; static int gControllerDeadFrames; +static int gTargetRumbleState; static OSMesgQueue gControllerDataQueue; static OSMesg gControllerDataMesg; @@ -71,6 +72,8 @@ void controllersSavePreviousState() { #define CONTROLLER_READ_SKIP_NUMBER 10 void controllersTriggerRead() { + gTargetRumbleState = rumblePakCalculateState(); + OSMesg msg; if (osRecvMesg(&gControllerDataQueue, &msg, OS_MESG_NOBLOCK) == 0) { memCopy(&gControllerData, msg, sizeof(gControllerData)); @@ -160,12 +163,10 @@ void controllerCheckRumble(int prevStatus, OSMesgQueue* serialMsgQ) { gRumblePakState = RumblepakStateDisconnected; } - int targetRumbleStatus = rumblePakCalculateState(); - if (gRumblePakState == RumblepakStateInitialized) { - if (targetRumbleStatus != gRumblePakOn) { + if (gTargetRumbleState != gRumblePakOn) { for (int i = 0; i < 3; ++i) { - s32 rumbleError = targetRumbleStatus ? osMotorStart(&gRumbleBackFs) : osMotorStop(&gRumbleBackFs); + s32 rumbleError = gTargetRumbleState ? osMotorStart(&gRumbleBackFs) : osMotorStop(&gRumbleBackFs); if (rumbleError == PFS_ERR_CONTRFAIL) { if (i == 2) { @@ -175,12 +176,12 @@ void controllerCheckRumble(int prevStatus, OSMesgQueue* serialMsgQ) { gRumblePakState = RumblepakStateDisconnected; break; } else { - gRumblePakOn = targetRumbleStatus; + gRumblePakOn = gTargetRumbleState; gRumbleFailCount = 0; break; } } - } else if (!targetRumbleStatus) { + } else if (!gTargetRumbleState) { osMotorStop(&gRumbleBackFs); } diff --git a/src/controls/rumble_pak.c b/src/controls/rumble_pak.c index c74ff47..a6d6475 100644 --- a/src/controls/rumble_pak.c +++ b/src/controls/rumble_pak.c @@ -30,6 +30,7 @@ void rumblePakClipInit() { } prev->next = NULL; + gFirstActiveClip = NULL; } RumbleID rumblePakClipPlay(struct RumblePakWave* wave) { diff --git a/src/decor/decor_object.c b/src/decor/decor_object.c index 09e8307..9eba7d9 100644 --- a/src/decor/decor_object.c +++ b/src/decor/decor_object.c @@ -149,6 +149,10 @@ enum FizzleCheckResult decorObjectUpdateFizzler(struct CollisionObject* collisio } int decorObjectUpdate(struct DecorObject* decorObject) { + if (decorObject->collisionObject.flags & COLLISION_OBJECT_PLAYER_STANDING) { + decorObject->collisionObject.flags &= ~COLLISION_OBJECT_PLAYER_STANDING; + } + if (decorObject->playingSound != SOUND_ID_NONE) { soundPlayerUpdatePosition( decorObject->playingSound, diff --git a/src/menu/audio_options.c b/src/menu/audio_options.c index 31f40cd..f5a2c5b 100644 --- a/src/menu/audio_options.c +++ b/src/menu/audio_options.c @@ -58,11 +58,13 @@ void audioOptionsHandleSlider(short selectedItem, unsigned short* settingValue, newValue = newValue + chunk_size; newValue = newValue - (newValue % chunk_size); } + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerGetButtonDown(0, L_JPAD)) { newValue = newValue - 1; newValue = newValue - (newValue % chunk_size); + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (newValue < 0) { @@ -126,6 +128,7 @@ enum MenuDirection audioOptionsUpdate(struct AudioOptions* audioOptions) { if (audioOptions->selectedItem == AudioOptionCount) { audioOptions->selectedItem = 0; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerDir & ControllerDirectionUp) { @@ -134,16 +137,17 @@ enum MenuDirection audioOptionsUpdate(struct AudioOptions* audioOptions) { } else { --audioOptions->selectedItem; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } switch (audioOptions->selectedItem) { case AudioOptionGameVolume: audioOptionsHandleSlider(audioOptions->selectedItem, &gSaveData.audio.soundVolume, &audioOptions->gameVolume.value); - soundPlayerGameVolumeUpdate(SoundTypeAll); + soundPlayerGameVolumeUpdate(); break; case AudioOptionMusicVolume: audioOptionsHandleSlider(audioOptions->selectedItem, &gSaveData.audio.musicVolume, &audioOptions->musicVolume.value); - soundPlayerGameVolumeUpdate(SoundTypeMusic); + soundPlayerGameVolumeUpdate(); break; case AudioOptionSubtitlesEnabled: if (controllerGetButtonDown(0, A_BUTTON)) { @@ -274,4 +278,4 @@ void audioOptionsRender(struct AudioOptions* audioOptions, struct RenderState* r gSPDisplayList(renderState->dl++, audioOptions->audioLanguageDynamicText); gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]); -} \ No newline at end of file +} diff --git a/src/menu/controls.c b/src/menu/controls.c index aeafb08..dd2181b 100644 --- a/src/menu/controls.c +++ b/src/menu/controls.c @@ -296,6 +296,7 @@ enum MenuDirection controlsMenuUpdate(struct ControlsMenu* controlsMenu) { if (controlsMenu->selectedRow == ControllerActionCount + 1) { controlsMenu->selectedRow = 0; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerDir & ControllerDirectionUp) { @@ -304,6 +305,7 @@ enum MenuDirection controlsMenuUpdate(struct ControlsMenu* controlsMenu) { if (controlsMenu->selectedRow < 0) { controlsMenu->selectedRow = ControllerActionCount; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controlsMenu->selectedRow >= 0 && controlsMenu->selectedRow < ControllerActionCount) { @@ -558,4 +560,4 @@ void controlsRenderSubtitle(char* message, float textOpacity, float backgroundOp renderState->dl ); gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]); -} \ No newline at end of file +} diff --git a/src/menu/gameplay_options.c b/src/menu/gameplay_options.c index 1bbb67f..137527e 100644 --- a/src/menu/gameplay_options.c +++ b/src/menu/gameplay_options.c @@ -35,11 +35,13 @@ void gameplayOptionsHandleSlider(unsigned short* settingValue, float* sliderValu newValue = newValue + SCROLL_CHUNK_SIZE; newValue = newValue - (newValue % SCROLL_CHUNK_SIZE); } + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerGetButtonDown(0, L_JPAD)) { newValue = newValue - 1; newValue = newValue - (newValue % SCROLL_CHUNK_SIZE); + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (newValue < 0) { @@ -88,6 +90,7 @@ enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions if (gameplayOptions->selectedItem == GameplayOptionCount) { gameplayOptions->selectedItem = 0; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerDir & ControllerDirectionUp) { @@ -96,6 +99,7 @@ enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions } else { --gameplayOptions->selectedItem; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } switch (gameplayOptions->selectedItem) { diff --git a/src/menu/joystick_options.c b/src/menu/joystick_options.c index eadc619..1b78ba9 100644 --- a/src/menu/joystick_options.c +++ b/src/menu/joystick_options.c @@ -60,11 +60,13 @@ void joystickOptionsHandleSlider(unsigned short* settingValue, float* sliderValu newValue = newValue + SCROLL_CHUNK_SIZE; newValue = newValue - (newValue % SCROLL_CHUNK_SIZE); } + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerGetButtonDown(0, L_JPAD)) { newValue = newValue - 1; newValue = newValue - (newValue % SCROLL_CHUNK_SIZE); + soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (newValue < 0) { @@ -92,6 +94,7 @@ enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions if (joystickOptions->selectedItem == JoystickOptionCount) { joystickOptions->selectedItem = 0; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (controllerDir & ControllerDirectionUp) { @@ -100,6 +103,7 @@ enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions } else { --joystickOptions->selectedItem; } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } switch (joystickOptions->selectedItem) { @@ -222,4 +226,4 @@ void joystickOptionsRender(struct JoystickOptions* joystickOptions, struct Rende gSPDisplayList(renderState->dl++, joystickOptions->joystickDeadzoneText); gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]); -} \ No newline at end of file +} diff --git a/src/menu/landing_menu.c b/src/menu/landing_menu.c index 3ec8d34..78cd20a 100644 --- a/src/menu/landing_menu.c +++ b/src/menu/landing_menu.c @@ -71,13 +71,21 @@ void landingMenuInit(struct LandingMenu* landingMenu, struct LandingMenuOption* } struct LandingMenuOption* landingMenuUpdate(struct LandingMenu* landingMenu) { - if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0 && landingMenu->selectedItem > 0) { - --landingMenu->selectedItem; + if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0) { + if (landingMenu->selectedItem > 0) { + --landingMenu->selectedItem; + } else { + landingMenu->selectedItem = landingMenu->optionCount - 1; + } soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } - if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0 && landingMenu->selectedItem + 1 < landingMenu->optionCount) { - ++landingMenu->selectedItem; + if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0) { + if (landingMenu->selectedItem + 1 < landingMenu->optionCount) { + ++landingMenu->selectedItem; + } else { + landingMenu->selectedItem = 0; + } soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } @@ -109,4 +117,4 @@ void landingMenuRender(struct LandingMenu* landingMenu, struct RenderState* rend gSPDisplayList(renderState->dl++, landingMenu->optionText[i]); } gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]); -} \ No newline at end of file +} diff --git a/src/menu/new_game_menu.c b/src/menu/new_game_menu.c index ecf999c..6bf2339 100644 --- a/src/menu/new_game_menu.c +++ b/src/menu/new_game_menu.c @@ -144,13 +144,14 @@ enum MenuDirection newGameUpdate(struct NewGameMenu* newGameMenu) { newGameMenu->selectedChapter + 1 < newGameMenu->chapterCount && gChapters[newGameMenu->selectedChapter + 1].imageData) { newGameMenu->selectedChapter = newGameMenu->selectedChapter + 1; - soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if ((controllerGetDirectionDown(0) & ControllerDirectionLeft) != 0 && newGameMenu->selectedChapter > 0) { newGameMenu->selectedChapter = newGameMenu->selectedChapter - 1; - soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } + + if ((controllerGetDirectionDown(0) & ControllerDirectionLeft) != 0 || (controllerGetDirectionDown(0) & ControllerDirectionRight) != 0) + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); int nextChapterOffset = newGameMenu->selectedChapter & ~1; @@ -229,4 +230,4 @@ void newGameRender(struct NewGameMenu* newGameMenu, struct RenderState* renderSt gColorWhite ); } -} \ No newline at end of file +} diff --git a/src/menu/options_menu.c b/src/menu/options_menu.c index 2cf467a..11f4309 100644 --- a/src/menu/options_menu.c +++ b/src/menu/options_menu.c @@ -8,6 +8,7 @@ #include "../build/assets/materials/ui.h" #include "../controls/controller.h" +#include "../build/src/audio/clips.h" struct Tab gOptionTabs[] = { @@ -87,6 +88,7 @@ enum MenuDirection optionsMenuUpdate(struct OptionsMenu* options) { } tabsSetSelectedTab(&options->tabs, options->tabs.selectedTab); + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } if (menuDirection == MenuDirectionRight) { @@ -95,6 +97,7 @@ enum MenuDirection optionsMenuUpdate(struct OptionsMenu* options) { } else { tabsSetSelectedTab(&options->tabs, options->tabs.selectedTab + 1); } + soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); } @@ -134,4 +137,4 @@ void optionsMenuRender(struct OptionsMenu* options, struct RenderState* renderSt gameplayOptionsRender(&options->gameplayOptions, renderState, task); break; } -} \ No newline at end of file +} diff --git a/src/player/player.c b/src/player/player.c index e6589c8..c8553d4 100644 --- a/src/player/player.c +++ b/src/player/player.c @@ -45,7 +45,7 @@ struct Vector3 gCameraOffset = {0.0f, 0.0f, 0.0f}; struct CollisionQuad gPlayerColliderFaces[8]; -#define TARGET_CAPSULE_EXTEND_HEIGHT 0.5f +#define TARGET_CAPSULE_EXTEND_HEIGHT 0.45f struct CollisionCapsule gPlayerCollider = { 0.25f, @@ -241,7 +241,10 @@ void playerApplyPortalGrab(struct Player* player, int portalIndex) { } void playerSetGrabbing(struct Player* player, struct CollisionObject* grabbing) { - if (grabbing && !player->grabConstraint.object) { + if (grabbing && grabbing->flags & COLLISION_OBJECT_PLAYER_STANDING){ + player->grabConstraint.object = NULL; + } + else if (grabbing && !player->grabConstraint.object) { pointConstraintInit(&player->grabConstraint, grabbing, 8.0f, 5.0f, 1.0f); contactSolverAddPointConstraint(&gContactSolver, &player->grabConstraint); hudResolvePrompt(&gScene.hud, CutscenePromptTypePickup); @@ -833,7 +836,6 @@ void playerUpdate(struct Player* player) { soundPlayerPlay(soundsPortalExit[2 - didPassThroughPortal], 0.75f, 1.0f, NULL, NULL, SoundTypeAll); hudShowSubtitle(&gScene.hud, PORTALPLAYER_EXITPORTAL, SubtitleTypeCaption); gPlayerCollider.extendDownward = 0.0f; - rumblePakClipPlay(&gPlayerPassPortalWave); } else { gPlayerCollider.extendDownward = mathfMoveTowards(gPlayerCollider.extendDownward, TARGET_CAPSULE_EXTEND_HEIGHT, STAND_SPEED * FIXED_DELTA_TIME); } diff --git a/src/player/player_rumble_clips.c b/src/player/player_rumble_clips.c index e5899e9..b43b059 100644 --- a/src/player/player_rumble_clips.c +++ b/src/player/player_rumble_clips.c @@ -1,15 +1,5 @@ #include "./player_rumble_clips.h" -unsigned char gPlayerPassPortalData[] = { - 0xFE, 0x09, -}; - -struct RumblePakWave gPlayerPassPortalWave = { - .samples = gPlayerPassPortalData, - .sampleCount = 6, - .samplesPerTick = 1 << 6, -}; - unsigned char gPlayerDieRumbleData[] = { 0xFF, 0xE9, 0x9E, 0xFF, 0xFF, 0xE9 }; diff --git a/src/player/player_rumble_clips.h b/src/player/player_rumble_clips.h index d67bfab..8ea1a15 100644 --- a/src/player/player_rumble_clips.h +++ b/src/player/player_rumble_clips.h @@ -3,7 +3,6 @@ #include "../controls/rumble_pak.h" -extern struct RumblePakWave gPlayerPassPortalWave; extern struct RumblePakWave gPlayerDieRumbleWave; #endif \ No newline at end of file