Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Famidash: the debug mode

Mason3631bb6fe24f7cd
diff --git a/docs/play.md b/docs/play.md
index 838595f4..c49bf78d 100644
--- a/docs/play.md
+++ b/docs/play.md
@@ -799,6 +799,7 @@ Last from 12 to 6 AM in the bedroom. At a door, listen with the light off: breat
| **Back** | Pause (with Resume, Practice and Quit game) |
| **Down** | In practice mode: place a checkpoint |
| **⌫** (backspace) | In practice mode: remove the last checkpoint |
+| **⌫** otherwise | The game's debug mode: no deaths, Right flips gravity, Down the size, held a second ends the level (not counted). In the pause, Left the gravity, Right the mode |
| **Arrows** | Choose in the menus |
| **Home** | Save and quit |
diff --git a/games/famidash/README.md b/games/famidash/README.md
index d3285ef4..d8809389 100644
--- a/games/famidash/README.md
+++ b/games/famidash/README.md
@@ -61,6 +61,7 @@ Each level hides three coins. They only count when you finish the level in one g
| Back | Pause (Resume, Practice, Quit game) |
| Down | In practice mode: place a checkpoint |
| ⌫ (backspace) | In practice mode: remove the last checkpoint |
+| ⌫ (backspace) otherwise | The game's debug mode: no deaths, Right flips gravity, Down the size, held a second ends the level (not counted). In the pause, Left the gravity, Right the mode |
| Left, Right | In the menus: choose. In platformer mode: walk |
| Home | Save and quit |
diff --git a/games/famidash/src/fd.h b/games/famidash/src/fd.h
index b62f638a..b3fd2204 100644
--- a/games/famidash/src/fd.h
+++ b/games/famidash/src/fd.h
@@ -75,6 +75,11 @@ void game_death_frame(int f); /* the 30 frames of the explosion */
void game_reset(void); /* reset_level (after the fade) */
void game_draw(void); /* draw_sprites into the sprite list */
void game_store_practice(void); /* pause, B: practice mode on */
+/* the debug mode (Select, here backspace, with no checkpoints): no deaths, Right flips gravity, Down (here: Down in
+ it) the size, Select held a second ends the level; in the pause Left the gravity, Right the next mode */
+extern uint8_t DEBUG_MODE, cheated;
+void game_debug_gravity(void);
+void game_debug_mode(void);
void update_level_completeness(void);
void set_completion_data(void);
uint8_t level_percent(void);
diff --git a/games/famidash/src/game.c b/games/famidash/src/game.c
index 8ff34361..de39559b 100644
--- a/games/famidash/src/game.c
+++ b/games/famidash/src/game.c
@@ -49,6 +49,7 @@ uint8_t icon, icon_colors[3] = {0x2A, 0x2C, 0x0F}, options, invisible, invisbloc
#define color3 icon_colors[2]
uint8_t practice_point_count, curr_practice_point;
+uint8_t DEBUG_MODE, cheated;
static uint8_t latest_practice_point, practicebuffer, practice_sprite_x_pos;
static uint16_t auto_practicepoint_timer;
static struct {
@@ -2284,6 +2285,7 @@ void update_level_completeness(void) {
}
void set_completion_data(void) {
+ if (DEBUG_MODE) return;
if (!practice_point_count) {
if (!invisblocks) {
prog.complete[level] = 1;
@@ -2468,6 +2470,11 @@ static void everything_else(void) {
if (dashing[0]) currplayer_vel_y = 0;
dashing[0] = 0;
}
+ if ((joypad1.press & PAD_SELECT) && practice_point_count == 0) { /* (DEBUG_MODE_ENABLED) */
+ DEBUG_MODE = !DEBUG_MODE;
+ cheated = 1;
+ cube_data[0] &= 2, cube_data[1] &= 2;
+ }
if (practice_point_count > 1 && (joypad1.press & PAD_SELECT) && !(joypad1.hold & (PAD_UP | PAD_DOWN))) {
curr_practice_point--;
if (latest_practice_point) latest_practice_point--;
@@ -2482,6 +2489,15 @@ static void everything_else(void) {
practicebuffer = 4;
} else game_store_practice();
}
+ if ((joypad1.press & PAD_RIGHT) && DEBUG_MODE && !(options & platformer) && !force_platformer) {
+ invert_gravity(currplayer_gravity);
+ update_currplayer_table_idx();
+ }
+ if ((joypad1.press & PAD_DOWN) && DEBUG_MODE) currplayer_mini ^= 1, update_currplayer_table_idx();
+ if ((joypad1.hold & PAD_SELECT) && DEBUG_MODE) {
+ if (++END_LEVEL_TIMER > 60) END_LEVEL_TIMER = 0, kandokidshack4 = 0, gameState = STATE_LVLDONE; /* end_level_debug */
+ } else
+ END_LEVEL_TIMER = 0;
decrement_was_on_slope();
check_for_cube_data_2_set();
if (orbed[currplayer] && !(controllingplayer->hold & (PAD_A | PAD_UP))) orbed[currplayer] = 0;
@@ -2560,7 +2576,14 @@ void game_step(void) {
}
bool game_platformer(void) { return force_platformer || (options & platformer); }
-bool game_dead(void) { return high_byte(player_relx[0]) > 0x20 && (cube_data[0] & 1 || cube_data[1] & 1); }
+bool game_dead(void) { return !DEBUG_MODE && high_byte(player_relx[0]) > 0x20 && (cube_data[0] & 1 || cube_data[1] & 1); }
+
+void game_debug_gravity(void) { gravity_mod == 4 ? gravity_mod = 0 : gravity_mod++; }
+void game_debug_mode(void) {
+ nocamlock = 1;
+ gamemode = gamemode == GAMEMODE_SWING ? GAMEMODE_CUBE : gamemode + 1;
+ cube_data[0] = 0;
+}
/* ---------------------------------------------------------------- sprites: draw_sprites and the player */
static uint8_t death_player;
diff --git a/games/famidash/src/main.c b/games/famidash/src/main.c
index ca3505c5..7f10129c 100644
--- a/games/famidash/src/main.c
+++ b/games/famidash/src/main.c
@@ -514,6 +514,7 @@ static void draw_both_progress_bars(void) {
}
static void enter_levels(void) {
+ cheated = 0;
if (tempplat == 1) tempplat = 0, options |= platformer;
bg_mode = BG_NAMETABLE;
menu_banks(98);
@@ -626,7 +627,7 @@ static void play_input(void) {
if (keys & PK_UP) h |= PAD_UP;
if (keys & PK_LEFT) h |= PAD_LEFT;
if (keys & PK_RIGHT) h |= PAD_RIGHT;
- if (keys & PK_DOWN) h |= PAD_B;
+ if (keys & PK_DOWN) h |= DEBUG_MODE ? PAD_DOWN : PAD_B;
if (keys & PK_DEL) h |= PAD_SELECT;
joypad1.press = (uint8_t)(h & ~joypad1.hold);
joypad1.release = (uint8_t)(~h & joypad1.hold);
@@ -677,6 +678,8 @@ static void play_tick(void) {
case P_QUIT:
joypad1.press = 0;
if (hit & PK_BACK) { phase = P_RUN; return; }
+ if (DEBUG_MODE && (hit & PK_LEFT)) game_debug_gravity();
+ if (DEBUG_MODE && (hit & PK_RIGHT)) game_debug_mode();
if (hit & PK_UP) pause_sel = (pause_sel + 2) % 3, phase = P_PAUSE;
if (hit & PK_DOWN) pause_sel = (pause_sel + 1) % 3, phase = P_PAUSE;
if (hit & (PK_OK | PK_EXE)) {
@@ -722,6 +725,7 @@ static void enter_done(void) {
char j[8];
snprintf(j, sizeof j, "%u", (unsigned)jumps);
for (int i = 0; j[i]; i++) nt_put(0, 18 + i, 15, (uint8_t)(0xD0 + j[i] - '0'));
+ if (DEBUG_MODE || cheated) nt_padded(0, 7, 14, "CHEATER", 18, cmap_endlevel_charmap);
done_state = 0, done_tmp5 = 0, done_tmp6 = 0xf000, done_tmp1 = 0, done_coin = 0, done_sel = 1;
nt_scroll_x = 0, nt_scroll_y = 0xe8, nt_split_y0 = nt_split_y1 = -1;
}
@@ -1044,11 +1048,13 @@ static void scene(void *ctx) {
case S_SETTINGS: case S_FUN: keyline("Up Down: choose OK: switch Back: done"); break;
case S_CREDITS: keyline("OK: next Back: title"); break;
case S_PLAY:
+ if (DEBUG_MODE) gfx_fill_alpha(0, 200, 320, 1, HEX(0x808080), 256); /* (the game's gray line) */
if (phase == P_PAUSE || phase == P_QUIT) {
box(80, 52, 160, 124);
text_c(&np_font_title, 160, 80, "Paused", W());
const char *it[3] = {"Resume", practice_point_count ? "Practice off" : "Practice", phase == P_QUIT ? "Sure? OK quits" : "Quit game"};
for (int i = 0; i < 3; i++) button(96, 92 + i * 26, 128, 22, it[i], pause_sel == i);
+ if (DEBUG_MODE) text_c(&np_font_small, 160, 214, "Debug Left: gravity Right: mode", DIM());
keyline("Up Down: choose OK: go Back: resume");
} else if (practice_point_count && phase == P_RUN) {
if (frame < (uint32_t)auto_cp_seen + 240) keyline("Practice: Down places a checkpoint, backspace removes one");
diff --git a/games/famidash/tests/play.c b/games/famidash/tests/play.c
index 1f6f9b4d..f6977ec4 100644
--- a/games/famidash/tests/play.c
+++ b/games/famidash/tests/play.c
@@ -298,6 +298,31 @@ static void test_physics(void) {
}
/* ---------------------------------------------------------------- Stereo Madness, played */
+/* the debug mode: Select (backspace) with no checkpoints; no deaths, Right flips gravity, Select held ends the
+ level and it isn't counted */
+static void test_debug(void) {
+ fresh_level(0);
+ DEBUG_MODE = 0;
+ step_keys(PAD_SELECT), step_keys(0);
+ CHECK(DEBUG_MODE == 1 && cheated, "Select: the debug mode");
+ uint8_t g0 = player_gravity[0];
+ step_keys(PAD_RIGHT), step_keys(0);
+ CHECK(player_gravity[0] != g0, "Right flips the gravity");
+ int f = 0;
+ while (f < 60 * 40 && !game_dead() && gameState != STATE_LVLDONE) step_keys(0), f++;
+ CHECK(!game_dead() && f > 600, "nothing kills (%d frames)", f);
+ step_keys(PAD_SELECT), step_keys(0);
+ CHECK(!DEBUG_MODE, "Select again: off");
+ for (int i = 0; i < 62 && gameState != STATE_LVLDONE; i++) step_keys(PAD_SELECT); /* (on, then held) */
+ CHECK(DEBUG_MODE && gameState == STATE_LVLDONE, "Select held a second ends the level");
+ uint8_t was = prog.complete[0];
+ prog.complete[0] = 0;
+ set_completion_data();
+ CHECK(!prog.complete[0], "and it doesn't count");
+ prog.complete[0] = was;
+ DEBUG_MODE = 0, cheated = 0;
+}
+
static void test_run(void) {
memset(bot_hold, 0, sizeof bot_hold);
for (unsigned i = 0; i < sizeof stereo_madness / sizeof stereo_madness[0]; i += 2)
@@ -612,6 +637,7 @@ int main(int argc, char **argv) {
}
if (!strcmp(mode, "test")) {
test_physics();
+ test_debug();
test_run();
test_practice();
test_saves();