From 11751e75e7a929afe5c7d400cdb1b5a5ed733b00 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 22 Feb 2018 11:38:31 +0300 Subject: [PATCH] changed pixel format to RGBA --- src/system.c | 13 +++---------- src/tools.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/system.c b/src/system.c index bf5cc3e..5e683e6 100644 --- a/src/system.c +++ b/src/system.c @@ -14,7 +14,7 @@ #endif #define STUDIO_UI_SCALE 4 -#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888 +#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ABGR8888 #define TEXTURE_SIZE (TIC80_FULLWIDTH) #define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2) #define OFFSET_TOP ((TIC80_FULLHEIGHT-TIC80_HEIGHT)/2) @@ -1101,11 +1101,6 @@ u32 load_shader_program() } } -void free_shader(Uint32 p) -{ - GPU_FreeShaderProgram(p); -} - #include static s32 start(s32 argc, char **argv, const char* folder) @@ -1133,7 +1128,7 @@ static s32 start(s32 argc, char **argv, const char* folder) GPU_Target* screen = GPU_Init(Width, Height, GPU_INIT_DISABLE_VSYNC); - GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA);// GPU_FORMAT_BGRA); + GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA); GPU_SetAnchor(texture, 0, 0); GPU_SetImageFilter(texture, GPU_FILTER_NEAREST); @@ -1196,10 +1191,8 @@ static s32 start(s32 argc, char **argv, const char* folder) SDL_CloseAudioDevice(platform.audio.device); - free_shader(crt_shader); - + GPU_FreeShaderProgram(crt_shader); GPU_FreeImage(texture); - GPU_Quit(); return 0; diff --git a/src/tools.c b/src/tools.c index 807f530..3b9f397 100644 --- a/src/tools.c +++ b/src/tools.c @@ -88,20 +88,20 @@ u32 tic_tool_find_closest_color(const tic_rgb* palette, const tic_rgb* color) u32* tic_palette_blit(const tic_palette* srcpal) { - static u32 pal[TIC_PALETTE_SIZE] = {0}; - - const u8* src = srcpal->data; - - memset(pal, 0xff, sizeof pal); + static u32 pal[TIC_PALETTE_SIZE]; + const tic_rgb* src = srcpal->colors; + const tic_rgb* end = src + TIC_PALETTE_SIZE; u8* dst = (u8*)pal; - const u8* end = src + sizeof(tic_palette); - enum{RGB = sizeof(tic_rgb)}; - - for(; src != end; dst++, src+=RGB) - for(s32 j = 0; j < RGB; j++) - *dst++ = *(src+(RGB-1)-j); + while(src != end) + { + *dst++ = src->r; + *dst++ = src->g; + *dst++ = src->b; + *dst++ = 0xff; + src++; + } return pal; -} \ No newline at end of file +}