From 94ca7e3d0891fa05eeebd799b053170d3c2cac97 Mon Sep 17 00:00:00 2001 From: Quinn Date: Mon, 10 Feb 2025 11:58:00 +0100 Subject: [PATCH] rename `Colour8` to `colour8` --- src/game/game.c | 2 +- src/game/game.h | 4 ++-- src/game/tetromino/placing.c | 2 +- src/game/tetromino/shapes.c | 2 +- src/game/tetromino/shapes.h | 2 +- src/window/colour8.h | 26 +++++++++++++------------- src/window/renderer.c | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/game/game.c b/src/game/game.c index 25d905a..fd86a95 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -48,7 +48,7 @@ void game_init(GameData* const game_data) { // allocate size for each row for (int8_t i = 0; i < ROWS; i++) { - game_data->rows[i] = calloc(COLUMNS, sizeof(Colour8)); + game_data->rows[i] = calloc(COLUMNS, sizeof(colour8)); // game_data->rows[i][0] = (colour8){(uint8_t)((((i + 1) ^ ((i + 1) >> 3)) * 0x27) & 0xFF)}; // for debugging rows } diff --git a/src/game/game.h b/src/game/game.h index 59fa1b3..dbe0790 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -10,8 +10,8 @@ #define COLUMNS ((int8_t)10) #define ROWS ((int8_t)24) -typedef const Colour8* const CRow; -typedef Colour8* Row; +typedef const colour8* const CRow; +typedef colour8* Row; typedef struct { Row rows[ROWS]; diff --git a/src/game/tetromino/placing.c b/src/game/tetromino/placing.c index 08d68db..584d6e1 100644 --- a/src/game/tetromino/placing.c +++ b/src/game/tetromino/placing.c @@ -59,7 +59,7 @@ 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, ShapeId const id, int8_t const pos_x) { Shape const shape = shape_from_id(id); - Colour8 const colour = colour_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); diff --git a/src/game/tetromino/shapes.c b/src/game/tetromino/shapes.c index 8cd9e14..c8b7e37 100644 --- a/src/game/tetromino/shapes.c +++ b/src/game/tetromino/shapes.c @@ -53,7 +53,7 @@ Shape shape_from_id(ShapeId const id) { return shapes[id & 7][id >> 3]; } -Colour8 colour_from_id(ShapeId const id) { +colour8 colour_from_id(ShapeId const id) { switch (id & 7) { case TETROMINO_O: return COLOUR_YELLOW; case TETROMINO_I: return COLOUR_CYAN; diff --git a/src/game/tetromino/shapes.h b/src/game/tetromino/shapes.h index 89abc6f..00ec00d 100644 --- a/src/game/tetromino/shapes.h +++ b/src/game/tetromino/shapes.h @@ -36,4 +36,4 @@ static inline bool is_set(ShapeRow const row, uint8_t const index) { } Shape shape_from_id(ShapeId id); -Colour8 colour_from_id(ShapeId id); +colour8 colour_from_id(ShapeId id); diff --git a/src/window/colour8.h b/src/window/colour8.h index 88fa83c..32ef4e0 100644 --- a/src/window/colour8.h +++ b/src/window/colour8.h @@ -9,30 +9,30 @@ typedef union { uint8_t g : 3; uint8_t r : 3; }; -} Colour8; +} colour8; /* rrrg ggbb */ -#define COLOUR_BLACK ((Colour8){0x00}) // 0000 0000 -#define COLOUR_RED ((Colour8){0xE0}) // 1110 0000 -#define COLOUR_YELLOW ((Colour8){0xFC}) // 1111 1100 -#define COLOUR_ORANGE ((Colour8){0xEC}) // 1111 1100 -#define COLOUR_GREEN ((Colour8){0x1C}) // 0001 1100 -#define COLOUR_CYAN ((Colour8){0x1F}) // 0001 1111 -#define COLOUR_BLUE ((Colour8){0x03}) // 0000 0011 -#define COLOUR_MAGENTA ((Colour8){0xE3}) // 1110 0011 -#define COLOUR_WHITE ((Colour8){0xFF}) // 1111 1111 +#define COLOUR_BLACK ((colour8){0x00}) // 0000 0000 +#define COLOUR_RED ((colour8){0xE0}) // 1110 0000 +#define COLOUR_YELLOW ((colour8){0xFC}) // 1111 1100 +#define COLOUR_ORANGE ((colour8){0xEC}) // 1111 1100 +#define COLOUR_GREEN ((colour8){0x1C}) // 0001 1100 +#define COLOUR_CYAN ((colour8){0x1F}) // 0001 1111 +#define COLOUR_BLUE ((colour8){0x03}) // 0000 0011 +#define COLOUR_MAGENTA ((colour8){0xE3}) // 1110 0011 +#define COLOUR_WHITE ((colour8){0xFF}) // 1111 1111 // gets the red channel in 32 bit colour space -static inline uint8_t colour8_red32(Colour8 const colour) { +static inline uint8_t colour8_red32(colour8 const colour) { return colour.r * (255 / 7); } // gets the green channel in 32 bit colour space -static inline uint8_t colour8_green32(Colour8 const colour) { +static inline uint8_t colour8_green32(colour8 const colour) { return colour.g * (255 / 7); } // gets the blue channel in 32 bit colour space -static inline uint8_t colour8_blue32(Colour8 const colour) { +static inline uint8_t colour8_blue32(colour8 const colour) { return colour.b * (255 / 3); } diff --git a/src/window/renderer.c b/src/window/renderer.c index e2ba287..772a1bb 100644 --- a/src/window/renderer.c +++ b/src/window/renderer.c @@ -69,7 +69,7 @@ static inline int draw_block(SDL_Renderer* const renderer, int8_t const x, int8_ } // sets the colour32 from the colour8 -static inline void set_colour(SDL_Renderer* const renderer, Colour8 const c) { +static inline void set_colour(SDL_Renderer* const renderer, colour8 const c) { (void)SDL_SetRenderDrawColor(renderer, colour8_red32(c), colour8_green32(c), colour8_blue32(c), 0xFF); }