Skip to content

Commit

Permalink
cheat code protect in pacman app (#1945)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxkmm authored Mar 7, 2024
1 parent 9e9dd3a commit c28087a
Showing 1 changed file with 62 additions and 17 deletions.
79 changes: 62 additions & 17 deletions firmware/application/external/pacman/playfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ boolean but_DOWN = false; // 50
boolean but_LEFT = false; // 48
boolean but_RIGHT = false; // 46

enum cheat_code_keymap {
UP,
DOWN,
LEFT,
RIGHT
};

enum cheat_code_keymap cheat_code[] = {UP, DOWN, UP, DOWN, RIGHT, LEFT, RIGHT, LEFT};
byte cheat_code_index = 0;

/******************************************************************************/
/* GAME VARIABLES AND DEFINITIONS */
/******************************************************************************/
Expand Down Expand Up @@ -1280,29 +1290,64 @@ class Playfield {
but_A = false;
GAMEPAUSED = 1;
} else if (but_LEFT && DEMO == 1 && GAMEPAUSED == 0) { // -level
cheat_level = true;
but_LEFT = false;
if (LEVEL > 1) {
LEVEL--;

if ((cheat_code[cheat_code_index] == 2) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
Init();

if (cheat_code_index == 8) {
cheat_level = true;
if (LEVEL > 1) {
LEVEL--;
}
Init();
}

but_LEFT = false;

} else if (but_RIGHT && DEMO == 1 && GAMEPAUSED == 0) { // +level
cheat_level = true;
but_RIGHT = false;
if (LEVEL < 255) {
LEVEL++;

if ((cheat_code[cheat_code_index] == 3) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
Init();

if (cheat_code_index == 8) {
cheat_level = true;
if (LEVEL < 255) {
LEVEL++;
}
Init();
}

but_RIGHT = false;

} else if (but_UP && DEMO == 1 && GAMEPAUSED == 0) { // full of lifes
cheat_lifes = true;

if ((cheat_code[cheat_code_index] == 0) && (cheat_code_index <= 8)) {
cheat_code_index++;
}

if (cheat_code_index == 8) {
cheat_lifes = true;
Init();
}

but_UP = false;
Init();

} else if (but_DOWN && DEMO == 1 && GAMEPAUSED == 0) { // reset
cheat_level = false;
cheat_lifes = false;
but_DOWN = false;
LIFES = START_LIFES;
Init();

if ((cheat_code[cheat_code_index] == 1) && (cheat_code_index <= 8)) {
cheat_code_index++;
}

if (cheat_code_index == 8) {
cheat_level = false;
cheat_lifes = false;
but_DOWN = false;
LIFES = START_LIFES;
cheat_code_index = 0;
Init();
}
}

if (GAMEPAUSED && but_A && DEMO == 0) {
Expand Down

0 comments on commit c28087a

Please sign in to comment.