|
|
@@ -1,42 +1,19 @@ |
|
|
|
#include <SDL.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
#include "IZ_action.h" |
|
|
|
#include "IZ_app.h" |
|
|
|
|
|
|
|
int main(int argc, char* args[]) { |
|
|
|
SDL_Window* window = NULL; |
|
|
|
SDL_Surface* screen_surface = NULL; |
|
|
|
IZ_App app; |
|
|
|
IZ_ProcedureResult result = IZ_InitializeApp(&app); |
|
|
|
|
|
|
|
IZ_InitializeApp(&app); |
|
|
|
if (SDL_Init( |
|
|
|
SDL_INIT_VIDEO |
|
|
|
| SDL_INIT_GAMECONTROLLER |
|
|
|
| SDL_INIT_EVENTS |
|
|
|
) < 0) { |
|
|
|
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); |
|
|
|
return -1; |
|
|
|
if (result) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
window = SDL_CreateWindow( |
|
|
|
APP_NAME, |
|
|
|
SDL_WINDOWPOS_CENTERED, |
|
|
|
SDL_WINDOWPOS_CENTERED, |
|
|
|
app.video_config.width, |
|
|
|
app.video_config.height, |
|
|
|
SDL_WINDOW_SHOWN |
|
|
|
); |
|
|
|
if (window == NULL) { |
|
|
|
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); |
|
|
|
return -2; |
|
|
|
} |
|
|
|
screen_surface = SDL_GetWindowSurface(window); |
|
|
|
|
|
|
|
bool quit = false; |
|
|
|
SDL_Event e; |
|
|
|
|
|
|
|
while (true) { |
|
|
|
uint64_t ticks = SDL_GetTicks64(); |
|
|
|
|
|
|
@@ -63,19 +40,19 @@ int main(int argc, char* args[]) { |
|
|
|
|
|
|
|
if (ticks - app.video_update_at > 1000 / app.video_config.max_fps) { |
|
|
|
// Update window |
|
|
|
SDL_FillRect(screen_surface, NULL, SDL_MapRGB(screen_surface->format, 0x00, 0x00, 0x00)); |
|
|
|
SDL_FillRect(app.screen_surface, NULL, SDL_MapRGB(app.screen_surface->format, 0x00, 0x00, 0x00)); |
|
|
|
for (uint8_t i = 0; i < 64; i += 1) { |
|
|
|
const uint8_t column = (64 - i) % 32; |
|
|
|
const uint8_t row = i / 32; |
|
|
|
const uint64_t bitflag = (0x1lu << i); |
|
|
|
const uint8_t size = 4; |
|
|
|
if (ticks & bitflag) { |
|
|
|
SDL_FillRect(screen_surface, &(SDL_Rect) { |
|
|
|
SDL_FillRect(app.screen_surface, &(SDL_Rect) { |
|
|
|
column * size, |
|
|
|
app.video_config.height - ((row + 1) * size), |
|
|
|
size, |
|
|
|
size |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0x00, 0xff, 0xff)); |
|
|
|
}, SDL_MapRGB(app.screen_surface->format, 0x00, 0xff, 0xff)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -86,20 +63,20 @@ int main(int argc, char* args[]) { |
|
|
|
const IZ_Action bitflag = (0x1 << i); |
|
|
|
const uint8_t size = 4; |
|
|
|
if (app.actions[p] & bitflag) { |
|
|
|
SDL_FillRect(screen_surface, &(SDL_Rect) { |
|
|
|
SDL_FillRect(app.screen_surface, &(SDL_Rect) { |
|
|
|
column * size, |
|
|
|
row * size, |
|
|
|
size, |
|
|
|
size |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0xff, 0xff, 0x00)); |
|
|
|
}, SDL_MapRGB(app.screen_surface->format, 0xff, 0xff, 0x00)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SDL_UpdateWindowSurface(window); |
|
|
|
SDL_UpdateWindowSurface(app.window); |
|
|
|
app.video_update_at = ticks; |
|
|
|
} |
|
|
|
} |
|
|
|
SDL_DestroyWindow(window); |
|
|
|
SDL_DestroyWindow(app.window); |
|
|
|
SDL_Quit(); |
|
|
|
|
|
|
|
return 0; |
|
|
|