commit 1c60f709021fd5b9364d47e0f11c3720620a54b5
parent c2f990a9da71763ab284fb6e4f22771f902991cd
Author: Frederic Cambus <fred@statdns.com>
Date: Sat, 18 Jan 2020 23:12:04 +0100
Allow more granularity for the IDF_*_LENGTH macros.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c
@@ -18,7 +18,9 @@
#include "drawchar.h"
#include "output.h"
-#define IDF_HEADER_LENGTH 4144 /* 4096 + 48 */
+#define IDF_HEADER_LENGTH 12
+#define IDF_FONT_LENGTH 4096
+#define IDF_PALETTE_LENGTH 48
int
ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options)
@@ -30,7 +32,7 @@ ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options)
return -1;
}
- if (ctx->length < IDF_HEADER_LENGTH) {
+ if (ctx->length < IDF_HEADER_LENGTH + IDF_FONT_LENGTH + IDF_PALETTE_LENGTH) {
ctx->error = ANSILOVE_FORMAT_ERROR;
return -1;
}
@@ -52,7 +54,7 @@ ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options)
uint8_t *ptr, *idf_buffer;
idf_buffer = malloc(2);
- while (loop < ctx->length - IDF_HEADER_LENGTH) {
+ while (loop < ctx->length - IDF_FONT_LENGTH - IDF_PALETTE_LENGTH) {
/* RLE compressed data */
if (ctx->buffer[loop] == 1) {
idf_sequence_length = ctx->buffer[loop+2];
@@ -129,7 +131,7 @@ ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options)
background = (attribute & 240) >> 4;
foreground = attribute & 15;
- drawchar(canvas, ctx->buffer+(ctx->length - IDF_HEADER_LENGTH),
+ drawchar(canvas, ctx->buffer+(ctx->length - IDF_FONT_LENGTH - IDF_PALETTE_LENGTH),
8, 16, column, row,
colors[background], colors[foreground], character);