Slightly better? I dunno.
This commit is contained in:
parent
8ab853d166
commit
3196fe9678
9 changed files with 244 additions and 102 deletions
|
@ -1,18 +1,18 @@
|
|||
#ifndef _COMMANDS_H
|
||||
#define _COMMANDS_H
|
||||
|
||||
void cammy_command_usage(int argc, char **argv, const char *message, ...);
|
||||
void cammy_usage(int argc, char **argv, const char *message, ...);
|
||||
|
||||
void cammy_command_validate_photo_number(int argc, char **argv, int num);
|
||||
void cammy_validate_photo_number(int argc, char **argv, int num);
|
||||
|
||||
int cammy_command_import(int argc, char **argv);
|
||||
int cammy_command_export(int argc, char **argv);
|
||||
int cammy_command_dither(int argc, char **argv);
|
||||
int cammy_command_split_rgb(int argc, char **argv);
|
||||
int cammy_command_merge_rgb(int argc, char **argv);
|
||||
int cammy_command_import_tile(int argc, char **argv);
|
||||
int cammy_command_export_tile(int argc, char **argv);
|
||||
int cammy_command_convert_tile(int argc, char **argv);
|
||||
int cammy_command_slice(int argc, char **argv);
|
||||
int cammy_import(int argc, char **argv);
|
||||
int cammy_export(int argc, char **argv);
|
||||
int cammy_dither(int argc, char **argv);
|
||||
int cammy_rgb_split(int argc, char **argv);
|
||||
int cammy_rgb_merge(int argc, char **argv);
|
||||
int cammy_tile_import(int argc, char **argv);
|
||||
int cammy_tile_export(int argc, char **argv);
|
||||
int cammy_tile_convert(int argc, char **argv);
|
||||
int cammy_slice(int argc, char **argv);
|
||||
|
||||
#endif /* _COMMANDS_H */
|
||||
|
|
23
bin/dither.c
23
bin/dither.c
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
@ -24,15 +24,30 @@ static cammy_tile_palette palette = {
|
|||
}
|
||||
};
|
||||
|
||||
int cammy_command_dither(int argc, char **argv) {
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s dither input.png output.png\n", argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_dither(int argc, char **argv) {
|
||||
uint8_t *bufin, *bufout;
|
||||
size_t width, height;
|
||||
int depth;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No PNG input file provided");
|
||||
usage(argc, argv, "No PNG input file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No PNG output filename provided");
|
||||
usage(argc, argv, "No PNG output filename provided");
|
||||
}
|
||||
|
||||
if ((bufin = cammy_png_load(argv[2], &width,
|
||||
|
|
27
bin/export.c
27
bin/export.c
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
@ -24,23 +24,38 @@ static cammy_tile_palette palette = {
|
|||
}
|
||||
};
|
||||
|
||||
int cammy_command_export(int argc, char **argv) {
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s export file.sav 1..30 output.png\n", argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_export(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
int photo = 0;
|
||||
uint8_t *buf;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No save file provided");
|
||||
usage(argc, argv, "No save file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No photo number provided");
|
||||
usage(argc, argv, "No photo number provided");
|
||||
} else if (argc < 5) {
|
||||
cammy_command_usage(argc, argv, "No output filename provided");
|
||||
usage(argc, argv, "No output filename provided");
|
||||
}
|
||||
|
||||
photo = atoi(argv[3]);
|
||||
|
||||
if (photo < 1 || photo > CAMMY_SRAM_PHOTO_COUNT) {
|
||||
cammy_command_usage(argc, argv, "Invalid photo number");
|
||||
usage(argc, argv, "Invalid photo number");
|
||||
}
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
|
|
26
bin/import.c
26
bin/import.c
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -9,7 +10,22 @@
|
|||
#include "pnglite.h"
|
||||
#include "commands.h"
|
||||
|
||||
int cammy_command_import(int argc, char **argv) {
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s import file.sav 1..30 input.png\n", argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_import(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
png_t *png;
|
||||
int photo = 0;
|
||||
|
@ -18,17 +34,17 @@ int cammy_command_import(int argc, char **argv) {
|
|||
int error;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No save file provided");
|
||||
usage(argc, argv, "No save file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No photo number provided");
|
||||
usage(argc, argv, "No photo number provided");
|
||||
} else if (argc < 5) {
|
||||
cammy_command_usage(argc, argv, "No photo provided");
|
||||
usage(argc, argv, "No photo provided");
|
||||
}
|
||||
|
||||
photo = atoi(argv[3]);
|
||||
|
||||
if (photo < 1 || photo > CAMMY_SRAM_PHOTO_COUNT) {
|
||||
cammy_command_usage(argc, argv, "Invalid photo number");
|
||||
usage(argc, argv, "Invalid photo number");
|
||||
}
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
|
|
69
bin/main.c
69
bin/main.c
|
@ -7,7 +7,25 @@
|
|||
|
||||
#include "commands.h"
|
||||
|
||||
void cammy_command_usage(int argc, char **argv, const char *message, ...) {
|
||||
static struct {
|
||||
char *name;
|
||||
int (*fun)(int, char **);
|
||||
} commands[] = {
|
||||
{ "import", cammy_import },
|
||||
{ "export", cammy_export },
|
||||
{ "dither", cammy_dither },
|
||||
{ "rgb-split", cammy_rgb_split },
|
||||
{ "rgb-merge", cammy_rgb_merge },
|
||||
{ "tile-import", cammy_tile_import },
|
||||
{ "tile-export", cammy_tile_export },
|
||||
{ "tile-convert", cammy_tile_convert },
|
||||
{ "slice", cammy_slice },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
int i;
|
||||
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
|
@ -17,47 +35,36 @@ void cammy_command_usage(int argc, char **argv, const char *message, ...) {
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s import file.sav 1..30 input.png\n"
|
||||
" %1$s export file.sav 1..30 output.png\n"
|
||||
" %1$s dither input.png output.png\n"
|
||||
" %1$s split-rgb file.sav rn gn bn input.png\n"
|
||||
" %1$s merge-rgb file.sav rn gn bn output.png\n"
|
||||
" %1$s import-tile file.sav 1..30 printer.tile\n"
|
||||
" %1$s export-tile file.sav 1..30 output.tile\n"
|
||||
" %1$s convert-tile printer.tile output.png\n"
|
||||
" %1$s slice x-pad y-pad input.png\n",
|
||||
argv[0]);
|
||||
for (i=0; commands[i].name; i++) {
|
||||
if (i == 0) {
|
||||
fprintf(stderr, "usage: %s %s\n", argv[0], commands[i].name);
|
||||
} else {
|
||||
int x, len = strlen(argv[0]);
|
||||
|
||||
fprintf(stderr, " ");
|
||||
|
||||
for (x=0; x<len; x++) {
|
||||
fprintf(stderr, " ");
|
||||
}
|
||||
|
||||
fprintf(stderr, " %s ...\n", commands[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void cammy_command_validate_photo_number(int argc, char **argv, int num) {
|
||||
void cammy_validate_photo_number(int argc, char **argv, int num) {
|
||||
if (num < 1 || num > CAMMY_SRAM_PHOTO_COUNT) {
|
||||
cammy_command_usage(argc, argv, "Invalid photo number");
|
||||
usage(argc, argv, "Invalid photo number");
|
||||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
int (*fun)(int, char **);
|
||||
} commands[] = {
|
||||
{ "import", cammy_command_import },
|
||||
{ "export", cammy_command_export },
|
||||
{ "dither", cammy_command_dither },
|
||||
{ "split-rgb", cammy_command_split_rgb },
|
||||
{ "merge-rgb", cammy_command_merge_rgb },
|
||||
{ "import-tile", cammy_command_import_tile },
|
||||
{ "export-tile", cammy_command_export_tile },
|
||||
{ "convert-tile", cammy_command_convert_tile },
|
||||
{ "slice", cammy_command_slice },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
|
||||
if (argc < 2) {
|
||||
cammy_command_usage(argc, argv, "No command specified");
|
||||
usage(argc, argv, "No command specified");
|
||||
}
|
||||
|
||||
for (i=0; commands[i].name; i++) {
|
||||
|
@ -66,7 +73,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
cammy_command_usage(argc, argv, "Unknown command '%s'", argv[1]);
|
||||
usage(argc, argv, "Unknown command '%s'", argv[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <cammy/screen.h>
|
||||
#include <cammy/image.h>
|
||||
#include <cammy/screen.h>
|
||||
#include <cammy/photo.h>
|
||||
#include <cammy/sram.h>
|
||||
|
||||
#include "pnglite.h"
|
||||
#include "png.h"
|
||||
|
|
66
bin/rgb.c
66
bin/rgb.c
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -10,7 +11,20 @@
|
|||
#include "pnglite.h"
|
||||
#include "commands.h"
|
||||
|
||||
int cammy_command_split_rgb(int argc, char **argv) {
|
||||
static void split_usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_rgb_split(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
png_t *png;
|
||||
|
||||
|
@ -23,20 +37,20 @@ int cammy_command_split_rgb(int argc, char **argv) {
|
|||
int error;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No save file provided");
|
||||
split_usage(argc, argv, "No save file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No red photo number provided");
|
||||
split_usage(argc, argv, "No red photo number provided");
|
||||
} else if (argc < 5) {
|
||||
cammy_command_usage(argc, argv, "No green photo number provided");
|
||||
split_usage(argc, argv, "No green photo number provided");
|
||||
} else if (argc < 6) {
|
||||
cammy_command_usage(argc, argv, "No blue photo number provided");
|
||||
split_usage(argc, argv, "No blue photo number provided");
|
||||
} else if (argc < 7) {
|
||||
cammy_command_usage(argc, argv, "No photo provided");
|
||||
split_usage(argc, argv, "No photo provided");
|
||||
}
|
||||
|
||||
cammy_command_validate_photo_number(argc, argv, photo_r = atoi(argv[3]));
|
||||
cammy_command_validate_photo_number(argc, argv, photo_g = atoi(argv[4]));
|
||||
cammy_command_validate_photo_number(argc, argv, photo_b = atoi(argv[5]));
|
||||
cammy_validate_photo_number(argc, argv, photo_r = atoi(argv[3]));
|
||||
cammy_validate_photo_number(argc, argv, photo_g = atoi(argv[4]));
|
||||
cammy_validate_photo_number(argc, argv, photo_b = atoi(argv[5]));
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
fprintf(stderr, "%s: %s: %s: %s\n",
|
||||
|
@ -111,7 +125,23 @@ error_sram_open:
|
|||
return 1;
|
||||
}
|
||||
|
||||
int cammy_command_merge_rgb(int argc, char **argv) {
|
||||
static void merge_usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s rgb-merge file.sav rn gn bn output.png\n",
|
||||
argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_rgb_merge(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
png_t *png;
|
||||
|
||||
|
@ -124,20 +154,20 @@ int cammy_command_merge_rgb(int argc, char **argv) {
|
|||
int error;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No save file provided");
|
||||
merge_usage(argc, argv, "No save file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No red photo number provided");
|
||||
merge_usage(argc, argv, "No red photo number provided");
|
||||
} else if (argc < 5) {
|
||||
cammy_command_usage(argc, argv, "No green photo number provided");
|
||||
merge_usage(argc, argv, "No green photo number provided");
|
||||
} else if (argc < 6) {
|
||||
cammy_command_usage(argc, argv, "No blue photo number provided");
|
||||
merge_usage(argc, argv, "No blue photo number provided");
|
||||
} else if (argc < 7) {
|
||||
cammy_command_usage(argc, argv, "No photo provided");
|
||||
merge_usage(argc, argv, "No photo provided");
|
||||
}
|
||||
|
||||
cammy_command_validate_photo_number(argc, argv, photo_r = atoi(argv[3]));
|
||||
cammy_command_validate_photo_number(argc, argv, photo_g = atoi(argv[4]));
|
||||
cammy_command_validate_photo_number(argc, argv, photo_b = atoi(argv[5]));
|
||||
cammy_validate_photo_number(argc, argv, photo_r = atoi(argv[3]));
|
||||
cammy_validate_photo_number(argc, argv, photo_g = atoi(argv[4]));
|
||||
cammy_validate_photo_number(argc, argv, photo_b = atoi(argv[5]));
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
fprintf(stderr, "%s: %s: %s: %s\n",
|
||||
|
|
25
bin/slice.c
25
bin/slice.c
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
@ -13,7 +13,22 @@
|
|||
#include "png.h"
|
||||
#include "commands.h"
|
||||
|
||||
int cammy_command_slice(int argc, char **argv) {
|
||||
static void usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s slice x-pad y-pad input.png\n", argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_slice(int argc, char **argv) {
|
||||
uint8_t *buf;
|
||||
|
||||
size_t width, height,
|
||||
|
@ -22,11 +37,11 @@ int cammy_command_slice(int argc, char **argv) {
|
|||
int depth;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No X padding provided");
|
||||
usage(argc, argv, "No X padding provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No Y padding provided");
|
||||
usage(argc, argv, "No Y padding provided");
|
||||
} else if (argc < 5) {
|
||||
cammy_command_usage(argc, argv, "No input PNG image provided");
|
||||
usage(argc, argv, "No input PNG image provided");
|
||||
}
|
||||
|
||||
x_pad = atoi(argv[2]);
|
||||
|
|
79
bin/tile.c
79
bin/tile.c
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -25,24 +26,42 @@ static cammy_tile_palette palette = {
|
|||
}
|
||||
};
|
||||
|
||||
int cammy_command_import_tile(int argc, char **argv) {
|
||||
static void import_usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s tile-import file.sav 1..30 printer.tile\n"
|
||||
" %1$s tile-export file.sav 1..30 output.tile\n"
|
||||
" %1$s tile-convert printer.tile output.png\n",
|
||||
argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_tile_import(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
cammy_image *dest, *src;
|
||||
int photo;
|
||||
|
||||
if (argc < 2) {
|
||||
cammy_command_usage(argc, argv, "No camera SRAM file provided");
|
||||
import_usage(argc, argv, "No camera SRAM file provided");
|
||||
} else if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No picture number provided");
|
||||
import_usage(argc, argv, "No picture number provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv,
|
||||
import_usage(argc, argv,
|
||||
"No Game Boy screen tile data file provided");
|
||||
}
|
||||
|
||||
photo = atoi(argv[3]);
|
||||
|
||||
if (photo < 1 || photo > CAMMY_SRAM_PHOTO_COUNT) {
|
||||
cammy_command_usage(argc, argv, "Invalid photo number");
|
||||
import_usage(argc, argv, "Invalid photo number");
|
||||
}
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
|
@ -90,24 +109,42 @@ error_sram_open:
|
|||
return 1;
|
||||
}
|
||||
|
||||
int cammy_command_export_tile(int argc, char **argv) {
|
||||
static void export_usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s tile-import file.sav 1..30 printer.tile\n"
|
||||
" %1$s tile-export file.sav 1..30 output.tile\n"
|
||||
" %1$s tile-convert printer.tile output.png\n",
|
||||
argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_tile_export(int argc, char **argv) {
|
||||
cammy_sram *sram;
|
||||
cammy_image *dest, *src;
|
||||
int photo;
|
||||
|
||||
if (argc < 2) {
|
||||
cammy_command_usage(argc, argv, "No camera SRAM file provided");
|
||||
export_usage(argc, argv, "No camera SRAM file provided");
|
||||
} else if (argc < 3) {
|
||||
cammy_command_usage(argc, argv, "No picture number provided");
|
||||
export_usage(argc, argv, "No picture number provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv,
|
||||
export_usage(argc, argv,
|
||||
"No Game Boy screen tile data file provided");
|
||||
}
|
||||
|
||||
photo = atoi(argv[3]);
|
||||
|
||||
if (photo < 1 || photo > CAMMY_SRAM_PHOTO_COUNT) {
|
||||
cammy_command_usage(argc, argv, "Invalid photo number");
|
||||
export_usage(argc, argv, "Invalid photo number");
|
||||
}
|
||||
|
||||
if ((sram = cammy_sram_open(argv[2])) == NULL) {
|
||||
|
@ -172,15 +209,31 @@ error_sram_open:
|
|||
return errno || 1;
|
||||
}
|
||||
|
||||
int cammy_command_convert_tile(int argc, char **argv) {
|
||||
static void convert_usage(int argc, char **argv, const char *message, ...) {
|
||||
if (message) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, message);
|
||||
vfprintf(stderr, message, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: %1$s tile-convert printer.tile output.png\n",
|
||||
argv[0]);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cammy_tile_convert(int argc, char **argv) {
|
||||
int fd;
|
||||
void *in, *out;
|
||||
|
||||
if (argc < 3) {
|
||||
cammy_command_usage(argc, argv,
|
||||
convert_usage(argc, argv,
|
||||
"No input Game Boy screen tile data file provided");
|
||||
} else if (argc < 4) {
|
||||
cammy_command_usage(argc, argv, "No output PNG filename provided");
|
||||
convert_usage(argc, argv, "No output PNG filename provided");
|
||||
}
|
||||
|
||||
if ((fd = open(argv[2], O_RDONLY)) < 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue