From 1e10da13232311227da1bbbddd5d2020e917d0d5 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 3 Apr 2021 14:41:25 +0200 Subject: [PATCH] update recoil to version 6.1.0 --- 3rdparty/Makefile | 4 +- src/loadrecoil.c | 99 +++++++++++++++++++++-------------------------- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/3rdparty/Makefile b/3rdparty/Makefile index dcc9a29e..cba76710 100644 --- a/3rdparty/Makefile +++ b/3rdparty/Makefile @@ -135,14 +135,14 @@ LUAPATCHES = lua-atari-log2.patch \ LATESTLUAVER = $(shell curl -s -S https://www.lua.org/download.html | grep -A1 "current release is" | tail -n1 | sed 's/.*lua-\([0-9.]*\)\.tar.*/\1/' ) LATESTLUA53VER = $(shell curl -s -S https://www.lua.org/versions.html |grep 5[.]3[.] | head -n 1 | sed 's/.*\(5[0-9.]*\).*/\1/' ) # https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1.tar.gz -RECOILVER=5.1.1 +RECOILVER=6.1.0 LATESTRECOILVER = $(shell curl -s -S -I https://sourceforge.net/projects/recoil/files/latest/download|grep -i "^location:"|sed 's:.*/\([0-9.]*\)/.*:\1:' ) RECOIL=recoil-$(RECOILVER) RECOILARCH=$(RECOIL).tar.gz # https://downloads.sourceforge.net/project/recoil/recoil/4.3.0/recoil-4.3.0.tar.gz RECOILURL=https://downloads.sourceforge.net/project/recoil/recoil/$(RECOILVER)/$(RECOILARCH) RECOILURLALT=http://nanard.free.fr/grafx2/$(RECOILARCH) -RECOILSHA256=13ad32d669c73393114da2cc2d1c1af4880fbebcfcc807ca96fc20b181d50db5 +RECOILSHA256=a10384a69de0ae4cbc6a21b2bf598e6191da9e8b2847f7aeda66ec18d66e27b9 #https://github.com/redcode/6502/releases/download/v0.1/6502-v0.1.tar.xz REDCODE6502=6502-v0.1 REDCODE6502ARCH=6502-v0.1.tar.xz diff --git a/src/loadrecoil.c b/src/loadrecoil.c index 112b12af..d205ac4e 100644 --- a/src/loadrecoil.c +++ b/src/loadrecoil.c @@ -130,7 +130,6 @@ void Load_Recoil_Image(T_IO_Context *context) int original_width, original_height; int x, y; int x_ratio, y_ratio; - byte * pixels; const int *palette; enum PIXEL_RATIO ratio = PIXEL_SIMPLE; @@ -144,69 +143,61 @@ void Load_Recoil_Image(T_IO_Context *context) ratio = PIXEL_WIDE; else if(x_ratio == 1 && y_ratio > 1) ratio = PIXEL_TALL; - pixels = GFX2_malloc(width * height); - if (pixels == NULL) + // try to convert to 8bpp image + File_error = 0; + palette = RECOIL_ToPalette(recoil); + if (palette == NULL) { - File_error = 1; + // 24bits + const int * tc_pixels; + + Pre_load(context, original_width, original_height, file_length, FORMAT_MISC, ratio, 24); + tc_pixels = RECOIL_GetPixels(recoil); + for (y = 0; y < original_height; y++) + { + for (x = 0; x < original_width; x++) + { + Set_pixel_24b(context, x, y, *tc_pixels >> 16, *tc_pixels >> 8, *tc_pixels); + tc_pixels += x_ratio; + } + tc_pixels += width * (y_ratio - 1); + } } else { - // try to convert to 8bpp image - File_error = 0; - palette = RECOIL_ToPalette(recoil, pixels); - if (palette == NULL) - { - // 24bits - const int * tc_pixels; + // 8bits + int i; + int bpp; + int ncolors = RECOIL_GetColors(recoil); + const uint8_t * pixels = RECOIL_GetIndexes(recoil); + const byte * p = pixels; - Pre_load(context, original_width, original_height, file_length, FORMAT_MISC, ratio, 24); - tc_pixels = RECOIL_GetPixels(recoil); - for (y = 0; y < original_height; y++) - { - for (x = 0; x < original_width; x++) - { - Set_pixel_24b(context, x, y, *tc_pixels >> 16, *tc_pixels >> 8, *tc_pixels); - tc_pixels += x_ratio; - } - tc_pixels += width * (y_ratio - 1); - } - } - else + bpp = 8; + while (ncolors <= (1 << (bpp - 1))) + bpp--; + if (Config.Clear_palette) + memset(context->Palette,0,sizeof(T_Palette)); + for (i = 0; i < ncolors; i++) { - // 8bits - int i; - int bpp; - int ncolors = RECOIL_GetColors(recoil); - const byte * p = pixels; - - bpp = 8; - while (ncolors <= (1 << (bpp - 1))) - bpp--; - if (Config.Clear_palette) - memset(context->Palette,0,sizeof(T_Palette)); - for (i = 0; i < ncolors; i++) - { - context->Palette[i].R = (byte)(palette[i] >> 16); - context->Palette[i].G = (byte)(palette[i] >> 8); - context->Palette[i].B = (byte)(palette[i]); - } - Pre_load(context, original_width, original_height, file_length, FORMAT_MISC, ratio, bpp); - for (y = 0; y < original_height; y++) - { - for (x = 0; x < original_width; x++) - { - Set_pixel(context, x, y, *p); - p += x_ratio; - } - p += width * (y_ratio - 1); - } + context->Palette[i].R = (byte)(palette[i] >> 16); + context->Palette[i].G = (byte)(palette[i] >> 8); + context->Palette[i].B = (byte)(palette[i]); } - free(pixels); - if (!File_error) + Pre_load(context, original_width, original_height, file_length, FORMAT_MISC, ratio, bpp); + for (y = 0; y < original_height; y++) { - snprintf(context->Comment, COMMENT_SIZE + 1, "RECOIL: %s %d colors", RECOIL_GetPlatform(recoil), RECOIL_GetColors(recoil)); + for (x = 0; x < original_width; x++) + { + Set_pixel(context, x, y, *p); + p += x_ratio; + } + p += width * (y_ratio - 1); } } + if (!File_error) + { + snprintf(context->Comment, COMMENT_SIZE + 1, "RECOIL: %s %d colors", RECOIL_GetPlatform(recoil), RECOIL_GetColors(recoil)); + } } RECOIL_Delete(recoil); #ifdef WIN32