35
35
***************************************************************************/
37
typedef struct _rom_load_data rom_load_data;
37
typedef struct _open_chd open_chd;
40
open_chd * next; /* pointer to next in the list */
41
const char * region; /* disk region we came from */
42
chd_file * origchd; /* handle to the original CHD */
43
mame_file * origfile; /* file handle to the original CHD file */
44
chd_file * diffchd; /* handle to the diff CHD */
45
mame_file * difffile; /* file handle to the diff CHD file */
49
typedef struct _romload_private rom_load_data;
50
struct _romload_private
40
52
running_machine *machine; /* machine object where needed */
41
53
int system_bios; /* the system BIOS we wish to load */
49
61
UINT32 romstotalsize; /* total size of ROMs to read */
51
63
mame_file * file; /* current file */
64
open_chd * chd_list; /* disks */
65
open_chd ** chd_list_tailptr;
53
67
UINT8 * regionbase; /* base of current region */
54
68
UINT32 regionlength; /* length of current region */
60
typedef struct _open_chd open_chd;
63
open_chd * next; /* pointer to next in the list */
64
const char * region; /* disk region we came from */
65
chd_file * origchd; /* handle to the original CHD */
66
mame_file * origfile; /* file handle to the original CHD file */
67
chd_file * diffchd; /* handle to the diff CHD */
68
mame_file * difffile; /* file handle to the diff CHD file */
73
/***************************************************************************
75
***************************************************************************/
78
static open_chd *chd_list;
79
static open_chd **chd_list_tailptr;
81
static int total_rom_load_warnings;
85
74
/***************************************************************************
86
75
FUNCTION PROTOTYPES
87
76
***************************************************************************/
99
88
CHD file associated with the given region
100
89
-------------------------------------------------*/
102
chd_file *get_disk_handle(const char *region)
91
chd_file *get_disk_handle(running_machine *machine, const char *region)
104
93
open_chd *curdisk;
106
for (curdisk = chd_list; curdisk != NULL; curdisk = curdisk->next)
95
for (curdisk = machine->romload_data->chd_list; curdisk != NULL; curdisk = curdisk->next)
107
96
if (strcmp(curdisk->region, region) == 0)
108
97
return (curdisk->diffchd != NULL) ? curdisk->diffchd : curdisk->origchd;
113
102
/*-------------------------------------------------
103
add_disk_handle - add a disk to the to the
105
-------------------------------------------------*/
107
static void add_disk_handle(running_machine *machine, open_chd *chd)
109
romload_private *romload_data = machine->romload_data;
111
*romload_data->chd_list_tailptr = auto_alloc(machine, open_chd);
112
**romload_data->chd_list_tailptr = *chd;
113
romload_data->chd_list_tailptr = &(*romload_data->chd_list_tailptr)->next;
117
/*-------------------------------------------------
114
118
set_disk_handle - set a pointer to the CHD
115
119
file associated with the given region
116
120
-------------------------------------------------*/
125
129
chd.origfile = file;
127
131
/* we're okay, add to the list of disks */
128
*chd_list_tailptr = auto_alloc(machine, open_chd);
129
**chd_list_tailptr = chd;
130
chd_list_tailptr = &(*chd_list_tailptr)->next;
132
add_disk_handle(machine, &chd);
1226
1228
/* we're okay, add to the list of disks */
1227
1229
LOG(("Assigning to handle %d\n", DISK_GETINDEX(romp)));
1228
*chd_list_tailptr = auto_alloc(romdata->machine, open_chd);
1229
**chd_list_tailptr = chd;
1230
chd_list_tailptr = &(*chd_list_tailptr)->next;
1230
add_disk_handle(romdata->machine, &chd);
1233
1233
astring_free(filename);
1339
1339
void rom_init(running_machine *machine)
1341
rom_load_data romdata;
1341
rom_load_data *romdata;
1343
/* allocate private data */
1344
machine->romload_data = romdata = auto_alloc_clear(machine, romload_private);
1343
1346
/* make sure we get called back on the way out */
1344
1347
add_exit_callback(machine, rom_exit);
1346
1349
/* reset the romdata struct */
1347
memset(&romdata, 0, sizeof(romdata));
1348
romdata.machine = machine;
1349
romdata.errorstring = astring_alloc();
1350
romdata->machine = machine;
1351
romdata->errorstring = astring_alloc();
1351
1353
/* figure out which BIOS we are using */
1352
determine_bios_rom(&romdata);
1354
determine_bios_rom(romdata);
1354
1356
/* count the total number of ROMs */
1355
count_roms(&romdata);
1357
count_roms(romdata);
1357
1359
/* reset the disk list */
1359
chd_list_tailptr = &chd_list;
1360
romdata->chd_list = NULL;
1361
romdata->chd_list_tailptr = &machine->romload_data->chd_list;
1361
1363
/* process the ROM entries we were passed */
1362
process_region_list(&romdata);
1364
process_region_list(romdata);
1364
1366
/* display the results and exit */
1365
total_rom_load_warnings = romdata.warnings;
1366
display_rom_load_results(&romdata);
1367
astring_free(romdata.errorstring);
1367
display_rom_load_results(romdata);
1368
astring_free(romdata->errorstring);
1387
1388
/* close all hard drives */
1388
for (curchd = chd_list; curchd != NULL; curchd = curchd->next)
1389
for (curchd = machine->romload_data->chd_list; curchd != NULL; curchd = curchd->next)
1390
1391
if (curchd->diffchd != NULL)
1391
1392
chd_close(curchd->diffchd);
1404
1405
warnings we generated
1405
1406
-------------------------------------------------*/
1407
int rom_load_warnings(void)
1408
int rom_load_warnings(running_machine *machine)
1409
return total_rom_load_warnings;
1410
return machine->romload_data->warnings;