diff options
| author | 2026-07-18 13:34:49 -0400 | |
|---|---|---|
| committer | 2026-07-18 13:45:01 -0400 | |
| commit | 72f5ec3ce777fc05150856f1841e60b0f5c9f8f7 (patch) | |
| tree | 9b26fd3b314bcf3a2259704c076d819212f172f0 /lib | |
| parent | e6b1631d27f9fe54f3cdd3d7ee1e65d726927e3c (diff) | |
| download | cetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.tar.gz cetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.tar.bz2 cetris-72f5ec3ce777fc05150856f1841e60b0f5c9f8f7.zip | |
restore old frontends as they were
Minimal changes, just enough to get them building and running.
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/cetris.h | 42 | ||||
| -rwxr-xr-x | lib/rules.h | 13 |
2 files changed, 32 insertions, 23 deletions
diff --git a/lib/cetris.h b/lib/cetris.h index a400779..7525cd2 100755 --- a/lib/cetris.h +++ b/lib/cetris.h @@ -6,10 +6,6 @@ #include <string.h> #include <time.h> -#ifndef CETRIS_ENABLE_DAS -#define CETRIS_ENABLE_DAS 1 -#endif - typedef struct { char x; @@ -109,7 +105,8 @@ typedef struct bool (*win_condition)(ctrs_game *); } ctrs_config; -typedef struct { +typedef struct +{ unsigned char move_event; unsigned char hold_event; @@ -123,10 +120,10 @@ typedef struct { bool start_game; bool stop_game; - } ctrs_events; -struct ctrs_game { +struct ctrs_game +{ // playfield represented by a 2d array unsigned char **board; @@ -183,7 +180,7 @@ struct ctrs_game { ctrs_config config; }; -const ctrs_matrix ctrs_default_matrices[7] = +static const ctrs_matrix ctrs_default_matrices[7] = { { 0b0000, 0b1100, 0b0110, 0b0000}, { 0b0000, 0b0010, 0b1110, 0b0000}, @@ -195,7 +192,8 @@ const ctrs_matrix ctrs_default_matrices[7] = }; // https://tetris.wiki/SRS -static const ctrs_vec2 srs_wall_kicks[8][5] = { +static const ctrs_vec2 srs_wall_kicks[8][5] = +{ {{0, 0}, {-1, 0}, {-1, 1}, {0, -2}, {-1, -2}}, // 0->R {{0, 0}, {1, 0}, {1, -1}, {0, 2}, {1, 2}}, // R->0 {{0, 0}, {1, 0}, {1, -1}, {0, 2}, {1, 2}}, // R->2 @@ -206,7 +204,8 @@ static const ctrs_vec2 srs_wall_kicks[8][5] = { {{0, 0}, {1, 0}, {1, 1}, {0, -2}, {1, -2}} // 0->L }; -static const ctrs_vec2 srs_wall_kicks_i[8][5] = { +static const ctrs_vec2 srs_wall_kicks_i[8][5] = +{ {{0, 0}, {-2, 0}, {1, 0}, {-2, -1}, {1, 2}}, // 0->R {{0, 0}, {2, 0}, {-1, 0}, {2, 1}, {-1, -2}}, // R->0 {{0, 0}, {-1, 0}, {2, 0}, {-1, 2}, {2, -1}}, // R->2 @@ -217,14 +216,15 @@ static const ctrs_vec2 srs_wall_kicks_i[8][5] = { {{0, 0}, {-1, 0}, {2, 0}, {-1, 2}, {2, -1}} // 0->L }; -static const ctrs_vec2 basic_movements[3] = { +static const ctrs_vec2 basic_movements[3] = +{ {0, 1}, {1, 0}, {-1, 0} // DOWN, RIGHT, LEFT }; static void update_board(ctrs_game *g); static void -set_piece(ctrs_game *g, unsigned char type, ctrs_mino* mino) +set_piece(ctrs_game *g, unsigned char type, ctrs_mino *mino) { memset(mino, 0, sizeof(ctrs_mino)); @@ -383,8 +383,10 @@ move_current(ctrs_game *g, unsigned char move) g->events.move_event++; if (g->current.lock_tick) g->current.lock_tick = g->tick + g->config.lock_delay; +#if CETRIS_ENABLE_DAS if (move == DOWN && g->held_moves[DOWN]) g->score++; +#endif } update_board(g); @@ -652,7 +654,7 @@ update_board(ctrs_game *g) if (g->lines >= (g->level * 10)) g->level++; } -void +static void ctrs_hold_piece(ctrs_game *g) { if (g->current.held) return; @@ -676,8 +678,8 @@ ctrs_hold_piece(ctrs_game *g) } #if CETRIS_ENABLE_DAS -void -ctrs_unhold_move(ctrs_game* g, unsigned char move) +static void +ctrs_unhold_move(ctrs_game *g, unsigned char move) { if (!g->held_moves[move]) return; @@ -706,7 +708,7 @@ ctrs_unhold_move(ctrs_game* g, unsigned char move) } #endif -void +static void ctrs_move_piece(ctrs_game *g, unsigned char move) { #if CETRIS_ENABLE_DAS @@ -752,7 +754,7 @@ ctrs_move_piece(ctrs_game *g, unsigned char move) } } -void +static void ctrs_init_game(ctrs_game *g) { srand(time(NULL)); @@ -772,6 +774,8 @@ ctrs_init_game(ctrs_game *g) g->line_remove_tick = (unsigned long *)calloc(g->config.board_y, sizeof(unsigned long)); + g->events.lock_event.processed = true; + g->waiting = false; g->level = g->config.starting_level; @@ -787,7 +791,7 @@ ctrs_init_game(ctrs_game *g) next_piece(g); } -bool +static bool ctrs_update_game_tick(ctrs_game *g) { if (g->game_over) @@ -809,11 +813,13 @@ ctrs_update_game_tick(ctrs_game *g) if (!g->next_drop_tick) { +#if CETRIS_ENABLE_DAS if (g->held_moves[DOWN]) { g->next_drop_tick = g->tick + g->config.drop_period; } else +#endif { if (g->level <= 20) g->next_drop_tick = g->tick + g->config.levels[g->level - 1]; diff --git a/lib/rules.h b/lib/rules.h index c18104e..ac441a8 100755 --- a/lib/rules.h +++ b/lib/rules.h @@ -3,37 +3,40 @@ #include "cetris.h" -bool twenty_line_sprint(ctrs_game *g) +static bool twenty_line_sprint(ctrs_game *g) { return g->lines >= 20; } -bool forty_line_sprint(ctrs_game *g) +static bool forty_line_sprint(ctrs_game *g) { return g->lines >= 40; } -bool marathon(ctrs_game *g) +static bool marathon(ctrs_game *g) { + (void)g; return false; } // https://tetris.fandom.com/wiki/Tetris_Worlds -unsigned long tetris_worlds_levels[20] = +static unsigned long tetris_worlds_levels[20] = { 1000, 793, 618, 473, 355, 262, 189, 134, 94, 64, 43, 28, 18, 11, 7, 4, 2, 1, 1, 1 }; // https://tetris.fandom.com/wiki/Tetris_DS -ctrs_config tetris_ds_config = { +static ctrs_config tetris_ds_config = { .drop_period = 83, .next_piece_delay = 666, .line_delay_clear = 666, .lock_delay = 500, .force_lock = 0, +#if CETRIS_ENABLE_DAS .das_arr = 83, .das_das = 183, +#endif .board_x = 10, .board_y = 43, .board_visible = 20, |