diff --git a/Makefile b/Makefile index 98b5ce4..1c0f4db 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ $(SKELATOOL64): skelatool64/setup_dependencies.sh make -C skelatool64 -OPTIMIZER := -Og +OPTIMIZER := -Os LCDEFS := -DDEBUG -g -Isrc/ -I/usr/include/n64/nustd -Werror -Wall N64LIB := -lultra_rom -lnustd diff --git a/README.md b/README.md index 814096f..5f6f660 100644 --- a/README.md +++ b/README.md @@ -142,10 +142,10 @@ That will generate the rom at `/build/portal64.z64` ## Current New Feature TODO List - [ ] rumble pak support? -- [ ] Investigate crash after falling into death water on test chamber 8 - [ ] Add auto save checkpoints - [ ] Correct elevator timing - [ ] pausing while glados is speaking can end her speech early +- [x] Investigate crash after falling into death water on test chamber 8 - [x] wake up objects after opening a portal under them - [x] button prompts - [x] investigate no_portals surface under portal pedestal diff --git a/src/controls/controller_actions.c b/src/controls/controller_actions.c index 8bf7110..7438894 100644 --- a/src/controls/controller_actions.c +++ b/src/controls/controller_actions.c @@ -42,10 +42,13 @@ unsigned short gActionSourceButtonMask[ControllerActionSourceCount] = { }; int gActionState = 0; +int gMutedActions = 0; struct Vector2 gDirections[2]; +#define ACTION_TO_BITMASK(action) (1 << (action)) + void controllerActionApply(enum ControllerAction action) { - gActionState |= (1 << action); + gActionState |= ACTION_TO_BITMASK(action); } #define DEADZONE_SIZE 5 @@ -126,6 +129,8 @@ void controllerActionRead() { gDirections[0] = gZeroVec2; gDirections[1] = gZeroVec2; + int nextMutedState = 0; + for (int controllerIndex = 0; controllerIndex < 2; ++controllerIndex) { for (int sourceIndex = 0; sourceIndex < ControllerActionSourceCount; ++sourceIndex) { enum ControllerAction action = gSaveData.controls.controllerSettings[controllerIndex][sourceIndex]; @@ -136,9 +141,13 @@ void controllerActionRead() { if (sourceIndex == ControllerActionSourceCUpButton || sourceIndex == ControllerActionSourceDUpButton) { sourceIndex += 3; } - }else if (IS_HOLDABLE_ACTION(action) && controllerGetButton(controllerIndex, gActionSourceButtonMask[sourceIndex])){ - controllerActionApply(action); - }else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) { + } else if (IS_HOLDABLE_ACTION(action) && controllerGetButton(controllerIndex, gActionSourceButtonMask[sourceIndex])) { + if (ACTION_TO_BITMASK(action) & gMutedActions) { + nextMutedState |= ACTION_TO_BITMASK(action); + } else { + controllerActionApply(action); + } + } else if (controllerGetButtonDown(controllerIndex, gActionSourceButtonMask[sourceIndex])) { controllerActionApply(action); } } @@ -148,6 +157,8 @@ void controllerActionRead() { gDirections[i].x = clampf(gDirections[i].x, -1.0f, 1.0f); gDirections[i].y = clampf(gDirections[i].y, -1.0f, 1.0f); } + + gMutedActions = nextMutedState; } struct Vector2 controllerDirectionGet(enum ControllerAction direction) { @@ -162,6 +173,10 @@ int controllerActionGet(enum ControllerAction action) { return (gActionState & (1 << action)) != 0; } +void controllerActionMuteActive() { + gMutedActions = gActionState; +} + int controllerSourcesForAction(enum ControllerAction action, struct ControllerSourceWithController* sources, int maxSources) { int index = 0; diff --git a/src/controls/controller_actions.h b/src/controls/controller_actions.h index 72c180d..1037ed0 100644 --- a/src/controls/controller_actions.h +++ b/src/controls/controller_actions.h @@ -61,6 +61,7 @@ void controllerActionRead(); void controllerSetDeadzone(float percent); struct Vector2 controllerDirectionGet(enum ControllerAction direction); int controllerActionGet(enum ControllerAction action); +void controllerActionMuteActive(); int controllerSourcesForAction(enum ControllerAction action, struct ControllerSourceWithController* sources, int maxSources); diff --git a/src/main.c b/src/main.c index 191d498..1cd468d 100644 --- a/src/main.c +++ b/src/main.c @@ -235,6 +235,9 @@ static void gameProc(void* arg) { levelLoadWithCallbacks(levelGetQueued()); cutsceneRunnerReset(); dynamicAssetsReset(); + // if a portal fire button is being held + // don't fire portals until it is released + controllerActionMuteActive(); gSceneCallbacks->initCallback(gSceneCallbacks->data); } diff --git a/src/scene/scene.c b/src/scene/scene.c index b3a73a6..ccae010 100644 --- a/src/scene/scene.c +++ b/src/scene/scene.c @@ -354,7 +354,7 @@ void sceneCheckPortals(struct Scene* scene) { soundPlayerPlay(soundsPortalgunShoot[0], 1.0f, 1.0f, NULL, NULL); } - if ((fireBlue || (!hasOrange && fireOrange)) && !fireOrange && hasBlue && !playerIsGrabbing(&scene->player) &&!portalGunIsFiring(&scene->portalGun)) { + if (((fireBlue && !fireOrange) || (!hasOrange && fireOrange)) && hasBlue && !playerIsGrabbing(&scene->player) && !portalGunIsFiring(&scene->portalGun)) { portalGunFire(&scene->portalGun, 1, &raycastRay, &playerUp, scene->player.body.currentRoom); scene->player.flags |= PlayerJustShotPortalGun; hudPortalFired(&scene->hud, 1);