ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 176816c645a69ea3398f79b3e4509bc35a2573c0
parent 2690b56f816a3254530223a4889df93c0470a1ad
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat, 23 Jul 2016 13:29:39 +0200

Variable names harmonisation

Diffstat:
Msrc/ansilove.c | 14+++++++-------
Msrc/ansilove.h | 2+-
Msrc/loaders/ansi.c | 30+++++++++++++++---------------
Msrc/loaders/ansi.h | 2+-
Msrc/loaders/artworx.c | 18+++++++++---------
Msrc/loaders/artworx.h | 2+-
Msrc/loaders/binary.c | 16++++++++--------
Msrc/loaders/binary.h | 2+-
Msrc/loaders/icedraw.c | 28++++++++++++++--------------
Msrc/loaders/icedraw.h | 2+-
Msrc/loaders/pcboard.c | 28++++++++++++++--------------
Msrc/loaders/pcboard.h | 2+-
Msrc/loaders/tundra.c | 62+++++++++++++++++++++++++++++++-------------------------------
Msrc/loaders/tundra.h | 2+-
Msrc/loaders/xbin.c | 48++++++++++++++++++++++++------------------------
Msrc/loaders/xbin.h | 2+-
Msrc/main.c | 28++++++++++++++--------------
17 files changed, 144 insertions(+), 144 deletions(-)

