|
|
@@ -19,12 +19,16 @@ IZ_ProcedureResult IZ_InitializeApp(IZ_App* app) { |
|
|
|
|
|
|
|
IZ_InitializeInput(config_path, &app->input_state); |
|
|
|
IZ_InitializePool(&app->memory_pool); |
|
|
|
void* p1 = IZ_PoolAllocate(&app->memory_pool, sizeof(u16))->pointer; |
|
|
|
void* p2 = IZ_PoolAllocate(&app->memory_pool, sizeof(u8))->pointer; |
|
|
|
void* p3 = IZ_PoolAllocate(&app->memory_pool, sizeof(u64))->pointer; |
|
|
|
void* p4 = IZ_PoolAllocate(&app->memory_pool, sizeof(u32))->pointer; |
|
|
|
printf("\n%p %p %p %p\n", p1, p2, p3, p4); |
|
|
|
// void* p1 = IZ_PoolAllocate(&app->memory_pool, sizeof(u16), 0)->pointer; |
|
|
|
// void* p2 = IZ_PoolAllocate(&app->memory_pool, sizeof(u8), 0)->pointer; |
|
|
|
// void* p3 = IZ_PoolAllocate(&app->memory_pool, sizeof(u64), 0)->pointer; |
|
|
|
// void* p4 = IZ_PoolAllocate(&app->memory_pool, sizeof(u32), 0)->pointer; |
|
|
|
// printf("\n%p %p %p %p\n", p1, p2, p3, p4); |
|
|
|
// IZ_PoolDeallocate(p1); |
|
|
|
// void* p5 = IZ_PoolAllocate(&app->memory_pool, sizeof(u16), 0)->pointer; |
|
|
|
// printf("\n%p\n", p5); |
|
|
|
app->quit = false; |
|
|
|
app->ticks = 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
@@ -46,20 +50,26 @@ void IZ_HandleSDLEvents(IZ_App* app) { |
|
|
|
} |
|
|
|
|
|
|
|
void IZ_HandlePortMIDIEvents(IZ_App* app) { |
|
|
|
for (u8 player_index = 0; player_index < PLAYERS; player_index += 1) { |
|
|
|
i32 midi_events_count = Pm_Read( |
|
|
|
u8 player_index; |
|
|
|
i32* midi_events_count; |
|
|
|
u32 midi_event_index; |
|
|
|
for (player_index = 0; player_index < PLAYERS; player_index += 1) { |
|
|
|
midi_events_count = &app->input_state.midi_input_state[player_index].midi_events_count; |
|
|
|
*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 (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 |
|
|
|
); |
|
|
|
} |
|
|
|
if (*midi_events_count < 1) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
for (midi_event_index = 0; midi_event_index < *midi_events_count; midi_event_index += 1) { |
|
|
|
IZ_HandlePortMIDIInputEvents( |
|
|
|
app->input_state.midi_input_state[player_index].event_buffer[midi_event_index], |
|
|
|
&app->input_state |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -69,10 +79,11 @@ void IZ_HandleEvents(IZ_App* app) { |
|
|
|
IZ_HandlePortMIDIEvents(app); |
|
|
|
} |
|
|
|
|
|
|
|
IZ_ProcedureResult IZ_RunApp(IZ_App* app, u8 argc, char* argv[]) { |
|
|
|
printf_s("Args (%u):\n", argc); |
|
|
|
for (u8 i = 0; i < argc; i += 1) { |
|
|
|
printf_s(" %s", argv[i]); |
|
|
|
IZ_ProcedureResult IZ_RunApp(IZ_App* app, u8 arg_count, char* arg_values[]) { |
|
|
|
printf_s("Args (%u):\n", arg_count); |
|
|
|
u8 arg_index; |
|
|
|
for (arg_index = 0; arg_index < arg_count; arg_index += 1) { |
|
|
|
printf_s(" %s\n", arg_values[arg_index]); |
|
|
|
} |
|
|
|
|
|
|
|
IZ_ProcedureResult init_result = IZ_InitializeApp(app); |
|
|
@@ -80,20 +91,18 @@ IZ_ProcedureResult IZ_RunApp(IZ_App* app, u8 argc, char* argv[]) { |
|
|
|
return init_result; |
|
|
|
} |
|
|
|
|
|
|
|
u64 ticks; |
|
|
|
while (true) { |
|
|
|
ticks = SDL_GetTicks64(); |
|
|
|
app->ticks = SDL_GetTicks64(); |
|
|
|
|
|
|
|
// TODO do audio processing |
|
|
|
// TODO do networking? |
|
|
|
|
|
|
|
// process events |
|
|
|
IZ_HandleEvents(app); |
|
|
|
if (app->quit) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
IZ_UpdateVideo(&app->video_state, &app->input_state, ticks); |
|
|
|
IZ_UpdateVideo(&app->video_state, &app->input_state, app->ticks); |
|
|
|
} |
|
|
|
|
|
|
|
IZ_TeardownApp(app); |
|
|
|