1 #ifndef UAE_ROMMGR_H
2 #define UAE_ROMMGR_H
3 
4 #ifdef FSUAE // NL
5 #include "uae/types.h"
6 #endif
7 
8 extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size);
9 
10 #define ROMTYPE_SUB_MASK    0x000000ff
11 #define ROMTYPE_GROUP_MASK  0x003fff00
12 #define ROMTYPE_MASK		0x003fffff
13 
14 #define ROMTYPE_KICK		0x00000100
15 #define ROMTYPE_KICKCD32	0x00000200
16 #define ROMTYPE_EXTCD32		0x00000400
17 #define ROMTYPE_EXTCDTV		0x00000800
18 #define ROMTYPE_KEY			0x00001000
19 #define ROMTYPE_ARCADIABIOS	0x00002000
20 #define ROMTYPE_ARCADIAGAME	0x00004000
21 #define ROMTYPE_CD32CART	0x00008000
22 #define ROMTYPE_SPECIALKICK	0x00010000
23 
24 #define ROMTYPE_CPUBOARD	0x00040000
25 #define ROMTYPE_CB_A3001S1	0x00040001
26 #define ROMTYPE_CB_APOLLO	0x00040002
27 #define ROMTYPE_CB_FUSION	0x00040003
28 #define ROMTYPE_CB_DKB12x0	0x00040004
29 #define ROMTYPE_CB_WENGINE	0x00040005
30 #define ROMTYPE_CB_TEKMAGIC	0x00040006
31 #define ROMTYPE_CB_BLIZ1230	0x00040007
32 #define ROMTYPE_CB_BLIZ1260	0x00040008
33 #define ROMTYPE_CB_BLIZ2060	0x00040009
34 #define ROMTYPE_CB_A26x0	0x0004000a
35 #define ROMTYPE_CB_CSMK1	0x0004000b
36 #define ROMTYPE_CB_CSMK2	0x0004000c
37 #define ROMTYPE_CB_CSMK3	0x0004000d
38 #define ROMTYPE_CB_CSPPC	0x0004000e
39 #define ROMTYPE_CB_BLIZPPC	0x0004000f
40 #define ROMTYPE_CB_GOLEM030	0x00040010
41 #define ROMTYPE_CB_ACA500	0x00040011
42 #define ROMTYPE_CB_DBK_WF	0x00040012
43 #define ROMTYPE_CB_EMATRIX	0x00040013
44 #define ROMTYPE_CB_SX32PRO	0x00040014
45 
46 #define ROMTYPE_FREEZER		0x00080000
47 #define ROMTYPE_AR			0x00080001
48 #define ROMTYPE_AR2			0x00080002
49 #define ROMTYPE_HRTMON		0x00080003
50 #define ROMTYPE_NORDIC		0x00080004
51 #define ROMTYPE_XPOWER		0x00080005
52 #define ROMTYPE_SUPERIV		0x00080006
53 
54 #define ROMTYPE_SCSI		0x00100000
55 #define ROMTYPE_A2091		0x00100001
56 #define ROMTYPE_A4091		0x00100002
57 #define ROMTYPE_BLIZKIT4	0x00100003
58 #define ROMTYPE_FASTLANE	0x00100004
59 #define ROMTYPE_OKTAGON		0x00100005
60 #define ROMTYPE_GVPS1		0x00100006
61 #define ROMTYPE_GVPS12		0x00100007
62 #define ROMTYPE_GVPS2		0x00100008
63 #define ROMTYPE_AMAX		0x00100009
64 #define ROMTYPE_ALFA		0x0010000a
65 #define ROMTYPE_ALFAPLUS	0x0010000b
66 #define ROMTYPE_APOLLO		0x0010000c
67 #define ROMTYPE_MASOBOSHI	0x0010000d
68 #define ROMTYPE_SUPRA		0x0010000e
69 #define ROMTYPE_A2090		0x0010000f
70 #define ROMTYPE_GOLEM		0x00100010
71 #define ROMTYPE_STARDRIVE	0x00100011
72 #define ROMTYPE_KOMMOS		0x00100012
73 #define ROMTYPE_VECTOR		0x00100013
74 #define ROMTYPE_ADIDE		0x00100014
75 #define ROMTYPE_MTEC		0x00100015
76 #define ROMTYPE_PROTAR		0x00100016
77 #define ROMTYPE_ADD500		0x00100017
78 #define ROMTYPE_KRONOS		0x00100018
79 #define ROMTYPE_ADSCSI		0x00100019
80 #define ROMTYPE_ROCHARD		0x0010001a
81 #define ROMTYPE_CLTDSCSI	0x0010001b
82 #define ROMTYPE_PTNEXUS		0x0010001c
83 #define ROMTYPE_DATAFLYER	0x0010001d
84 #define ROMTYPE_SUPRADMA	0x0010001e
85 #define ROMTYPE_GREX		0x0010001f
86 #define ROMTYPE_PROMETHEUS	0x00100020
87 #define ROMTYPE_MEDIATOR	0x00100021
88 #define ROMTYPE_TECMAR		0x00100022
89 #define ROMTYPE_XEBEC		0x00100023
90 #define ROMTYPE_MICROFORGE	0x00100024
91 #define ROMTYPE_PARADOX		0x00100025
92 #define ROMTYPE_HDA506		0x00100026
93 #define ROMTYPE_ALF1		0x00100027
94 #define ROMTYPE_PROMIGOS	0x00100028
95 #define ROMTYPE_SYSTEM2000	0x00100029
96 #define ROMTYPE_A1060		0x0010002a
97 #define ROMTYPE_A2088		0x0010002b
98 #define ROMTYPE_A2088T		0x0010002c
99 #define ROMTYPE_A2286		0x0010002d
100 #define ROMTYPE_A2386		0x0010002e
101 #define ROMTYPE_OMTIADAPTER	0x0010002f
102 #define ROMTYPE_X86_HD		0x00100030
103 #define ROMTYPE_X86_AT_HD1	0x00100031
104 #define ROMTYPE_X86_AT_HD2	0x00100032
105 #define ROMTYPE_X86_XT_IDE	0x00100033
106 #define ROMTYPE_PICASSOIV	0x00100034
107 #define ROMTYPE_x86_VGA		0x00100035
108 #define ROMTYPE_APOLLOHD	0x00100036
109 #define ROMTYPE_MEVOLUTION	0x00100037
110 #define ROMTYPE_GOLEMFAST	0x00100038
111 #define ROMTYPE_PHOENIXB	0x00100039
112 
113 #define ROMTYPE_NOT			0x00800000
114 #define ROMTYPE_QUAD		0x01000000
115 #define ROMTYPE_EVEN		0x02000000
116 #define ROMTYPE_ODD			0x04000000
117 #define ROMTYPE_8BIT		0x08000000
118 #define ROMTYPE_BYTESWAP	0x10000000
119 #define ROMTYPE_CD32		0x20000000
120 #define ROMTYPE_SCRAMBLED	0x40000000
121 #define ROMTYPE_NONE		0x80000000
122 
123 #define ROMTYPE_ALL_KICK (ROMTYPE_KICK | ROMTYPE_KICKCD32 | ROMTYPE_CD32)
124 #define ROMTYPE_ALL_EXT (ROMTYPE_EXTCD32 | ROMTYPE_EXTCDTV)
125 #define ROMTYPE_ALL_CART (ROMTYPE_AR | ROMTYPE_HRTMON | ROMTYPE_NORDIC | ROMTYPE_XPOWER | ROMTYPE_CD32CART)
126 
127 struct romheader {
128 	const TCHAR *name;
129 	int id;
130 };
131 
132 struct romdata {
133 	const TCHAR *name;
134 	int ver, rev;
135 	int subver, subrev;
136 	const TCHAR *model;
137 	uae_u32 size;
138 	int id;
139 	int cpu;
140 	int cloanto;
141 	unsigned int type;
142 	int group;
143 	int title;
144 	const TCHAR *partnumber;
145 	uae_u32 crc32;
146 	uae_u32 sha1[5];
147 	const TCHAR *configname;
148 	const TCHAR *defaultfilename;
149 };
150 
151 struct romlist {
152 	TCHAR *path;
153 	struct romdata *rd;
154 };
155 
156 extern struct romdata *getromdatabypath (const TCHAR *path);
157 extern struct romdata *getromdatabycrc (uae_u32 crc32);
158 extern struct romdata *getromdatabycrc (uae_u32 crc32, bool);
159 extern struct romdata *getromdatabydata (uae_u8 *rom, int size);
160 extern struct romdata *getromdatabyid (int id);
161 extern struct romdata *getromdatabyidgroup (int id, int group, int subitem);
162 extern struct romdata *getromdatabyzfile (struct zfile *f);
163 extern struct romdata *getfrombydefaultname(const TCHAR *name, int size);
164 extern struct romlist **getarcadiaroms (void);
165 extern struct romdata *getarcadiarombyname (const TCHAR *name);
166 extern struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, const TCHAR *model, int romflags, bool all);
167 extern void getromname (const struct romdata*, TCHAR*);
168 extern struct romdata *getromdatabyname (const TCHAR*);
169 extern struct romlist *getromlistbyids (const int *ids, const TCHAR *romname);
170 extern struct romdata *getromdatabyids (const int *ids);
171 extern struct romlist *getromlistbyromtype(uae_u32 romtype);
172 extern void romwarning(const int *ids);
173 extern struct romlist *getromlistbyromdata (const struct romdata *rd);
174 extern void romlist_add (const TCHAR *path, struct romdata *rd);
175 extern TCHAR *romlist_get (const struct romdata *rd);
176 extern void romlist_clear (void);
177 extern struct zfile *read_rom (struct romdata *rd);
178 extern struct zfile *read_rom_name (const TCHAR *filename);
179 extern struct zfile *read_device_from_romconfig(struct romconfig *rc, uae_u32 romtype);
180 
181 extern int load_keyring (struct uae_prefs *p, const TCHAR *path);
182 extern uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *size, TCHAR *name);
183 extern void free_keyring (void);
184 extern int get_keyring (void);
185 extern void kickstart_fix_checksum (uae_u8 *mem, int size);
186 extern void descramble_nordicpro (uae_u8*, int, int);
187 extern int kickstart_checksum (uae_u8 *mem, int size);
188 extern int decode_rom (uae_u8 *mem, int size, int mode, int real_size);
189 extern struct zfile *rom_fopen (const TCHAR *name, const TCHAR *mode, int mask);
190 extern struct zfile *read_rom_name_guess (const TCHAR *filename);
191 extern void addkeydir (const TCHAR *path);
192 extern void addkeyfile (const TCHAR *path);
193 extern int romlist_count (void);
194 extern struct romlist *romlist_getit (void);
195 extern int configure_rom (struct uae_prefs *p, const int *rom, int msg);
196 
197 int is_device_rom(struct uae_prefs *p, int romtype, int devnum);
198 struct zfile *read_device_rom(struct uae_prefs *p, int romtype, int devnum, int *roms);
199 struct romconfig *get_device_romconfig(struct uae_prefs *p, int romtype, int devnum);
200 struct boardromconfig *get_device_rom(struct uae_prefs *p, int romtype, int devnum, int *index);
201 void set_device_rom(struct uae_prefs *p, const TCHAR *path, int romtype, int devnum);
202 const struct expansionromtype *get_device_expansion_rom(int romtype);
203 const struct expansionromtype *get_unit_expansion_rom(int hdunit);
204 struct boardromconfig *get_device_rom_new(struct uae_prefs *p, int romtype, int devnum, int *index);
205 void clear_device_rom(struct uae_prefs *p, int romtype, int devnum);
206 struct boardromconfig *get_boardromconfig(struct uae_prefs *p, int romtype, int *index);
207 
208 #define LOADROM_FILL 1
209 #define LOADROM_EVENONLY 2
210 #define LOADROM_EVENONLY_ODDONE ((255 << 16) | LOADROM_EVENONLY)
211 #define LOADROM_ONEFILL 4
212 #define LOADROM_ZEROFILL 8
213 #define LOADROM_ODDFILL(x) ((x << 16) | LOADROM_EVENONLY)
214 bool load_rom_rc(struct romconfig *rc, uae_u32 romtype, int maxfilesize, int fileoffset, uae_u8 *rom, int maxromsize, int flags);
215 
216 #endif /* UAE_ROMMGR_H */
217