aboutsummaryrefslogtreecommitdiff
path: root/src/ppusim/work.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-03-10 13:16:16 +0100
committerlonkaars <loek@pipeframe.xyz>2023-03-10 13:16:16 +0100
commitc37397234534e9888dfeed9b1728c46646c33b58 (patch)
treec0e97dcccb1fce5bcd4550db243a67949a42ea1a /src/ppusim/work.c
parentbf8c5fdb43ae2446a502227a95f17167c3dcda33 (diff)
`clang-format`
Diffstat (limited to 'src/ppusim/work.c')
-rw-r--r--src/ppusim/work.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/ppusim/work.c b/src/ppusim/work.c
index 3b9cee6..96d15aa 100644
--- a/src/ppusim/work.c
+++ b/src/ppusim/work.c
@@ -2,12 +2,12 @@
#include <pthread.h>
#include <stdio.h>
-#include "ppusim/work.h"
-#include "ppusim/sim.h"
#include "ppu/consts.h"
#include "ppusim/pixel.h"
+#include "ppusim/sim.h"
+#include "ppusim/work.h"
-pthread_t* g_hh_ppusim_threads;
+pthread_t *g_hh_ppusim_threads;
unsigned g_hh_ppusim_core_count;
hh_s_ppusim_screen g_hh_ppusim_screen;
@@ -15,29 +15,26 @@ hh_s_ppusim_screen g_hh_ppusim_screen;
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
-void* hh_ppusim_draw_thread(void* arg) {
- unsigned core = (unsigned long) arg;
+void *hh_ppusim_draw_thread(void *arg) {
+ unsigned core = (unsigned long)arg;
for (unsigned y = core; y < HH_PPU_SCREEN_HEIGHT; y += g_hh_ppusim_core_count)
- for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++)
- hh_ppusim_pixel(g_hh_ppusim_screen[y][x], x, y);
+ for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++) hh_ppusim_pixel(g_hh_ppusim_screen[y][x], x, y);
return NULL;
}
-void hh_ppusim_draw_frame(SDL_Renderer* renderer) {
- for (unsigned core = 0; core < g_hh_ppusim_core_count; core++)
- pthread_create(&g_hh_ppusim_threads[core], NULL, hh_ppusim_draw_thread, (void*)(unsigned long)core);
- for (unsigned core = 0; core < g_hh_ppusim_core_count; core++)
- pthread_join(g_hh_ppusim_threads[core], NULL);
-
+void hh_ppusim_draw_frame(SDL_Renderer *renderer) {
+ for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_create(&g_hh_ppusim_threads[core], NULL, hh_ppusim_draw_thread, (void *)(unsigned long)core);
+ for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_join(g_hh_ppusim_threads[core], NULL);
+
for (unsigned x = 0; x < HH_PPU_SCREEN_WIDTH; x++) {
for (unsigned y = 0; y < HH_PPU_SCREEN_HEIGHT; y++) {
SDL_SetRenderDrawColor(renderer, g_hh_ppusim_screen[y][x][0], g_hh_ppusim_screen[y][x][1], g_hh_ppusim_screen[y][x][2], 255);
- SDL_RenderFillRect(renderer, &(SDL_Rect) {
- .x = x * HH_PPUSIM_UPSCALE_FACTOR,
- .y = y * HH_PPUSIM_UPSCALE_FACTOR,
- .w = HH_PPUSIM_UPSCALE_FACTOR,
- .h = HH_PPUSIM_UPSCALE_FACTOR,
- });
+ SDL_RenderFillRect(renderer, &(SDL_Rect){
+ .x = x * HH_PPUSIM_UPSCALE_FACTOR,
+ .y = y * HH_PPUSIM_UPSCALE_FACTOR,
+ .w = HH_PPUSIM_UPSCALE_FACTOR,
+ .h = HH_PPUSIM_UPSCALE_FACTOR,
+ });
}
}
}