ucon64.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. uCON64 - a tool to modify video game ROMs and to transfer ROMs to the
  3. different backup units/emulators that exist. It is based on the old uCON but
  4. with completely new source. It aims to support all cartridge consoles and
  5. handhelds like N64, JAG, SNES, NG, GENESIS, GB, LYNX, PCE, SMS, GG, NES and
  6. their backup units
  7. Copyright (c) 1999 - 2004 NoisyB
  8. Copyright (c) 2001 - 2004, 2015 dbjh
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef UCON64_H
  22. #define UCON64_H
  23. #ifdef HAVE_CONFIG_H
  24. #include "config.h"
  25. #endif
  26. #include <stdio.h>
  27. #include "misc/itypes.h"
  28. #include "ucon64_defines.h" // MAXBUFSIZE, etc..
  29. #define UCON64_ISSET(x) (x != UCON64_UNKNOWN)
  30. typedef enum { UCON64_SPP, UCON64_EPP, UCON64_ECP } parport_mode_t;
  31. /*
  32. st_ucon64_nfo_t this struct contains very specific informations only
  33. <console>_init() can supply after the correct console
  34. type was identified.
  35. st_ucon64_t this struct containes st_ucon64_nfo_t and unspecific
  36. informations and some workflow stuff
  37. st_ucon64_obj_t ucon64 object for use in st_getopt2_t
  38. */
  39. typedef struct
  40. {
  41. const char *console_usage; // console system of the ROM
  42. const char *backup_usage; // backup unit of the ROM
  43. int interleaved; // ROM is interleaved (swapped)
  44. int data_size; // ROM data size without "red tape"
  45. const void *backup_header; // (possible) header of backup unit
  46. int backup_header_start; // start of backup unit header (mostly 0)
  47. int backup_header_len; // length of backup unit header 0 == no bu hdr
  48. const void *header; // (possible) internal ROM header
  49. int header_start; // start of internal ROM header
  50. int header_len; // length of internal ROM header 0 == no hdr
  51. char name[MAXBUFSIZE]; // internal ROM name
  52. const char *maker; // maker name of the ROM
  53. const char *country; // country name of the ROM
  54. char misc[MAXBUFSIZE]; // some miscellaneous information
  55. // about the ROM in one single string
  56. int has_internal_crc; // ROM has internal checksum (SNES, Mega Drive, Game Boy)
  57. unsigned int current_internal_crc; // calculated checksum
  58. unsigned int internal_crc; // internal checksum
  59. int internal_crc_start; // start of internal checksum in ROM header
  60. int internal_crc_len; // length (in bytes) of internal checksum in ROM header
  61. char internal_crc2[MAXBUFSIZE]; // 2nd or inverse internal checksum
  62. } st_ucon64_nfo_t;
  63. typedef struct
  64. {
  65. int argc;
  66. char **argv;
  67. int option; // current option (UCON64_HEX, UCON64_FIND, ...)
  68. const char *optarg; // ptr to current options optarg
  69. char *temp_file; // global temp_file
  70. const char *fname; // ROM (cmdline) with path
  71. int recursive;
  72. char fname_arch[FILENAME_MAX]; // filename in archive (currently only for zip)
  73. int file_size; // (uncompressed) ROM file size (NOT console specific)
  74. unsigned int crc32; // crc32 value of ROM (used for DAT files) (NOT console specific)
  75. unsigned int fcrc32; // if non-zero: crc32 of ROM as it is on disk (NOT console specific)
  76. /*
  77. if console == UCON64_UNKNOWN or st_ucon64_nfo_t == NULL ucon64_rom_nfo() won't
  78. be shown
  79. */
  80. int console; // the detected console system
  81. int org_console; // the value of console before processing the first file
  82. const char *file; // FILE (cmdline) with path
  83. char configfile[FILENAME_MAX]; // path and name of the config file
  84. char configdir[FILENAME_MAX]; // directory for config
  85. char datdir[FILENAME_MAX]; // directory for DAT files
  86. char output_path[FILENAME_MAX]; // -o argument (default: cwd)
  87. #ifdef USE_DISCMAGE
  88. char discmage_path[FILENAME_MAX]; // path to the discmage DLL
  89. #endif
  90. //#if defined USE_PPDEV || defined AMIGA
  91. char parport_dev[80]; // parallel port device (e.g.
  92. //#endif // /dev/parport0 or parallel.device)
  93. int parport_needed;
  94. uint16_t parport; // parallel port address
  95. #ifdef _MSC_VER
  96. #pragma warning(push)
  97. #pragma warning(disable: 4820) // 'bytes' bytes padding added after construct 'member_name'
  98. #endif
  99. parport_mode_t parport_mode; // parallel port mode: ECP, EPP, SPP
  100. #ifdef _MSC_VER
  101. #pragma warning(pop)
  102. #endif
  103. #ifdef USE_USB
  104. int usbport; // non-zero => use usbport, 1 = USB0, 2 = USB1
  105. char usbport_dev[80]; // usb port device (e.g. /dev/usb/hiddev0)
  106. #endif
  107. #ifdef USE_ANSI_COLOR
  108. int ansi_color;
  109. #endif
  110. int backup; // flag if backups files should be created
  111. int frontend; // flag if uCON64 was started by a frontend
  112. #ifdef USE_DISCMAGE
  113. int discmage_enabled; // flag if discmage DLL is loaded
  114. #endif
  115. int dat_enabled; // flag if DAT file(s) are usable/enabled
  116. int quiet; // quiet == -1 means verbose + 1
  117. int force_disc; // --disc was used
  118. uint32_t flags; // detect and init ROM info
  119. int do_not_calc_crc; // disable checksum calc. to speed up --ls,--lsv, etc.
  120. /*
  121. These values override values in st_ucon64_nfo_t. Use UCON64_ISSET()
  122. to check them. When adding new ones don't forget to update
  123. ucon64_execute_options() too.
  124. */
  125. int backup_header_len; // length of backup unit header 0 == no bu hdr
  126. int interleaved; // ROM is interleaved (swapped)
  127. #if 1
  128. int id; // generate unique name (currently
  129. // only used by snes_gd3())
  130. // the following values are for SNES, NES, Genesis and Nintendo 64
  131. int battery; // NES UNIF/iNES/Pasofami
  132. int bs_dump; // SNES "ROM" is a Broadcast Satellaview dump
  133. const char *comment; // NES UNIF
  134. int controller; // NES UNIF & SNES NSRT
  135. int controller2; // SNES NSRT
  136. const char *dump_info; // NES UNIF
  137. int io_mode; // SNES SWC, Nintendo 64 CD64 & Cyan's Megadrive copier
  138. const char *mapr; // NES UNIF board name or iNES mapper number
  139. int mirror; // NES UNIF/iNES/Pasofami
  140. int part_size; // SNES/Genesis split part size
  141. int region; // Genesis (for -multi)
  142. int snes_header_base; // SNES ROM is "Extended" (or Sufami Turbo)
  143. int snes_hirom; // SNES ROM is HiROM
  144. int split; // ROM is split
  145. int tv_standard; // NES UNIF
  146. int use_dump_info; // NES UNIF
  147. int vram; // NES UNIF
  148. #endif
  149. #ifdef USE_DISCMAGE
  150. void *image; // info from libdiscmage (dm_image_t *)
  151. #endif
  152. void *dat; // info from DATabase (st_ucon64_dat_t *)
  153. st_ucon64_nfo_t *nfo; // info from <console>_init() (st_ucon64_nfo_t *)
  154. } st_ucon64_t;
  155. typedef struct
  156. {
  157. int console; // UCON64_SNES, etc...
  158. uint32_t flags; // WF_INIT, etc..
  159. } st_ucon64_obj_t;
  160. /*
  161. ucon64_init() init st_ucon64_nfo_t, st_ucon64_dat_t and dm_image_t
  162. ucon64_nfo() display contents of st_ucon64_nfo_t, st_ucon64_dat_t and
  163. dm_image_t
  164. ucon64_usage() print usage
  165. ucon64_fname_arch()
  166. ucon64 global (st_ucon64_t *)
  167. */
  168. extern int ucon64_init (void);
  169. extern int ucon64_nfo (void);
  170. enum {
  171. USAGE_VIEW_SHORT = 0,
  172. USAGE_VIEW_LONG,
  173. USAGE_VIEW_PAD,
  174. USAGE_VIEW_DAT,
  175. USAGE_VIEW_PATCH,
  176. USAGE_VIEW_BACKUP,
  177. USAGE_VIEW_DISC
  178. };
  179. extern void ucon64_usage (int argc, char *argv[], int view);
  180. #ifdef USE_ZLIB
  181. extern void ucon64_fname_arch (const char *fname);
  182. #endif
  183. extern st_ucon64_t ucon64;
  184. #endif // UCON64_H