diff --git a/Makefile b/Makefile index 336e4de..75d1b4b 100644 --- a/Makefile +++ b/Makefile @@ -333,6 +333,7 @@ build/src/menu/new_game_menu.o: build/src/audio/clips.h build/assets/materials/u build/src/menu/options_menu.o: build/assets/materials/ui.h build/src/menu/save_game_menu.o: build/src/audio/clips.h build/src/scene/scene_animator.o: build/src/audio/clips.h +build/src/menu/cheat_codes.o: build/src/audio/clips.h build/src/levels/intro.o: build/src/audio/clips.h build/assets/materials/images.h build/src/menu/savefile_list.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/font/dejavusans_images.o: build/assets/materials/ui.h diff --git a/README.md b/README.md index 886ec06..fda2c96 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,8 @@ That will generate the rom at `/build/portal64.z64`
## Current New Feature TODO List +- [ ] add translations to menus +- [ ] check if display list is long enough - [ ] pausing while glados is speaking can end her speech early - [x] jump animation - [x] optimize static culling diff --git a/src/menu/cheat_codes.c b/src/menu/cheat_codes.c new file mode 100644 index 0000000..1cc03d1 --- /dev/null +++ b/src/menu/cheat_codes.c @@ -0,0 +1,48 @@ +#include "cheat_codes.h" + +#include "../build/src/audio/clips.h" +#include "../audio/soundplayer.h" +#include "../scene/scene.h" + +struct CheatCodePattern gCheatCodes[CheatCodeCount] = { + [CheatCodeUnlockGun] = { + {'u', 'u', 'd', 'd', 'l', 'r', 'l', 'r'}, + SOUNDS_01_PART1_GET_PORTAL_GUN_1, + }, +}; + +unsigned char gCheatProgress[CheatCodeCount]; + +void cheatCodeReset() { + for (int i = 0; i < CheatCodeCount; ++i) { + gCheatProgress[i] = 0; + } +} + +void cheatCodeApply(enum CheatCode cheat) { + switch (cheat) { + case CheatCodeUnlockGun: + playerGivePortalGun(&gScene.player, PlayerHasFirstPortalGun | PlayerHasSecondPortalGun); + break; + case CheatCodeCount: + break; + } +} + +void cheatCodeEnterDirection(enum CheatCodeDir dir) { + for (int i = 0; i < CheatCodeCount; ++i) { + if (gCheatCodes[i].pattern[gCheatProgress[i]] == dir) { + ++gCheatProgress[i]; + + if (gCheatProgress[i] == CHEAT_CODE_LENGTH) { + cheatCodeApply(i); + soundPlayerPlay(gCheatCodes[i].soundId, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); + gCheatProgress[i] = 0; + } + } else if (gCheatCodes[i].pattern[0] == dir) { + gCheatProgress[i] = 1; + } else { + gCheatProgress[i] = 0; + } + } +} \ No newline at end of file diff --git a/src/menu/cheat_codes.h b/src/menu/cheat_codes.h new file mode 100644 index 0000000..85fd929 --- /dev/null +++ b/src/menu/cheat_codes.h @@ -0,0 +1,26 @@ +#ifndef __MENU_CHEAT_CODES_H__ +#define __MENU_CHEAT_CODES_H__ + +#define CHEAT_CODE_LENGTH 8 + +enum CheatCode { + CheatCodeUnlockGun, + CheatCodeCount, +}; + +enum CheatCodeDir { + CheatCodeDirUp = 'u', + CheatCodeDirRight = 'r', + CheatCodeDirDown = 'd', + CheatCodeDirLeft = 'l', +}; + +struct CheatCodePattern { + char pattern[CHEAT_CODE_LENGTH]; + short soundId; +}; + +void cheatCodeReset(); +void cheatCodeEnterDirection(enum CheatCodeDir dir); + +#endif \ No newline at end of file diff --git a/src/menu/landing_menu.c b/src/menu/landing_menu.c index 08cddad..d69b801 100644 --- a/src/menu/landing_menu.c +++ b/src/menu/landing_menu.c @@ -8,6 +8,7 @@ #include "../build/assets/materials/ui.h" #include "../build/src/audio/clips.h" +#include "cheat_codes.h" #define PORTAL_LOGO_X 30 #define PORTAL_LOGO_Y 74 @@ -71,22 +72,36 @@ void landingMenuInit(struct LandingMenu* landingMenu, struct LandingMenuOption* } struct LandingMenuOption* landingMenuUpdate(struct LandingMenu* landingMenu) { - if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0) { + enum ControllerDirection dir = controllerGetDirectionDown(0); + + if (dir & ControllerDirectionUp) { if (landingMenu->selectedItem > 0) { --landingMenu->selectedItem; } else { landingMenu->selectedItem = landingMenu->optionCount - 1; } soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); + + cheatCodeEnterDirection(CheatCodeDirUp); } - if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0) { + if (dir & ControllerDirectionDown) { if (landingMenu->selectedItem + 1 < landingMenu->optionCount) { ++landingMenu->selectedItem; } else { landingMenu->selectedItem = 0; } soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll); + + cheatCodeEnterDirection(CheatCodeDirDown); + } + + if (dir & ControllerDirectionLeft) { + cheatCodeEnterDirection(CheatCodeDirLeft); + } + + if (dir & ControllerDirectionRight) { + cheatCodeEnterDirection(CheatCodeDirRight); } if (controllerGetButtonDown(0, A_BUTTON)) { diff --git a/src/scene/scene.c b/src/scene/scene.c index 4b0e400..4daead0 100644 --- a/src/scene/scene.c +++ b/src/scene/scene.c @@ -50,8 +50,6 @@ Lights1 gSceneLights = gdSPDefLights1(128, 128, 128, 128, 128, 128, 0, 127, 0); #define LEVEL_INDEX_WITH_GUN_0 2 #define LEVEL_INDEX_WITH_GUN_1 8 -#define FADE_IN_ - void sceneUpdateListeners(struct Scene* scene); void sceneInitDynamicColliders(struct Scene* scene) {