|
|
@@ -35,31 +35,18 @@ int main(int argc, char* args[]) { |
|
|
|
return -2; |
|
|
|
} |
|
|
|
|
|
|
|
screen_surface = SDL_GetWindowSurface(window); |
|
|
|
|
|
|
|
bool quit = false; |
|
|
|
SDL_Event e; |
|
|
|
screen_surface = SDL_GetWindowSurface(window); |
|
|
|
|
|
|
|
while (!quit) { |
|
|
|
SDL_FillRect(screen_surface, NULL, SDL_MapRGB(screen_surface->format, 0x00, 0x00, 0x00)); |
|
|
|
while (true) { |
|
|
|
uint64_t ticks = SDL_GetTicks64(); |
|
|
|
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) { |
|
|
|
column * size, |
|
|
|
app.config.video.height - ((row + 1) * size), |
|
|
|
size, |
|
|
|
size |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0x00, 0xff, 0xff)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
while (SDL_PollEvent(&e) != 0) { |
|
|
|
if (e.type == SDL_QUIT) { |
|
|
|
quit = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
// Handle joystick events |
|
|
@@ -137,25 +124,49 @@ int main(int argc, char* args[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Update window |
|
|
|
for (uint8_t current_player = 0; current_player < PLAYERS; current_player += 1) { |
|
|
|
for (uint8_t i = 0; i < CONTROLS; i += 1) { |
|
|
|
const uint8_t column = i % 4; |
|
|
|
const uint8_t row = i / 4; |
|
|
|
const IZ_Action bitflag = (0x1 << i); |
|
|
|
if (quit) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (ticks - app.video_update_at > 1000 / app.config.video.max_fps) { |
|
|
|
// Update window |
|
|
|
SDL_FillRect(screen_surface, NULL, SDL_MapRGB(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 (app.actions[current_player] & bitflag) { |
|
|
|
if (ticks & bitflag) { |
|
|
|
SDL_FillRect(screen_surface, &(SDL_Rect) { |
|
|
|
column * size, |
|
|
|
row * size, |
|
|
|
app.config.video.height - ((row + 1) * size), |
|
|
|
size, |
|
|
|
size |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0xff, 0xff, 0x00)); |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0x00, 0xff, 0xff)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SDL_UpdateWindowSurface(window); |
|
|
|
for (uint8_t current_player = 0; current_player < PLAYERS; current_player += 1) { |
|
|
|
for (uint8_t i = 0; i < CONTROLS; i += 1) { |
|
|
|
const uint8_t column = i % 4; |
|
|
|
const uint8_t row = i / 4; |
|
|
|
const IZ_Action bitflag = (0x1 << i); |
|
|
|
const uint8_t size = 4; |
|
|
|
if (app.actions[current_player] & bitflag) { |
|
|
|
SDL_FillRect(screen_surface, &(SDL_Rect) { |
|
|
|
column * size, |
|
|
|
row * size, |
|
|
|
size, |
|
|
|
size |
|
|
|
}, SDL_MapRGB(screen_surface->format, 0xff, 0xff, 0x00)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SDL_UpdateWindowSurface(window); |
|
|
|
|
|
|
|
app.video_update_at = ticks; |
|
|
|
} |
|
|
|
} |
|
|
|
SDL_DestroyWindow(window); |
|
|
|
SDL_Quit(); |
|
|
|