Parcourir la source

Add convenience typedefs

Use short names for int types.
feature/data-structs
TheoryOfNekomata il y a 2 ans
Parent
révision
d1999f7667
16 fichiers modifiés avec 100 ajouts et 86 suppressions
  1. +9
    -9
      src/packages/game/IZ_app.c
  2. +3
    -1
      src/packages/game/IZ_app.h
  3. +13
    -3
      src/packages/game/IZ_common.h
  4. +2
    -1
      src/packages/game/core/IZ_creature.h
  5. +3
    -1
      src/packages/game/geometry/IZ_point2d.h
  6. +2
    -2
      src/packages/game/input/IZ_action.h
  7. +1
    -1
      src/packages/game/input/IZ_input.c
  8. +0
    -1
      src/packages/game/input/IZ_input.h
  9. +11
    -11
      src/packages/game/input/IZ_joystick.c
  10. +3
    -3
      src/packages/game/input/IZ_joystick.h
  11. +8
    -8
      src/packages/game/input/IZ_keyboard.c
  12. +22
    -22
      src/packages/game/input/IZ_midi.c
  13. +4
    -4
      src/packages/game/input/IZ_midi.h
  14. +7
    -7
      src/packages/game/input/input.test.c
  15. +9
    -9
      src/packages/game/output/IZ_video.c
  16. +3
    -3
      src/packages/game/output/IZ_video.h

+ 9
- 9
src/packages/game/IZ_app.c Voir le fichier

@@ -30,26 +30,26 @@ void IZ_TeardownApp(IZ_App* app) {
}

