mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 14:05:45 +01:00
update pointer alignment rule
This commit is contained in:
@@ -85,9 +85,9 @@ BinPackArguments: true
|
||||
# pointer alignment
|
||||
# ---------------------------
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
PointerAlignment: Right
|
||||
ReferenceAlignment: Pointer
|
||||
QualifierAlignment: Right
|
||||
QualifierAlignment: Left
|
||||
|
||||
# ---------------------------
|
||||
# include settings and sorting
|
||||
|
||||
@@ -55,7 +55,7 @@ static int plcmnt_valid(u8* restrict const* restrict const rows, i8vec2 pos) {
|
||||
!rows[pos[VY]][pos[VX]];
|
||||
}
|
||||
|
||||
static int plcmnt_intersect(u8* restrict const* restrict const rows, u8 const id, i8vec2 pos) {
|
||||
static int plcmnt_intersect(u8 *restrict const *restrict const rows, const u8 id, i8vec2 pos) {
|
||||
i8vec2 bpos[4];
|
||||
shape_getblocks(id, bpos);
|
||||
return !(plcmnt_valid(rows, pos + bpos[0]) &&
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "../util/types.h"
|
||||
|
||||
struct audioplayer {
|
||||
u8 const* buf;
|
||||
const u8 *buf;
|
||||
int len;
|
||||
};
|
||||
|
||||
@@ -25,13 +25,13 @@ static struct audiodevice {
|
||||
|
||||
struct audiodata audio_dat[AUDIO_ID_COUNT] = {0}; // contains pointers to audio buffers.
|
||||
|
||||
static char const* const audio_path[AUDIO_ID_COUNT] = {
|
||||
static const char *const audio_path[AUDIO_ID_COUNT] = {
|
||||
"korobeiniki.wav",
|
||||
"place.wav",
|
||||
};
|
||||
|
||||
/* mixes the audio output stream, using the different audio as sources */
|
||||
static void audiomixer(void* const userdata, u8* const stream, int const len) {
|
||||
static void audiomixer(void *const userdata, u8 *const stream, const int len) {
|
||||
(void)userdata;
|
||||
memset(stream, 0, len); // clear the playing audio
|
||||
|
||||
@@ -50,7 +50,7 @@ static void audiomixer(void* const userdata, u8* const stream, int const len) {
|
||||
* `len` is a pointer to the current size, the new size will be written to this location.
|
||||
* returns the pointer to the audio buffer to use, or NULL, when something went wrong.
|
||||
* NULL will never be returned after the conversion */
|
||||
static u8* audio_cvt(SDL_AudioSpec const* spec, u8* bufptr, unsigned* len) {
|
||||
static u8 *audio_cvt(const SDL_AudioSpec *spec, u8 *bufptr, unsigned *len) {
|
||||
if (!bufptr) return NULL;
|
||||
|
||||
// init the converter
|
||||
@@ -91,7 +91,7 @@ static inline u32 audio_btoms(u32 len) {
|
||||
}
|
||||
|
||||
/* loads a `struct audiodata` from `fpat` to `out`. */
|
||||
static void audio_wav_load(char const* restrict fpat, struct audiodata* restrict out) {
|
||||
static void audio_wav_load(const char *restrict fpat, struct audiodata *restrict out) {
|
||||
debug("loading audio file '%s'...", fpat);
|
||||
if (faccess(fpat, FA_R)) {
|
||||
error("audio file either isn't readable or doesn't exist. path: '%s'!", fpat);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define AUDIO_MAX 4 // maximum number of sound effects that are allowed to play at once
|
||||
|
||||
struct audiodata {
|
||||
u8 const* buf; // pointer to the audio buffer
|
||||
const u8 *buf; // pointer to the audio buffer
|
||||
u32 len; // length in bytes of the audio buffer
|
||||
u32 ms; // length in miliseconds of the audio buffer
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef union {
|
||||
#define COLOUR32_WHITE ((colour32){0xFFFFFFFF})
|
||||
|
||||
// sets the render colour to a colour32 value
|
||||
static inline void set_colour32(SDL_Renderer* const renderer, colour32 const c) {
|
||||
static inline void set_colour32(SDL_Renderer *const renderer, const colour32 c) {
|
||||
(void)SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, c.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,22 +18,22 @@ typedef uint8_t colour8;
|
||||
#define COLOUR8_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(const colour8 colour) {
|
||||
return (colour >> 5) * (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(const colour8 colour) {
|
||||
return ((colour >> 2) & 7) * (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(const colour8 colour) {
|
||||
return (colour & 3) * (255 / 3);
|
||||
}
|
||||
|
||||
// sets the render colour to a colour8 value
|
||||
static inline void set_colour8(SDL_Renderer* const renderer, colour8 const c) {
|
||||
static inline void set_colour8(SDL_Renderer *const renderer, const colour8 c) {
|
||||
(void)SDL_SetRenderDrawColor(renderer, colour8_red32(c), colour8_green32(c), colour8_blue32(c), 0xFF);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ static void draw_score_text(void) {
|
||||
}
|
||||
|
||||
static inline int draw_block(SDL_Renderer *const renderer, i8vec2 pos) {
|
||||
SDL_Rect const block = {colpos(pos[VX]), rowpos(pos[VY]), BLOCK_WIDTH - 1, BLOCK_HEIGHT - 1};
|
||||
const SDL_Rect block = {colpos(pos[VX]), rowpos(pos[VY]), BLOCK_WIDTH - 1, BLOCK_HEIGHT - 1};
|
||||
return SDL_RenderFillRect(renderer, &block);
|
||||
}
|
||||
|
||||
static void draw_shape(u8 const id, i8vec2 pos) {
|
||||
static void draw_shape(const u8 id, i8vec2 pos) {
|
||||
set_colour8(rend, colour_from_id(id));
|
||||
i8vec2 bpos[4];
|
||||
shape_getblocks(id, bpos);
|
||||
@@ -73,7 +73,7 @@ static void draw_shape(u8 const id, i8vec2 pos) {
|
||||
|
||||
static void render_level(void) {
|
||||
for (int y = 0; y < ROWS; y++) {
|
||||
u8 const* row = gdat->rows[y];
|
||||
const u8 *row = gdat->rows[y];
|
||||
|
||||
for (int x = 0; x < COLUMNS; x++) {
|
||||
if (row[x] != 0) {
|
||||
@@ -99,7 +99,7 @@ void render_update(void) {
|
||||
SDL_RenderClear(rend);
|
||||
set_colour32(rend, COLOUR32_WHITE);
|
||||
|
||||
static SDL_Rect const field_size = {TET_PADDING, TET_PADDING, TET_WIDTH + 1, TET_HEIGHT + 1};
|
||||
static const SDL_Rect field_size = {TET_PADDING, TET_PADDING, TET_WIDTH + 1, TET_HEIGHT + 1};
|
||||
SDL_RenderDrawRect(rend, &field_size);
|
||||
|
||||
if (font) draw_score_text();
|
||||
|
||||
@@ -46,7 +46,7 @@ enum faccess_perms {
|
||||
|
||||
/* tests a files access with F_OK, X_OK, R_OK, W_OK OR'd together
|
||||
returns 0 upon success. -1 when errno is set and anything else when one or more of the permissions isn't set */
|
||||
static inline int faccess(char const* restrict fname, int perms) {
|
||||
static inline int faccess(const char *restrict fname, int perms) {
|
||||
#if defined __unix__ && _POSIX_C_SOURCE >= 200809L
|
||||
return access(fname, perms);
|
||||
#elif defined _WIN32
|
||||
|
||||
Reference in New Issue
Block a user