libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit cdab91515752f8ecf5fe2fae0c0d647780185173
parent b9e53e008d8b641ef98927f13563dc7347f03bea
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu,  4 Oct 2018 10:20:58 +0200

Use unsigned types everywhere possible

Diffstat:
Msrc/fonts.h | 4++--
Msrc/loaders/binary.c | 2+-
Msrc/loaders/icedraw.c | 12++++++------
Msrc/loaders/pcboard.c | 12++++++------
Msrc/loaders/xbin.c | 22+++++++++++-----------
5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/fonts.h b/src/fonts.h @@ -19,8 +19,8 @@ struct fontStruct { const unsigned char *font_data; - int32_t width; - int32_t height; + uint32_t width; + uint32_t height; bool isAmigaFont; }; diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -44,7 +44,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) gdImageColorAllocate(canvas, 0, 0, 0); // allocate color palette - int32_t colors[16]; + uint32_t colors[16]; for (int i = 0; i < 16; i++) { colors[i] = gdImageColorAllocate(canvas, binary_palette[i*3], diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -14,14 +14,14 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) { // extract relevant part of the IDF header, 16-bit endian unsigned short - int32_t x2 = (ctx->buffer[9] << 8) + ctx->buffer[8]; + uint32_t x2 = (ctx->buffer[9] << 8) + ctx->buffer[8]; // libgd image pointers gdImagePtr canvas; uint32_t loop = 12; - int32_t index; - int32_t colors[16]; + uint32_t index; + uint32_t colors[16]; // process IDF uint32_t idf_sequence_length, idf_sequence_loop, i = 0; @@ -30,7 +30,7 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) unsigned char *idf_buffer, *temp; idf_buffer = malloc(2); - int16_t idf_data, idf_data_length; + uint16_t idf_data, idf_data_length; while (loop < ctx->length - 4096 - 48) { memcpy(&idf_data, ctx->buffer+loop, 2); @@ -94,8 +94,8 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) } // render IDF - int32_t column = 0, row = 0; - int32_t character, attribute, foreground, background; + uint32_t column = 0, row = 0; + uint32_t character, attribute, foreground, background; for (loop = 0; loop < i; loop += 2) { if (column == x2 + 1) { diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -13,11 +13,11 @@ // Character structure struct pcbChar { - int32_t column; - int32_t row; - int32_t background; - int32_t foreground; - int32_t current_character; + uint32_t column; + uint32_t row; + uint32_t background; + uint32_t foreground; + uint32_t current_character; }; int ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options) @@ -147,7 +147,7 @@ int ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options) gdImageFill(canvas, 0, 0, 0); // allocate color palette - int32_t colors[16]; + uint32_t colors[16]; for (int i = 0; i < 16; i++) { colors[i] = gdImageColorAllocate(canvas, ansi_palette[i*3], diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -21,10 +21,10 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } - int32_t xbin_width = (ctx->buffer[6] << 8) + ctx->buffer[5]; - int32_t xbin_height = (ctx->buffer[8] << 8) + ctx->buffer[7]; - int32_t xbin_fontsize = ctx->buffer[9]; - int32_t xbin_flags = ctx->buffer[10]; + uint32_t xbin_width = (ctx->buffer[6] << 8) + ctx->buffer[5]; + uint32_t xbin_height = (ctx->buffer[8] << 8) + ctx->buffer[7]; + uint32_t xbin_fontsize = ctx->buffer[9]; + uint32_t xbin_flags = ctx->buffer[10]; gdImagePtr canvas; @@ -43,8 +43,8 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) // palette if ((xbin_flags & 1) == 1) { - int32_t loop; - int32_t index; + uint32_t loop; + uint32_t index; for (loop = 0; loop < 16; loop++) { index = (loop * 3) + offset; @@ -65,7 +65,7 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) // font if ((xbin_flags & 2) == 2) { - int32_t numchars = (xbin_flags & 0x10 ? 512 : 256); + uint32_t numchars = (xbin_flags & 0x10 ? 512 : 256); // allocate memory to contain the XBin font font_data_xbin = (unsigned char *)malloc(xbin_fontsize * numchars); @@ -83,14 +83,14 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) font_data = font_pc_80x25; } - int32_t column = 0, row = 0; - int32_t character, attribute, foreground, background; + uint32_t column = 0, row = 0, foreground, background; + int32_t character, attribute; // read compressed xbin if ((xbin_flags & 4) == 4) { while (offset < ctx->length && row != xbin_height) { - int32_t ctype = ctx->buffer[offset] & 0xC0; - int32_t counter = (ctx->buffer[offset] & 0x3F) + 1; + uint32_t ctype = ctx->buffer[offset] & 0xC0; + uint32_t counter = (ctx->buffer[offset] & 0x3F) + 1; character = -1; attribute = -1;