|
|
nono 0.1.0
//
// Copyright (C) 2012-2016 [email protected]
//
// cgrom.dat を C ソースに変換する
//
// 書式
// gencgrom <cgrom.dat> <cgrom.cpp>
//
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
int
main(int ac, char *av[])
{
char buf[4096];
const char *infile;
const char *outfile;
FILE *in;
FILE *out;
int n;
int i;
if (ac < 3) {
fprintf(stderr, "usage: %s <infile> <outfile>\n", av[0]);
exit(1);
}
infile = av[1];
outfile = av[2];
in = fopen(infile, "rb");
if (in == NULL) {
fprintf(stderr, "cannot open %s\n", infile);
exit(1);
}
out = fopen(outfile, "wb");
if (out == NULL) {
fprintf(stderr, "cannot open %s\n", outfile);
exit(1);
}
fprintf(out, "// This file is auto-generated by %s\n", av[0]);
fprintf(out, "#include \"cgrom.h\"\n");
fprintf(out, "/*static*/ uint8 const BuiltinCGROM::data[] = {");
for (;;) {
n = fread(buf, 1, sizeof(buf), in);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
if (i % 8 == 0) {
fprintf(out, "\n\t");
}
fprintf(out, "0x%02x,", (unsigned char)buf[i]);
}
}
fprintf(out, "\n};\n");
fclose(in);
fclose(out);
exit(0);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.