Subversion Repositories ipe_artfile_utils

Rev

Blame | Last modification | View Log | RSS feed

  1. /**
  2.  * ART file packer by Daniel Marschall, ViaThinkSoft (C) 2014-2018
  3.  * Supports:
  4.  * - Blown Away - The Interactive Game by Imagination Pilots
  5.  * - Panic in the Park - The Interactive Game by Imagination Pilots
  6.  * - Where's Waldo? At the Circus
  7.  * - Where's Waldo? Exploring Geography
  8.  * - Eraser Turnabout by Imagination Pilots
  9.  * - Virtual K'Nex by Imagination Pilots
  10.  * Revision: 2018-02-21
  11.  **/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <stdbool.h>
  16. #include <string.h>
  17. #include <math.h>
  18. #include <getopt.h>
  19.  
  20. #include "ipe_artfile_packer_ipe16_ba.h"
  21. #include "ipe_artfile_packer_ipe16_pip.h"
  22. #include "ipe_artfile_packer_ipe32.h"
  23.  
  24. #define VERSION "2018-02-21"
  25.  
  26. void print_syntax() {
  27.         fprintf(stderr, "Syntax: [-v] -t <type> -i <input dir> -o <output artfile>\n");
  28.         fprintf(stderr, "   -t : ba (Blown Away)\n");
  29.         fprintf(stderr, "        pip (Panic in the Park)\n");
  30.         fprintf(stderr, "        waldo (Where's Waldo? At the Circus)\n");
  31.         fprintf(stderr, "        waldo2 (Where's Waldo? Exploring Geography)\n");
  32.         fprintf(stderr, "        eraser (Eraser Turnabout)\n");
  33.         fprintf(stderr, "        knex (Virtual K'Nex)\n");
  34.         fprintf(stderr, "   -v : verbose output\n");
  35. }
  36.  
  37. #define GAME_UNKNOWN 0
  38. #define GAME_BA 1
  39. #define GAME_PIP 2
  40. #define GAME_WALDO_CIRCUS 3
  41. #define GAME_WALDO_GEOGRAPHY 4
  42. #define GAME_ERASER 5
  43. #define GAME_KNEX 6
  44.  
  45. int main(int argc, char *argv[]) {
  46.         int verbosity = 0;
  47.         char* szSrcFolder = "";
  48.         char* szArtFile = "";
  49.         int c;
  50.  
  51.         #define PRINT_SYNTAX { print_syntax(); return 0; }
  52.  
  53.         int game = GAME_UNKNOWN;
  54.  
  55.         while ((c = getopt(argc, argv, "Vvi:o:t:")) != -1) {
  56.                 switch (c) {
  57.                         case 't':
  58.                                 if (strcmp(optarg, "ba")     == 0) game = GAME_BA;
  59.                                 if (strcmp(optarg, "pip")    == 0) game = GAME_PIP;
  60.                                 if (strcmp(optarg, "waldo")  == 0) game = GAME_WALDO_CIRCUS;
  61.                                 if (strcmp(optarg, "waldo2") == 0) game = GAME_WALDO_GEOGRAPHY;
  62.                                 if (strcmp(optarg, "eraser") == 0) game = GAME_ERASER;
  63.                                 if (strcmp(optarg, "knex")   == 0) game = GAME_KNEX;
  64.                                 break;
  65.                         case 'v':
  66.                                 verbosity++;
  67.                                 break;
  68.                         case 'V':
  69.                                 fprintf(stdout, "IPE artfile packer, revision %s\n", VERSION);
  70.                                 return 0;
  71.                         case 'i':
  72.                                 szSrcFolder = optarg;
  73.                                 break;
  74.                         case 'o':
  75.                                 szArtFile = optarg;
  76.                                 break;
  77.                         case '?':
  78.                                 PRINT_SYNTAX;
  79.                                 break;
  80.                 }
  81.         }
  82.         if (optind < argc) PRINT_SYNTAX;
  83.         if (game == GAME_UNKNOWN) {
  84.                 fprintf(stderr, "Please specify the game\n");
  85.                 PRINT_SYNTAX;
  86.         }
  87.  
  88.         if (strlen(szArtFile) == 0) PRINT_SYNTAX;
  89.         if (strlen(szSrcFolder) == 0) PRINT_SYNTAX;
  90.  
  91.         FILE* fobArt = fopen(szArtFile, "wb");
  92.  
  93.         switch (game) {
  94.                 case GAME_BA:
  95.                         return ba_pack_art(szSrcFolder, fobArt, verbosity) ? 0 : 1;
  96.                         break;
  97.                 case GAME_PIP:
  98.                 case GAME_WALDO_CIRCUS:
  99.                         return pip_pack_art(szSrcFolder, fobArt, verbosity) ? 0 : 1;
  100.                         break;
  101.                 case GAME_WALDO_GEOGRAPHY:
  102.                 case GAME_ERASER:
  103.                 case GAME_KNEX:
  104.                         return ipe32_pack_art(szSrcFolder, fobArt, verbosity) ? 0 : 1;
  105.                         break;
  106.         }
  107. }
  108.