Added support for .fon files with -f option
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1145 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+22
-12
@@ -32,12 +32,13 @@ struct options {
|
|||||||
char verbose;
|
char verbose;
|
||||||
int num_palettefiles;
|
int num_palettefiles;
|
||||||
char **palettefiles;
|
char **palettefiles;
|
||||||
|
char font;
|
||||||
};
|
};
|
||||||
|
|
||||||
int max_palettes;
|
int max_palettes;
|
||||||
png_color palettes[256][256];
|
png_color palettes[256][256];
|
||||||
|
|
||||||
index_header *readIndex(const uint8 *buf);
|
index_header *readIndex(const uint8 *buf, int isfont);
|
||||||
void printIndex(const index_header *h, const uint8 *buf, FILE *out);
|
void printIndex(const index_header *h, const uint8 *buf, FILE *out);
|
||||||
void generateAni(const index_header *h, const uint8 *buf, const char *prefix,
|
void generateAni(const index_header *h, const uint8 *buf, const char *prefix,
|
||||||
FILE *out);
|
FILE *out);
|
||||||
@@ -89,7 +90,7 @@ main(int argc, char *argv[]) {
|
|||||||
loadPalette(opts.palettefiles[i]);
|
loadPalette(opts.palettefiles[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
h = readIndex(buf);
|
h = readIndex(buf, opts.font);
|
||||||
if (opts.print)
|
if (opts.print)
|
||||||
printIndex(h, buf, stdout);
|
printIndex(h, buf, stdout);
|
||||||
|
|
||||||
@@ -152,9 +153,9 @@ main(int argc, char *argv[]) {
|
|||||||
void
|
void
|
||||||
usage() {
|
usage() {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"unani -a <infile>\n"
|
"unani -a [-f] <infile>\n"
|
||||||
"unani -p <infile>\n"
|
"unani -p [-f] <infile>\n"
|
||||||
"unani [-c <clutfile>] [-o <outdir>] [-n <prefix>] <infile>\n");
|
"unani [-f] [-c <clutfile>] [-o <outdir>] [-n <prefix>] <infile>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -163,7 +164,7 @@ parse_arguments(int argc, char *argv[], struct options *opts) {
|
|||||||
|
|
||||||
memset(opts, '\0', sizeof (struct options));
|
memset(opts, '\0', sizeof (struct options));
|
||||||
while (1) {
|
while (1) {
|
||||||
ch = getopt(argc, argv, "ac:hln:o:pv");
|
ch = getopt(argc, argv, "ac:hln:o:pfv");
|
||||||
if (ch == -1)
|
if (ch == -1)
|
||||||
break;
|
break;
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
@@ -188,6 +189,9 @@ parse_arguments(int argc, char *argv[], struct options *opts) {
|
|||||||
case 'p':
|
case 'p':
|
||||||
opts->print = 1;
|
opts->print = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
opts->font = 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
opts->verbose = 1;
|
opts->verbose = 1;
|
||||||
break;
|
break;
|
||||||
@@ -211,7 +215,7 @@ parse_arguments(int argc, char *argv[], struct options *opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
index_header *
|
index_header *
|
||||||
readIndex(const uint8 *buf) {
|
readIndex(const uint8 *buf, int isfont) {
|
||||||
index_header *h;
|
index_header *h;
|
||||||
const uint8 *bufptr;
|
const uint8 *bufptr;
|
||||||
uint16 i;
|
uint16 i;
|
||||||
@@ -224,10 +228,16 @@ readIndex(const uint8 *buf) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
h->num_frames =
|
if (isfont) {
|
||||||
|
h->num_frames = MAX_FONT_CHARS;
|
||||||
|
h->frames_ofs = 0x70;
|
||||||
|
} else {
|
||||||
|
h->num_frames =
|
||||||
INDEX_GET(MAKE_DWORD(buf[11], buf[10], buf[9], buf[8])) + 1;
|
INDEX_GET(MAKE_DWORD(buf[11], buf[10], buf[9], buf[8])) + 1;
|
||||||
|
h->frames_ofs = 0x0c;
|
||||||
bufptr = buf + 12;
|
}
|
||||||
|
|
||||||
|
bufptr = buf + h->frames_ofs;
|
||||||
h->frames = malloc(h->num_frames * sizeof (frame_desc));
|
h->frames = malloc(h->num_frames * sizeof (frame_desc));
|
||||||
for (i = 0; i < h->num_frames; i++) {
|
for (i = 0; i < h->num_frames; i++) {
|
||||||
uint32 temp;
|
uint32 temp;
|
||||||
@@ -255,8 +265,8 @@ printIndex(const index_header *h, const uint8 *buf, FILE *out) {
|
|||||||
fprintf(out, "0x00000008 Number of frames: %d\n",
|
fprintf(out, "0x00000008 Number of frames: %d\n",
|
||||||
h->num_frames);
|
h->num_frames);
|
||||||
|
|
||||||
bufptr = buf + 0x0c;
|
bufptr = buf + h->frames_ofs;
|
||||||
fprintf(out, "0x0000000c frame info:\n");
|
fprintf(out, "0x%08x frame info:\n", h->frames_ofs);
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,23 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16 num_frames; // only first 12 bits used
|
uint16 num_frames; // only first 12 bits used
|
||||||
|
uint16 frames_ofs;
|
||||||
frame_desc *frames;
|
frame_desc *frames;
|
||||||
} index_header;
|
} index_header;
|
||||||
|
|
||||||
|
#define MAX_FONT_CHARS 0x60
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8 leading;
|
||||||
|
uint8 max_ascend;
|
||||||
|
uint8 max_descend;
|
||||||
|
uint8 spacing;
|
||||||
|
uint8 kern_amount;
|
||||||
|
uint8 kerntab[MAX_FONT_CHARS];
|
||||||
|
uint8 padding1_[3];
|
||||||
|
frame_desc frames[MAX_FONT_CHARS];
|
||||||
|
} FONT_DESC;
|
||||||
|
|
||||||
#define FTYPE_SHIFT 12
|
#define FTYPE_SHIFT 12
|
||||||
#define FINDEX_MASK ((1 << FTYPE_SHIFT) - 1)
|
#define FINDEX_MASK ((1 << FTYPE_SHIFT) - 1)
|
||||||
#define FTYPE_MASK (0xffff & ~FINDEX_MASK)
|
#define FTYPE_MASK (0xffff & ~FINDEX_MASK)
|
||||||
|
|||||||
Reference in New Issue
Block a user