1 #ifndef METADATA_H_
2 #define METADATA_H_
3 
4 #include "config.h"
5 
6 #ifdef __cplusplus
7 extern "C"
8 {
9 #endif
10 
11 #include "misc/types.h"
12 
13 /* ------------------------------------------------------------------------ */
14 /*  COMPAT_LEVEL_T  Specifies compatibility with various hardware.          */
15 /*                                                                          */
16 /*      Incompatible   Will not function correctly if hardware is present.  */
17 /*      Tolerates      Works, but is not enhanced by hardware's presence.   */
18 /*      Enhanced       Enhanced by hardware, but doesn't require it.        */
19 /*      Requires       Will not function correctly if hardware is absent.   */
20 /* ------------------------------------------------------------------------ */
21 typedef enum compat_level_t
22 {
23     CMP_UNSPECIFIED     = -1,
24     CMP_INCOMPATIBLE    = 0x00,
25     CMP_TOLERATES       = 0x01,
26     CMP_ENHANCED        = 0x02,
27     CMP_REQUIRES        = 0x03
28 } compat_level_t;
29 
30 /* ------------------------------------------------------------------------ */
31 /*  JLP_ACCEL_T     Specifies JLP Acceleration ability                      */
32 /*                                                                          */
33 /*      Disabled        No JLP functionality                                */
34 /*      Accel On        Accel enabled at reset; no flash.                   */
35 /*      Accel Off       Accel disabled at reset; jlp_flash controls flash   */
36 /*      Accel Flash On  Accel enabled at reset; jlp_flash controls flash    */
37 /*                                                                          */
38 /*  In all modes but "disabled", programs can switch accelerators + RAM     */
39 /*  on and off by writing special values to $8033/$8034.                    */
40 /*                                                                          */
41 /*  The "Accel On" setting is redundant with respect to "Accel Flash On"    */
42 /*  when combined with jlp_flash setting.                                   */
43 /* ------------------------------------------------------------------------ */
44 typedef enum jlp_accel_t
45 {
46     JLP_UNSPECIFIED     = -1,
47     JLP_DISABLED        = 0x00, /* No JLP functionality, period             */
48     JLP_ACCEL_ON        = 0x01, /* Accel+RAM on; no flash                   */
49     JLP_ACCEL_OFF       = 0x02, /* Accel+RAM off; jlp_flash controls flash  */
50     JLP_ACCEL_FLASH_ON  = 0x03  /* Accel+RAM on;  jlp_flash controls flash  */
51 } jlp_accel_t;
52 
53 #define REQ_JLP(j) ((int)(j) >= (int)JLP_ACCEL_ON)
54 
55 /* ------------------------------------------------------------------------ */
56 /*  JLP Flash Parameters                                                    */
57 /* ------------------------------------------------------------------------ */
58 #define JLP_FLASH_MIN (1)
59 #define JLP_FLASH_MAX (682)
60 
61 /* ======================================================================== */
62 /*  Each of these fields is NULL if absent.                                 */
63 /*                                                                          */
64 /*  Pointer-to-pointer fields represent NULL-terminated lists when the      */
65 /*  list pointer is itself not-NULL.                                        */
66 /*                                                                          */
67 /*  Pointer-to-integer fields represent zero-terminated lists when the list */
68 /*  pointer is itself not-NULL.                                             */
69 /*                                                                          */
70 /*  Pointer-to-date fields represent 0/0/0-terminated lists when the list   */
71 /*  pointer is itself not-NULL.                                             */
72 /* ======================================================================== */
73 typedef struct game_metadata_t
74 {
75     const char* name;               /*  Full title of program               */
76     const char* short_name;         /*  Abbreviated title of program        */
77     const char** authors;           /*  Program authors (programmers)       */
78     const char** game_artists;      /*  Game artists (in-game gfx)          */
79     const char** composers;         /*  In-game music composers/arrangers   */
80     const char** sfx_artists;       /*  Sound effects artists               */
81     const char** voice_actors;      /*  Voice actors for samples            */
82     const char** doc_writers;       /*  Documentation writers               */
83     const char** conceptualizers;   /*  Game concept creators               */
84     const char** box_artists;       /*  Box/manual/overlay/etc. artists.    */
85     const char** more_infos;        /*  Pointers to more information.       */
86     const char** publishers;        /*  Publishers of the title             */
87     const game_date_t* release_dates;   /*  List of game release dates      */
88     const char** licenses;          /*  License published under.            */
89     const char** descriptions;      /*  Description of the game             */
90     const char** misc;              /*  key=value pairs for un-handled vars */
91     const game_date_t* build_dates; /* List of game build dates.            */
92     const char** versions;          /* List of game version strings.        */
93 
94     compat_level_t      ecs_compat;
95     compat_level_t      voice_compat;
96     compat_level_t      intv2_compat;
97     compat_level_t      kc_compat;  /* Keyboard component */
98     compat_level_t      tv_compat;  /* TutorVision / INTV88 SuperPro */
99     int                 lto_mapper;
100     jlp_accel_t         jlp_accel;
101     int                 jlp_flash;
102 
103     /* -------------------------------------------------------------------- */
104     /*  is_defaults == 0 means user has explicitly specified at least 1     */
105     /*  setting, whether or not the setting is equivalent to the default.   */
106     /* -------------------------------------------------------------------- */
107     int                 is_defaults;
108 } game_metadata_t;
109 
110 /* ------------------------------------------------------------------------ */
111 /*  GAME_METADATA_SET_COMPAT_TO_UNSPEC       -- Set all compat to unspec    */
112 /* ------------------------------------------------------------------------ */
113 void game_metadata_set_compat_to_unspec( game_metadata_t *const metadata );
114 
115 /* ------------------------------------------------------------------------ */
116 /*  GAME_METADATA_SET_UNSPEC_COMPAT_TO_DEFAULTS                             */
117 /*  Returns 1 if all of the compat flags were unspecified, 0 otherwise.     */
118 /* ------------------------------------------------------------------------ */
119 int game_metadata_set_unspec_compat_to_defaults
120 (
121     game_metadata_t *const metadata
122 );
123 
124 /* ------------------------------------------------------------------------ */
125 /*  DEFAULT_METADATA                                                        */
126 /* ------------------------------------------------------------------------ */
127 game_metadata_t *default_game_metadata( void );
128 
129 /* ------------------------------------------------------------------------ */
130 /*  METADATA_FREE                                                           */
131 /*  Free the metadata structure                                             */
132 /* ------------------------------------------------------------------------ */
133 void free_game_metadata( game_metadata_t *const metadata );
134 
135 /* ------------------------------------------------------------------------ */
136 /*  MERGE_GAME_METADATA                                                     */
137 /*                                                                          */
138 /*  Given two game_metadata structures, merge them into one that has data   */
139 /*  from them both.                                                         */
140 /*                                                                          */
141 /*  For "name" and "short_name", first argument takes precedence when both  */
142 /*  are set.                                                                */
143 /*                                                                          */
144 /*  For string-arrays and date arrays, all dupes are eliminated.            */
145 /*                                                                          */
146 /*  For "compat" entries, we us the following hierarchy:                    */
147 /*                                                                          */
148 /*   -- If both have is_defaults = 1, first argument wins.                  */
149 /*   -- If exactly one has is_defaults = 0, its settings win.               */
150 /*   -- If both have is_defaults = 0, then things get fun.                  */
151 /*                                                                          */
152 /*                    |   UNS  INC  TOL  ENH  REQ  second                   */
153 /*            --------+-----------------------------------                  */
154 /*               UNS  |   UNS  INC  TOL  ENH  REQ                           */
155 /*               INC  |   INC  INC  INC  INC  uns                           */
156 /*               TOL  |   TOL  INC  TOL  ENH  REQ                           */
157 /*               ENH  |   ENH  INC  ENH  ENH  REQ                           */
158 /*               REQ  |   REQ  uns  REQ  REQ  REQ                           */
159 /*             first  |                                                     */
160 /*                                                                          */
161 /*   -- For jlp_accel:  The greater value takes precedence.                 */
162 /*   -- For jlp_flash:  The greater value takes precedence.                 */
163 /*   -- For lto_mapper:  The greater value takes precedence.                */
164 /*                                                                          */
165 /*  A new game_metadata structure gets created; neither of the source args  */
166 /*  is modified.                                                            */
167 /* ------------------------------------------------------------------------ */
168 game_metadata_t *merge_game_metadata
169 (
170     const game_metadata_t *const src1,
171     const game_metadata_t *const src2
172 );
173 
174 /* ------------------------------------------------------------------------ */
175 /*  PRINT_METADATA   -- Print game metadata.                                */
176 /* ------------------------------------------------------------------------ */
177 void print_metadata
178 (
179     const game_metadata_t *const meta
180 );
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif
187 
188