diff --git a/src/ansilove.c b/src/ansilove.c @@ -12,24 +12,24 @@ #include "ansilove.h" // shared method for drawing characters -void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t int_bits, +void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t bits, int32_t font_size_y, int32_t position_x, int32_t position_y, int32_t color_background, int32_t color_foreground, unsigned char character) { int32_t column, line; - gdImageFilledRectangle(im, position_x * int_bits, position_y*font_size_y, position_x * int_bits + - int_bits - 1, position_y * font_size_y + font_size_y - 1, color_background); + gdImageFilledRectangle(im, position_x * bits, position_y*font_size_y, position_x * bits + + bits - 1, position_y * font_size_y + font_size_y - 1, color_background); for (line = 0; line < font_size_y; line++) { - for (column = 0; column < int_bits; column++) { + for (column = 0; column < bits; column++) { if ((font_data[line+character*font_size_y] & (0x80 >> column)) != 0) { - gdImageSetPixel(im, position_x * int_bits + column, position_y*font_size_y + line, color_foreground); + gdImageSetPixel(im, position_x * bits + column, position_y*font_size_y + line, color_foreground); - if (int_bits==9 && column==7 && character > 191 && character < 224) + if (bits==9 && column==7 && character > 191 && character < 224) { - gdImageSetPixel(im, position_x * int_bits + 8, position_y * font_size_y + line, color_foreground); + gdImageSetPixel(im, position_x * bits + 8, position_y * font_size_y + line, color_foreground); } } } diff --git a/src/ansilove.h b/src/ansilove.h @@ -31,7 +31,7 @@ #define ansilove_h // prototypes -void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t int_bits, +void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t bits, int32_t font_size_y, int32_t position_x, int32_t position_y, int32_t color_background, int32_t color_foreground, unsigned char character); diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -11,7 +11,7 @@ #include "ansi.h" -void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, char *mode, bool icecolors, char *fext, bool createRetinaRep) +void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, char *mode, bool icecolors, char *fext, bool createRetinaRep) { // ladies and gentlemen, it's type declaration time struct fontStruct fontData; @@ -77,10 +77,10 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu ansi_buffer = malloc(sizeof(struct ansiChar)); // ANSi interpreter - while (loop < input_file_size) + while (loop < inputFileSize) { - current_character = input_file_buffer[loop]; - next_character = input_file_buffer[loop + 1]; + current_character = inputFileBuffer[loop]; + next_character = inputFileBuffer[loop + 1]; if (position_x==80 && WRAP_COLUMN_80) { @@ -119,13 +119,13 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu { for (ansi_sequence_loop = 0; ansi_sequence_loop < 12; ansi_sequence_loop++) { - ansi_sequence_character = input_file_buffer[loop + 2 + ansi_sequence_loop]; + ansi_sequence_character = inputFileBuffer[loop + 2 + ansi_sequence_loop]; // cursor position if (ansi_sequence_character == 'H' || ansi_sequence_character == 'f') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // create sequence content array seqArrayCount = explode(&seqArray, ';', seqGrab); @@ -152,7 +152,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='A') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // now get escape sequence's position value int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr); @@ -171,7 +171,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='B') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // now get escape sequence's position value int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr); @@ -190,7 +190,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='C') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // now get escape sequence's position value int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr); @@ -214,7 +214,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='D') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // now get escape sequence's content length int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr); @@ -258,7 +258,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='J') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // convert grab to an integer int32_t eraseDisplayInt = strtonum(seqGrab, 0, INT32_MAX, &errstr); @@ -284,7 +284,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (ansi_sequence_character=='m') { // create substring from the sequence's content - seqGrab = substr((char *)input_file_buffer, loop+2, ansi_sequence_loop); + seqGrab = substr((char *)inputFileBuffer, loop+2, ansi_sequence_loop); // create sequence content array seqArrayCount = explode(&seqArray, ';', seqGrab); @@ -423,7 +423,7 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu } // create that damn thingy - im_ANSi = gdImageCreate(columns * int_bits,(position_y_max)*fontData.font_size_y); + im_ANSi = gdImageCreate(columns * bits,(position_y_max)*fontData.font_size_y); if (!im_ANSi) { fputs ("\nCan't allocate ANSi buffer image memory.\n\n", stderr); exit (6); @@ -500,10 +500,10 @@ void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu position_y = ansi_buffer[loop].position_y; if (ced) { - alDrawChar(im_ANSi, fontData.font_data, int_bits, fontData.font_size_y, + alDrawChar(im_ANSi, fontData.font_data, bits, fontData.font_size_y, position_x, position_y, ced_background, ced_foreground, character); } else { - alDrawChar(im_ANSi, fontData.font_data, int_bits, fontData.font_size_y, + alDrawChar(im_ANSi, fontData.font_data, bits, fontData.font_size_y, position_x, position_y, colors[color_background], colors[color_foreground], character); } diff --git a/src/loaders/ansi.h b/src/loaders/ansi.h @@ -26,6 +26,6 @@ struct ansiChar { bool underline; }; -void ansi(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, char *mode, bool icecolors, char *fext, bool createRetinaRep); +void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, char *mode, bool icecolors, char *fext, bool createRetinaRep); #endif diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -11,7 +11,7 @@ #include "artworx.h" -void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep) +void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep) { const unsigned char *font_data; unsigned char *font_data_adf; @@ -20,7 +20,7 @@ void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *ou gdImagePtr im_ADF; // create ADF instance - im_ADF = gdImageCreate(640,(((input_file_size - 192 - 4096 -1) / 2) / 80) * 16); + im_ADF = gdImageCreate(640,(((inputFileSize - 192 - 4096 -1) / 2) / 80) * 16); // error output if (!im_ADF) { @@ -38,7 +38,7 @@ void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *ou if (font_data_adf == NULL) { fputs ("\nMemory error.\n\n", stderr); exit (7); } - memcpy(font_data_adf,input_file_buffer+193,4096); + memcpy(font_data_adf,inputFileBuffer+193,4096); font_data=font_data_adf; @@ -46,9 +46,9 @@ void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *ou for (loop = 0; loop < 16; loop++) { index = (adf_colors[loop] * 3) + 1; - gdImageColorAllocate(im_ADF, (input_file_buffer[index] << 2 | input_file_buffer[index] >> 4), - (input_file_buffer[index + 1] << 2 | input_file_buffer[index + 1] >> 4), - (input_file_buffer[index + 2] << 2 | input_file_buffer[index + 2] >> 4)); + gdImageColorAllocate(im_ADF, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4), + (inputFileBuffer[index + 1] << 2 | inputFileBuffer[index + 1] >> 4), + (inputFileBuffer[index + 2] << 2 | inputFileBuffer[index + 2] >> 4)); } gdImageColorAllocate(im_ADF, 0, 0, 0); @@ -58,7 +58,7 @@ void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *ou int32_t character, attribute, color_foreground, color_background; loop = 192 + 4096 + 1; - while(loop < input_file_size) + while(loop < inputFileSize) { if (position_x == 80) { @@ -66,8 +66,8 @@ void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *ou position_y++; } - character = input_file_buffer[loop]; - attribute = input_file_buffer[loop+1]; + character = inputFileBuffer[loop]; + attribute = inputFileBuffer[loop+1]; color_background = (attribute & 240) >> 4; color_foreground = attribute & 15; diff --git a/src/loaders/artworx.h b/src/loaders/artworx.h @@ -14,6 +14,6 @@ #ifndef artworx_h #define artworx_h -void artworx(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep); +void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep); #endif diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -11,7 +11,7 @@ #include "binary.h" -void binary(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, int32_t int_columns, char *font, int32_t int_bits, bool icecolors, bool createRetinaRep) +void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, int32_t columns, char *font, int32_t bits, bool icecolors, bool createRetinaRep) { // some type declarations struct fontStruct fontData; @@ -23,8 +23,8 @@ void binary(unsigned char *input_file_buffer, int32_t input_file_size, char *out gdImagePtr im_Binary; // allocate buffer image memory - im_Binary = gdImageCreate(int_columns * int_bits, - ((input_file_size / 2) / int_columns * fontData.font_size_y)); + im_Binary = gdImageCreate(columns * bits, + ((inputFileSize / 2) / columns * fontData.font_size_y)); if (!im_Binary) { fputs ("\nError, can't allocate buffer image memory.\n\n", stderr); exit (6); @@ -57,16 +57,16 @@ void binary(unsigned char *input_file_buffer, int32_t input_file_size, char *out int32_t character, attribute, color_background, color_foreground; int32_t loop = 0, position_x = 0, position_y = 0; - while (loop < input_file_size) + while (loop < inputFileSize) { - if (position_x == int_columns) + if (position_x == columns) { position_x = 0; position_y++; } - character = input_file_buffer[loop]; - attribute = input_file_buffer[loop+1]; + character = inputFileBuffer[loop]; + attribute = inputFileBuffer[loop+1]; color_background = (attribute & 240) >> 4; color_foreground = (attribute & 15); @@ -76,7 +76,7 @@ void binary(unsigned char *input_file_buffer, int32_t input_file_size, char *out color_background -= 8; } - alDrawChar(im_Binary, fontData.font_data, int_bits, fontData.font_size_y, + alDrawChar(im_Binary, fontData.font_data, bits, fontData.font_size_y, position_x, position_y, colors[color_background], colors[color_foreground], character); position_x++; diff --git a/src/loaders/binary.h b/src/loaders/binary.h @@ -14,7 +14,7 @@ #ifndef binary_h #define binary_h -void binary(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, int32_t int_columns, char *font, int32_t int_bits, bool icecolors, bool createRetinaRep); +void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, int32_t columns, char *font, int32_t bits, bool icecolors, bool createRetinaRep); #endif diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -11,13 +11,13 @@ #include "icedraw.h" -void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep) +void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep) { const unsigned char *font_data; unsigned char *font_data_idf; // extract relevant part of the IDF header, 16-bit endian unsigned short - int32_t x2 = (input_file_buffer[9] << 8) + input_file_buffer[8]; + int32_t x2 = (inputFileBuffer[9] << 8) + inputFileBuffer[8]; // libgd image pointers gdImagePtr im_IDF; @@ -31,7 +31,7 @@ void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *ou if (font_data_idf == NULL) { fputs ("\nMemory error.\n\n", stderr); exit (7); } - memcpy(font_data_idf,input_file_buffer+(input_file_size - 48 - 4096),4096); + memcpy(font_data_idf,inputFileBuffer+(inputFileSize - 48 - 4096),4096); font_data=font_data_idf; @@ -45,14 +45,14 @@ void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *ou int16_t idf_data, idf_data_length; - while (loop < input_file_size - 4096 - 48) + while (loop < inputFileSize - 4096 - 48) { - memcpy(&idf_data,input_file_buffer+loop,2); + memcpy(&idf_data,inputFileBuffer+loop,2); // RLE compressed data if (idf_data==1) { - memcpy(&idf_data_length,input_file_buffer+loop+2,2); + memcpy(&idf_data_length,inputFileBuffer+loop+2,2); idf_sequence_length = idf_data_length & 255; @@ -67,8 +67,8 @@ void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *ou fputs ("\nError allocating IDF buffer memory.\n\n", stderr); exit (7); } - idf_buffer[i] = input_file_buffer[loop + 4]; - idf_buffer[i+1] = input_file_buffer[loop + 5]; + idf_buffer[i] = inputFileBuffer[loop + 4]; + idf_buffer[i+1] = inputFileBuffer[loop + 5]; i+=2; } loop += 4; @@ -84,8 +84,8 @@ void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *ou } // normal character - idf_buffer[i] = input_file_buffer[loop]; - idf_buffer[i+1] = input_file_buffer[loop + 1]; + idf_buffer[i] = inputFileBuffer[loop]; + idf_buffer[i+1] = inputFileBuffer[loop + 1]; i+=2; } loop += 2; @@ -103,10 +103,10 @@ void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *ou // process IDF palette for (loop = 0; loop < 16; loop++) { - index = (loop * 3) + input_file_size - 48; - colors[loop] = gdImageColorAllocate(im_IDF, (input_file_buffer[index] << 2 | input_file_buffer[index] >> 4), - (input_file_buffer[index + 1] << 2 | input_file_buffer[index + 1] >> 4), - (input_file_buffer[index + 2] << 2 | input_file_buffer[index + 2] >> 4)); + index = (loop * 3) + inputFileSize - 48; + colors[loop] = gdImageColorAllocate(im_IDF, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4), + (inputFileBuffer[index + 1] << 2 | inputFileBuffer[index + 1] >> 4), + (inputFileBuffer[index + 2] << 2 | inputFileBuffer[index + 2] >> 4)); } // render IDF diff --git a/src/loaders/icedraw.h b/src/loaders/icedraw.h @@ -14,7 +14,7 @@ #ifndef icedraw_h #define icedraw_h -void icedraw(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep); +void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep); #endif diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -11,7 +11,7 @@ #include "pcboard.h" -void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, bool createRetinaRep) +void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, bool createRetinaRep) { // some type declarations struct fontStruct fontData; @@ -39,10 +39,10 @@ void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *ou loop = 0; structIndex = 0; - while (loop < input_file_size) + while (loop < inputFileSize) { - current_character = input_file_buffer[loop]; - next_character = input_file_buffer[loop+1]; + current_character = inputFileBuffer[loop]; + next_character = inputFileBuffer[loop+1]; if (position_x == 80) { @@ -80,12 +80,12 @@ void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *ou if (current_character == 64 && next_character == 88) { // set graphics rendition - color_background = input_file_buffer[loop+2]; - color_foreground = input_file_buffer[loop+3]; + color_background = inputFileBuffer[loop+2]; + color_foreground = inputFileBuffer[loop+3]; loop+=3; } else if (current_character == 64 && next_character == 67 && - input_file_buffer[loop+2] == 'L' && input_file_buffer[loop+3] == 'S') + inputFileBuffer[loop+2] == 'L' && inputFileBuffer[loop+3] == 'S') { // erase display position_x = 0; @@ -96,18 +96,18 @@ void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *ou loop+=4; } - else if (current_character == 64 && next_character == 80 && input_file_buffer[loop+2] == 'O' - && input_file_buffer[loop+3] == 'S' && input_file_buffer[loop+4]== ':') + else if (current_character == 64 && next_character == 80 && inputFileBuffer[loop+2] == 'O' + && inputFileBuffer[loop+3] == 'S' && inputFileBuffer[loop+4]== ':') { // cursor position - if (input_file_buffer[loop+6]=='@') + if (inputFileBuffer[loop+6]=='@') { - position_x=((input_file_buffer[loop+5])-48)-1; + position_x=((inputFileBuffer[loop+5])-48)-1; loop+=5; } else { - position_x = (10 * ((input_file_buffer[loop+5])-48) + (input_file_buffer[loop+6])-48)-1; + position_x = (10 * ((inputFileBuffer[loop+5])-48) + (inputFileBuffer[loop+6])-48)-1; loop+=6; } } @@ -144,7 +144,7 @@ void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *ou position_y_max++; // allocate buffer image memory - im_PCB = gdImageCreate(columns * int_bits, (position_y_max)*fontData.font_size_y); + im_PCB = gdImageCreate(columns * bits, (position_y_max)*fontData.font_size_y); // allocate black color and create background canvas gdImageColorAllocate(im_PCB, 0, 0, 0); @@ -183,7 +183,7 @@ void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *ou color_foreground = pcboard_buffer[loop].color_foreground; character = pcboard_buffer[loop].current_character; - alDrawChar(im_PCB, fontData.font_data, int_bits, fontData.font_size_y, + alDrawChar(im_PCB, fontData.font_data, bits, fontData.font_size_y, position_x, position_y, colors[color_background], colors[color_foreground], character); } diff --git a/src/loaders/pcboard.h b/src/loaders/pcboard.h @@ -23,6 +23,6 @@ struct pcbChar { int32_t current_character; }; -void pcboard(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, bool createRetinaRep); +void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, bool createRetinaRep); #endif diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -11,7 +11,7 @@ #include "tundra.h" -void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, bool createRetinaRep) +void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, bool createRetinaRep) { // some type declarations struct fontStruct fontData; @@ -26,8 +26,8 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out gdImagePtr im_Tundra; // extract tundra header - tundra_version = input_file_buffer[0]; - memcpy(&tundra_header,input_file_buffer+1,8); + tundra_version = inputFileBuffer[0]; + memcpy(&tundra_header,inputFileBuffer+1,8); // need to add check for "TUNDRA24" string in the header if (tundra_version != 24) @@ -41,7 +41,7 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out loop=9; - while (loop < input_file_size) + while (loop < inputFileSize) { if (position_x == 80) { @@ -49,38 +49,38 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out position_y++; } - character = input_file_buffer[loop]; + character = inputFileBuffer[loop]; if (character == 1) { position_y = - (input_file_buffer[loop + 1] << 24) + (input_file_buffer[loop + 2] << 16) + - (input_file_buffer[loop + 3] << 8) + input_file_buffer[loop+4]; + (inputFileBuffer[loop + 1] << 24) + (inputFileBuffer[loop + 2] << 16) + + (inputFileBuffer[loop + 3] << 8) + inputFileBuffer[loop+4]; position_x = - (input_file_buffer[loop + 5] << 24) + (input_file_buffer[loop + 6] << 16) + - (input_file_buffer[loop + 7] << 8) + input_file_buffer[loop+8]; + (inputFileBuffer[loop + 5] << 24) + (inputFileBuffer[loop + 6] << 16) + + (inputFileBuffer[loop + 7] << 8) + inputFileBuffer[loop+8]; loop+=8; } if (character == 2) { - character = input_file_buffer[loop + 1]; + character = inputFileBuffer[loop + 1]; loop+=5; } if (character == 4) { - character = input_file_buffer[loop + 1]; + character = inputFileBuffer[loop + 1]; loop+=5; } if (character == 6) { - character = input_file_buffer[loop + 1]; + character = inputFileBuffer[loop + 1]; loop+=9; } @@ -95,7 +95,7 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out position_y++; // allocate buffer image memory - im_Tundra = gdImageCreateTrueColor(columns * int_bits , (position_y) * fontData.font_size_y); + im_Tundra = gdImageCreateTrueColor(columns * bits , (position_y) * fontData.font_size_y); if (!im_Tundra) { fputs ("\nError, can't allocate buffer image memory.\n\n", stderr); exit (6); @@ -107,7 +107,7 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out loop = 9; - while (loop < input_file_size) + while (loop < inputFileSize) { if (position_x == 80) { @@ -115,17 +115,17 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out position_y++; } - character = input_file_buffer[loop]; + character = inputFileBuffer[loop]; if (character == 1) { position_y = - (input_file_buffer[loop + 1] << 24) + (input_file_buffer[loop + 2] << 16) + - (input_file_buffer[loop + 3] << 8) + input_file_buffer[loop + 4]; + (inputFileBuffer[loop + 1] << 24) + (inputFileBuffer[loop + 2] << 16) + + (inputFileBuffer[loop + 3] << 8) + inputFileBuffer[loop + 4]; position_x = - (input_file_buffer[loop + 5] << 24) + (input_file_buffer[loop + 6] << 16) + - (input_file_buffer[loop + 7] << 8) + input_file_buffer[loop + 8]; + (inputFileBuffer[loop + 5] << 24) + (inputFileBuffer[loop + 6] << 16) + + (inputFileBuffer[loop + 7] << 8) + inputFileBuffer[loop + 8]; loop+=8; } @@ -133,20 +133,20 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out if (character == 2) { color_foreground = - (input_file_buffer[loop + 3] << 16) + (input_file_buffer[loop + 4] << 8) + - input_file_buffer[loop + 5]; + (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + + inputFileBuffer[loop + 5]; - character = input_file_buffer[loop+1]; + character = inputFileBuffer[loop+1]; loop+=5; } if (character == 4) { - color_background = (input_file_buffer[loop + 3] << 16) + (input_file_buffer[loop + 4] << 8) + - input_file_buffer[loop+5]; + color_background = (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + + inputFileBuffer[loop+5]; - character = input_file_buffer[loop+1]; + character = inputFileBuffer[loop+1]; loop+=5; } @@ -154,21 +154,21 @@ void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *out if (character==6) { color_foreground = - (input_file_buffer[loop + 3] << 16) + (input_file_buffer[loop + 4] << 8) + - input_file_buffer[loop+5]; + (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + + inputFileBuffer[loop+5]; color_background = - (input_file_buffer[loop + 7] << 16) + (input_file_buffer[loop + 8] << 8) + - input_file_buffer[loop+9]; + (inputFileBuffer[loop + 7] << 16) + (inputFileBuffer[loop + 8] << 8) + + inputFileBuffer[loop+9]; - character = input_file_buffer[loop+1]; + character = inputFileBuffer[loop+1]; loop+=9; } if (character !=1 && character !=2 && character !=4 && character !=6) { - alDrawChar(im_Tundra, fontData.font_data, int_bits, fontData.font_size_y, + alDrawChar(im_Tundra, fontData.font_data, bits, fontData.font_size_y, position_x, position_y, color_background, color_foreground, character); position_x++; diff --git a/src/loaders/tundra.h b/src/loaders/tundra.h @@ -14,6 +14,6 @@ #ifndef tundra_h #define tundra_h -void tundra(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, char *font, int32_t int_bits, bool createRetinaRep); +void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, char *font, int32_t bits, bool createRetinaRep); #endif diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -11,19 +11,19 @@ #include "xbin.h" -void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep) +void xbin(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep) { const unsigned char *font_data; unsigned char *font_data_xbin; - if (strncmp((char *)input_file_buffer, "XBIN\x1a", 5) != 0) { + if (strncmp((char *)inputFileBuffer, "XBIN\x1a", 5) != 0) { fputs("\nNot an XBin.\n\n", stderr); exit (4); } - int32_t xbin_width = (input_file_buffer[ 6 ] << 8) + input_file_buffer[ 5 ]; - int32_t xbin_height = (input_file_buffer[ 8 ] << 8) + input_file_buffer[ 7 ]; - int32_t xbin_fontsize = input_file_buffer[ 9 ]; - int32_t xbin_flags = input_file_buffer[ 10 ]; + int32_t xbin_width = (inputFileBuffer[ 6 ] << 8) + inputFileBuffer[ 5 ]; + int32_t xbin_height = (inputFileBuffer[ 8 ] << 8) + inputFileBuffer[ 7 ]; + int32_t xbin_fontsize = inputFileBuffer[ 9 ]; + int32_t xbin_flags = inputFileBuffer[ 10 ]; gdImagePtr im_XBIN; @@ -48,9 +48,9 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu { index = (loop * 3) + offset; - colors[loop] = gdImageColorAllocate(im_XBIN, (input_file_buffer[index] << 2 | input_file_buffer[index] >> 4), - (input_file_buffer[index + 1] << 2 | input_file_buffer[index + 1] >> 4), - (input_file_buffer[index + 2] << 2 | input_file_buffer[index + 2] >> 4)); + colors[loop] = gdImageColorAllocate(im_XBIN, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4), + (inputFileBuffer[index + 1] << 2 | inputFileBuffer[index + 1] >> 4), + (inputFileBuffer[index + 2] << 2 | inputFileBuffer[index + 2] >> 4)); } offset += 48; @@ -83,7 +83,7 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu if (font_data_xbin == NULL) { fputs ("\nMemory error.\n\n", stderr); exit (5); } - memcpy(font_data_xbin,input_file_buffer+offset,(xbin_fontsize * numchars)); + memcpy(font_data_xbin,inputFileBuffer+offset,(xbin_fontsize * numchars)); font_data=font_data_xbin; @@ -99,10 +99,10 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu // read compressed xbin if( (xbin_flags & 4) == 4) { - while(offset < input_file_size && position_y != xbin_height ) + while(offset < inputFileSize && position_y != xbin_height ) { - int32_t ctype = input_file_buffer[ offset ] & 0xC0; - int32_t counter = ( input_file_buffer[ offset ] & 0x3F ) + 1; + int32_t ctype = inputFileBuffer[ offset ] & 0xC0; + int32_t counter = ( inputFileBuffer[ offset ] & 0x3F ) + 1; character = -1; attribute = -1; @@ -111,36 +111,36 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu while( counter-- ) { // none if( ctype == 0 ) { - character = input_file_buffer[ offset ]; - attribute = input_file_buffer[ offset + 1 ]; + character = inputFileBuffer[ offset ]; + attribute = inputFileBuffer[ offset + 1 ]; offset += 2; } // char else if ( ctype == 0x40 ) { if( character == -1 ) { - character = input_file_buffer[ offset ]; + character = inputFileBuffer[ offset ]; offset++; } - attribute = input_file_buffer[ offset ]; + attribute = inputFileBuffer[ offset ]; offset++; } // attr else if ( ctype == 0x80 ) { if( attribute == -1 ) { - attribute = input_file_buffer[ offset ]; + attribute = inputFileBuffer[ offset ]; offset++; } - character = input_file_buffer[ offset ]; + character = inputFileBuffer[ offset ]; offset++; } // both else { if( character == -1 ) { - character = input_file_buffer[ offset ]; + character = inputFileBuffer[ offset ]; offset++; } if( attribute == -1 ) { - attribute = input_file_buffer[ offset ]; + attribute = inputFileBuffer[ offset ]; offset++; } } @@ -162,7 +162,7 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu } // read uncompressed xbin else { - while(offset < input_file_size && position_y != xbin_height ) + while(offset < inputFileSize && position_y != xbin_height ) { if (position_x == xbin_width) { @@ -170,8 +170,8 @@ void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *outpu position_y++; } - character = input_file_buffer[offset]; - attribute = input_file_buffer[offset+1]; + character = inputFileBuffer[offset]; + attribute = inputFileBuffer[offset+1]; color_background = (attribute & 240) >> 4; color_foreground = attribute & 15; diff --git a/src/loaders/xbin.h b/src/loaders/xbin.h @@ -14,6 +14,6 @@ #ifndef xbin_h #define xbin_h -void xbin(unsigned char *input_file_buffer, int32_t input_file_size, char *output, char *retinaout, bool createRetinaRep); +void xbin(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, char *retinaout, bool createRetinaRep); #endif diff --git a/src/main.c b/src/main.c @@ -283,26 +283,26 @@ int main(int argc, char *argv[]) { // get the file size (bytes) struct stat input_file_stat; stat (input, &input_file_stat); - size_t input_file_size=input_file_stat.st_size; + size_t inputFileSize=input_file_stat.st_size; // next up is loading our file into a dynamically allocated memory buffer - unsigned char *input_file_buffer; + unsigned char *inputFileBuffer; // allocate memory to contain the whole file - input_file_buffer = (unsigned char *) malloc(sizeof(unsigned char)*input_file_size); - if (input_file_buffer == NULL) { + inputFileBuffer = (unsigned char *) malloc(sizeof(unsigned char)*inputFileSize); + if (inputFileBuffer == NULL) { fputs ("\nMemory error.\n\n", stderr); exit (2); } // copy the file into the buffer - if (fread(input_file_buffer, 1, input_file_size, input_file) != input_file_size) { + if (fread(inputFileBuffer, 1, inputFileSize, input_file) != inputFileSize) { fputs ("\nReading error.\n\n", stderr); exit (3); - } // whole file is now loaded into input_file_buffer + } // whole file is now loaded into inputFileBuffer // adjust the file size if file contains a SAUCE record if(fileHasSAUCE) { sauce *saucerec = sauceReadFile(input_file); - input_file_size -= 129 - ( saucerec->comments > 0 ? 5 + 64 * saucerec->comments : 0); + inputFileSize -= 129 - ( saucerec->comments > 0 ? 5 + 64 * saucerec->comments : 0); } // close input file, we don't need it anymore @@ -311,27 +311,27 @@ int main(int argc, char *argv[]) { // create the output file by invoking the appropiate function if (!strcmp(fext, ".pcb")) { // params: input, output, font, bits, icecolors - pcboard(input_file_buffer, input_file_size, outputFile, retinaout, font, bits, createRetinaRep); + pcboard(inputFileBuffer, inputFileSize, outputFile, retinaout, font, bits, createRetinaRep); fileIsPCBoard = true; } else if (!strcmp(fext, ".bin")) { // params: input, output, columns, font, bits, icecolors - binary(input_file_buffer, input_file_size, outputFile, retinaout, columns, font, bits, icecolors, createRetinaRep); + binary(inputFileBuffer, inputFileSize, outputFile, retinaout, columns, font, bits, icecolors, createRetinaRep); fileIsBinary = true; } else if (!strcmp(fext, ".adf")) { // params: input, output, bits - artworx(input_file_buffer, input_file_size, outputFile, retinaout, createRetinaRep); + artworx(inputFileBuffer, inputFileSize, outputFile, retinaout, createRetinaRep); } else if (!strcmp(fext, ".idf")) { // params: input, output, bits - icedraw(input_file_buffer, input_file_size, outputFile, retinaout, createRetinaRep); + icedraw(inputFileBuffer, inputFileSize, outputFile, retinaout, createRetinaRep); } else if (!strcmp(fext, ".tnd")) { - tundra(input_file_buffer, input_file_size, outputFile, retinaout, font, bits, createRetinaRep); + tundra(inputFileBuffer, inputFileSize, outputFile, retinaout, font, bits, createRetinaRep); fileIsTundra = true; } else if (!strcmp(fext, ".xb")) { // params: input, output, bits - xbin(input_file_buffer, input_file_size, outputFile, retinaout, createRetinaRep); + xbin(inputFileBuffer, inputFileSize, outputFile, retinaout, createRetinaRep); } else { // params: input, output, font, bits, icecolors, fext - ansi(input_file_buffer, input_file_size, outputFile, retinaout, font, bits, mode, icecolors, fext, createRetinaRep); + ansi(inputFileBuffer, inputFileSize, outputFile, retinaout, font, bits, mode, icecolors, fext, createRetinaRep); fileIsANSi = true; }