From c1fee278f3afaeb19e6e484375e1ccd07c483b49 Mon Sep 17 00:00:00 2001 From: nesbox Date: Fri, 21 Sep 2018 17:32:02 +0300 Subject: [PATCH] sokol demo wip --- 3rd-party | 2 +- CMakeLists.txt | 2 +- sokol/main.c | 16 ++-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/3rd-party b/3rd-party index 746dd7e..f4349be 160000 --- a/3rd-party +++ b/3rd-party @@ -1 +1 @@ -Subproject commit 746dd7ec6a6f4d142db9e01aaca9459d0154e9e9 +Subproject commit f4349bec5a48b3a1261a10888edccd15aa649c4f diff --git a/CMakeLists.txt b/CMakeLists.txt index 314d5cd..ae037fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,7 +255,7 @@ if(APPLE) endif() target_include_directories(sokol PRIVATE include) -target_include_directories(sokol PRIVATE ../sokol) +target_include_directories(sokol PRIVATE 3rd-party/sokol) target_include_directories(sokol PRIVATE src) if(MINGW) diff --git a/sokol/main.c b/sokol/main.c index fd1dd84..c1fc619 100644 --- a/sokol/main.c +++ b/sokol/main.c @@ -8,8 +8,7 @@ #include #include -#define GFX_MAX_FB_WIDTH (TIC80_FULLWIDTH) -#define GFX_MAX_FB_HEIGHT (TIC80_FULLWIDTH) +static tic80* tic = NULL; #if defined(SOKOL_GLCORE33) static const char* gfx_vs_src = @@ -104,7 +103,6 @@ typedef struct { int fb_height; int fb_aspect_scale_x; int fb_aspect_scale_y; - uint32_t rgba8_buffer[GFX_MAX_FB_WIDTH * GFX_MAX_FB_HEIGHT]; } gfx_state; static gfx_state gfx; @@ -233,7 +231,7 @@ void gfx_draw() { /* copy emulator pixel data into upscaling source texture */ sg_update_image(gfx.upscale_draw_state.fs_images[0], &(sg_image_content){ .subimage[0][0] = { - .ptr = gfx.rgba8_buffer, + .ptr = tic->screen, .size = gfx.fb_width*gfx.fb_height*sizeof(uint32_t) } }); @@ -253,19 +251,12 @@ void gfx_draw() { sg_commit(); } -//////////////////////////////////////////////////////////////////////////////////////////// - -static tic80* tic = NULL; - static void app_init(void) { saudio_desc desc = {0}; saudio_setup(&desc); - printf("channels %i\n", saudio_channels()); - printf("samplerate %i\n", saudio_sample_rate()); - FILE* file = fopen("cart.tic", "rb"); if(file) @@ -299,10 +290,7 @@ static tic80_input tic_input; static void app_frame(void) { if(tic) - { tic80_tick(tic, tic_input); - memcpy(gfx.rgba8_buffer, tic->screen, sizeof gfx.rgba8_buffer); - } gfx_draw();