Merge branch 'lambertjamesd:master' into non-interlaced

This commit is contained in:
hackgrid 2023-10-19 13:09:28 +02:00 committed by GitHub
commit f1f9918017
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 60 additions and 36 deletions

View file

@ -199,6 +199,7 @@ That will generate the rom at `/build/portal64.z64`
<br />
## 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

View file

@ -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;
}

View file

@ -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);
}

View file

@ -30,6 +30,7 @@ void rumblePakClipInit() {
}
prev->next = NULL;
gFirstActiveClip = NULL;
}
RumbleID rumblePakClipPlay(struct RumblePakWave* wave) {

View file

@ -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,

View file

@ -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]);
}
}

View file

@ -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]);
}
}

View file

@ -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) {

View file

@ -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]);
}
}

View file

@ -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]);
}
}

View file

@ -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
);
}
}
}

View file

@ -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;
}
}
}

View file

@ -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);
}

View file

@ -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
};

View file

@ -3,7 +3,6 @@
#include "../controls/rumble_pak.h"
extern struct RumblePakWave gPlayerPassPortalWave;
extern struct RumblePakWave gPlayerDieRumbleWave;
#endif