From 663e28f08511b16d6367eaf93261fb84acdcb56e Mon Sep 17 00:00:00 2001 From: Quinn Date: Tue, 11 Feb 2025 21:53:17 +0100 Subject: [PATCH] rename more typedefs to lowercase --- src/game/game.c | 4 ++-- src/game/tetromino/placing.c | 10 +++++----- src/game/tetromino/placing.h | 4 ++-- src/game/tetromino/shapes.c | 4 ++-- src/game/tetromino/shapes.h | 10 +++++----- src/window/renderer.c | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/game/game.c b/src/game/game.c index 124697d..1444059 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -73,7 +73,7 @@ void game_update(game_data* const dat, uint8_t const* const keys) { if (keys[SDL_SCANCODE_ESCAPE]) stop(); - InputData move = MOVE_NONE; // contains the move data + input_data move = MOVE_NONE; // contains the move data uint32_t ctime = SDL_GetTicks(); if (ctime > dat->timer_update) { @@ -87,7 +87,7 @@ void game_update(game_data* const dat, uint8_t const* const keys) { } if (ctime > dat->timer_input) { - InputData umove = MOVE_NONE; + input_data umove = MOVE_NONE; // get the input data and apply it to move if (keys[SDL_SCANCODE_LEFT] || keys[SDL_SCANCODE_A]) umove |= MOVE_LEFT; diff --git a/src/game/tetromino/placing.c b/src/game/tetromino/placing.c index d22c003..28c3075 100644 --- a/src/game/tetromino/placing.c +++ b/src/game/tetromino/placing.c @@ -59,10 +59,10 @@ static void clear_rows(row* const rows, uint16_t* const score) { // sets a shape to the screen static void set_shape_i(row const* const row, shape_id const id, int8_t const pos_x) { - Shape const shape = shape_from_id(id); + shape const shape = shape_from_id(id); colour8 const colour = colour_from_id(id); for (int8_t y = 0; y < SHAPE_HEIGHT; y++) { - ShapeRow const shape_row = shape_get_row(shape, y); + shape_row const shape_row = shape_get_row(shape, y); if (shape_row == 0) continue; @@ -78,10 +78,10 @@ static inline void set_shape(row const* const row, shape_id const id, int8_t con } static bool shape_intersects(row const* const rows, shape_id const id, int8_t const x, int8_t const y) { - Shape const shape = shape_from_id(id); + shape const shape = shape_from_id(id); for (int8_t y0 = 0; y0 < SHAPE_HEIGHT; y0++) { - ShapeRow const shape_row = shape_get_row(shape, y0); // get the shape row + shape_row const shape_row = shape_get_row(shape, y0); // get the shape row if (shape_row == 0) continue; // if the row doesn't contain data; continue for (int8_t x0 = 0; x0 < SHAPE_WIDTH; x0++) { @@ -101,7 +101,7 @@ static inline shape_id rotate_id(shape_id const id, int const dir) { return (id + dir) & 31; } -void place_update(game_data* const game_data, InputData const move) { +void place_update(game_data* const game_data, input_data const move) { // store the current index and ID, only changes when placed (which yields no movement) and rotation (which occurs last) uint8_t const curr_idx = game_data->curr_idx; shape_id const curr_id = game_data->nxt[curr_idx]; diff --git a/src/game/tetromino/placing.h b/src/game/tetromino/placing.h index c79bea1..23be325 100644 --- a/src/game/tetromino/placing.h +++ b/src/game/tetromino/placing.h @@ -5,7 +5,7 @@ #include "../game.h" -typedef uint8_t InputData; +typedef uint8_t input_data; enum { MOVE_NONE = 0, MOVE_LEFT = 1, @@ -15,7 +15,7 @@ enum { MOVE_ROTRIGHT = 16, }; -void place_update(game_data* game_data, InputData move); +void place_update(game_data* game_data, input_data move); #ifdef DEBUG void dbg_set_all(game_data* game_data); diff --git a/src/game/tetromino/shapes.c b/src/game/tetromino/shapes.c index 137df99..cfbeeba 100644 --- a/src/game/tetromino/shapes.c +++ b/src/game/tetromino/shapes.c @@ -35,9 +35,9 @@ #define SHAPE_J_180 ((Shape)0x6440) // 0110 0100 0100 0000 the J tetromino with a 180° rotation #define SHAPE_J_270 ((Shape)0x0E20) // 0000 1110 0010 0000 the J tetromino with a 270° rotation -Shape shape_from_id(shape_id const id) { +shape shape_from_id(shape_id const id) { // clang-format off - static Shape const shapes[TETROMINO_COUNT][4] = { + static shape const shapes[TETROMINO_COUNT][4] = { // 0° 90° 180° 170° {SHAPE_O, SHAPE_O, SHAPE_O, SHAPE_O}, {SHAPE_I, SHAPE_I_90, SHAPE_I_180, SHAPE_I_270}, diff --git a/src/game/tetromino/shapes.h b/src/game/tetromino/shapes.h index 806ad28..beee4b7 100644 --- a/src/game/tetromino/shapes.h +++ b/src/game/tetromino/shapes.h @@ -4,8 +4,8 @@ #include "../../window/colour8.h" -typedef uint16_t Shape; -typedef uint8_t ShapeRow; +typedef uint16_t shape; +typedef uint8_t shape_row; typedef uint8_t shape_id; enum { @@ -27,13 +27,13 @@ enum { -static inline ShapeRow shape_get_row(Shape const shape, uint8_t const index) { +static inline shape_row shape_get_row(shape const shape, uint8_t const index) { return shape >> (((SHAPE_HEIGHT - 1) - index) * SHAPE_WIDTH) & 0xF; } -static inline bool is_set(ShapeRow const row, uint8_t const index) { +static inline bool is_set(shape_row const row, uint8_t const index) { return (row >> ((SHAPE_WIDTH - 1) - index) & 1) != 0; } -Shape shape_from_id(shape_id id); +shape shape_from_id(shape_id id); colour8 colour_from_id(shape_id id); diff --git a/src/window/renderer.c b/src/window/renderer.c index 4c2256e..ed89bc8 100644 --- a/src/window/renderer.c +++ b/src/window/renderer.c @@ -75,11 +75,11 @@ static inline void set_colour(SDL_Renderer* const renderer, colour8 const c) { // draws a shape at the specified position static void draw_shape(SDL_Renderer* const renderer, shape_id const id, int8_t const pos_x, int8_t const pos_y) { - Shape const shape = shape_from_id(id); + shape const shape = shape_from_id(id); set_colour(renderer, colour_from_id(id)); for (int8_t y = 0; y < SHAPE_HEIGHT; y++) { - ShapeRow const shape_row = shape_get_row(shape, y); + shape_row const shape_row = shape_get_row(shape, y); if (shape_row == 0) continue;