void IZ_HandleSDLEvents(IZ_App* app) {
while (SDL_PollEvent(&app->input_state.sdl_event) != 0) {
if (app->input_state.sdl_event.type == SDL_QUIT) {
while (SDL_PollEvent(&app->sdl_event) != 0) {
if (app->sdl_event.type == SDL_QUIT) {
app->quit = true;
break;
}

IZ_HandleSDLInputEvents(app->input_state.sdl_event, &app->input_state);
IZ_HandleSDLInputEvents(app->sdl_event, &app->input_state);
}
}

void IZ_HandlePortMIDIEvents(IZ_App* app) {
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
int32_t midi_events_count = Pm_Read(
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
i32 midi_events_count = Pm_Read(
app->input_state.midi_input_state[player_index].stream,
app->input_state.midi_input_state[player_index].event_buffer,
1024
);

if (midi_events_count > 0) {
for (int32_t midi_event_index = 0; midi_event_index < midi_events_count; midi_event_index += 1) {
for (i32 midi_event_index = 0; midi_event_index < midi_events_count; midi_event_index += 1) {
IZ_HandlePortMIDIInputEvents(
app->input_state.midi_input_state->event_buffer[midi_event_index],
&app->input_state
@@ -64,9 +64,9 @@ void IZ_HandleEvents(IZ_App* app) {
IZ_HandlePortMIDIEvents(app);
}

IZ_ProcedureResult IZ_RunApp(IZ_App* app, uint8_t argc, char* argv[]) {
IZ_ProcedureResult IZ_RunApp(IZ_App* app, u8 argc, char* argv[]) {
printf_s("Args (%u):\n", argc);
for (uint8_t i = 0; i < argc; i += 1) {
for (u8 i = 0; i < argc; i += 1) {
printf_s(" %s", argv[i]);
}

@@ -76,7 +76,7 @@ IZ_ProcedureResult IZ_RunApp(IZ_App* app, uint8_t argc, char* argv[]) {
}

while (true) {
uint64_t ticks = SDL_GetTicks64();
u64 ticks = SDL_GetTicks64();

// TODO do audio processing
// TODO do networking?


+ 3
- 1
src/packages/game/IZ_app.h Voir le fichier

@@ -8,6 +8,8 @@
#include "memory/IZ_pool.h"

typedef struct {
SDL_Event sdl_event;

IZ_InputState input_state;
IZ_VideoState video_state;

@@ -15,6 +17,6 @@ typedef struct {
bool quit;
} IZ_App;

IZ_ProcedureResult IZ_RunApp(IZ_App*, uint8_t, char**);
IZ_ProcedureResult IZ_RunApp(IZ_App*, u8, char**);

#endif

+ 13
- 3
src/packages/game/IZ_common.h Voir le fichier

@@ -3,10 +3,20 @@

#include <stdint.h>

#define PLAYERS 1
#define PLAYERS (unsigned char) 1
#define APP_NAME "SDL2"

static const char* APP_NAME = "SDL2";
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef float f32;
typedef double f64;
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;

typedef uint8_t IZ_ProcedureResult;
typedef u8 IZ_ProcedureResult;

#endif

+ 2
- 1
src/packages/game/core/IZ_creature.h Voir le fichier

@@ -1,12 +1,13 @@
#ifndef IZ_CREATURE_H
#define IZ_CREATURE_H

#include "../IZ_common.h"
#include "IZ_object.h"

typedef struct {
IZ_Object as_object;

float hp;
f32 hp;
} IZ_Creature;

#endif

+ 3
- 1
src/packages/game/geometry/IZ_point2d.h Voir le fichier

@@ -1,7 +1,9 @@
#ifndef IZ_POINT2D_H
#define IZ_POINT2D_H

typedef float IZ_GeoCoord;
#include "../IZ_common.h"

typedef f32 IZ_GeoCoord;

typedef struct {
IZ_GeoCoord x;


+ 2
- 2
src/packages/game/input/IZ_action.h Voir le fichier

@@ -3,9 +3,9 @@

#include "../IZ_common.h"

#define CONTROLS 16
#define CONTROLS (unsigned char) 16

typedef uint16_t IZ_Action;
typedef u16 IZ_Action;

static const char* ACTION_NAMES[CONTROLS] = {
"Up",


+ 1
- 1
src/packages/game/input/IZ_input.c Voir le fichier

@@ -27,7 +27,7 @@ void IZ_InitializeInput(const char* config_path, IZ_InputState* state) {
fprintf_s(stderr, "Error committing MIDI input config. Code: %u.\n", midi_input_result);
}

for (uint8_t p = 0; p < PLAYERS; p += 1) {
for (u8 p = 0; p < PLAYERS; p += 1) {
state->action[p] = 0;
}
}


+ 0
- 1
src/packages/game/input/IZ_input.h Voir le fichier

@@ -8,7 +8,6 @@

typedef struct {
IZ_Action action[PLAYERS];
SDL_Event sdl_event;
IZ_KeyboardState keyboard_state[PLAYERS];
IZ_JoystickState joystick_state[PLAYERS];
IZ_MIDIInputState midi_input_state[PLAYERS];


+ 11
- 11
src/packages/game/input/IZ_joystick.c Voir le fichier

@@ -65,9 +65,9 @@ void IZ_HandleJoystickHatEvents(SDL_Event e, IZ_Action* action) {
}

void IZ_HandleJoystickButtonEvents(SDL_Event e, IZ_JoystickState* state, IZ_Action* action) {
for (uint8_t i = 4; i < CONTROLS; i += 1) {
for (u8 i = 4; i < CONTROLS; i += 1) {
if (e.jbutton.button == state->config.control_mapping[i]) {
const uint16_t bitflag = (0x1 << i);
const u16 bitflag = (0x1 << i);

if (e.type == SDL_JOYBUTTONDOWN) {
*action |= bitflag;
@@ -83,7 +83,7 @@ void IZ_HandleJoystickButtonEvents(SDL_Event e, IZ_JoystickState* state, IZ_Acti
}

void IZ_HandleJoystickEvents(SDL_Event e, IZ_JoystickState(* state)[PLAYERS], IZ_Action(* action)[PLAYERS]) {
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
IZ_HandleJoystickDeviceEvents(e, state[player_index]);
IZ_HandleJoystickAxisEvents(e, state[player_index], action[player_index]);
IZ_HandleJoystickHatEvents(e, action[player_index]);
@@ -94,10 +94,10 @@ void IZ_HandleJoystickEvents(SDL_Event e, IZ_JoystickState(* state)[PLAYERS], IZ
void IZ_LoadJoystickConfig(const char* config_path, IZ_JoystickState(* state)[PLAYERS]) {
char control_mapping_section_name[26];
char main_section_name[11];
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(control_mapping_section_name, 26, "Joystick.%d.ControlMapping", player_index);

for (uint8_t i = 4; i < CONTROLS; i += 1) {
for (u8 i = 4; i < CONTROLS; i += 1) {
state[player_index]->config.control_mapping[i] = ini_getl(
control_mapping_section_name,
ACTION_NAMES[i],
@@ -113,14 +113,14 @@ void IZ_LoadJoystickConfig(const char* config_path, IZ_JoystickState(* state)[PL
}

IZ_ProcedureResult IZ_SaveJoystickConfig(const char* config_path, IZ_JoystickState(* state)[PLAYERS]) {
uint8_t problem = 0;
u8 problem = 0;

char control_mapping_section_name[26];
char main_section_name[11];

for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(control_mapping_section_name, 26, "Joystick.%d.ControlMapping", player_index);
for (uint8_t i = 4; i < CONTROLS; i += 1) {
for (u8 i = 4; i < CONTROLS; i += 1) {
if (!ini_putl(
control_mapping_section_name,
ACTION_NAMES[i],
@@ -162,8 +162,8 @@ IZ_ProcedureResult IZ_InitializeJoystickState(const char* config_path, IZ_Joysti
return 1;
}

uint8_t joysticks_count = SDL_NumJoysticks();
for (uint8_t player_index = 0; player_index < joysticks_count; player_index += 1) {
u8 joysticks_count = SDL_NumJoysticks();
for (u8 player_index = 0; player_index < joysticks_count; player_index += 1) {
state[player_index]->device = SDL_JoystickOpen(state[player_index]->config.device_id);
}

@@ -171,7 +171,7 @@ IZ_ProcedureResult IZ_InitializeJoystickState(const char* config_path, IZ_Joysti
}

void IZ_TeardownJoystickState(IZ_JoystickState(* state)[PLAYERS]) {
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
if (!state[player_index]->device) {
continue;
}


+ 3
- 3
src/packages/game/input/IZ_joystick.h Voir le fichier

@@ -6,9 +6,9 @@
#include <minIni.h>
#include "IZ_action.h"

typedef uint8_t IZ_PadButton;
typedef u8 IZ_PadButton;

static const uint16_t IZ_DEFAULT_AXIS_THRESHOLD = 8000;
static const u16 IZ_DEFAULT_AXIS_THRESHOLD = 8000;

typedef enum {
IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 = 0,
@@ -18,7 +18,7 @@ typedef enum {
} IZ_JoyAxisDirection;

typedef struct {
uint16_t axis_threshold;
u16 axis_threshold;
SDL_JoystickID device_id;
IZ_PadButton control_mapping[CONTROLS];
} IZ_JoystickConfig;


+ 8
- 8
src/packages/game/input/IZ_keyboard.c Voir le fichier

@@ -1,9 +1,9 @@
#include "IZ_keyboard.h"

void IZ_HandleKewyboardKeyUpDownEvents(SDL_Event e, IZ_KeyboardState* state, IZ_Action* action) {
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
if (e.key.keysym.sym == state->config.control_mapping[i]) {
const uint16_t bitflag = (0x1 << i);
const u16 bitflag = (0x1 << i);
if (e.type == SDL_KEYDOWN) {
*action |= bitflag;
return;
@@ -17,17 +17,17 @@ void IZ_HandleKewyboardKeyUpDownEvents(SDL_Event e, IZ_KeyboardState* state, IZ_
}

void IZ_HandleKeyboardEvents(SDL_Event e, IZ_KeyboardState(* state)[PLAYERS], IZ_Action(* action)[PLAYERS]) {
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
IZ_HandleKewyboardKeyUpDownEvents(e, state[player_index], action[player_index]);
}
}

IZ_ProcedureResult IZ_SaveKeyboardConfig(const char* config_path, IZ_KeyboardState(* state)[PLAYERS]) {
uint8_t problem = 0;
u8 problem = 0;
char control_mapping_section_name[26];
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(control_mapping_section_name, 26, "Keyboard.%d.ControlMapping", player_index);
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
if (!ini_puts(
control_mapping_section_name,
ACTION_NAMES[i],
@@ -45,9 +45,9 @@ IZ_ProcedureResult IZ_SaveKeyboardConfig(const char* config_path, IZ_KeyboardSta
void IZ_LoadKeyboardConfig(const char* config_path, IZ_KeyboardState(* state)[PLAYERS]) {
char buffer[128];
char keyboard_section_name[26];
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(keyboard_section_name, 26, "Keyboard.%d.ControlMapping", player_index);
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
ini_gets(
keyboard_section_name,
ACTION_NAMES[i],


+ 22
- 22
src/packages/game/input/IZ_midi.c Voir le fichier

@@ -1,6 +1,6 @@
#include "IZ_midi.h"

char* IZ_GetMIDINoteName(uint8_t midi_note) {
char* IZ_GetMIDINoteName(u8 midi_note) {
static const char* pitch_names[] = {
"C",
"C#",
@@ -16,24 +16,24 @@ char* IZ_GetMIDINoteName(uint8_t midi_note) {
"B"
};

const uint8_t pitch_class = midi_note % 12;
const uint8_t octave = midi_note / 12;
const u8 pitch_class = midi_note % 12;
const u8 octave = midi_note / 12;
static char note_name[4];
sprintf_s(note_name, 4, "%s%u", pitch_names[pitch_class], octave);
return note_name;
}

uint8_t IZ_GetMIDINoteFromName(char* name) {
u8 IZ_GetMIDINoteFromName(char* name) {
char name_copy[4];
memcpy_s(name_copy, 4, name, 4);
_strlwr_s(name_copy, 4);

uint8_t octave;
u8 octave;
const char base_pitch_name[] = "c d ef g a b";

if (strlen(name_copy) == 2) {
octave = name_copy[1] - '0';
for (uint8_t i = 0; i < 12; i += 1) {
for (u8 i = 0; i < 12; i += 1) {
if (base_pitch_name[i] == name_copy[0]) {
return (octave * 12) + i;
}
@@ -41,7 +41,7 @@ uint8_t IZ_GetMIDINoteFromName(char* name) {
return 255u;
}

uint8_t pitch_class;
u8 pitch_class;
octave = name_copy[2] - '0';
if (strstr(name_copy, "c#") || strstr(name_copy, "db")) {
pitch_class = 1;
@@ -61,13 +61,13 @@ uint8_t IZ_GetMIDINoteFromName(char* name) {
}

void IZ_HandleMIDINoteOnOffEvents(PmEvent e, IZ_MIDIInputState* state, IZ_Action* action) {
uint32_t message = e.message;
uint8_t status = message & 0xF0u;
uint8_t channel = message & 0x0Fu;
uint8_t data1 = (message >> 8) & 0xFFu;
// uint8_t data2 = (message >> 16) & 0xFFu;
u32 message = e.message;
u8 status = message & 0xF0u;
u8 channel = message & 0x0Fu;
u8 data1 = (message >> 8) & 0xFFu;
// u8 data2 = (message >> 16) & 0xFFu;

for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
if (
data1 == state->config.control_mapping[i]
&& (
@@ -75,7 +75,7 @@ void IZ_HandleMIDINoteOnOffEvents(PmEvent e, IZ_MIDIInputState* state, IZ_Action
|| state->config.channel >= 16
)
) {
const uint16_t bitflag = (0x1 << i);
const u16 bitflag = (0x1 << i);
if (status == IZ_MIDI_NOTE_ON) {
*action |= bitflag;
return;
@@ -89,20 +89,20 @@ void IZ_HandleMIDINoteOnOffEvents(PmEvent e, IZ_MIDIInputState* state, IZ_Action
}

void IZ_HandleMIDIInputEvents(PmEvent e, IZ_MIDIInputState(* state)[PLAYERS], IZ_Action(* action)[PLAYERS]) {
for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
IZ_HandleMIDINoteOnOffEvents(e, state[player_index], action[player_index]);
}
}

IZ_ProcedureResult IZ_SaveMIDIInputConfig(const char* config_path, IZ_MIDIInputState(* state)[PLAYERS]) {
uint8_t problem = 0;
u8 problem = 0;

char control_mapping_section_name[27];
char main_section_name[12];

for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(control_mapping_section_name, 27, "MIDIInput.%d.ControlMapping", player_index);
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
if (!ini_puts(
control_mapping_section_name,
ACTION_NAMES[i],
@@ -141,9 +141,9 @@ void IZ_LoadMIDIInputConfig(const char* config_path, IZ_MIDIInputState(* state)[
char control_mapping_section_name[27];
char main_section_name[12];

for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
sprintf_s(control_mapping_section_name, 27, "MIDIInput.%d.ControlMapping", player_index);
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
ini_gets(
control_mapping_section_name,
ACTION_NAMES[i],
@@ -173,7 +173,7 @@ IZ_ProcedureResult IZ_InitializeMIDIInput(const char* config_path, IZ_MIDIInputS
return 2;
}

for (uint8_t player_index = 0; player_index < PLAYERS; player_index += 1) {
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) {
state[player_index]->device_info = Pm_GetDeviceInfo(state[player_index]->config.device_id);
state[player_index]->stream = NULL;
Pm_OpenInput(
@@ -190,7 +190,7 @@ IZ_ProcedureResult IZ_InitializeMIDIInput(const char* config_path, IZ_MIDIInputS
}

void IZ_TeardownMIDIInput(IZ_MIDIInputState(* state)[PLAYERS]) {
for (uint8_t i = 0; i < PLAYERS; i += 1) {
for (u8 i = 0; i < PLAYERS; i += 1) {
if (!state[i]->stream) {
continue;
}


+ 4
- 4
src/packages/game/input/IZ_midi.h Voir le fichier

@@ -9,15 +9,15 @@

#define MIDI_EVENT_BUFFER_SIZE 1024

typedef uint8_t IZ_MIDINote;
typedef u8 IZ_MIDINote;

static const uint8_t IZ_MIDI_NOTE_ON = 0x90u;
static const u8 IZ_MIDI_NOTE_ON = 0x90u;

static const uint8_t IZ_MIDI_NOTE_OFF = 0x80u;
static const u8 IZ_MIDI_NOTE_OFF = 0x80u;

typedef struct {
PmDeviceID device_id;
uint8_t channel;
u8 channel;
IZ_MIDINote control_mapping[CONTROLS];
} IZ_MIDIInputConfig;



+ 7
- 7
src/packages/game/input/input.test.c Voir le fichier

@@ -4,11 +4,11 @@
#include "IZ_keyboard.h"
#include "IZ_joystick.h"

int16_t GenerateAxisValueWithinThreshold(uint16_t threshold) {
i16 GenerateAxisValueWithinThreshold(u16 threshold) {
return rand() % threshold;
}

int16_t GenerateAxisValueOutsideThreshold(uint16_t threshold) {
i16 GenerateAxisValueOutsideThreshold(u16 threshold) {
return threshold + (rand() % (RAND_MAX - threshold - 1)) + 1;
}

@@ -199,7 +199,7 @@ spec("input") {
e.type = SDL_JOYHATMOTION;
}

for (uint8_t i = 0; i < 4; i += 1) {
for (u8 i = 0; i < 4; i += 1) {
it("handles motion for %s action", ACTION_NAMES[i]) {
e.jhat.value = (0x1u << i);
action = 0;
@@ -225,7 +225,7 @@ spec("input") {
}

describe("on button events") {
for (uint8_t i = 4; i < CONTROLS; i += 1) {
for (u8 i = 4; i < CONTROLS; i += 1) {
it("handles %s action activation", ACTION_NAMES[i]) {
e.type = SDL_JOYBUTTONDOWN;
e.jbutton.button = IZ_DEFAULT_JOYSTICK_STATE[0][i];
@@ -284,7 +284,7 @@ spec("input") {
}

before_each() {
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
config.control_mapping[i] = IZ_DEFAULT_JOYSTICK_STATE[0][i];
}
}
@@ -310,7 +310,7 @@ spec("input") {
static IZ_KeyboardState state;
static IZ_Action action;

for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
it("handles %s action activation", ACTION_NAMES[i]) {
e.type = SDL_KEYDOWN;
e.key.keysym.sym = IZ_DEFAULT_KEYBOARD_STATE[0][i];
@@ -368,7 +368,7 @@ spec("input") {
}

before_each() {
for (uint8_t i = 0; i < CONTROLS; i += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
config.control_mapping[i] = IZ_DEFAULT_KEYBOARD_STATE[0][i];
}
}


+ 9
- 9
src/packages/game/output/IZ_video.c Voir le fichier

@@ -55,10 +55,10 @@ void IZ_UpdateVideo(IZ_VideoState* video_state, IZ_InputState* input_states, uin

SDL_SetRenderDrawColor(video_state->renderer, 0x00, 0xff, 0xff, 0xff);
uint64_t the_ticks = ticks;
for (uint8_t i = 0; i < 64; i += 1) {
const uint8_t column = i % 32;
const uint8_t row = i / 32;
const uint8_t size = 4;
for (u8 i = 0; i < 64; i += 1) {
const u8 column = i % 32;
const u8 row = i / 32;
const u8 size = 4;

if (the_ticks & 0x1) {
SDL_RenderFillRectF(video_state->renderer, &(SDL_FRect) {
@@ -73,12 +73,12 @@ void IZ_UpdateVideo(IZ_VideoState* video_state, IZ_InputState* input_states, uin

SDL_SetRenderDrawColor(video_state->renderer, 0xff, 0xff, 0x00, 0xff);
// TODO refer to app's state
for (uint8_t p = 0; p < PLAYERS; p += 1) {
for (uint8_t i = 0; i < CONTROLS; i += 1) {
const uint8_t column = (i % 4) + (p * 4);
const uint8_t row = i / 4;
for (u8 p = 0; p < PLAYERS; p += 1) {
for (u8 i = 0; i < CONTROLS; i += 1) {
const u8 column = (i % 4) + (p * 4);
const u8 row = i / 4;
const IZ_Action bitflag = (0x1 << i);
const uint8_t size = 4;
const u8 size = 4;
if (input_states->action[p] & bitflag) {
SDL_RenderFillRectF(video_state->renderer, &(SDL_FRect) {
column * size,


+ 3
- 3
src/packages/game/output/IZ_video.h Voir le fichier

@@ -12,9 +12,9 @@
#include "../IZ_config.h"

typedef struct {
uint16_t width;
uint16_t height;
uint8_t max_fps;
u16 width;
u16 height;
u8 max_fps;
} IZ_VideoConfig;

typedef struct {


Chargement…
Annuler
Enregistrer