| 1 |
/********************************************************************* |
| 2 |
|
| 3 |
common.h |
| 4 |
|
| 5 |
Generic functions, mostly ROM related. |
| 6 |
|
| 7 |
*********************************************************************/ |
| 8 |
|
| 9 |
#ifndef COMMON_H |
| 10 |
#define COMMON_H |
| 11 |
|
| 12 |
#ifdef __cplusplus |
| 13 |
extern "C" { |
| 14 |
#endif |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
/*************************************************************************** |
| 19 |
|
| 20 |
Type definitions |
| 21 |
|
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
struct mame_bitmap |
| 25 |
{ |
| 26 |
int width,height; /* width and height of the bitmap */ |
| 27 |
int depth; /* bits per pixel */ |
| 28 |
void **line; /* pointers to the start of each line - can be UINT8 **, UINT16 ** or UINT32 ** */ |
| 29 |
|
| 30 |
/* alternate way of accessing the pixels */ |
| 31 |
void *base; /* pointer to pixel (0,0) (adjusted for padding) */ |
| 32 |
int rowpixels; /* pixels per row (including padding) */ |
| 33 |
int rowbytes; /* bytes per row (including padding) */ |
| 34 |
|
| 35 |
/* functions to render in the correct orientation */ |
| 36 |
void (*plot)(struct mame_bitmap *bitmap,int x,int y,pen_t pen); |
| 37 |
pen_t (*read)(struct mame_bitmap *bitmap,int x,int y); |
| 38 |
void (*plot_box)(struct mame_bitmap *bitmap,int x,int y,int width,int height,pen_t pen); |
| 39 |
#ifdef MAME32JP |
| 40 |
void (*plot_box_ts)(struct mame_bitmap *bitmap,int x,int y,int width,int height); |
| 41 |
#endif |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
struct RomModule |
| 46 |
{ |
| 47 |
const char *_name; /* name of the file to load */ |
| 48 |
UINT32 _offset; /* offset to load it to */ |
| 49 |
UINT32 _length; /* length of the file */ |
| 50 |
UINT32 _flags; /* flags */ |
| 51 |
UINT32 _crc; /* standard CRC-32 checksum */ |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
struct GameSample |
| 56 |
{ |
| 57 |
int length; |
| 58 |
int smpfreq; |
| 59 |
int resolution; |
| 60 |
signed char data[1]; /* extendable */ |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
struct GameSamples |
| 65 |
{ |
| 66 |
int total; /* total number of samples */ |
| 67 |
struct GameSample *sample[1]; /* extendable */ |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
/*************************************************************************** |
| 73 |
|
| 74 |
Constants and macros |
| 75 |
|
| 76 |
***************************************************************************/ |
| 77 |
|
| 78 |
enum |
| 79 |
{ |
| 80 |
REGION_INVALID = 0x80, |
| 81 |
REGION_CPU1, |
| 82 |
REGION_CPU2, |
| 83 |
REGION_CPU3, |
| 84 |
REGION_CPU4, |
| 85 |
REGION_CPU5, |
| 86 |
REGION_CPU6, |
| 87 |
REGION_CPU7, |
| 88 |
REGION_CPU8, |
| 89 |
REGION_GFX1, |
| 90 |
REGION_GFX2, |
| 91 |
REGION_GFX3, |
| 92 |
REGION_GFX4, |
| 93 |
REGION_GFX5, |
| 94 |
REGION_GFX6, |
| 95 |
REGION_GFX7, |
| 96 |
REGION_GFX8, |
| 97 |
REGION_PROMS, |
| 98 |
REGION_SOUND1, |
| 99 |
REGION_SOUND2, |
| 100 |
REGION_SOUND3, |
| 101 |
REGION_SOUND4, |
| 102 |
REGION_SOUND5, |
| 103 |
REGION_SOUND6, |
| 104 |
REGION_SOUND7, |
| 105 |
REGION_SOUND8, |
| 106 |
REGION_USER1, |
| 107 |
REGION_USER2, |
| 108 |
REGION_USER3, |
| 109 |
REGION_USER4, |
| 110 |
REGION_USER5, |
| 111 |
REGION_USER6, |
| 112 |
REGION_USER7, |
| 113 |
REGION_USER8, |
| 114 |
REGION_MAX |
| 115 |
}; |
| 116 |
|
| 117 |
#define BADCRC( crc ) (~(crc)) |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
/*************************************************************************** |
| 122 |
|
| 123 |
Core macros for the ROM loading system |
| 124 |
|
| 125 |
***************************************************************************/ |
| 126 |
|
| 127 |
/* ----- per-entry constants ----- */ |
| 128 |
#define ROMENTRYTYPE_REGION 1 /* this entry marks the start of a region */ |
| 129 |
#define ROMENTRYTYPE_END 2 /* this entry marks the end of a region */ |
| 130 |
#define ROMENTRYTYPE_RELOAD 3 /* this entry reloads the previous ROM */ |
| 131 |
#define ROMENTRYTYPE_CONTINUE 4 /* this entry continues loading the previous ROM */ |
| 132 |
#define ROMENTRYTYPE_FILL 5 /* this entry fills an area with a constant value */ |
| 133 |
#define ROMENTRYTYPE_COPY 6 /* this entry copies data from another region/offset */ |
| 134 |
#define ROMENTRYTYPE_COUNT 7 |
| 135 |
|
| 136 |
#define ROMENTRY_REGION ((const char *)ROMENTRYTYPE_REGION) |
| 137 |
#define ROMENTRY_END ((const char *)ROMENTRYTYPE_END) |
| 138 |
#define ROMENTRY_RELOAD ((const char *)ROMENTRYTYPE_RELOAD) |
| 139 |
#define ROMENTRY_CONTINUE ((const char *)ROMENTRYTYPE_CONTINUE) |
| 140 |
#define ROMENTRY_FILL ((const char *)ROMENTRYTYPE_FILL) |
| 141 |
#define ROMENTRY_COPY ((const char *)ROMENTRYTYPE_COPY) |
| 142 |
|
| 143 |
/* ----- per-entry macros ----- */ |
| 144 |
#define ROMENTRY_GETTYPE(r) ((FPTR)(r)->_name) |
| 145 |
#define ROMENTRY_ISSPECIAL(r) (ROMENTRY_GETTYPE(r) < ROMENTRYTYPE_COUNT) |
| 146 |
#define ROMENTRY_ISFILE(r) (!ROMENTRY_ISSPECIAL(r)) |
| 147 |
#define ROMENTRY_ISREGION(r) ((r)->_name == ROMENTRY_REGION) |
| 148 |
#define ROMENTRY_ISEND(r) ((r)->_name == ROMENTRY_END) |
| 149 |
#define ROMENTRY_ISRELOAD(r) ((r)->_name == ROMENTRY_RELOAD) |
| 150 |
#define ROMENTRY_ISCONTINUE(r) ((r)->_name == ROMENTRY_CONTINUE) |
| 151 |
#define ROMENTRY_ISFILL(r) ((r)->_name == ROMENTRY_FILL) |
| 152 |
#define ROMENTRY_ISCOPY(r) ((r)->_name == ROMENTRY_COPY) |
| 153 |
#define ROMENTRY_ISREGIONEND(r) (ROMENTRY_ISREGION(r) || ROMENTRY_ISEND(r)) |
| 154 |
|
| 155 |
|
| 156 |
/* ----- per-region constants ----- */ |
| 157 |
#define ROMREGION_WIDTHMASK 0x00000003 /* native width of region, as power of 2 */ |
| 158 |
#define ROMREGION_8BIT 0x00000000 /* (non-CPU regions only) */ |
| 159 |
#define ROMREGION_16BIT 0x00000001 |
| 160 |
#define ROMREGION_32BIT 0x00000002 |
| 161 |
#define ROMREGION_64BIT 0x00000003 |
| 162 |
|
| 163 |
#define ROMREGION_ENDIANMASK 0x00000004 /* endianness of the region */ |
| 164 |
#define ROMREGION_LE 0x00000000 /* (non-CPU regions only) */ |
| 165 |
#define ROMREGION_BE 0x00000004 |
| 166 |
|
| 167 |
#define ROMREGION_INVERTMASK 0x00000008 /* invert the bits of the region */ |
| 168 |
#define ROMREGION_NOINVERT 0x00000000 |
| 169 |
#define ROMREGION_INVERT 0x00000008 |
| 170 |
|
| 171 |
#define ROMREGION_DISPOSEMASK 0x00000010 /* dispose of the region after init */ |
| 172 |
#define ROMREGION_NODISPOSE 0x00000000 |
| 173 |
#define ROMREGION_DISPOSE 0x00000010 |
| 174 |
|
| 175 |
#define ROMREGION_SOUNDONLYMASK 0x00000020 /* load only if sound is enabled */ |
| 176 |
#define ROMREGION_NONSOUND 0x00000000 |
| 177 |
#define ROMREGION_SOUNDONLY 0x00000020 |
| 178 |
|
| 179 |
#define ROMREGION_LOADUPPERMASK 0x00000040 /* load into the upper part of CPU space */ |
| 180 |
#define ROMREGION_LOADLOWER 0x00000000 /* (CPU regions only) */ |
| 181 |
#define ROMREGION_LOADUPPER 0x00000040 |
| 182 |
|
| 183 |
#define ROMREGION_ERASEMASK 0x00000080 /* erase the region before loading */ |
| 184 |
#define ROMREGION_NOERASE 0x00000000 |
| 185 |
#define ROMREGION_ERASE 0x00000080 |
| 186 |
|
| 187 |
#define ROMREGION_ERASEVALMASK 0x0000ff00 /* value to erase the region to */ |
| 188 |
#define ROMREGION_ERASEVAL(x) ((((x) & 0xff) << 8) | ROMREGION_ERASE) |
| 189 |
#define ROMREGION_ERASE00 ROMREGION_ERASEVAL(0) |
| 190 |
#define ROMREGION_ERASEFF ROMREGION_ERASEVAL(0xff) |
| 191 |
|
| 192 |
/* ----- per-region macros ----- */ |
| 193 |
#define ROMREGION_GETTYPE(r) ((r)->_crc) |
| 194 |
#define ROMREGION_GETLENGTH(r) ((r)->_length) |
| 195 |
#define ROMREGION_GETFLAGS(r) ((r)->_flags) |
| 196 |
#define ROMREGION_GETWIDTH(r) (8 << (ROMREGION_GETFLAGS(r) & ROMREGION_WIDTHMASK)) |
| 197 |
#define ROMREGION_ISLITTLEENDIAN(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ENDIANMASK) == ROMREGION_LE) |
| 198 |
#define ROMREGION_ISBIGENDIAN(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ENDIANMASK) == ROMREGION_BE) |
| 199 |
#define ROMREGION_ISINVERTED(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_INVERTMASK) == ROMREGION_INVERT) |
| 200 |
#define ROMREGION_ISDISPOSE(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_DISPOSEMASK) == ROMREGION_DISPOSE) |
| 201 |
#define ROMREGION_ISSOUNDONLY(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_SOUNDONLYMASK) == ROMREGION_SOUNDONLY) |
| 202 |
#define ROMREGION_ISLOADUPPER(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_LOADUPPERMASK) == ROMREGION_LOADUPPER) |
| 203 |
#define ROMREGION_ISERASE(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ERASEMASK) == ROMREGION_ERASE) |
| 204 |
#define ROMREGION_GETERASEVAL(r) ((ROMREGION_GETFLAGS(r) & ROMREGION_ERASEVALMASK) >> 8) |
| 205 |
|
| 206 |
|
| 207 |
/* ----- per-ROM constants ----- */ |
| 208 |
#define ROM_OPTIONALMASK 0x00000800 /* optional - won't hurt if it's not there */ |
| 209 |
#define ROM_REQUIRED 0x00000000 |
| 210 |
#define ROM_OPTIONAL 0x00000800 |
| 211 |
|
| 212 |
#define ROM_GROUPMASK 0x0000f000 /* load data in groups of this size + 1 */ |
| 213 |
#define ROM_GROUPSIZE(n) ((((n) - 1) & 15) << 12) |
| 214 |
#define ROM_GROUPBYTE ROM_GROUPSIZE(1) |
| 215 |
#define ROM_GROUPWORD ROM_GROUPSIZE(2) |
| 216 |
#define ROM_GROUPDWORD ROM_GROUPSIZE(4) |
| 217 |
|
| 218 |
#define ROM_SKIPMASK 0x000f0000 /* skip this many bytes after each group */ |
| 219 |
#define ROM_SKIP(n) (((n) & 15) << 16) |
| 220 |
#define ROM_NOSKIP ROM_SKIP(0) |
| 221 |
|
| 222 |
#define ROM_REVERSEMASK 0x00100000 /* reverse the byte order within a group */ |
| 223 |
#define ROM_NOREVERSE 0x00000000 |
| 224 |
#define ROM_REVERSE 0x00100000 |
| 225 |
|
| 226 |
#define ROM_BITWIDTHMASK 0x00e00000 /* width of data in bits */ |
| 227 |
#define ROM_BITWIDTH(n) (((n) & 7) << 21) |
| 228 |
#define ROM_NIBBLE ROM_BITWIDTH(4) |
| 229 |
#define ROM_FULLBYTE ROM_BITWIDTH(8) |
| 230 |
|
| 231 |
#define ROM_BITSHIFTMASK 0x07000000 /* left-shift count for the bits */ |
| 232 |
#define ROM_BITSHIFT(n) (((n) & 7) << 24) |
| 233 |
#define ROM_NOSHIFT ROM_BITSHIFT(0) |
| 234 |
#define ROM_SHIFT_NIBBLE_LO ROM_BITSHIFT(0) |
| 235 |
#define ROM_SHIFT_NIBBLE_HI ROM_BITSHIFT(4) |
| 236 |
|
| 237 |
#define ROM_INHERITFLAGSMASK 0x08000000 /* inherit all flags from previous definition */ |
| 238 |
#define ROM_INHERITFLAGS 0x08000000 |
| 239 |
|
| 240 |
#define ROM_INHERITEDFLAGS (ROM_GROUPMASK | ROM_SKIPMASK | ROM_REVERSEMASK | ROM_BITWIDTHMASK | ROM_BITSHIFTMASK) |
| 241 |
|
| 242 |
/* ----- per-ROM macros ----- */ |
| 243 |
#define ROM_GETNAME(r) ((r)->_name) |
| 244 |
#define ROM_SAFEGETNAME(r) (ROMENTRY_ISFILL(r) ? "fill" : ROMENTRY_ISCOPY(r) ? "copy" : ROM_GETNAME(r)) |
| 245 |
#define ROM_GETOFFSET(r) ((r)->_offset) |
| 246 |
#define ROM_GETCRC(r) ((r)->_crc) |
| 247 |
#define ROM_GETLENGTH(r) ((r)->_length) |
| 248 |
#define ROM_GETFLAGS(r) ((r)->_flags) |
| 249 |
#define ROM_ISOPTIONAL(r) ((ROM_GETFLAGS(r) & ROM_OPTIONALMASK) == ROM_OPTIONAL) |
| 250 |
#define ROM_GETGROUPSIZE(r) (((ROM_GETFLAGS(r) & ROM_GROUPMASK) >> 12) + 1) |
| 251 |
#define ROM_GETSKIPCOUNT(r) ((ROM_GETFLAGS(r) & ROM_SKIPMASK) >> 16) |
| 252 |
#define ROM_ISREVERSED(r) ((ROM_GETFLAGS(r) & ROM_REVERSEMASK) == ROM_REVERSE) |
| 253 |
#define ROM_GETBITWIDTH(r) (((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) >> 21) + 8 * ((ROM_GETFLAGS(r) & ROM_BITWIDTHMASK) == 0)) |
| 254 |
#define ROM_GETBITSHIFT(r) ((ROM_GETFLAGS(r) & ROM_BITSHIFTMASK) >> 24) |
| 255 |
#define ROM_INHERITSFLAGS(r) ((ROM_GETFLAGS(r) & ROM_INHERITFLAGSMASK) == ROM_INHERITFLAGS) |
| 256 |
#define ROM_NOGOODDUMP(r) (ROM_GETCRC(r) == 0) |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
/*************************************************************************** |
| 261 |
|
| 262 |
Derived macros for the ROM loading system |
| 263 |
|
| 264 |
***************************************************************************/ |
| 265 |
|
| 266 |
/* ----- start/stop macros ----- */ |
| 267 |
#define ROM_START(name) static const struct RomModule rom_##name[] = { |
| 268 |
#define ROM_END { ROMENTRY_END, 0, 0, 0, 0 } }; |
| 269 |
|
| 270 |
/* ----- ROM region macros ----- */ |
| 271 |
#define ROM_REGION(length,type,flags) { ROMENTRY_REGION, 0, length, flags, type }, |
| 272 |
#define ROM_REGION16_LE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_16BIT | ROMREGION_LE) |
| 273 |
#define ROM_REGION16_BE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_16BIT | ROMREGION_BE) |
| 274 |
#define ROM_REGION32_LE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_32BIT | ROMREGION_LE) |
| 275 |
#define ROM_REGION32_BE(length,type,flags) ROM_REGION(length, type, (flags) | ROMREGION_32BIT | ROMREGION_BE) |
| 276 |
|
| 277 |
/* ----- core ROM loading macros ----- */ |
| 278 |
#define ROMX_LOAD(name,offset,length,crc,flags) { name, offset, length, flags, crc }, |
| 279 |
#define ROM_LOAD(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, 0) |
| 280 |
#define ROM_LOAD_OPTIONAL(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_OPTIONAL) |
| 281 |
#define ROM_CONTINUE(offset,length) ROMX_LOAD(ROMENTRY_CONTINUE, offset, length, 0, ROM_INHERITFLAGS) |
| 282 |
#define ROM_RELOAD(offset,length) ROMX_LOAD(ROMENTRY_RELOAD, offset, length, 0, ROM_INHERITFLAGS) |
| 283 |
#define ROM_FILL(offset,length,value) ROM_LOAD(ROMENTRY_FILL, offset, length, value) |
| 284 |
#define ROM_COPY(rgn,srcoffset,offset,length) ROMX_LOAD(ROMENTRY_COPY, offset, length, srcoffset, (rgn) << 24) |
| 285 |
|
| 286 |
/* ----- nibble loading macros ----- */ |
| 287 |
#define ROM_LOAD_NIB_HIGH(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI) |
| 288 |
#define ROM_LOAD_NIB_LOW(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO) |
| 289 |
|
| 290 |
/* ----- new-style 16-bit loading macros ----- */ |
| 291 |
#define ROM_LOAD16_BYTE(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_SKIP(1)) |
| 292 |
#define ROM_LOAD16_WORD(name,offset,length,crc) ROM_LOAD(name, offset, length, crc) |
| 293 |
#define ROM_LOAD16_WORD_SWAP(name,offset,length,crc)ROMX_LOAD(name, offset, length, crc, ROM_GROUPWORD | ROM_REVERSE) |
| 294 |
|
| 295 |
/* ----- new-style 32-bit loading macros ----- */ |
| 296 |
#define ROM_LOAD32_BYTE(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_SKIP(3)) |
| 297 |
#define ROM_LOAD32_WORD(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_GROUPWORD | ROM_SKIP(2)) |
| 298 |
#define ROM_LOAD32_WORD_SWAP(name,offset,length,crc)ROMX_LOAD(name, offset, length, crc, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2)) |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
/*************************************************************************** |
| 303 |
|
| 304 |
Function prototypes |
| 305 |
|
| 306 |
***************************************************************************/ |
| 307 |
|
| 308 |
#if (defined(MAME32JP) && defined(BUILD_CONSOLE)) || !defined(MAME32JP) |
| 309 |
void showdisclaimer(void); |
| 310 |
#endif |
| 311 |
|
| 312 |
/* helper function that reads samples from disk - this can be used by other */ |
| 313 |
/* drivers as well (e.g. a sound chip emulator needing drum samples) */ |
| 314 |
struct GameSamples *readsamples(const char **samplenames,const char *name); |
| 315 |
#define freesamples(samps) |
| 316 |
|
| 317 |
/* return a pointer to the specified memory region - num can be either an absolute */ |
| 318 |
/* number, or one of the REGION_XXX identifiers defined above */ |
| 319 |
UINT8 *memory_region(int num); |
| 320 |
size_t memory_region_length(int num); |
| 321 |
|
| 322 |
/* allocate a new memory region - num can be either an absolute */ |
| 323 |
/* number, or one of the REGION_XXX identifiers defined above */ |
| 324 |
int new_memory_region(int num, size_t length, UINT32 flags); |
| 325 |
void free_memory_region(int num); |
| 326 |
|
| 327 |
/* common coin counter helpers */ |
| 328 |
#define COIN_COUNTERS 4 /* total # of coin counters */ |
| 329 |
void coin_counter_w(int num,int on); |
| 330 |
void coin_lockout_w(int num,int on); |
| 331 |
void coin_lockout_global_w(int on); /* Locks out all coin inputs */ |
| 332 |
|
| 333 |
/* generic NVRAM handler */ |
| 334 |
extern size_t generic_nvram_size; |
| 335 |
extern data8_t *generic_nvram; |
| 336 |
extern void nvram_handler_generic_0fill(void *file, int read_or_write); |
| 337 |
extern void nvram_handler_generic_1fill(void *file, int read_or_write); |
| 338 |
|
| 339 |
/* controls the global visible area */ |
| 340 |
void set_visible_area(int min_x,int max_x,int min_y,int max_y); |
| 341 |
|
| 342 |
/* bitmap allocation */ |
| 343 |
struct mame_bitmap *bitmap_alloc(int width,int height); |
| 344 |
struct mame_bitmap *bitmap_alloc_depth(int width,int height,int depth); |
| 345 |
void bitmap_free(struct mame_bitmap *bitmap); |
| 346 |
|
| 347 |
/* automatic resource management */ |
| 348 |
void begin_resource_tracking(void); |
| 349 |
void end_resource_tracking(void); |
| 350 |
INLINE int get_resource_tag(void) |
| 351 |
{ |
| 352 |
extern int resource_tracking_tag; |
| 353 |
return resource_tracking_tag; |
| 354 |
} |
| 355 |
|
| 356 |
/* automatically-freeing memory */ |
| 357 |
void *auto_malloc(size_t size); |
| 358 |
struct mame_bitmap *auto_bitmap_alloc(int width,int height); |
| 359 |
struct mame_bitmap *auto_bitmap_alloc_depth(int width,int height,int depth); |
| 360 |
|
| 361 |
/* screen snapshots */ |
| 362 |
void save_screen_snapshot_as(void *fp,struct mame_bitmap *bitmap); |
| 363 |
void save_screen_snapshot(struct mame_bitmap *bitmap); |
| 364 |
|
| 365 |
/* ROM processing */ |
| 366 |
const struct RomModule *rom_first_region(const struct GameDriver *drv); |
| 367 |
const struct RomModule *rom_next_region(const struct RomModule *romp); |
| 368 |
const struct RomModule *rom_first_file(const struct RomModule *romp); |
| 369 |
const struct RomModule *rom_next_file(const struct RomModule *romp); |
| 370 |
const struct RomModule *rom_first_chunk(const struct RomModule *romp); |
| 371 |
const struct RomModule *rom_next_chunk(const struct RomModule *romp); |
| 372 |
|
| 373 |
int readroms(void); |
| 374 |
void printromlist(const struct RomModule *romp,const char *name); |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
/*************************************************************************** |
| 379 |
|
| 380 |
Useful macros to deal with bit shuffling encryptions |
| 381 |
|
| 382 |
***************************************************************************/ |
| 383 |
|
| 384 |
#define BITSWAP8(val,B7,B6,B5,B4,B3,B2,B1,B0) \ |
| 385 |
(((((val) >> (B7)) & 1) << 7) | \ |
| 386 |
((((val) >> (B6)) & 1) << 6) | \ |
| 387 |
((((val) >> (B5)) & 1) << 5) | \ |
| 388 |
((((val) >> (B4)) & 1) << 4) | \ |
| 389 |
((((val) >> (B3)) & 1) << 3) | \ |
| 390 |
((((val) >> (B2)) & 1) << 2) | \ |
| 391 |
((((val) >> (B1)) & 1) << 1) | \ |
| 392 |
((((val) >> (B0)) & 1) << 0)) |
| 393 |
|
| 394 |
#define BITSWAP16(val,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \ |
| 395 |
(((((val) >> (B15)) & 1) << 15) | \ |
| 396 |
((((val) >> (B14)) & 1) << 14) | \ |
| 397 |
((((val) >> (B13)) & 1) << 13) | \ |
| 398 |
((((val) >> (B12)) & 1) << 12) | \ |
| 399 |
((((val) >> (B11)) & 1) << 11) | \ |
| 400 |
((((val) >> (B10)) & 1) << 10) | \ |
| 401 |
((((val) >> ( B9)) & 1) << 9) | \ |
| 402 |
((((val) >> ( B8)) & 1) << 8) | \ |
| 403 |
((((val) >> ( B7)) & 1) << 7) | \ |
| 404 |
((((val) >> ( B6)) & 1) << 6) | \ |
| 405 |
((((val) >> ( B5)) & 1) << 5) | \ |
| 406 |
((((val) >> ( B4)) & 1) << 4) | \ |
| 407 |
((((val) >> ( B3)) & 1) << 3) | \ |
| 408 |
((((val) >> ( B2)) & 1) << 2) | \ |
| 409 |
((((val) >> ( B1)) & 1) << 1) | \ |
| 410 |
((((val) >> ( B0)) & 1) << 0)) |
| 411 |
|
| 412 |
#define BITSWAP24(val,B23,B22,B21,B20,B19,B18,B17,B16,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \ |
| 413 |
(((((val) >> (B23)) & 1) << 23) | \ |
| 414 |
((((val) >> (B22)) & 1) << 22) | \ |
| 415 |
((((val) >> (B21)) & 1) << 21) | \ |
| 416 |
((((val) >> (B20)) & 1) << 20) | \ |
| 417 |
((((val) >> (B19)) & 1) << 19) | \ |
| 418 |
((((val) >> (B18)) & 1) << 18) | \ |
| 419 |
((((val) >> (B17)) & 1) << 17) | \ |
| 420 |
((((val) >> (B16)) & 1) << 16) | \ |
| 421 |
((((val) >> (B15)) & 1) << 15) | \ |
| 422 |
((((val) >> (B14)) & 1) << 14) | \ |
| 423 |
((((val) >> (B13)) & 1) << 13) | \ |
| 424 |
((((val) >> (B12)) & 1) << 12) | \ |
| 425 |
((((val) >> (B11)) & 1) << 11) | \ |
| 426 |
((((val) >> (B10)) & 1) << 10) | \ |
| 427 |
((((val) >> ( B9)) & 1) << 9) | \ |
| 428 |
((((val) >> ( B8)) & 1) << 8) | \ |
| 429 |
((((val) >> ( B7)) & 1) << 7) | \ |
| 430 |
((((val) >> ( B6)) & 1) << 6) | \ |
| 431 |
((((val) >> ( B5)) & 1) << 5) | \ |
| 432 |
((((val) >> ( B4)) & 1) << 4) | \ |
| 433 |
((((val) >> ( B3)) & 1) << 3) | \ |
| 434 |
((((val) >> ( B2)) & 1) << 2) | \ |
| 435 |
((((val) >> ( B1)) & 1) << 1) | \ |
| 436 |
((((val) >> ( B0)) & 1) << 0)) |
| 437 |
|
| 438 |
|
| 439 |
#ifdef __cplusplus |
| 440 |
} |
| 441 |
#endif |
| 442 |
|
| 443 |
#endif |