Skip to content

Commit

Permalink
add power save option, close #9
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Apr 2, 2023
1 parent a6dd910 commit f9b039d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions res/menu_entry_consts.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ menu_entry_trainer_torches=+5 TORCHES
menu_entry_trainer_time=+60 SECONDS
menu_entry_trainer_gems=+15 GEMS
menu_entry_trainer_dark=LIGHT SWITCH
menu_entry_power_save_off=POWER SAVE OFF
menu_entry_power_save_on=POWER SAVE ON
11 changes: 9 additions & 2 deletions src/game_menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "timer.h"
#include "txtwind.h"

uint8_t powersave_enabled = 1;

static void board_pause_enter(void) {
zoo_game_state.paused = true; // TODO: not here...

Expand Down Expand Up @@ -174,6 +176,7 @@ bool game_pause_menu(void) BANKED {
txtwind_init();
txtwind_append((uint16_t) menu_entry_continue, 3);
txtwind_append((uint16_t) menu_entry_restart, 3);
txtwind_append((uint16_t) (powersave_enabled ? menu_entry_power_save_on : menu_entry_power_save_off), 3);
txtwind_append((uint16_t) menu_entry_about, 3);
#ifdef SHOW_CHEATS
if (cheat_active == 255) {
Expand All @@ -185,12 +188,16 @@ bool game_pause_menu(void) BANKED {
game_menu_act_enter_world(zoo_game_state.world_id, true, false);
return true;
} break;
case 2: { /* ABOUT */
case 2: { /* POWER SAVE */
powersave_enabled = powersave_enabled ? 0 : 1;
goto MenuStart;
} break;
case 3: { /* ABOUT */
game_menu_act_about();
goto MenuStart;
} break;
#ifdef SHOW_CHEATS
case 3: { /* TRAINER */
case 4: { /* TRAINER */
game_menu_act_trainer();
return false;
} break;
Expand Down
3 changes: 3 additions & 0 deletions src/gamevars.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ extern zoo_game_state_t zoo_game_state;
#ifdef SHOW_CHEATS
extern uint8_t cheat_active;
#endif
extern uint8_t powersave_enabled;
#endif

#define ZOO_IN_TITLE() (zoo_game_state.game_state_element == E_MONITOR)
Expand All @@ -197,9 +198,11 @@ extern uint8_t cheat_active;
#define ZOO_STAT_AT(x, y) zoo_stats[get_stat_id_at((x), (y)) + 1]

#define ZOO_BUSYLOOP(cond) while ((cond)) { \
if (powersave_enabled) { \
__asm \
halt \
__endasm; \
} \
}

#endif

0 comments on commit f9b039d

Please sign in to comment.