commit 43a2259344b292f8970447c89df3a36e42e33831
parent 798e65ff05f3568ff95e507d3cb2243dc34fd70d
Author: Frederic Cambus <fred@statdns.com>
Date: Wed, 4 Jul 2018 10:41:47 +0200
Rename the input struct to ansilove_ctx, and its consumers as well
Diffstat:
8 files changed, 110 insertions(+), 110 deletions(-)
diff --git a/include/ansilove.h b/include/ansilove.h
@@ -16,7 +16,7 @@
#include <stddef.h>
#include <stdint.h>
-struct input {
+struct ansilove_ctx {
unsigned char *buffer;
size_t length;
};
@@ -33,12 +33,12 @@ struct output {
uint32_t retinaScaleFactor;
};
-int ansilove_ansi(struct input *, struct output *);
-int ansilove_artworx(struct input *, struct output *);
-int ansilove_binary(struct input *, struct output *);
-int ansilove_icedraw(struct input *, struct output *);
-int ansilove_pcboard(struct input *, struct output *);
-int ansilove_tundra(struct input *, struct output *);
-int ansilove_xbin(struct input *, struct output *);
+int ansilove_ansi(struct ansilove_ctx *, struct output *);
+int ansilove_artworx(struct ansilove_ctx *, struct output *);
+int ansilove_binary(struct ansilove_ctx *, struct output *);
+int ansilove_icedraw(struct ansilove_ctx *, struct output *);
+int ansilove_pcboard(struct ansilove_ctx *, struct output *);
+int ansilove_tundra(struct ansilove_ctx *, struct output *);
+int ansilove_xbin(struct ansilove_ctx *, struct output *);
#endif
diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c
@@ -25,7 +25,7 @@ struct ansiChar {
bool underline;
};
-int ansilove_ansi(struct input *inputFile, struct output *outputFile)
+int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile)
{
// ladies and gentlemen, it's type declaration time
struct fontStruct fontData;
@@ -85,9 +85,9 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
ansi_buffer = malloc(sizeof (struct ansiChar));
// ANSi interpreter
- while (loop < inputFile->length) {
- current_character = inputFile->buffer[loop];
- next_character = inputFile->buffer[loop + 1];
+ while (loop < ctx->length) {
+ current_character = ctx->buffer[loop];
+ next_character = ctx->buffer[loop + 1];
if (column == 80) {
row++;
@@ -118,12 +118,12 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// ANSi sequence
if (current_character == 27 && next_character == 91) {
for (ansi_sequence_loop = 0; ansi_sequence_loop < 14; ansi_sequence_loop++) {
- ansi_sequence_character = inputFile->buffer[loop + 2 + ansi_sequence_loop];
+ ansi_sequence_character = ctx->buffer[loop + 2 + ansi_sequence_loop];
// cursor position
if (ansi_sequence_character == 'H' || ansi_sequence_character == 'f') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// create sequence content array
seqArrayCount = explode(&seqArray, ';', seqGrab);
@@ -149,7 +149,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// cursor up
if (ansi_sequence_character == 'A') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -164,7 +164,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// cursor down
if (ansi_sequence_character == 'B') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -179,7 +179,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// cursor forward
if (ansi_sequence_character == 'C') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's position value
int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -197,7 +197,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// cursor backward
if (ansi_sequence_character == 'D') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// now get escape sequence's content length
int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -233,7 +233,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// erase display
if (ansi_sequence_character == 'J') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
// convert grab to an integer
int32_t eraseDisplayInt = strtonum(seqGrab, 0, INT32_MAX, &errstr);
@@ -258,7 +258,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// set graphics mode
if (ansi_sequence_character == 'm') {
// create substring from the sequence's content
- seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
+ seqGrab = strndup((char *)ctx->buffer + loop + 2, ansi_sequence_loop);
while ((seqTok = strtok(seqGrab, ";")) != NULL) {
seqValue = strtonum(seqTok, 0, INT32_MAX, &errstr);
diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c
@@ -11,13 +11,13 @@
#include "../ansilove.h"
-int ansilove_artworx(struct input *inputFile, struct output *outputFile)
+int ansilove_artworx(struct ansilove_ctx *ctx, struct output *outputFile)
{
// libgd image pointers
gdImagePtr canvas;
// create ADF instance
- canvas = gdImageCreate(640, (((inputFile->length - 192 - 4096 -1) / 2) / 80) * 16);
+ canvas = gdImageCreate(640, (((ctx->length - 192 - 4096 -1) / 2) / 80) * 16);
// error output
if (!canvas) {
@@ -34,9 +34,9 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
// process ADF palette
for (loop = 0; loop < 16; loop++) {
index = (adf_colors[loop] * 3) + 1;
- gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
- (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
- (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
+ gdImageColorAllocate(canvas, (ctx->buffer[index] << 2 | ctx->buffer[index] >> 4),
+ (ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4),
+ (ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4));
}
gdImageColorAllocate(canvas, 0, 0, 0);
@@ -46,19 +46,19 @@ int ansilove_artworx(struct input *inputFile, struct output *outputFile)
uint32_t character, attribute, foreground, background;
loop = 192 + 4096 + 1;
- while (loop < inputFile->length) {
+ while (loop < ctx->length) {
if (column == 80) {
column = 0;
row++;
}
- character = inputFile->buffer[loop];
- attribute = inputFile->buffer[loop+1];
+ character = ctx->buffer[loop];
+ attribute = ctx->buffer[loop+1];
background = (attribute & 240) >> 4;
foreground = attribute & 15;
- drawchar(canvas, inputFile->buffer+193, 8, 16, column, row, background, foreground, character);
+ drawchar(canvas, ctx->buffer+193, 8, 16, column, row, background, foreground, character);
column++;
loop += 2;
diff --git a/src/loaders/binary.c b/src/loaders/binary.c
@@ -11,10 +11,10 @@
#include "../ansilove.h"
-int ansilove_binary(struct input *inputFile, struct output *outputFile)
+int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile)
{
// binary files must have an even size
- if (inputFile->length % 2) {
+ if (ctx->length % 2) {
fprintf(stderr, "\nBinary file is not valid.\n");
return -1;
}
@@ -30,7 +30,7 @@ int ansilove_binary(struct input *inputFile, struct output *outputFile)
// allocate buffer image memory
canvas = gdImageCreate(outputFile->columns * outputFile->bits,
- ((inputFile->length / 2) / outputFile->columns * fontData.height));
+ ((ctx->length / 2) / outputFile->columns * fontData.height));
if (!canvas) {
perror("Error, can't allocate buffer image memory");
@@ -53,14 +53,14 @@ int ansilove_binary(struct input *inputFile, struct output *outputFile)
uint32_t character, attribute, background, foreground;
uint32_t loop = 0, column = 0, row = 0;
- while (loop < inputFile->length) {
+ while (loop < ctx->length) {
if (column == outputFile->columns) {
column = 0;
row++;
}
- character = inputFile->buffer[loop];
- attribute = inputFile->buffer[loop+1];
+ character = ctx->buffer[loop];
+ attribute = ctx->buffer[loop+1];
background = (attribute & 240) >> 4;
foreground = (attribute & 15);
diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c
@@ -11,10 +11,10 @@
#include "../ansilove.h"
-int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
+int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile)
{
// extract relevant part of the IDF header, 16-bit endian unsigned short
- int32_t x2 = (inputFile->buffer[9] << 8) + inputFile->buffer[8];
+ int32_t x2 = (ctx->buffer[9] << 8) + ctx->buffer[8];
// libgd image pointers
gdImagePtr canvas;
@@ -32,12 +32,12 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
int16_t idf_data, idf_data_length;
- while (loop < inputFile->length - 4096 - 48) {
- memcpy(&idf_data, inputFile->buffer+loop, 2);
+ while (loop < ctx->length - 4096 - 48) {
+ memcpy(&idf_data, ctx->buffer+loop, 2);
// RLE compressed data
if (idf_data == 1) {
- memcpy(&idf_data_length, inputFile->buffer+loop+2, 2);
+ memcpy(&idf_data_length, ctx->buffer+loop+2, 2);
idf_sequence_length = idf_data_length & 255;
@@ -52,8 +52,8 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
return -1;
}
- idf_buffer[i] = inputFile->buffer[loop + 4];
- idf_buffer[i+1] = inputFile->buffer[loop + 5];
+ idf_buffer[i] = ctx->buffer[loop + 4];
+ idf_buffer[i+1] = ctx->buffer[loop + 5];
i += 2;
}
loop += 4;
@@ -68,8 +68,8 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
}
// normal character
- idf_buffer[i] = inputFile->buffer[loop];
- idf_buffer[i+1] = inputFile->buffer[loop + 1];
+ idf_buffer[i] = ctx->buffer[loop];
+ idf_buffer[i+1] = ctx->buffer[loop + 1];
i += 2;
}
loop += 2;
@@ -87,10 +87,10 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
// process IDF palette
for (loop = 0; loop < 16; loop++) {
- index = (loop * 3) + inputFile->length - 48;
- colors[loop] = gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
- (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
- (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
+ index = (loop * 3) + ctx->length - 48;
+ colors[loop] = gdImageColorAllocate(canvas, (ctx->buffer[index] << 2 | ctx->buffer[index] >> 4),
+ (ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4),
+ (ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4));
}
// render IDF
@@ -109,7 +109,7 @@ int ansilove_icedraw(struct input *inputFile, struct output *outputFile)
background = (attribute & 240) >> 4;
foreground = attribute & 15;
- drawchar(canvas, inputFile->buffer+(inputFile->length - 48 - 4096), 8, 16, column, row, colors[background], colors[foreground], character);
+ drawchar(canvas, ctx->buffer+(ctx->length - 48 - 4096), 8, 16, column, row, colors[background], colors[foreground], character);
column++;
}
diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c
@@ -20,7 +20,7 @@ struct pcbChar {
int32_t current_character;
};
-int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
+int ansilove_pcboard(struct ansilove_ctx *ctx, struct output *outputFile)
{
// some type declarations
struct fontStruct fontData;
@@ -47,9 +47,9 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
loop = 0;
structIndex = 0;
- while (loop < inputFile->length) {
- current_character = inputFile->buffer[loop];
- next_character = inputFile->buffer[loop+1];
+ while (loop < ctx->length) {
+ current_character = ctx->buffer[loop];
+ next_character = ctx->buffer[loop+1];
if (column == 80) {
row++;
@@ -80,12 +80,12 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
// PCB sequence
if (current_character == 64 && next_character == 88) {
// set graphics rendition
- background = inputFile->buffer[loop+2];
- foreground = inputFile->buffer[loop+3];
+ background = ctx->buffer[loop+2];
+ foreground = ctx->buffer[loop+3];
loop += 3;
}
else if (current_character == 64 && next_character == 67 &&
- inputFile->buffer[loop+2] == 'L' && inputFile->buffer[loop+3] == 'S') {
+ ctx->buffer[loop+2] == 'L' && ctx->buffer[loop+3] == 'S') {
// erase display
column = 0;
row = 0;
@@ -94,17 +94,17 @@ int ansilove_pcboard(struct input *inputFile, struct output *outputFile)
rowMax = 0;
loop += 4;
- } else if (current_character == 64 && next_character == 80 && inputFile->buffer[loop+2] == 'O'
- && inputFile->buffer[loop+3] == 'S' && inputFile->buffer[loop+4] == ':') {
+ } else if (current_character == 64 && next_character == 80 && ctx->buffer[loop+2] == 'O'
+ && ctx->buffer[loop+3] == 'S' && ctx->buffer[loop+4] == ':') {
// cursor position
- if (inputFile->buffer[loop+6] == '@')
+ if (ctx->buffer[loop+6] == '@')
{
- column = ((inputFile->buffer[loop+5])-48)-1;
+ column = ((ctx->buffer[loop+5])-48)-1;
loop += 5;
}
else
{
- column = (10 * ((inputFile->buffer[loop+5])-48) + (inputFile->buffer[loop+6])-48)-1;
+ column = (10 * ((ctx->buffer[loop+5])-48) + (ctx->buffer[loop+6])-48)-1;
loop += 6;
}
} else if (current_character != 10 && current_character != 13 && current_character != 9) {
diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c
@@ -18,7 +18,7 @@
#define TUNDRA_COLOR_FOREGROUND 4
#define TUNDRA_COLOR_BOTH 6
-int ansilove_tundra(struct input *inputFile, struct output *outputFile)
+int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile)
{
// some type declarations
struct fontStruct fontData;
@@ -31,7 +31,7 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
gdImagePtr canvas;
// extract tundra header
- tundra_version = inputFile->buffer[0];
+ tundra_version = ctx->buffer[0];
// need to add check for "TUNDRA24" string in the header
if (tundra_version != TUNDRA_VERSION) {
@@ -43,23 +43,23 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
uint32_t cursor, character, background = 0, foreground = 0;
uint32_t loop = 9, column = 0, row = 1;
- while (loop < inputFile->length) {
+ while (loop < ctx->length) {
if (column == 80) {
column = 0;
row++;
}
- cursor = inputFile->buffer[loop];
+ cursor = ctx->buffer[loop];
switch(cursor) {
case TUNDRA_POSITION:
row =
- (inputFile->buffer[loop + 1] << 24) + (inputFile->buffer[loop + 2] << 16) +
- (inputFile->buffer[loop + 3] << 8) + inputFile->buffer[loop+4];
+ (ctx->buffer[loop + 1] << 24) + (ctx->buffer[loop + 2] << 16) +
+ (ctx->buffer[loop + 3] << 8) + ctx->buffer[loop+4];
column =
- (inputFile->buffer[loop + 5] << 24) + (inputFile->buffer[loop + 6] << 16) +
- (inputFile->buffer[loop + 7] << 8) + inputFile->buffer[loop+8];
+ (ctx->buffer[loop + 5] << 24) + (ctx->buffer[loop + 6] << 16) +
+ (ctx->buffer[loop + 7] << 8) + ctx->buffer[loop+8];
loop += 8;
break;
@@ -97,56 +97,56 @@ int ansilove_tundra(struct input *inputFile, struct output *outputFile)
loop = 9;
- while (loop < inputFile->length) {
+ while (loop < ctx->length) {
if (column == 80) {
column = 0;
row++;
}
- cursor = character = inputFile->buffer[loop];
+ cursor = character = ctx->buffer[loop];
switch(cursor) {
case TUNDRA_POSITION:
row =
- (inputFile->buffer[loop + 1] << 24) + (inputFile->buffer[loop + 2] << 16) +
- (inputFile->buffer[loop + 3] << 8) + inputFile->buffer[loop + 4];
+ (ctx->buffer[loop + 1] << 24) + (ctx->buffer[loop + 2] << 16) +
+ (ctx->buffer[loop + 3] << 8) + ctx->buffer[loop + 4];
column =
- (inputFile->buffer[loop + 5] << 24) + (inputFile->buffer[loop + 6] << 16) +
- (inputFile->buffer[loop + 7] << 8) + inputFile->buffer[loop + 8];
+ (ctx->buffer[loop + 5] << 24) + (ctx->buffer[loop + 6] << 16) +
+ (ctx->buffer[loop + 7] << 8) + ctx->buffer[loop + 8];
loop += 8;
break;
case TUNDRA_COLOR_BACKGROUND:
foreground =
- (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
- inputFile->buffer[loop + 5];
+ (ctx->buffer[loop + 3] << 16) + (ctx->buffer[loop + 4] << 8) +
+ ctx->buffer[loop + 5];
- character = inputFile->buffer[loop+1];
+ character = ctx->buffer[loop+1];
loop += 5;
break;
case TUNDRA_COLOR_FOREGROUND:
- background = (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
- inputFile->buffer[loop+5];
+ background = (ctx->buffer[loop + 3] << 16) + (ctx->buffer[loop + 4] << 8) +
+ ctx->buffer[loop+5];
- character = inputFile->buffer[loop+1];
+ character = ctx->buffer[loop+1];
loop += 5;
break;
case TUNDRA_COLOR_BOTH:
foreground =
- (inputFile->buffer[loop + 3] << 16) + (inputFile->buffer[loop + 4] << 8) +
- inputFile->buffer[loop+5];
+ (ctx->buffer[loop + 3] << 16) + (ctx->buffer[loop + 4] << 8) +
+ ctx->buffer[loop+5];
background =
- (inputFile->buffer[loop + 7] << 16) + (inputFile->buffer[loop + 8] << 8) +
- inputFile->buffer[loop+9];
+ (ctx->buffer[loop + 7] << 16) + (ctx->buffer[loop + 8] << 8) +
+ ctx->buffer[loop+9];
- character = inputFile->buffer[loop+1];
+ character = ctx->buffer[loop+1];
loop += 9;
break;
diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c
@@ -11,20 +11,20 @@
#include "../ansilove.h"
-int ansilove_xbin(struct input *inputFile, struct output *outputFile)
+int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile)
{
const unsigned char *font_data;
unsigned char *font_data_xbin = NULL;
- if (strncmp((char *)inputFile->buffer, "XBIN\x1a", 5) != 0) {
+ if (strncmp((char *)ctx->buffer, "XBIN\x1a", 5) != 0) {
fputs("\nNot an XBin.\n\n", stderr);
return -1;
}
- int32_t xbin_width = (inputFile->buffer[6] << 8) + inputFile->buffer[5];
- int32_t xbin_height = (inputFile->buffer[8] << 8) + inputFile->buffer[7];
- int32_t xbin_fontsize = inputFile->buffer[9];
- int32_t xbin_flags = inputFile->buffer[10];
+ 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];
gdImagePtr canvas;
@@ -49,9 +49,9 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
for (loop = 0; loop < 16; loop++) {
index = (loop * 3) + offset;
- colors[loop] = gdImageColorAllocate(canvas, (inputFile->buffer[index] << 2 | inputFile->buffer[index] >> 4),
- (inputFile->buffer[index + 1] << 2 | inputFile->buffer[index + 1] >> 4),
- (inputFile->buffer[index + 2] << 2 | inputFile->buffer[index + 2] >> 4));
+ colors[loop] = gdImageColorAllocate(canvas, (ctx->buffer[index] << 2 | ctx->buffer[index] >> 4),
+ (ctx->buffer[index + 1] << 2 | ctx->buffer[index + 1] >> 4),
+ (ctx->buffer[index + 2] << 2 | ctx->buffer[index + 2] >> 4));
}
offset += 48;
@@ -73,7 +73,7 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
perror("Memory error");
return -1;
}
- memcpy(font_data_xbin, inputFile->buffer+offset, (xbin_fontsize * numchars));
+ memcpy(font_data_xbin, ctx->buffer+offset, (xbin_fontsize * numchars));
font_data = font_data_xbin;
@@ -88,9 +88,9 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
// read compressed xbin
if ((xbin_flags & 4) == 4) {
- while (offset < inputFile->length && row != xbin_height) {
- int32_t ctype = inputFile->buffer[offset] & 0xC0;
- int32_t counter = (inputFile->buffer[offset] & 0x3F) + 1;
+ while (offset < ctx->length && row != xbin_height) {
+ int32_t ctype = ctx->buffer[offset] & 0xC0;
+ int32_t counter = (ctx->buffer[offset] & 0x3F) + 1;
character = -1;
attribute = -1;
@@ -99,36 +99,36 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
while (counter--) {
// none
if (ctype == 0) {
- character = inputFile->buffer[offset];
- attribute = inputFile->buffer[offset + 1];
+ character = ctx->buffer[offset];
+ attribute = ctx->buffer[offset + 1];
offset += 2;
}
// char
else if (ctype == 0x40) {
if (character == -1) {
- character = inputFile->buffer[offset];
+ character = ctx->buffer[offset];
offset++;
}
- attribute = inputFile->buffer[offset];
+ attribute = ctx->buffer[offset];
offset++;
}
// attr
else if (ctype == 0x80) {
if (attribute == -1) {
- attribute = inputFile->buffer[offset];
+ attribute = ctx->buffer[offset];
offset++;
}
- character = inputFile->buffer[offset];
+ character = ctx->buffer[offset];
offset++;
}
// both
else {
if (character == -1) {
- character = inputFile->buffer[offset];
+ character = ctx->buffer[offset];
offset++;
}
if (attribute == -1) {
- attribute = inputFile->buffer[offset];
+ attribute = ctx->buffer[offset];
offset++;
}
}
@@ -148,14 +148,14 @@ int ansilove_xbin(struct input *inputFile, struct output *outputFile)
}
} else {
// read uncompressed xbin
- while (offset < inputFile->length && row != xbin_height) {
+ while (offset < ctx->length && row != xbin_height) {
if (column == xbin_width) {
column = 0;
row++;
}
- character = inputFile->buffer[offset];
- attribute = inputFile->buffer[offset+1];
+ character = ctx->buffer[offset];
+ attribute = ctx->buffer[offset+1];
background = (attribute & 240) >> 4;
foreground = attribute & 15;