Previous 15994 Revisions Next

r10385 Saturday 12th February, 2011 at 16:15:16 UTC by Miodrag Milanović
Sync with MAME (file handling change). Baseline compile, will update else soon.
[src/emu]audit.c cheat.c cheat.h clifront.c config.c crsshair.c devimage.c devintrf.c devintrf.h devlegcy.c devlegcy.h diexec.c diexec.h diimage.c diimage.h dimemory.c dimemory.h dinvram.h disound.c disound.h emu.mak emuopts.c fileio.c fileio.h hashfile.c hashfile.h image.c image.h inptport.c input.c machine.c machine.h mame.c mame.h mconfig.h render.c rendfont.c rendfont.h rendlay.c rendlay.h rendutil.c rendutil.h romload.c romload.h screen.c screen.h softlist.c softlist.h sound.c state.c state.h timer.c timer.h ui.c uimenu.c validity.c validity.h video.c video.h
[src/emu/debug]debugcmd.c debugcpu.c
[src/emu/imagedev]cartslot.c multcart.c multcart.h
[src/emu/machine]at28c16.c at28c16.h ds2401.c ds2401.h ds2404.c ds2404.h eeprom.c eeprom.h er2055.c er2055.h generic.c generic.h i2cmem.c i2cmem.h intelfsh.c intelfsh.h mb3773.c mb3773.h mc146818.c mc146818.h nvram.c nvram.h ram.c rtc65271.c secflash.c* secflash.h* timekpr.c timekpr.h x2212.c x2212.h x76f041.c x76f041.h x76f100.c x76f100.h
[src/emu/sound]okim9810.c okim9810.h samples.c tms5110r.c
[src/emu/video]vector.c
[src/ldplayer]ldplayer.c
[src/mame]mamedriv.c
[src/mame/drivers]bfm_sc2.c bmcbowl.c dgpix.c gal3.c jchan.c kaneko16.c ksys573.c mcr68.c mitchell.c mjkjidai.c moo.c namcona1.c namconb1.c namcos22.c naomi.c nbmj9195.c neogeo.c pinkiri8.c segas24.c seicross.c sfbonus.c vegas.c
[src/mame/etc]jrcrypt.c
[src/mame/includes]kaneko16.h naomibd.h
[src/mame/machine]atari_vg.c fddebug.c kaneko16.c megadriv.c midwayic.c naomibd.c segamsys.c zs01.c zs01.h
[src/mame/video]gp9001.c gp9001.h kaneko16.c
[src/mess/devices]aescart.c sonydriv.c
[src/mess/drivers]cat.c gp32.c ip22.c jaguar.c micronic.c nc.c ng_aes.c pocketc.c psion.c px4.c saturn.c x07.c
[src/mess/formats]ti85_ser.c
[src/mess/includes]msx_slot.h nc.h
[src/mess/machine]apple2gs.c at29040.c at29040.h at45dbxx.c at45dbxx.h cybiko.c docg3.c europc.c lisa.c mac.c msx.c msx_slot.c pc1251.c pc1350.c pc1401.c pc1403.c pce.c pcf8593.c pcf8593.h sst39vfx.c sst39vfx.h strata.c strata.h tandy1t.c tc8521.c tc8521.h ti85.c wswan.c
[src/mess/machine/ti99]evpc.c gromport.c hsgpl.c
[src/mess/tools/castool]stubs.c
[src/mess/tools/imgtool]stubs.c
[src/mess/tools/imgtool/windows]wimgtool.c
[src/mess/tools/messdocs]messdocs.c
[src/mess/tools/messtest]testmess.c
[src/osd]osdcore.h
[src/osd/sdl]draw13.c drawogl.c drawsdl.c input.c sdlmain.c sdlos_unix.c sound.c video.c window.c window.h
[src/osd/windows]debugwin.c debugwin.h drawd3d.c drawdd.c drawgdi.c drawnone.c input.c sound.c video.c window.c winmain.c
[src/tools]chdcd.c chdman.c

src/mame/machine/atari_vg.c
r10384r10385
9393   atari_vg_earom_state *earom = get_safe_token(device);
9494
9595   if (read_or_write)
96      mame_fwrite(file,earom->rom,EAROM_SIZE);
96      file->write(earom->rom,EAROM_SIZE);
9797   else if (file)
98      mame_fread(file,earom->rom,EAROM_SIZE);
98      file->read(earom->rom,EAROM_SIZE);
9999   else
100100      memset(earom,0,EAROM_SIZE);
101101}
src/mame/machine/midwayic.c
r10384r10385
520520NVRAM_HANDLER( midway_serial_pic2 )
521521{
522522   if (read_or_write)
523      mame_fwrite(file, pic.nvram, sizeof(pic.nvram));
523      file->write(pic.nvram, sizeof(pic.nvram));
524524   else if (file)
525      mame_fread(file, pic.nvram, sizeof(pic.nvram));
525      file->read(pic.nvram, sizeof(pic.nvram));
526526   else
527527      memcpy(pic.nvram, pic.default_nvram, sizeof(pic.nvram));
528528}
src/mame/machine/fddebug.c
r10384r10385
581581
582582static void load_overlay_file(running_machine *machine)
583583{
584   char filename[20];
585   file_error filerr;
586   mame_file *file;
587584   int pcaddr;
588585
589586   /* determine the filename and open the file */
590   sprintf(filename, "%s.kov", machine->gamedrv->name);
591   filerr = mame_fopen(SEARCHPATH_RAW, filename, OPEN_FLAG_READ, &file);
587   emu_file file(machine->options(), SEARCHPATH_RAW, OPEN_FLAG_READ);
588   file_error filerr = file.open(machine->gamedrv->name, ".kov");
592589   if (filerr == FILERR_NONE)
593590   {
594      mame_fread(file, keystatus, keystatus_words * 2);
595      mame_fclose(file);
591      file.read(keystatus, keystatus_words * 2);
596592
597593      /* convert from big-endian */
598594      for (pcaddr = 0; pcaddr < keystatus_words; pcaddr++)
r10384r10385
611607
612608static void save_overlay_file(running_machine *machine)
613609{
614   char filename[20];
615   file_error filerr;
616   mame_file *file;
617610   int pcaddr;
618611
619612   /* determin the filename and open the file */
620   sprintf(filename, "%s.kov", machine->gamedrv->name);
621   filerr = mame_fopen(SEARCHPATH_RAW, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
613   emu_file file(machine->options(), SEARCHPATH_RAW, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
614   file_error filerr = file.open(machine->gamedrv->name, ".kov");
622615   if (filerr == FILERR_NONE)
623616   {
624617      /* convert to big-endian */
r10384r10385
626619         keystatus[pcaddr] = BIG_ENDIANIZE_INT16(keystatus[pcaddr]);
627620
628621      /* write the data */
629      mame_fwrite(file, keystatus, keystatus_words * 2);
630      mame_fclose(file);
622      file.write(keystatus, keystatus_words * 2);
631623
632624      /* convert from big-endian */
633625      for (pcaddr = 0; pcaddr < keystatus_words; pcaddr++)
r10384r10385
756748
757749static void execute_fdoutput(running_machine *machine, int ref, int params, const char **param)
758750{
759   file_error filerr;
760   mame_file *file;
761
762751   /* make sure we're up-to-date */
763752   if (keydirty)
764753      fd1094_regenerate_key(machine);
765754
766755   /* determin the filename and open the file */
767   filerr = mame_fopen(SEARCHPATH_RAW, param[0], OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
756   emu_file file(machine->options(), SEARCHPATH_RAW, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
757   file_error filerr = file.open(param[0]);
768758   if (filerr == FILERR_NONE)
769   {
770      mame_fwrite(file, keyregion, KEY_SIZE);
771      mame_fclose(file);
772   }
759      file.write(keyregion, KEY_SIZE);
760
773761   debug_console_printf(machine, "File '%s' saved\n", param[0]);
774762}
775763
r10384r10385
11821170   int origstate = fd1094_set_state(keyregion, -1);
11831171   const char *filename;
11841172   int skipped = FALSE;
1185   file_error filerr;
1186   mame_file *file;
11871173   UINT32 pcaddr;
11881174
11891175   /* extract the parameters */
11901176   filename = param[0];
11911177
11921178   /* open the file */
1193   filerr = mame_fopen(SEARCHPATH_RAW, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
1179   emu_file file(machine->options(), SEARCHPATH_RAW, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
1180   file_error filerr = file.open(filename);
11941181   if (filerr != FILERR_NONE)
11951182   {
11961183      debug_console_printf(machine, "Unable to create file '%s'\n", filename);
r10384r10385
12431230
12441231      /* print the line */
12451232      if (skipped)
1246         mame_fprintf(file, "\n");
1233         file.printf("\n");
12471234      skipped = FALSE;
1248      mame_fprintf(file, " %02X %06X:", keystatus[pcaddr] >> 8, pcaddr * 2);
1235      file.printf(" %02X %06X:", keystatus[pcaddr] >> 8, pcaddr * 2);
12491236      for (pcoffs = 0; pcoffs < 5; pcoffs++)
12501237      {
12511238         if (pcoffs < length)
r10384r10385
12541241            int keystat = keystatus[pcaddr + pcoffs] & STATUS_MASK;
12551242            if (keystat != STATUS_LOCKED && keystat != STATUS_NOCHANGE)
12561243               unknowns = TRUE;
1257            mame_fprintf(file, " %02X%02X%c", instrbuffer[pcoffs*2+0], instrbuffer[pcoffs*2+1], statchar[keystat]);
1244            file.printf(" %02X%02X%c", instrbuffer[pcoffs*2+0], instrbuffer[pcoffs*2+1], statchar[keystat]);
12581245         }
12591246         else
1260            mame_fprintf(file, "      ");
1247            file.printf("      ");
12611248      }
1262      mame_fprintf(file, "%s\n", disasm);
1249      file.printf("%s\n", disasm);
12631250
12641251      /* if we have unknowns, display them as well */
12651252      if (unknowns > 0)
r10384r10385
12691256         for (pnum = 0; pnum < posscount; pnum++)
12701257            if (strcmp(disasm, posslist[pnum].dasm) != 0)
12711258            {
1272               mame_fprintf(file, "          :");
1259               file.printf("          :");
12731260               for (pcoffs = 0; pcoffs < 5; pcoffs++)
12741261                  if (pcoffs < posslist[pnum].length)
1275                     mame_fprintf(file, " %02X%02X ", posslist[pnum].instrbuffer[pcoffs*2+0], posslist[pnum].instrbuffer[pcoffs*2+1]);
1262                     file.printf(" %02X%02X ", posslist[pnum].instrbuffer[pcoffs*2+0], posslist[pnum].instrbuffer[pcoffs*2+1]);
12761263                  else
1277                     mame_fprintf(file, "      ");
1278               mame_fprintf(file, "%s\n", posslist[pnum].dasm);
1264                     file.printf("      ");
1265               file.printf("%s\n", posslist[pnum].dasm);
12791266            }
12801267      }
12811268
r10384r10385
12841271   }
12851272
12861273   /* close the file */
1287   mame_fclose(file);
12881274   fd1094_set_state(keyregion, origstate);
12891275}
12901276
src/mame/machine/megadriv.c
r10384r10385
91459145   if (megadriv_backupram!=NULL)
91469146   {
91479147      if (read_or_write)
9148         mame_fwrite(file, megadriv_backupram, megadriv_backupram_length);
9148         file->write(megadriv_backupram, megadriv_backupram_length);
91499149      else
91509150      {
91519151         if (file)
91529152         {
9153            mame_fread(file, megadriv_backupram, megadriv_backupram_length);
9153            file->read(megadriv_backupram, megadriv_backupram_length);
91549154         }
91559155         else
91569156         {
src/mame/machine/zs01.c
r10384r10385
99
1010#include "emu.h"
1111#include "machine/zs01.h"
12#include "machine/ds2401.h"
1213
13#define VERBOSE_LEVEL ( 0 )
14#define VERBOSE_LEVEL 0
1415
15INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
16inline void ATTR_PRINTF(3,4) zs01_device::verboselog(int n_level, const char *s_fmt, ...)
1617{
17   if( VERBOSE_LEVEL >= n_level )
18   if(VERBOSE_LEVEL >= n_level)
1819   {
1920      va_list v;
20      char buf[ 32768 ];
21      va_start( v, s_fmt );
22      vsprintf( buf, s_fmt, v );
23      va_end( v );
24      logerror( "%s: %s", machine->describe_context(), buf );
21      char buf[32768];
22      va_start(v, s_fmt);
23      vsprintf(buf, s_fmt, v);
24      va_end(v);
25      logerror("zs01 %s %s: %s", config.tag(), machine->describe_context(), buf);
2526   }
2627}
2728
28#define SIZE_WRITE_BUFFER ( 12 )
29#define SIZE_READ_BUFFER ( 12 )
30#define SIZE_DATA_BUFFER ( 8 )
29const device_type ZS01 = zs01_device_config::static_alloc_device_config;
3130
32#define SIZE_RESPONSE_TO_RESET ( 4 )
33#define SIZE_KEY ( 8 )
34#define SIZE_DATA ( 4096 )
31zs01_device_config::zs01_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
32   : device_secure_serial_flash_config(mconfig, static_alloc_device_config, "ZS01", tag, owner, clock)
33{
34}
3535
36struct zs01_chip
36void zs01_device_config::static_set_ds2401_tag(device_config *device, const char *ds2401_tag)
3737{
38   int cs;
39   int rst;
40   int scl;
41   int sdaw;
42   int sdar;
43   int state;
44   int shift;
45   int bit;
46   int byte;
47   UINT8 write_buffer[ SIZE_WRITE_BUFFER ];
48   UINT8 read_buffer[ SIZE_READ_BUFFER ];
49   UINT8 response_key[ SIZE_KEY ];
50   UINT8 *response_to_reset;
51   UINT8 *command_key;
52   UINT8 *data_key;
53   UINT8 *data;
54   UINT8 *ds2401;
55   zs01_write_handler write;
56   zs01_read_handler read;
57};
38   zs01_device_config *zs01 = downcast<zs01_device_config *>(device);
39   zs01->ds2401_tag = ds2401_tag;
40}
5841
59static struct zs01_chip zs01[ ZS01_MAXCHIP ];
42device_config *zs01_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
43{
44   return global_alloc(zs01_device_config(mconfig, tag, owner, clock));
45}
6046
61#define COMMAND_WRITE ( 0x00 )
62#define COMMAND_READ ( 0x01 )
47device_t *zs01_device_config::alloc_device(running_machine &machine) const
48{
49   return auto_alloc(&machine, zs01_device(machine, *this));
50}
6351
64#define STATE_STOP ( 0 )
65#define STATE_RESPONSE_TO_RESET ( 1 )
66#define STATE_LOAD_COMMAND ( 2 )
67#define STATE_READ_DATA ( 3 )
52zs01_device::zs01_device(running_machine &_machine, const zs01_device_config &_config)
53   : device_secure_serial_flash(_machine, _config),
54     config(_config)
55{
56}
6857
69void zs01_init( running_machine *machine, int chip, UINT8 *data, zs01_write_handler write, zs01_read_handler read, UINT8 *ds2401 )
58void zs01_device::device_start()
7059{
71   int offset;
72   struct zs01_chip *c;
60   device_secure_serial_flash::device_start();
61   save_item(NAME(state));
62   save_item(NAME(shift));
63   save_item(NAME(bit));
64   save_item(NAME(byte));
65   save_item(NAME(write_buffer));
66   save_item(NAME(read_buffer));
67   save_item(NAME(response_key));
68   save_item(NAME(response_to_reset));
69   save_item(NAME(command_key));
70   save_item(NAME(data_key));
71}
7372
74   if( chip >= ZS01_MAXCHIP )
75   {
76      verboselog( machine, 0, "zs01_init( %d ) chip out of range\n", chip );
77      return;
78   }
73void zs01_device::device_reset()
74{
75   device_secure_serial_flash::device_reset();
76   state = STATE_STOP;
77   shift = 0;
78   bit = 0;
79   byte = 0;
80   memset(write_buffer, 0, SIZE_WRITE_BUFFER);
81   memset(read_buffer, 0, SIZE_READ_BUFFER);
82   memset(response_key, 0, SIZE_KEY);
83}
7984
80   c = &zs01[ chip ];
81
82   if( data == NULL )
85void zs01_device::nvram_default()
86{
87   // region always wins
88   if(m_region)
8389   {
84      data = auto_alloc_array(machine, UINT8,
85         SIZE_RESPONSE_TO_RESET +
86         SIZE_KEY +
87         SIZE_KEY +
88         SIZE_DATA );
90      // Ensure the size is correct though
91      if(m_region->bytes() != SIZE_RESPONSE_TO_RESET+SIZE_KEY+SIZE_KEY+SIZE_DATA)
92         logerror("zs01 %s: Wrong region length for initialization data, expected 0x%x, got 0x%x\n",
93                config.tag(),
94                SIZE_RESPONSE_TO_RESET+SIZE_KEY+SIZE_KEY+SIZE_DATA,
95                m_region->bytes());
96      else {
97         UINT8 *rb = m_region->base();
98         int offset = 0;
99         memcpy(response_to_reset, rb + offset, SIZE_RESPONSE_TO_RESET); offset += SIZE_RESPONSE_TO_RESET;
100         memcpy(command_key,       rb + offset, SIZE_KEY); offset += SIZE_KEY;
101         memcpy(data_key,          rb + offset, SIZE_KEY); offset += SIZE_KEY;
102         memcpy(data,              rb + offset, SIZE_DATA); offset += SIZE_DATA;
103         return;
104      }
89105   }
90106
91   if( ds2401 == NULL )
92   {
93      ds2401 = auto_alloc_array(machine, UINT8,  SIZE_DATA_BUFFER );
94   }
95
96   c->cs = 0;
97   c->rst = 0;
98   c->scl = 0;
99   c->sdaw = 0;
100   c->sdar = 0;
101   c->state = STATE_STOP;
102   c->shift = 0;
103   c->bit = 0;
104   c->byte = 0;
105   memset( c->write_buffer, 0, SIZE_WRITE_BUFFER );
106   memset( c->read_buffer, 0, SIZE_READ_BUFFER );
107   memset( c->response_key, 0, SIZE_KEY );
108
109   offset = 0;
110   c->response_to_reset = &data[ offset ]; offset += SIZE_RESPONSE_TO_RESET;
111   c->command_key = &data[ offset ]; offset += SIZE_KEY;
112   c->data_key = &data[ offset ]; offset += SIZE_KEY;
113   c->data = &data[ offset ]; offset += SIZE_DATA;
114   c->ds2401 = ds2401;
115   c->write = write;
116   c->read = read;
117
118   state_save_register_item( machine, "zs01", NULL, chip, c->cs );
119   state_save_register_item( machine, "zs01", NULL, chip, c->rst );
120   state_save_register_item( machine, "zs01", NULL, chip, c->scl );
121   state_save_register_item( machine, "zs01", NULL, chip, c->sdaw );
122   state_save_register_item( machine, "zs01", NULL, chip, c->sdar );
123   state_save_register_item( machine, "zs01", NULL, chip, c->state );
124   state_save_register_item( machine, "zs01", NULL, chip, c->shift );
125   state_save_register_item( machine, "zs01", NULL, chip, c->bit );
126   state_save_register_item( machine, "zs01", NULL, chip, c->byte );
127   state_save_register_item_array( machine, "zs01", NULL, chip, c->write_buffer );
128   state_save_register_item_array( machine, "zs01", NULL, chip, c->read_buffer );
129   state_save_register_item_array( machine, "zs01", NULL, chip, c->response_key );
130   state_save_register_item_pointer( machine, "zs01", NULL, chip, c->response_to_reset, SIZE_RESPONSE_TO_RESET );
131   state_save_register_item_pointer( machine, "zs01", NULL, chip, c->command_key, SIZE_KEY );
132   state_save_register_item_pointer( machine, "zs01", NULL, chip, c->data_key, SIZE_DATA );
107   // That chip isn't really usable without the passwords, so bitch
108   // if there's no region
109   logerror("zs01 %s: Warning, no default data provided, chip is unusable.\n", config.tag());
110   memset(response_to_reset, 0, SIZE_RESPONSE_TO_RESET);
111   memset(command_key,       0, SIZE_KEY);
112   memset(data_key,          0, SIZE_KEY);
113   memset(data,              0, SIZE_DATA);
133114}
134115
135void zs01_rst_write( running_machine *machine, int chip, int rst )
116void zs01_device::cs_0()
136117{
137   struct zs01_chip *c;
118}
138119
139   if( chip >= ZS01_MAXCHIP )
140   {
141      verboselog( machine, 0, "zs01_rst_write( %d ) chip out of range\n", chip );
142      return;
143   }
144
145   c = &zs01[ chip ];
146
147   if( c->rst != rst )
148   {
149      verboselog( machine, 2, "zs01(%d) rst=%d\n", chip, rst );
150   }
151   if( c->rst == 0 && rst != 0 && c->cs == 0 )
152   {
153      verboselog( machine, 1, "zs01(%d) goto response to reset\n", chip );
154      c->state = STATE_RESPONSE_TO_RESET;
155      c->bit = 0;
156      c->byte = 0;
157   }
158   c->rst = rst;
120void zs01_device::cs_1()
121{
159122}
160123
161void zs01_cs_write( running_machine *machine, int chip, int cs )
124void zs01_device::rst_0()
162125{
163   struct zs01_chip *c;
126}
164127
165   if( chip >= ZS01_MAXCHIP )
166   {
167      verboselog( machine, 0, "zs01_cs_write( %d ) chip out of range\n", chip );
168      return;
128void zs01_device::rst_1()
129{
130   if(!cs) {
131      verboselog(1, "goto response to reset\n");
132      state = STATE_RESPONSE_TO_RESET;
133      bit = 0;
134      byte = 0;
169135   }
170
171   c = &zs01[ chip ];
172
173   if( c->cs != cs )
174   {
175      verboselog( machine, 2, "zs01(%d) cs=%d\n", chip, cs );
176   }
177//  if( c->cs != 0 && cs == 0 )
178//  {
179//      /* enable chip */
180//      c->state = STATE_STOP;
181//  }
182//  if( c->cs == 0 && cs != 0 )
183//  {
184//      /* disable chip */
185//      c->state = STATE_STOP;
186//      /* high impendence? */
187//      c->sdar = 0;
188//  }
189   c->cs = cs;
190136}
191137
192static void zs01_decrypt( UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte )
138void zs01_device::decrypt(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte)
193139{
194140   UINT32 a0;
195141   UINT32 v1;
r10384r10385
236182   }
237183}
238184
239static void zs01_decrypt2( UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte )
185void zs01_device::decrypt2(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte)
240186{
241187   UINT32 a0;
242188   UINT32 v1;
r10384r10385
284230   }
285231}
286232
287static void zs01_encrypt( UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT32 previous_byte )
233void zs01_device::encrypt(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT32 previous_byte)
288234{
289235   UINT32 t0;
290236   UINT32 v0;
r10384r10385
332278   }
333279}
334280
335static UINT16 zs01_crc( UINT8 *buffer, UINT32 length )
281UINT16 zs01_device::do_crc(UINT8 *buffer, UINT32 length)
336282{
337283   UINT32 v1;
338284   UINT32 a3;
r10384r10385
380326   return v0;
381327}
382328
383static int zs01_data_offset( struct zs01_chip *c )
329int zs01_device::data_offset()
384330{
385   int block = ( ( c->write_buffer[ 0 ] & 2 ) << 7 ) | c->write_buffer[ 1 ];
331   int block = ( (write_buffer[0] & 2 ) << 7 ) | write_buffer[1];
386332
387333   return block * SIZE_DATA_BUFFER;
388334}
389335
390void zs01_scl_write( running_machine *machine, int chip, int scl )
336void zs01_device::scl_0()
391337{
392   struct zs01_chip *c;
393
394   if( chip >= ZS01_MAXCHIP )
395   {
396      verboselog( machine, 0, "zs01_scl_write( %d ) chip out of range\n", chip );
397      return;
398   }
399
400   c = &zs01[ chip ];
401
402   if( c->scl != scl )
403   {
404      verboselog( machine, 2, "zs01(%d) scl=%d\n", chip, scl );
405   }
406   if( c->cs == 0 )
407   {
408      switch( c->state )
409      {
338   if(!cs) {
339      switch(state) {
410340      case STATE_STOP:
411341         break;
412342
413343      case STATE_RESPONSE_TO_RESET:
414         if( c->scl != 0 && scl == 0 )
415         {
416            if( c->bit == 0 )
417            {
418               c->shift = c->response_to_reset[ c->byte ];
419               verboselog( machine, 1, "zs01(%d) <- response_to_reset[%d]: %02x\n", chip, c->byte, c->shift );
420            }
344         if(!bit) {
345            shift = response_to_reset[byte];
346            verboselog(1, "<- response_to_reset[%d]: %02x\n", byte, shift);
347         }
421348
422            c->sdar = ( c->shift >> 7 ) & 1;
423            c->shift <<= 1;
424            c->bit++;
349         sdar = (shift >> 7) & 1;
350         shift <<= 1;
351         bit++;
425352
426            if( c->bit == 8 )
427            {
428               c->bit = 0;
429               c->byte++;
430               if( c->byte == 4 )
431               {
432                  c->sdar = 1;
433                  verboselog( machine, 1, "zs01(%d) goto stop\n", chip );
434                  c->state = STATE_STOP;
435               }
353         if( bit == 8 ) {
354            bit = 0;
355            byte++;
356            if( byte == 4 ) {
357               sdar = true;
358               verboselog(1, "goto stop\n");
359               state = STATE_STOP;
436360            }
437361         }
438362         break;
439363
440364      case STATE_LOAD_COMMAND:
441         if( c->scl == 0 && scl != 0 )
442         {
443            if( c->bit < 8 )
444            {
445               verboselog( machine, 2, "zs01(%d) clock\n", chip );
446               c->shift <<= 1;
447               if( c->sdaw != 0 )
448               {
449                  c->shift |= 1;
450               }
451               c->bit++;
452            }
453            else
454            {
455               c->sdar = 0;
365         break;
456366
457               switch( c->state )
458               {
459               case STATE_LOAD_COMMAND:
460                  c->write_buffer[ c->byte ] = c->shift;
461                  verboselog( machine, 2, "zs01(%d) -> write_buffer[%d]: %02x\n", chip, c->byte, c->write_buffer[ c->byte ] );
367      case STATE_READ_DATA:
368         break;
369      }
370   }
371}
462372
463                  c->byte++;
464                  if( c->byte == SIZE_WRITE_BUFFER )
465                  {
466                     UINT16 crc;
373void zs01_device::scl_1()
374{
375   if(!cs) {
376      switch(state) {
377      case STATE_STOP:
378         break;
467379
468                     zs01_decrypt( c->write_buffer, c->write_buffer, SIZE_WRITE_BUFFER, c->command_key, 0xff );
380      case STATE_RESPONSE_TO_RESET:
381         break;
469382
470                     if( ( c->write_buffer[ 0 ] & 4 ) != 0 )
471                     {
472                        zs01_decrypt2( &c->write_buffer[ 2 ], &c->write_buffer[ 2 ], SIZE_DATA_BUFFER, c->data_key, 0x00 );
473                     }
383      case STATE_LOAD_COMMAND:
384         if(bit < 8) {
385            shift <<= 1;
386            if(sdaw)
387               shift |= 1;
388            bit++;
389            verboselog(2, "clock %d %02x\n", bit, shift);
390         } else {
391            sdar = false;
474392
475                     crc = zs01_crc( c->write_buffer, 10 );
393            switch(state) {
394            case STATE_LOAD_COMMAND:
395               write_buffer[byte] = shift;
396               verboselog(2, "-> write_buffer[%d]: %02x\n", byte, write_buffer[byte]);
397               byte++;
398               if(byte == SIZE_WRITE_BUFFER) {
399                  UINT16 crc;
476400
477                     if( crc == ( ( c->write_buffer[ 10 ] << 8 ) | c->write_buffer[ 11 ] ) )
478                     {
479                        verboselog( machine, 1, "zs01(%d) -> command: %02x\n", chip, c->write_buffer[ 0 ] );
480                        verboselog( machine, 1, "zs01(%d) -> address: %02x\n", chip, c->write_buffer[ 1 ] );
481                        verboselog( machine, 1, "zs01(%d) -> data: %02x%02x%02x%02x%02x%02x%02x%02x\n", chip,
482                           c->write_buffer[ 2 ], c->write_buffer[ 3 ], c->write_buffer[ 4 ], c->write_buffer[ 5 ],
483                           c->write_buffer[ 6 ], c->write_buffer[ 7 ], c->write_buffer[ 8 ], c->write_buffer[ 9 ] );
484                        verboselog( machine, 1, "zs01(%d) -> crc: %02x%02x\n", chip, c->write_buffer[ 10 ], c->write_buffer[ 11 ] );
401                  decrypt(write_buffer, write_buffer, SIZE_WRITE_BUFFER, command_key, 0xff);
485402
486                        switch( c->write_buffer[ 0 ] & 1 )
487                        {
488                        case COMMAND_WRITE:
489                           memcpy( &c->data[ zs01_data_offset( c ) ], &c->write_buffer[ 2 ], SIZE_DATA_BUFFER );
403                  if(write_buffer[0] & 4)
404                     decrypt2(&write_buffer[2], &write_buffer[2], SIZE_DATA_BUFFER, data_key, 0x00);
490405
491                           /* todo: find out what should be returned. */
492                           memset( &c->read_buffer[ 0 ], 0, SIZE_WRITE_BUFFER );
493                           break;
406                  crc = do_crc(write_buffer, 10);
494407
495                        case COMMAND_READ:
496                           /* todo: find out what should be returned. */
497                           memset( &c->read_buffer[ 0 ], 0, 2 );
408                  if(crc == ((write_buffer[10] << 8) | write_buffer[11])) {
409                     verboselog(1, "-> command: %02x\n", write_buffer[0]);
410                     verboselog(1, "-> address: %02x\n", write_buffer[1]);
411                     verboselog(1, "-> data: %02x%02x%02x%02x%02x%02x%02x%02x\n",
412                              write_buffer[2], write_buffer[3], write_buffer[4], write_buffer[5],
413                              write_buffer[6], write_buffer[7], write_buffer[8], write_buffer[9]);
414                     verboselog(1, "-> crc: %02x%02x\n", write_buffer[10], write_buffer[11]);
415                     switch(write_buffer[0] & 1) {
416                     case COMMAND_WRITE:
417                        memcpy(&data[data_offset()], &write_buffer[2], SIZE_DATA_BUFFER);
418                       
419                        /* todo: find out what should be returned. */
420                        memset(&read_buffer[0] , 0, SIZE_WRITE_BUFFER);
421                        break;
498422
499                           switch( c->write_buffer[ 1 ] )
500                           {
501                           case 0xfd:
502                              {
503                                 /* TODO: use read/write to talk to the ds2401, which will require a timer. */
504                                 int i;
505                                 for( i = 0; i < SIZE_DATA_BUFFER; i++ )
506                                 {
507                                    c->read_buffer[ 2 + i ] = c->ds2401[ SIZE_DATA_BUFFER - i - 1 ];
508                                 }
509                              }
510                              break;
511                           default:
512                              memcpy( &c->read_buffer[ 2 ], &c->data[ zs01_data_offset( c ) ], SIZE_DATA_BUFFER );
513                              break;
514                           }
423                     case COMMAND_READ:
424                        /* todo: find out what should be returned. */
425                        memset(&read_buffer[0], 0, 2);
515426
516                           memcpy( c->response_key, &c->write_buffer[ 2 ], SIZE_KEY );
427                        switch(write_buffer[1]) {
428                        case 0xfd: {
429                           /* TODO: use read/write to talk to the ds2401, which will require a timer. */
430                           ds2401_device *ds2401 = machine->device<ds2401_device>(config.ds2401_tag);
431                           for(int i = 0; i < SIZE_DATA_BUFFER; i++)
432                              read_buffer[2+i] = ds2401->direct_read(SIZE_DATA_BUFFER-i-1);
517433                           break;
518434                        }
519                     }
520                     else
521                     {
522                        verboselog( machine, 0, "zs01(%d) bad crc\n", chip );
435                        default:
436                           memcpy(&read_buffer[2], &data[data_offset()], SIZE_DATA_BUFFER);
437                           break;
438                        }
523439
524                        /* todo: find out what should be returned. */
525                        memset( &c->read_buffer[ 0 ], 0xff, 2 );
440                        memcpy(response_key, &write_buffer[2], SIZE_KEY);
441                        break;
526442                     }
443                  } else {
444                     verboselog(0, "bad crc\n");
445                     /* todo: find out what should be returned. */
446                     memset(&read_buffer[0], 0xff, 2 );
447                  }
527448
528                     verboselog( machine, 1, "zs01(%d) <- status: %02x%02x\n", chip,
529                        c->read_buffer[ 0 ], c->read_buffer[ 1 ] );
449                  verboselog(1, "<- status: %02x%02x\n",
450                           read_buffer[0], read_buffer[1]);
530451
531                     verboselog( machine, 1, "zs01(%d) <- data: %02x%02x%02x%02x%02x%02x%02x%02x\n", chip,
532                        c->read_buffer[ 2 ], c->read_buffer[ 3 ], c->read_buffer[ 4 ], c->read_buffer[ 5 ],
533                        c->read_buffer[ 6 ], c->read_buffer[ 7 ], c->read_buffer[ 8 ], c->read_buffer[ 9 ] );
452                  verboselog(1, "<- data: %02x%02x%02x%02x%02x%02x%02x%02x\n",
453                           read_buffer[2], read_buffer[3], read_buffer[4], read_buffer[5],
454                           read_buffer[6], read_buffer[7], read_buffer[8], read_buffer[9]);
534455
535                     crc = zs01_crc( c->read_buffer, 10 );
536                     c->read_buffer[ 10 ] = crc >> 8;
537                     c->read_buffer[ 11 ] = crc & 255;
456                  crc = do_crc(read_buffer, 10);
457                  read_buffer[10] = crc >> 8;
458                  read_buffer[11] = crc & 255;
538459
539                     zs01_encrypt( c->read_buffer, c->read_buffer, SIZE_READ_BUFFER, c->response_key, 0xff );
460                  encrypt(read_buffer, read_buffer, SIZE_READ_BUFFER, response_key, 0xff);
540461
541                     c->byte = 0;
542                     c->state = STATE_READ_DATA;
543                  }
544                  break;
462                  byte = 0;
463                  state = STATE_READ_DATA;
545464               }
546
547               c->bit = 0;
548               c->shift = 0;
465               break;
549466            }
467
468            bit = 0;
469            shift = 0;
550470         }
551471         break;
552472
553473      case STATE_READ_DATA:
554         if( c->scl == 0 && scl != 0 )
555         {
556            if( c->bit < 8 )
557            {
558               if( c->bit == 0 )
559               {
560                  switch( c->state )
561                  {
562                  case STATE_READ_DATA:
563                     c->shift = c->read_buffer[ c->byte ];
564                     verboselog( machine, 2, "zs01(%d) <- read_buffer[%d]: %02x\n", chip, c->byte, c->shift );
565                     break;
566                  }
474         if(bit < 8) {
475            if(bit == 0) {
476               switch(state) {
477               case STATE_READ_DATA:
478                  shift = read_buffer[byte];
479                  verboselog(2, "<- read_buffer[%d]: %02x\n", byte, shift);
480                  break;
567481               }
568               c->sdar = ( c->shift >> 7 ) & 1;
569               c->shift <<= 1;
570               c->bit++;
571482            }
572            else
573            {
574               c->bit = 0;
575               c->sdar = 0;
576               if( c->sdaw == 0 )
577               {
578                  verboselog( machine, 2, "zs01(%d) ack <-\n", chip );
579                  c->byte++;
580                  if( c->byte == SIZE_READ_BUFFER )
581                  {
582                     c->byte = 0;
583                     c->sdar = 1;
584                     c->state = STATE_LOAD_COMMAND;
585                  }
483            sdar = (shift >> 7) & 1;
484            shift <<= 1;
485            bit++;
486         } else {
487            bit = 0;
488            sdar = false;
489            if(!sdaw) {
490               verboselog(2, "ack <-\n");
491               byte++;
492               if(byte == SIZE_READ_BUFFER) {
493                  byte = 0;
494                  sdar = true;
495                  state = STATE_LOAD_COMMAND;
586496               }
587               else
588               {
589                  verboselog( machine, 2, "zs01(%d) nak <-\n", chip );
590               }
497            } else {
498               verboselog(2, "nak <-\n");
591499            }
592500         }
593501         break;
594502      }
595503   }
596   c->scl = scl;
597504}
598505
599void zs01_sda_write( running_machine *machine, int chip, int sda )
506void zs01_device::sda_1()
600507{
601   struct zs01_chip *c;
602
603   if( chip >= ZS01_MAXCHIP )
604   {
605      verboselog( machine, 0, "zs01_sda_write( %d ) chip out of range\n", chip );
606      return;
508   if(!cs && scl){
509//      state = STATE_STOP;
510//      sdar = false;
607511   }
608
609   c = &zs01[ chip ];
610
611   if( c->sdaw != sda )
612   {
613      verboselog( machine, 2, "zs01(%d) sdaw=%d\n", chip, sda );
614   }
615   if( c->cs == 0 && c->scl != 0 )
616   {
617//      if( c->sdaw == 0 && sda != 0 )
618//      {
619//          verboselog( machine, 1, "zs01(%d) goto stop\n", chip );
620//          c->state = STATE_STOP;
621//          c->sdar = 0;
622//      }
623      if( c->sdaw != 0 && sda == 0 )
624      {
625         switch( c->state )
626         {
627         case STATE_STOP:
628            verboselog( machine, 1, "zs01(%d) goto start\n", chip );
629            c->state = STATE_LOAD_COMMAND;
630            break;
631
632//          default:
633//              verboselog( machine, 1, "zs01(%d) skipped start (default)\n", chip );
634//              break;
635         }
636
637         c->bit = 0;
638         c->byte = 0;
639         c->shift = 0;
640         c->sdar = 0;
641      }
642   }
643   c->sdaw = sda;
644512}
645513
646int zs01_sda_read( running_machine *machine, int chip )
514void zs01_device::sda_0()
647515{
648   struct zs01_chip *c;
516   if(!cs && scl) {
517      switch(state) {
518      case STATE_STOP:
519         verboselog(1, "goto start\n");
520         state = STATE_LOAD_COMMAND;
521         break;
522         //   default:
523         //      verboselog(1, "skipped start (default)\n");
524         //      break;
525      }
649526
650   if( chip >= ZS01_MAXCHIP )
651   {
652      verboselog( machine, 0, "zs01_sda_read( %d ) chip out of range\n", chip );
653      return 1;
527      bit = 0;
528      byte = 0;
529      shift = 0;
530      sdar = false;
654531   }
655
656   c = &zs01[ chip ];
657   if( c->cs != 0 )
658   {
659      verboselog( machine, 2, "zs01(%d) not selected\n", chip );
660      return 1;
661   }
662   verboselog( machine, 2, "zs01(%d) sdar=%d\n", chip, c->sdar );
663
664   return c->sdar;
665532}
666533
667static void nvram_handler_zs01( running_machine *machine, mame_file *file, int read_or_write, int chip )
534void zs01_device::nvram_read(emu_file &file)
668535{
669   struct zs01_chip *c;
670
671   if( chip >= ZS01_MAXCHIP )
672   {
673      verboselog( machine, 0, "nvram_handler_zs01( %d ) chip out of range\n", chip );
674      return;
675   }
676
677   c = &zs01[ chip ];
678
679   if( read_or_write )
680   {
681      mame_fwrite( file, c->data, SIZE_DATA );
682   }
683   else if( file )
684   {
685      mame_fread( file, c->data, SIZE_DATA );
686   }
536   file.read(response_to_reset, SIZE_RESPONSE_TO_RESET);
537   file.read(command_key,       SIZE_KEY);
538   file.read(data_key,          SIZE_KEY);
539   file.read(data,              SIZE_DATA);
687540}
688541
689NVRAM_HANDLER( zs01_0 ) { nvram_handler_zs01( machine, file, read_or_write, 0 ); }
690NVRAM_HANDLER( zs01_1 ) { nvram_handler_zs01( machine, file, read_or_write, 1 ); }
542void zs01_device::nvram_write(emu_file &file)
543{
544   file.write(response_to_reset, SIZE_RESPONSE_TO_RESET);
545   file.write(command_key,       SIZE_KEY);
546   file.write(data_key,          SIZE_KEY);
547   file.write(data,              SIZE_DATA);
548}
src/mame/machine/zs01.h
r10384r10385
55 *
66 */
77
8#if !defined( ZS01_H )
8#ifndef __ZS01_H__
9#define __ZS01_H__
910
10#define ZS01_MAXCHIP ( 2 )
11#define MCFG_ZS01_ADD(_tag, ds2401_tag) \
12   MCFG_DEVICE_ADD(_tag, ZS01, 0) \
13   zs01_device_config::static_set_ds2401_tag(device, ds2401_tag); \
1114
12typedef void (*zs01_write_handler)( running_machine *machine, int pin, int value );
13typedef int (*zs01_read_handler)( running_machine *machine, int pin );
15#include "machine/secflash.h"
1416
15extern void zs01_init( running_machine *machine, int chip, UINT8 *data, zs01_write_handler write, zs01_read_handler read, UINT8 *ds2401 );
16extern void zs01_cs_write( running_machine *machine, int chip, int cs );
17extern void zs01_rst_write( running_machine *machine, int chip, int rst );
18extern void zs01_scl_write( running_machine *machine, int chip, int scl );
19extern void zs01_sda_write( running_machine *machine, int chip, int sda );
20extern int zs01_sda_read( running_machine *machine, int chip );
21extern NVRAM_HANDLER( zs01_0 );
22extern NVRAM_HANDLER( zs01_1 );
17class zs01_device_config : public device_secure_serial_flash_config
18{
19   friend class zs01_device;
2320
24#define ZS01_H
21   // construction/destruction
22   zs01_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
23
24public:
25   // allocators
26   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
27
28   // inline configuration helpers
29   static void static_set_ds2401_tag(device_config *device, const char *ds2401_tag);
30
31   virtual device_t *alloc_device(running_machine &machine) const;
32
33protected:
34   // internal state
35   const char *ds2401_tag;
36};
37
38class zs01_device : public device_secure_serial_flash
39{
40   friend class zs01_device_config;
41
42   // construction/destruction
43   zs01_device(running_machine &_machine, const zs01_device_config &config);
44
45protected:
46   // device-level overrides
47   virtual void device_start();
48   virtual void device_reset();
49
50   // device_nvram_interface overrides
51   virtual void nvram_default();
52   virtual void nvram_read(emu_file &file);
53   virtual void nvram_write(emu_file &file);
54
55   // device_secure_serial_flash implementations
56   virtual void cs_0();
57   virtual void cs_1();
58   virtual void rst_0();
59   virtual void rst_1();
60   virtual void scl_0();
61   virtual void scl_1();
62   virtual void sda_0();
63   virtual void sda_1();
64
65   // internal state
66   const zs01_device_config &config;
67
68   enum {
69      SIZE_WRITE_BUFFER = 12,
70      SIZE_READ_BUFFER = 12,
71      SIZE_DATA_BUFFER = 8,
72      SIZE_RESPONSE_TO_RESET = 4,
73      SIZE_KEY = 8,
74      SIZE_DATA = 4096,
75
76      COMMAND_WRITE = 0x00,
77      COMMAND_READ = 0x01
78   };
79
80   enum {
81      STATE_STOP,
82      STATE_RESPONSE_TO_RESET,
83      STATE_LOAD_COMMAND,
84      STATE_READ_DATA
85   };
86
87   int state, bit, byte;
88   UINT8 shift;
89   UINT8 write_buffer[SIZE_WRITE_BUFFER];
90   UINT8 read_buffer[SIZE_READ_BUFFER];
91   UINT8 response_key[SIZE_KEY];
92   UINT8 response_to_reset[SIZE_RESPONSE_TO_RESET];
93   UINT8 command_key[SIZE_KEY];
94   UINT8 data_key[SIZE_KEY];
95   UINT8 data[SIZE_DATA];
96
97   void decrypt(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte);
98   void decrypt2(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT8 previous_byte);
99   void encrypt(UINT8 *destination, UINT8 *source, int length, UINT8 *key, UINT32 previous_byte);
100   UINT16 do_crc(UINT8 *buffer, UINT32 length);
101   int data_offset();
102
103private:
104   inline void ATTR_PRINTF(3,4) verboselog(int n_level, const char *s_fmt, ...);
105};
106
107
108// device type definition
109extern const device_type ZS01;
110
25111#endif
src/mame/machine/naomibd.c
r10384r10385
580580   {
581581      UINT64 ret;
582582
583      ret = x76f100_sda_read( device->machine, 0 ) << 15;
583      ret = device->machine->device<x76f100_device>("naomibd_eeprom")->sda_r() << 15;
584584
585585      return ret << 32;
586586   }
r10384r10385
903903      {
904904         if(ACCESSING_BITS_0_15)
905905         {
906            running_machine *machine = device->machine;
907
906            x76f100_device *x76f100 = device->machine->device<x76f100_device>("naomibd_eeprom");
908907            // NAOMI_BOARDID_WRITE
909            x76f100_cs_write(machine, 0, (data >> 2) & 1 );
910            x76f100_rst_write(machine, 0, (data >> 3) & 1 );
911            x76f100_scl_write(machine, 0, (data >> 1) & 1 );
912            x76f100_sda_write(machine, 0, (data >> 0) & 1 );
908            x76f100->cs_w((data >> 2) & 1);
909            x76f100->rst_w((data >> 3) & 1);
910            x76f100->scl_w((data >> 1) & 1);
911            x76f100->sda_w((data >> 0) & 1);
913912         }
914913      }
915914      break;
r10384r10385
18501849
18511850
18521851/*-------------------------------------------------
1853    device nvram callback
1854-------------------------------------------------*/
1855
1856
1857static DEVICE_NVRAM( naomibd )
1858{
1859   //naomibd_state *v = get_safe_token(device);
1860   static const UINT8 eeprom_romboard[20+48] =
1861   {
1862      0x19,0x00,0xaa,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x79,0x68,0x6b,0x74,0x6d,0x68,0x6d,
1863      0xa1,0x09,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
1864      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
1865      0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30
1866   };
1867   UINT8 *games_contents;
1868
1869   if (read_or_write)
1870      /*eeprom_save(file)*/;
1871   else
1872   {
1873      /*if (file)
1874            eeprom_load(file);
1875        else*/
1876      games_contents = device->machine->region("naomibd_eeprom")->base();
1877
1878      if (games_contents)
1879      {
1880         x76f100_init( device->machine, 0, games_contents );
1881      }
1882      else
1883      {
1884         UINT8 *eeprom = auto_alloc_array_clear(device->machine, UINT8, 0x84);
1885         memcpy(eeprom, eeprom_romboard, sizeof(eeprom_romboard));
1886         x76f100_init( device->machine, 0, eeprom );
1887      }
1888
1889   }
1890}
1891
1892/*-------------------------------------------------
18931852    device get info callback
18941853-------------------------------------------------*/
18951854
r10384r10385
19101869      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(naomibd);      break;
19111870      case DEVINFO_FCT_STOP:               info->stop = DEVICE_STOP_NAME(naomibd);         break;
19121871      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(naomibd);      break;
1913      case DEVINFO_FCT_NVRAM:               info->nvram = DEVICE_NVRAM_NAME(naomibd);      break;
19141872
19151873      /* --- the following bits of info are returned as NULL-terminated strings --- */
19161874      case DEVINFO_STR_NAME:
r10384r10385
19301888}
19311889
19321890
1933DEFINE_LEGACY_NVRAM_DEVICE(NAOMI_BOARD, naomibd);
1891DEFINE_LEGACY_DEVICE(NAOMI_BOARD, naomibd);
src/mame/machine/segamsys.c
r10384r10385
17001700   if (smsgg_backupram!=NULL)
17011701   {
17021702      if (read_or_write)
1703         mame_fwrite(file, smsgg_backupram, 0x2000);
1703         file->write(smsgg_backupram, 0x2000);
17041704      else
17051705      {
17061706         if (file)
17071707         {
1708            mame_fread(file, smsgg_backupram, 0x2000);
1708            file->read(smsgg_backupram, 0x2000);
17091709         }
17101710      }
17111711   }
src/mame/machine/kaneko16.c
r10384r10385
24472447   {
24482448      case 0x02:   // Read from NVRAM
24492449      {
2450         mame_file *f;
2451         if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0)
2452         {
2453            mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128);
2454            mame_fclose(f);
2455         }
2450         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
24562451         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2);
24572452      }
24582453      break;
24592454
24602455      case 0x42:   // Write to NVRAM
24612456      {
2462         mame_file *f;
2463         if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0)
2464         {
2465            mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128);
2466            mame_fclose(f);
2467         }
2457         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
24682458         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2);
24692459      }
24702460      break;
r10384r10385
25062496
25072497      case 0x02:   // Read from NVRAM
25082498      {
2509         mame_file *f;
2510         if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0)
2511         {
2512            mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128);
2513            mame_fclose(f);
2514         }
2499         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
25152500         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2);
25162501      }
25172502      break;
25182503
25192504      case 0x42:   // Write to NVRAM
25202505      {
2521         mame_file *f;
2522         if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0)
2523         {
2524            mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128);
2525            mame_fclose(f);
2526         }
2506         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
25272507         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2);
25282508      }
25292509      break;
25302510
25312511      case 0x43:   // Initialize NVRAM - MCU writes Default Data Set directly to NVRAM
25322512      {
2533         mame_file *f;
2534         if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0)
2535         {
2536            mame_fwrite(f, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
2537            mame_fclose(f);
2538         }
2513         memcpy(kaneko16_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
25392514         logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine->describe_context(), mcu_command, mcu_offset*2);
25402515      }
25412516      break;
r10384r10385
26012576
26022577      case 0x02:   // Read from NVRAM
26032578      {
2604         mame_file *f;
2605         if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0)
2606         {
2607            mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128);
2608            mame_fclose(f);
2609         }
2579         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
26102580      }
26112581      break;
26122582
26132583      case 0x42:   // Write to NVRAM
26142584      {
2615         mame_file *f;
2616         if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0)
2617         {
2618            mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128);
2619            mame_fclose(f);
2620         }
2585         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
26212586      }
26222587      break;
26232588
src/mame/mamedriv.c
r10384r10385
14941494   DRIVER( archrivl2 )   /* (c) 1989 */
14951495   DRIVER( trisport )   /* (c) 1989 */
14961496   DRIVER( pigskin )   /* (c) 1990 */
1497   DRIVER( pigskina )   /* (c) 1990 */
14971498
14981499   /* Bally / Sente games */
14991500   DRIVER( sentetst )
r10384r10385
57525753   DRIVER( prmrsocr )   /* GX101 (c) 1993 (Europe) */
57535754   DRIVER( prmrsocrj )   /* GX101 (c) 1993 (Japan) */
57545755   DRIVER( qgakumon )   /* GX248 (c) 1993 (Japan) */
5755   DRIVER( moo )      /* GX151 (c) 1992 (World) */
5756   DRIVER( mooua )      /* GX151 (c) 1992 (US) */
5757   DRIVER( mooaa )      /* GX151 (c) 1992 (US) */
5758   DRIVER( moobl )      /* bootleg */
5756   DRIVER( moomesa )   /* GX151 (c) 1992 (World) */
5757   DRIVER( moomesau )   /* GX151 (c) 1992 (US) */
5758   DRIVER( moomesaua )   /* GX151 (c) 1992 (US) */
5759   DRIVER( moomesaa )   /* GX151 (c) 1992 (Asia) */
5760   DRIVER( moomesabl )   /* bootleg */
57595761   DRIVER( bucky )      /* GX173 (c) 1992 (World) */
57605762   DRIVER( buckyua )   /* GX173 (c) 1992 (US) */
57615763   DRIVER( buckyaa )   /* GX173 (c) 1992 (Asia) */
src/mame/includes/kaneko16.h
r10384r10385
44
55***************************************************************************/
66
7#include "machine/nvram.h"
8
79/*----------- defined in machine/kaneko16.c -----------*/
810
911extern UINT16 *kaneko16_mcu_ram; /* for calc3 and toybox */
12extern UINT8 kaneko16_nvram_save[128];
1013
1114READ16_HANDLER( galpanib_calc_r );
1215WRITE16_HANDLER( galpanib_calc_w );
src/mame/includes/naomibd.h
r10384r10385
9494
9595/* ----- device interface ----- */
9696
97DECLARE_LEGACY_NVRAM_DEVICE(NAOMI_BOARD, naomibd);
97DECLARE_LEGACY_DEVICE(NAOMI_BOARD, naomibd);
src/mame/video/kaneko16.c
r10384r10385
5555UINT16 kaneko16_sprite_yoffs, kaneko16_sprite_flipy;
5656UINT16 *kaneko16_sprites_regs;
5757
58UINT8 kaneko16_nvram_save[128];
5859
5960UINT16 *kaneko16_bg15_select, *kaneko16_bg15_reg;
6061static bitmap_t *kaneko16_bg15_bitmap;
src/mame/video/gp9001.c
r10384r10385
234234   vdp->m_gfxregion = gfxregion;
235235}
236236
237bool gp9001vdp_device_config::device_validity_check(const game_driver &driver) const
237bool gp9001vdp_device_config::device_validity_check(core_options &options, const game_driver &driver) const
238238{
239239   bool error = false;
240240   return error;
src/mame/video/gp9001.h
r10384r10385
1010   virtual device_t *alloc_device(running_machine &machine) const;
1111   static void static_set_gfx_region(device_config *device, int gfxregion);
1212protected:
13   virtual bool device_validity_check(const game_driver &driver) const;
13   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
1414   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
1515   address_space_config      m_space_config;
1616   UINT8                  m_gfxregion;
src/mame/etc/jrcrypt.c
r10384r10385
486486
487487void Load(char *name,byte *buffer,int from, int length)
488488{
489   file_error filerr;
490   mame_file *file;
491
492   filerr = mame_fopen(NULL, name, OPEN_FLAG_READ, &file);
489/*
490   emu_file file(options, NULL, OPEN_FLAG_READ);
491   file_error filerr = file.open(name);
493492   if (filerr != FILERR_NONE)
494493      return;
495494   while (length--)
496      buffer[from++]=mame_fgetc(file);
497   mame_fclose(file);
495      buffer[from++]=file->getc();
496*/
498497}
499498
500499void CreateJrDecodeTable(byte *x, int length)
src/mame/drivers/mitchell.c
r10384r10385
101101   if (read_or_write)
102102   {
103103      if (nvram_size)   /* Super Pang, Block Block */
104         mame_fwrite(file,nvram,nvram_size);   /* NVRAM */
104         file->write(nvram,nvram_size);   /* NVRAM */
105105   }
106106   else
107107   {
108108      if (file)
109109      {
110110         if (nvram_size)   /* Super Pang, Block Block */
111            mame_fread(file,nvram,nvram_size);   /* NVRAM */
111            file->read(nvram,nvram_size);   /* NVRAM */
112112      }
113113   }
114114}
src/mame/drivers/nbmj9195.c
r10384r10385
5050static NVRAM_HANDLER( nbmj9195 )
5151{
5252   if (read_or_write)
53      mame_fwrite(file, nbmj9195_nvram, nbmj9195_nvram_size);
53      file->write(nbmj9195_nvram, nbmj9195_nvram_size);
5454   else {
5555      if (file)
56         mame_fread(file, nbmj9195_nvram, nbmj9195_nvram_size);
56         file->read(nbmj9195_nvram, nbmj9195_nvram_size);
5757      else
5858         memset(nbmj9195_nvram, 0, nbmj9195_nvram_size);
5959   }
src/mame/drivers/kaneko16.c
r10384r10385
18241824   MCFG_PALETTE_INIT(berlwall)
18251825   MCFG_VIDEO_START(berlwall)
18261826   MCFG_VIDEO_UPDATE(berlwall)
1827
1827   
18281828   /* sound hardware */
18291829   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18301830
r10384r10385
19611961   MCFG_CPU_VBLANK_INT_HACK(kaneko16_interrupt,KANEKO16_INTERRUPTS_NUM)
19621962
19631963   MCFG_MACHINE_RESET(gtmr)
1964   MCFG_NVRAM_ADD_0FILL("nvram")
19641965
19651966   /* video hardware */
19661967   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
r10384r10385
38423843
38433844static DRIVER_INIT( bloodwar )
38443845{
3846   machine->device<nvram_device>("nvram")->set_base(kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
38453847   DRIVER_INIT_CALL(samplebank);
38463848   DRIVER_INIT_CALL(decrypt_toybox_rom);
38473849}
38483850
38493851static DRIVER_INIT( gtmr2 )
38503852{
3853   machine->device<nvram_device>("nvram")->set_base(kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
38513854   DRIVER_INIT_CALL(samplebank);
38523855   DRIVER_INIT_CALL(decrypt_toybox_rom_alt);
38533856}
src/mame/drivers/pinkiri8.c
r10384r10385
7474   virtual device_t *alloc_device(running_machine &machine) const;
7575protected:
7676   virtual void device_config_complete();
77   virtual bool device_validity_check(const game_driver &driver) const;
77   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
7878   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
7979   address_space_config      m_space_config;
8080};
r10384r10385
117117//  m_space_config = address_space_config("janshi_vdp", ENDIANNESS_BIG, 8,  address_bits, 0, *ADDRESS_MAP_NAME(janshi_vdp_map8));
118118}
119119
120bool janshi_vdp_device_config::device_validity_check(const game_driver &driver) const
120bool janshi_vdp_device_config::device_validity_check(core_options &options, const game_driver &driver) const
121121{
122122   bool error = false;
123123   return error;
src/mame/drivers/namconb1.c
r10384r10385
574574         data[1] = (dword&0x00ff0000)>>16;
575575         data[2] = (dword&0x0000ff00)>>8;
576576         data[3] = dword&0xff;
577         mame_fwrite( file, data, 4 );
577         file->write( data, 4 );
578578      }
579579   }
580580   else
r10384r10385
583583      {
584584         for( i=0; i<NB1_NVMEM_SIZE/4; i++ )
585585         {
586            mame_fread( file, data, 4 );
586            file->read( data, 4 );
587587            nvmem32[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
588588         }
589589      }
src/mame/drivers/mjkjidai.c
r10384r10385
158158   mjkjidai_state *state = machine->driver_data<mjkjidai_state>();
159159
160160   if (read_or_write)
161      mame_fwrite(file, state->nvram, state->nvram_size);
161      file->write(state->nvram, state->nvram_size);
162162   else if (file)
163      mame_fread(file, state->nvram, state->nvram_size);
163      file->read(state->nvram, state->nvram_size);
164164   else
165165   {
166166      state->nvram_init_count = 1;
src/mame/drivers/gal3.c
r10384r10385
242242         data[1] = (dword&0x00ff0000)>>16;
243243         data[2] = (dword&0x0000ff00)>>8;
244244         data[3] = dword&0xff;
245         mame_fwrite( file, data, 4 );
245         file->write( data, 4 );
246246      }
247247   }
248248   else
r10384r10385
251251      {
252252         for( i=0; i<gal3_nvmem_size/4; i++ )
253253         {
254            mame_fread( file, data, 4 );
254            file->read( data, 4 );
255255            gal3_nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
256256         }
257257      }
src/mame/drivers/naomi.c
r10384r10385
13421342#include "cpu/arm7/arm7.h"
13431343#include "machine/eeprom.h"
13441344#include "machine/intelfsh.h"
1345#include "machine/x76f100.h"
13451346#include "includes/naomibd.h"
13461347#include "includes/naomi.h"
13471348#include "cpu/sh4/sh4.h"
r10384r10385
14171418   if (read_or_write)
14181419   {
14191420      /* JVS 'eeprom' */
1420      mame_fwrite(file,maple0x86data1,0x80);
1421      file->write(maple0x86data1,0x80);
14211422   }
14221423   else
14231424   {
14241425      if (file)
14251426      {
14261427         /* JVS 'eeprom' */
1427         mame_fread(file,maple0x86data1,0x80);
1428         file->read(maple0x86data1,0x80);
14281429      }
14291430       else
14301431      {
r10384r10385
20632064
20642065static MACHINE_CONFIG_DERIVED( naomi, naomi_base )
20652066   MCFG_NAOMI_ROM_BOARD_ADD("rom_board", "user1")
2067   MCFG_X76F100_ADD("naomibd_eeprom")
20662068MACHINE_CONFIG_END
20672069
20682070/*
r10384r10385
20712073
20722074static MACHINE_CONFIG_DERIVED( naomigd, naomi_base )
20732075   MCFG_NAOMI_DIMM_BOARD_ADD("rom_board", "gdrom", "user1", "picreturn")
2076   MCFG_X76F100_ADD("naomibd_eeprom")
20742077MACHINE_CONFIG_END
20752078
20762079/*
r10384r10385
20952098   MCFG_CPU_PROGRAM_MAP(aw_map)
20962099   MCFG_MACRONIX_29L001MC_ADD("awflash")
20972100   MCFG_AW_ROM_BOARD_ADD("rom_board", "user1")
2101   MCFG_X76F100_ADD("naomibd_eeprom")
20982102MACHINE_CONFIG_END
20992103
21002104#define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \
r10384r10385
23212325/* default EEPROM values, same works for all games */
23222326#define NAOMI_DEFAULT_EEPROM \
23232327   ROM_REGION16_BE( 0x80, "main_eeprom", 0 ) \
2328   ROM_LOAD16_WORD("eeprom-naomi-main-default.bin", 0x0000, 0x0080, CRC(fea29cbb) SHA1(4099f1747aafa07db34f6e072cd9bfaa83bae10e) ) \
2329   ROM_REGION( 0x84, "naomibd_eeprom", 0 ) \
2330   ROM_LOAD("eeprom-naomi-x76f100-default.bin", 0x0000, 0x0084, CRC(3ea24b6a) SHA1(3a730ebcf56e0060fef6b1b02eb2eb7cfb7e61dc) )
2331
2332/* Version without the default x76f100 eeprom */
2333#define NAOMI_DEFAULT_EEPROM_NO_BD   \
2334   ROM_REGION16_BE( 0x80, "main_eeprom", 0 ) \
23242335   ROM_LOAD16_WORD("eeprom-naomi-main-default.bin", 0x0000, 0x0080, CRC(fea29cbb) SHA1(4099f1747aafa07db34f6e072cd9bfaa83bae10e) )
23252336
23262337ROM_START( naomi )
r10384r10385
26132624ROM_START( doa2 )
26142625   ROM_REGION( 0x200000, "maincpu", 0)
26152626   NAOMI_BIOS
2616   NAOMI_DEFAULT_EEPROM
2627   NAOMI_DEFAULT_EEPROM_NO_BD
26172628
26182629   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
26192630   ROM_LOAD("epr-22121.ic22",0x0000000, 0x0400000,  CRC(30f93b5e) SHA1(0e33383e7ab9a721dab4708b063598f2e9c9f2e7) ) // partially encrypted
r10384r10385
26412652   ROM_LOAD("mpr-22120.ic21",0xa800000, 0x0800000, CRC(a30facb4) SHA1(70415ca34095c795297486bce1f956f6a8d4817f) )
26422653
26432654   // on-cart X76F100 eeprom contents
2644   ROM_REGION( 0x100, "naomibd_eeprom", ROMREGION_ERASE00 )
2655   ROM_REGION( 0x84, "naomibd_eeprom", 0 )
26452656   ROM_LOAD( "841-0003.sf",  0x000000, 0x000084, CRC(3a119a17) SHA1(d37a092cca7c9cfc5f2637b355af90a65d04013e) )
26462657
26472658   // trojaned protection data (filename is word offset)
r10384r10385
27022713ROM_START( doa2m )
27032714   ROM_REGION( 0x200000, "maincpu", 0)
27042715   NAOMI_BIOS
2705   NAOMI_DEFAULT_EEPROM
2716   NAOMI_DEFAULT_EEPROM_NO_BD
27062717
27072718   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
27082719   ROM_LOAD("doa2verm.ic22", 0x0000000, 0x0400000,  CRC(94b16f08) SHA1(225cd3e5dd5f21facf0a1d5e66fa17db8497573d) )
r10384r10385
27302741   ROM_LOAD("mpr-22120.ic21",0xa800000, 0x0800000, CRC(a30facb4) SHA1(70415ca34095c795297486bce1f956f6a8d4817f) )
27312742
27322743   // on-cart X76F100 eeprom contents
2733   ROM_REGION( 0x100, "naomibd_eeprom", ROMREGION_ERASE00 )
2744   ROM_REGION( 0x84, "naomibd_eeprom", 0 )
27342745   ROM_LOAD( "841-0003.sf",  0x000000, 0x000084, CRC(3a119a17) SHA1(d37a092cca7c9cfc5f2637b355af90a65d04013e) )
27352746
27362747   // trojaned protection data (filename is word offset)
r10384r10385
31343145ROM_START( alpiltdx )
31353146   ROM_REGION( 0x200000, "maincpu", 0)
31363147   AIRLINE_BIOS
3137   NAOMI_DEFAULT_EEPROM
3148   NAOMI_DEFAULT_EEPROM_NO_BD
31383149
31393150   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
31403151   ROM_LOAD( "epr-21787b.ic22", 0x0000000, 0x400000, CRC(56893156) SHA1(8e56e0633f92b1f50105421b7eb8428f51a78b27) )
r10384r10385
31513162   ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
31523163
31533164   // on-cart X76F100 eeprom contents
3154   ROM_REGION( 0x100, "naomibd_eeprom", ROMREGION_ERASE00 )
3165   ROM_REGION( 0x84, "naomibd_eeprom", 0 )
31553166   ROM_LOAD( "airlinepdx.sf",  0x000000, 0x000084, CRC(404b2add) SHA1(540c8474806775646ace111a2993397b1419fee3) )
31563167ROM_END
31573168
r10384r10385
50895100
50905101/* games on Namco custom ROM board */
50915102/* ???????? */ GAME( 2000, wldkicks,  naomi,    naomi,    naomi,    naomi,    ROT0, "Capcom / Namco",  "World Kicks", GAME_UNEMULATED_PROTECTION|GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
5092/* 25709801 */ GAME( 2001, gunsur2,  naomi,    naomi,    naomi,    naomi,    ROT0, "Capcom / Namco",  "Gun Survivor 2: Bio Hazard Code Veronica", GAME_UNEMULATED_PROTECTION|GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
5103/* 25709801 */ GAME( 2001, gunsur2,  naomi,    naomi,    naomi,    naomi,    ROT0, "Capcom / Namco",  "Gun Survivor 2: Bio Hazard Code Veronica", GAME_UNEMULATED_PROTECTION|GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
50935104
50945105/* Games with game specific bios sets */
50955106/*    BIOS   */ GAME( 1998, hod2bios, 0,         naomi,    naomi,    0,     ROT0, "Sega",  "Naomi House of the Dead 2 Bios", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING|GAME_IS_BIOS_ROOT )
r10384r10385
52735284   NAOMIGD_BIOS
52745285   NAOMI_DEFAULT_EEPROM
52755286
5276
5277
52785287   DISK_REGION( "gdrom" )
52795288   DISK_IMAGE_READONLY( "gdl-0013", 0, SHA1(c8869069c28bc8eec96d820886bc388d69d46143) )
52805289
r10384r10385
52925301   NAOMIGD_BIOS
52935302   NAOMI_DEFAULT_EEPROM
52945303
5295
5296
52975304   DISK_REGION( "gdrom" )
52985305   DISK_IMAGE_READONLY( "gdl-0014a", 0, SHA1(f88d8203c8692f51c9492d5549a3ad7d9583dc6f) )
52995306
r10384r10385
53115318   NAOMIGD_BIOS
53125319   NAOMI_DEFAULT_EEPROM
53135320
5314
5315
53165321   DISK_REGION( "gdrom" )
53175322   DISK_IMAGE_READONLY( "gdl-0017", 0, SHA1(94a9319633388968611892e36691b45c94b4f83f) )
53185323
r10384r10385
53295334   NAOMIGD_BIOS
53305335   NAOMI_DEFAULT_EEPROM
53315336
5332
5333
53345337   DISK_REGION( "gdrom" )
53355338   DISK_IMAGE_READONLY( "gdl-0018", 0, SHA1(3e40ca7d43173fe7048d199fdc127b9411e10360) )
53365339
r10384r10385
53445347   NAOMIGD_BIOS
53455348   NAOMI_DEFAULT_EEPROM
53465349
5347
5348
53495350   DISK_REGION( "gdrom" )
53505351   DISK_IMAGE_READONLY( "gdl-0019a", 0, SHA1(d44906505ff698eda6feee6c2b9402e19f64e5d3) )
53515352
r10384r10385
53635364   NAOMIGD_BIOS
53645365   NAOMI_DEFAULT_EEPROM
53655366
5366
5367
53685367   DISK_REGION( "gdrom" )
53695368   DISK_IMAGE_READONLY( "gdl-0020", 0, SHA1(7b2ef47ca2038d6a93615b760b03e8f7cb1b83c2) )
53705369
r10384r10385
53825381   NAOMIGD_BIOS
53835382   NAOMI_DEFAULT_EEPROM
53845383
5385
5386
53875384   DISK_REGION( "gdrom" )
53885385   DISK_IMAGE_READONLY( "gdl-0021", 0, SHA1(f5036711a28a211e8d71400a8322db3172c5733f) )
53895386
r10384r10385
54015398   NAOMIGD_BIOS
54025399   NAOMI_DEFAULT_EEPROM
54035400
5404
5405
54065401   DISK_REGION( "gdrom" )
54075402   DISK_IMAGE_READONLY( "gdl-0022", 0, SHA1(45deba05a12abbf6390c0fc0e4cdeaedfa7d2ca5) )
54085403
r10384r10385
54205415   NAOMIGD_BIOS
54215416   NAOMI_DEFAULT_EEPROM
54225417
5423
5424
54255418   DISK_REGION( "gdrom" )
54265419   DISK_IMAGE_READONLY( "gdl-0023a", 0, SHA1(caac915104d61f2122f5afe27da1ef5fa9cf9f9a) )
54275420
r10384r10385
54405433   NAOMIGD_BIOS
54415434   NAOMI_DEFAULT_EEPROM
54425435
5443
5444
54455436   DISK_REGION( "gdrom" )
54465437   DISK_IMAGE_READONLY( "gdl-0024", 0,  SHA1(d346762036fb1c40a261a434b50e63459f306f14) )
54475438
r10384r10385
54595450   NAOMIGD_BIOS
54605451   NAOMI_DEFAULT_EEPROM
54615452
5462
5463
54645453   DISK_REGION( "gdrom" )
54655454   DISK_IMAGE_READONLY( "gdl-0025", 0, SHA1(be0d88eb4f48403a2ceaa7ef588ed60b96ba93bf) )
54665455
5467
54685456   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
54695457   //ROM_LOAD("317-5102-com.data", 0x00, 0x50, CRC(32adf2eb) SHA1(d86752e6fe9ccac093c512828fca5b7ae62a3ff2) )
54705458
r10384r10385
54795467   NAOMIGD_BIOS
54805468   NAOMI_DEFAULT_EEPROM
54815469
5482
5483
54845470   DISK_REGION( "gdrom" )
54855471   DISK_IMAGE_READONLY( "gdl-0026", 0, SHA1(e4c1e51292a7923b25bfc61d38fe386bf596002a) )
54865472
5487
54885473   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
54895474   //ROM_LOAD("317-5103-jpn.data", 0x00, 0x50,  CRC(3affbf82) SHA1(268746e86e7546f4bab54bdd268f7b58f10c1aaf) )
54905475
r10384r10385
54995484   NAOMIGD_BIOS
55005485   NAOMI_DEFAULT_EEPROM
55015486
5502
5503
55045487   DISK_REGION( "gdrom" )
55055488   DISK_IMAGE_READONLY( "gdl-0028c", 0, SHA1(66de09738551e351784cc9695a58b35fdf6b6c4b) )
55065489
r10384r10385
55185501   NAOMIGD_BIOS
55195502   NAOMI_DEFAULT_EEPROM
55205503
5521
5522
55235504   DISK_REGION( "gdrom" )
55245505   DISK_IMAGE_READONLY( "gdl-0030a", 0,  SHA1(1f7ade47e37a0026451b5baf3ba746400de8d156) )
55255506
r10384r10385
55365517   NAOMIGD_BIOS
55375518   NAOMI_DEFAULT_EEPROM
55385519
5539
5540
55415520   DISK_REGION( "gdrom" )
55425521   DISK_IMAGE_READONLY( "gdl-0030", 0,  SHA1(c7f25c05f47a490c5da9369c588b6136e93c280e) )
55435522
r10384r10385
72787257GAME( 2005, kofxi,    awbios,   aw,    aw,    kofxi,    ROT0, "Sammy / SNK Playmore",            "The King of Fighters XI", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
72797258GAME( 2005, fotns,    awbios,   aw,    aw,    fotns,    ROT0, "Sega / Arc System Works",         "Fist Of The North Star", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
72807259GAME( 2005, kofnw,    awbios,   aw,    aw,    kofnw,    ROT0, "Sammy / SNK Playmore",            "The King of Fighters Neowave", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
7281GAME( 2005, kofnwj,   kofnw,   aw,    aw,    kofnw,    ROT0, "Sammy / SNK Playmore",            "The King of Fighters Neowave (Japan)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
7260GAME( 2005, kofnwj,   kofnw,    aw,    aw,    kofnw,    ROT0, "Sammy / SNK Playmore",            "The King of Fighters Neowave (Japan)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
72827261GAME( 2005, xtrmhunt, awbios,   aw,    aw,    xtrmhunt, ROT0, "Sammy",                           "Extreme Hunting", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
72837262GAME( 2006, mslug6,   awbios,   aw,    aw,    mslug6,   ROT0, "Sega / SNK Playmore",             "Metal Slug 6", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND )
72847263GAME( 2006, xtrmhnt2, awbios,   aw,    aw,    xtrmhnt2, ROT0, "Sega",                            "Extreme Hunting 2", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
src/mame/drivers/neogeo.c
r10384r10385
540540{
541541   if (read_or_write)
542542      /* save the SRAM settings */
543      mame_fwrite(file, save_ram, 0x2000);
543      file->write(save_ram, 0x2000);
544544   else
545545   {
546546      /* load the SRAM settings */
547547      if (file)
548         mame_fread(file, save_ram, 0x2000);
548         file->read(save_ram, 0x2000);
549549      else
550550         memset(save_ram, 0, 0x10000);
551551   }
r10384r10385
615615   {
616616   case MEMCARD_CREATE:
617617      memset(memcard_data, 0, MEMCARD_SIZE);
618      mame_fwrite(file, memcard_data, MEMCARD_SIZE);
618      file.write(memcard_data, MEMCARD_SIZE);
619619      break;
620620
621621   case MEMCARD_INSERT:
622      mame_fread(file, memcard_data, MEMCARD_SIZE);
622      file.read(memcard_data, MEMCARD_SIZE);
623623      break;
624624
625625   case MEMCARD_EJECT:
626      mame_fwrite(file, memcard_data, MEMCARD_SIZE);
626      file.write(memcard_data, MEMCARD_SIZE);
627627      break;
628628   }
629629}
src/mame/drivers/moo.c
r10384r10385
610610
611611
612612
613ROM_START( moo ) /* Version EA - Euro Ver A */
613ROM_START( moomesa ) /* Version EA - Euro Ver A */
614614   ROM_REGION( 0x180000, "maincpu", 0 )
615615   /* main program */
616   ROM_LOAD16_BYTE( "151b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) )
617   ROM_LOAD16_BYTE( "151b02.ea", 0x000001,  0x40000, CRC(37b30c01) SHA1(cb91739097a4a36f8f8d92998d822ffc851e1279) )
616   ROM_LOAD16_BYTE( "151_b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) )
617   ROM_LOAD16_BYTE( "151_ea_b02", 0x000001,  0x40000, CRC(37b30c01) SHA1(cb91739097a4a36f8f8d92998d822ffc851e1279) )
618618
619619   /* data */
620620   ROM_LOAD16_BYTE( "151a03", 0x100000,  0x40000, CRC(c896d3ea) SHA1(ea83c63e2c3dbc4f1e1d49f1852a78ffc1f0ea4b) )
r10384r10385
645645   ROM_LOAD( "moo.nv", 0x0000, 0x080, CRC(7bd904a8) SHA1(8747c5c62d1832e290be8ace73c61b1f228c0bec) )
646646ROM_END
647647
648ROM_START( mooua ) /* Version UA - USA Ver A */
648ROM_START( moomesau ) /* Version UA - USA Ver A */
649649   ROM_REGION( 0x180000, "maincpu", 0 )
650650   /* main program */
651   ROM_LOAD16_BYTE( "151b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) )
652   ROM_LOAD16_BYTE( "151b02.ua", 0x000001,  0x40000, CRC(3d9f4d59) SHA1(db47044bd4935fce94ec659242c9819c30eb6d0f) )
651   ROM_LOAD16_BYTE( "151_c01",    0x000000,  0x40000, CRC(10555732) SHA1(b67cb756c250ddd6f3291683b3f3449e13a2ee83) ) /* Version UAC? */
652   ROM_LOAD16_BYTE( "151_ua_c02", 0x000001,  0x40000, CRC(52ae87b0) SHA1(552d41a2ddd040f92c6a3cfdc07f9d6e751ac9c1) )
653653
654654   /* data */
655655   ROM_LOAD16_BYTE( "151a03", 0x100000,  0x40000, CRC(c896d3ea) SHA1(ea83c63e2c3dbc4f1e1d49f1852a78ffc1f0ea4b) )
r10384r10385
680680   ROM_LOAD( "moou.nv", 0x0000, 0x080, CRC(a5cb137a) SHA1(119df859d6b5c366481305b1433eea0deadc3fa9) )
681681ROM_END
682682
683ROM_START( mooaa ) /* Version AA - Asia Ver A */
683ROM_START( moomesaua ) /* Version UA - USA Ver A */
684684   ROM_REGION( 0x180000, "maincpu", 0 )
685685   /* main program */
686   ROM_LOAD16_BYTE( "151b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) )
687   ROM_LOAD16_BYTE( "151b02.aa", 0x000001,  0x40000, CRC(2162d593) SHA1(a6cfe4a57b3f22b2aa0f04f91acefe3b7bea9e76) )
686   ROM_LOAD16_BYTE( "151_b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) ) /* Version UAB? */
687   ROM_LOAD16_BYTE( "151_ua_b02", 0x000001,  0x40000, CRC(3d9f4d59) SHA1(db47044bd4935fce94ec659242c9819c30eb6d0f) )
688688
689689   /* data */
690690   ROM_LOAD16_BYTE( "151a03", 0x100000,  0x40000, CRC(c896d3ea) SHA1(ea83c63e2c3dbc4f1e1d49f1852a78ffc1f0ea4b) )
r10384r10385
712712   ROM_LOAD( "151a08", 0x000000, 0x200000, CRC(962251d7) SHA1(32dccf515d2ca8eeffb45cada3dcc60089991b77) )
713713
714714   ROM_REGION( 0x80, "eeprom", 0 ) // default eeprom to prevent game booting upside down with error
715   ROM_LOAD( "moou.nv", 0x0000, 0x080, CRC(a5cb137a) SHA1(119df859d6b5c366481305b1433eea0deadc3fa9) )
716ROM_END
717
718ROM_START( moomesaa ) /* Version AA - Asia Ver A */
719   ROM_REGION( 0x180000, "maincpu", 0 )
720   /* main program */
721   ROM_LOAD16_BYTE( "151_b01",    0x000000,  0x40000, CRC(fb2fa298) SHA1(f03b24681a2b329ba797fd2780ac9a3cf862ebcb) )
722   ROM_LOAD16_BYTE( "151_ua_b02", 0x000001,  0x40000, CRC(2162d593) SHA1(a6cfe4a57b3f22b2aa0f04f91acefe3b7bea9e76) )
723
724   /* data */
725   ROM_LOAD16_BYTE( "151a03", 0x100000,  0x40000, CRC(c896d3ea) SHA1(ea83c63e2c3dbc4f1e1d49f1852a78ffc1f0ea4b) )
726   ROM_LOAD16_BYTE( "151a04", 0x100001,  0x40000, CRC(3b24706a) SHA1(c2a77944284e35ff57f0774fa7b67e53d3b63e1f) )
727
728   ROM_REGION( 0x050000, "soundcpu", 0 )
729   /* Z80 sound program */
730   ROM_LOAD( "151a07", 0x000000, 0x040000, CRC(cde247fc) SHA1(cdee0228db55d53ae43d7cd2d9001dadd20c2c61) )
731   ROM_RELOAD(         0x010000, 0x040000 )
732
733   ROM_REGION( 0x200000, "gfx1", 0 )
734   /* tilemaps */
735   ROM_LOAD( "151a05", 0x000000, 0x100000, CRC(bc616249) SHA1(58c1f1a03ce9bead8f79d12ce4b2d342432b24b5) )
736   ROM_LOAD( "151a06", 0x100000, 0x100000, CRC(38dbcac1) SHA1(c357779733921695b20ac586db5b475f5b2b8f4c) )
737
738   ROM_REGION( 0x800000, "gfx2", 0 )
739   /* sprites */
740   ROM_LOAD( "151a10", 0x000000, 0x200000, CRC(376c64f1) SHA1(eb69c5a27f9795e28f04a503955132f0a9e4de12) )
741   ROM_LOAD( "151a11", 0x200000, 0x200000, CRC(e7f49225) SHA1(1255b214f29b6507540dad5892c60a7ae2aafc5c) )
742   ROM_LOAD( "151a12", 0x400000, 0x200000, CRC(4978555f) SHA1(d9871f21d0c8a512b408e137e2e80e9392c2bf6f) )
743   ROM_LOAD( "151a13", 0x600000, 0x200000, CRC(4771f525) SHA1(218d86b6230919b5db0304dac00513eb6b27ba9a) )
744
745   ROM_REGION( 0x200000, "k054539", 0 )
746   /* K054539 samples */
747   ROM_LOAD( "151a08", 0x000000, 0x200000, CRC(962251d7) SHA1(32dccf515d2ca8eeffb45cada3dcc60089991b77) )
748
749   ROM_REGION( 0x80, "eeprom", 0 ) // default eeprom to prevent game booting upside down with error
715750   ROM_LOAD( "moo.nv", 0x0000, 0x080, CRC(7bd904a8) SHA1(8747c5c62d1832e290be8ace73c61b1f228c0bec) )
716751ROM_END
717752
r10384r10385
824859ROM_END
825860
826861
827ROM_START( moobl )
862ROM_START( moomesabl )
828863   ROM_REGION( 0x180000, "maincpu", 0 )
829864   ROM_LOAD16_WORD_SWAP( "moo03.rom", 0x000000, 0x80000, CRC(fed6a1cb) SHA1(be58e266973930d643b5e15dcc974a82e1a3ae35) )
830865   ROM_LOAD16_WORD_SWAP( "moo04.rom", 0x100000, 0x80000, CRC(ec45892a) SHA1(594330cbbfbca87e61ddf519e565018b6eaf5a20) )
r10384r10385
885920}
886921
887922
888GAME( 1992, moo,     0,       moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver EA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
889GAME( 1992, mooua,   moo,     moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver UA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
890GAME( 1992, mooaa,   moo,     moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver AA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
891GAME( 1992, moobl,   moo,     moobl,   moo,     moo,      ROT0, "bootleg", "Wild West C.O.W.-Boys of Moo Mesa (bootleg ver AA)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
892GAME( 1992, bucky,   0,       bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver EA)", GAME_SUPPORTS_SAVE )
893GAME( 1992, buckyua, bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver UA)", GAME_SUPPORTS_SAVE )
894GAME( 1992, buckyaa, bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver AA)", GAME_SUPPORTS_SAVE )
923GAME( 1992, moomesa,  0,       moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver EA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
924GAME( 1992, moomesau, moomesa, moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver UA, set 1)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
925GAME( 1992, moomesaua,moomesa, moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver UA, set 2)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
926GAME( 1992, moomesaa, moomesa, moo,     moo,     moo,      ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver AA)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
927GAME( 1992, moomesabl,moomesa, moobl,   moo,     moo,      ROT0, "bootleg", "Wild West C.O.W.-Boys of Moo Mesa (bootleg ver AA)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
928GAME( 1992, bucky,    0,       bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver EA)", GAME_SUPPORTS_SAVE )
929GAME( 1992, buckyua,  bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver UA)", GAME_SUPPORTS_SAVE )
930GAME( 1992, buckyaa,  bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver AA)", GAME_SUPPORTS_SAVE )
src/mame/drivers/sfbonus.c
r10384r10385
12251225static NVRAM_HANDLER( sfbonus )
12261226{
12271227   if (read_or_write)
1228      mame_fwrite(file,nvram,nvram_size);
1228      file->write(nvram,nvram_size);
12291229   else
12301230   {
12311231      if (file)
12321232      {
12331233         memset(nvram,0x00,nvram_size);
1234         mame_fread(file,nvram,nvram_size);
1234         file->read(nvram,nvram_size);
12351235      }
12361236      else
12371237      {
src/mame/drivers/bfm_sc2.c
r10384r10385
438438   static const UINT8 init_e2ram[10] = { 1, 4, 10, 20, 0, 1, 1, 4, 10, 20 };
439439   if ( read_or_write )
440440   {   // writing
441      mame_fwrite(file,e2ram,sizeof(e2ram));
441      file->write(e2ram,sizeof(e2ram));
442442   }
443443   else
444444   { // reading
445445      if ( file )
446446      {
447         mame_fread(file,e2ram,sizeof(e2ram));
447         file->read(e2ram,sizeof(e2ram));
448448      }
449449      else
450450      {
src/mame/drivers/vegas.c
r10384r10385
670670static NVRAM_HANDLER( timekeeper_save )
671671{
672672   if (read_or_write)
673      mame_fwrite(file, timekeeper_nvram, timekeeper_nvram_size);
673      file->write(timekeeper_nvram, timekeeper_nvram_size);
674674   else if (file)
675      mame_fread(file, timekeeper_nvram, timekeeper_nvram_size);
675      file->read(timekeeper_nvram, timekeeper_nvram_size);
676676   else
677677      memset(timekeeper_nvram, 0xff, timekeeper_nvram_size);
678678}
src/mame/drivers/namcona1.c
r10384r10385
209209{
210210   if( read_or_write )
211211   {
212      mame_fwrite( file, namcona1_nvmem, NA1_NVRAM_SIZE );
212      file->write( namcona1_nvmem, NA1_NVRAM_SIZE );
213213   }
214214   else
215215   {
216216      if (file)
217217      {
218         mame_fread( file, namcona1_nvmem, NA1_NVRAM_SIZE );
218         file->read( namcona1_nvmem, NA1_NVRAM_SIZE );
219219      }
220220      else
221221      {
src/mame/drivers/seicross.c
r10384r10385
5656   size_t nvram_size = state->nvram_size;
5757
5858   if (read_or_write)
59      mame_fwrite(file,nvram,nvram_size);
59      file->write(nvram,nvram_size);
6060   else
6161   {
6262      if (file)
63         mame_fread(file,nvram,nvram_size);
63         file->read(nvram,nvram_size);
6464      else
6565      {
6666         /* fill in the default values */
src/mame/drivers/dgpix.c
r10384r10385
216216      for( i = 0; i < 0x40000; i++ )
217217         tmp[i] = rom[WORD_XOR_BE(i)];
218218
219      mame_fwrite( file, tmp, 0x40000 );
219      file->write( tmp, 0x40000 );
220220   }
221221   else if (file)
222222   {
r10384r10385
225225      UINT8 tmp[0x40000];
226226      int i;
227227
228      mame_fread( file, tmp, 0x40000 );
228      file->read( tmp, 0x40000 );
229229
230230      // overlap the default settings with the saved ones
231231      for( i = 0; i < 0x40000; i++ )
src/mame/drivers/bmcbowl.c
r10384r10385
289289   int i;
290290
291291   if (read_or_write)
292      mame_fwrite(file, stats_ram, stats_ram_size);
292      file->write(stats_ram, stats_ram_size);
293293   else
294294
295295#ifdef NVRAM_HACK
r10384r10385
301301   init_stats(bmc_nv3,ARRAY_LENGTH(bmc_nv3),0xfe2);
302302#else
303303   if (file)
304      mame_fread(file, stats_ram, stats_ram_size);
304      file->read(stats_ram, stats_ram_size);
305305   else
306306
307307      for (i = 0; i < stats_ram_size; i++)
src/mame/drivers/jchan.c
r10384r10385
170170#include "emu.h"
171171#include "cpu/m68000/m68000.h"
172172#include "deprecat.h"
173#include "machine/nvram.h"
173174#include "sound/ymz280b.h"
174175#include "includes/suprnova.h"
175176#include "includes/kaneko16.h"
r10384r10385
191192
192193static UINT16 *mainsub_shared_ram;
193194
195static UINT8 nvram_data[128];
196
197
194198/***************************************************************************
195199
196200                            MCU Code Simulation
r10384r10385
239243
240244      case 0x02: /* load game settings from 93C46 EEPROM ($1090-$10dc) */
241245      {
242         mame_file *f;
243         if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0)
244         {
245            mame_fread(f,&mcu_ram[mcu_offset], 128);
246            mame_fclose(f);
247         }
246         memcpy(&mcu_ram[mcu_offset], nvram_data, sizeof(nvram_data));
248247         logerror("(load NVRAM settings)\n");
249248      }
250249      break;
251250
252251      case 0x42: /* save game settings to 93C46 EEPROM ($50d4) */
253252      {
254         mame_file *f;
255         if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0)
256         {
257            mame_fwrite(f,&mcu_ram[mcu_offset], 128);
258            mame_fclose(f);
259         }
253         memcpy(nvram_data, &mcu_ram[mcu_offset], sizeof(nvram_data));
260254         logerror("(save NVRAM settings)\n");
261255      }
262256      break;
r10384r10385
678672
679673   MCFG_VIDEO_START(jchan)
680674   MCFG_VIDEO_UPDATE(jchan)
675   
676   MCFG_NVRAM_ADD_0FILL("nvram")
681677
682678   /* sound hardware */
683679   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
r10384r10385
778774
779775
780776   memset(jchan_mcu_com, 0, 4 * sizeof( UINT16 ) );
777   
778   machine->device<nvram_device>("nvram")->set_base(nvram_data, sizeof(nvram_data));
781779}
782780
783781
src/mame/drivers/namcos22.c
r10384r10385
19461946         data[1] = (dword&0x00ff0000)>>16;
19471947         data[2] = (dword&0x0000ff00)>>8;
19481948         data[3] = dword&0xff;
1949         mame_fwrite( file, data, 4 );
1949         file->write( data, 4 );
19501950      }
19511951   }
19521952   else
r10384r10385
19551955      {
19561956         for( i=0; i<namcos22_nvmem_size/4; i++ )
19571957         {
1958            mame_fread( file, data, 4 );
1958            file->read( data, 4 );
19591959            namcos22_nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
19601960         }
19611961      }
src/mame/drivers/ksys573.c
r10384r10385
392392   fujitsu_29f016a_device *flash_device[5][16];
393393   int security_cart_number;
394394
395   int chiptype[ 2 ];
396   int has_ds2401[ 2 ];
397
398   nvram_handler_func nvram_handler_security_cart_0;
399   nvram_handler_func nvram_handler_security_cart_1;
400
401395   UINT32 control;
402396
403397   emu_timer *atapi_timer;
r10384r10385
467461
468462static const char *const diskregions[] = { "cdrom0", "cdrom1" };
469463
470/* EEPROM handlers */
471
472static NVRAM_HANDLER( konami573 )
473{
474   ksys573_state *state = machine->driver_data<ksys573_state>();
475
476   if( state->nvram_handler_security_cart_0 != NULL )
477   {
478      state->nvram_handler_security_cart_0(machine, file, read_or_write);
479   }
480
481   if( state->nvram_handler_security_cart_1 != NULL )
482   {
483      state->nvram_handler_security_cart_1(machine, file, read_or_write);
484   }
485}
486
487464static WRITE32_HANDLER( mb89371_w )
488465{
489466   verboselog( space->machine, 2, "mb89371_w %08x %08x %08x\n", offset, mem_mask, data );
r10384r10385
504481   UINT32 data = input_port_read(machine, "IN1");
505482   data |= 0x000000c0;
506483
507   if( state->has_ds2401[ security_cart_number ] )
484   ds2401_device *ds2401 = space->machine->device<ds2401_device>(security_cart_number ? "game_id" : "install_id");
485   device_secure_serial_flash *secflash = space->machine->device<device_secure_serial_flash>(security_cart_number ? "game_eeprom" : "install_eeprom");
486
487   if( ds2401 )
508488   {
509      data |= ds2401_read( machine, security_cart_number ) << 14;
489      data |= ds2401->read() << 14;
510490   }
511491
512   switch( state->chiptype[ security_cart_number ] )
513   {
514   case 1:
515      data |= x76f041_sda_read( machine, security_cart_number ) << 18;
516      break;
492   if( secflash )
493      data |= secflash->sda_r() << 18;
517494
518   case 2:
519      data |= x76f100_sda_read( machine, security_cart_number ) << 18;
520      break;
521
522   case 3:
523      data |= zs01_sda_read( machine, security_cart_number ) << 18;
524      break;
525   }
526
527495   if( state->flash_device[1][0] == NULL )
528496   {
529497      data |= ( 1 << 26 );
r10384r10385
560528
561529   state->flash_bank = -1;
562530
563   switch( state->chiptype[ state->security_cart_number ] )
564   {
565   case 3:
566      zs01_sda_write( space->machine, state->security_cart_number, !( ( control >> 6 ) & 1 ) ); /* 0x40 */
567      break;
568   }
531   // zs01 only, others are reached through security_w
532   device_secure_serial_flash *secflash = space->machine->device<device_secure_serial_flash>(state->security_cart_number ? "game_eeprom" : "install_eeprom");
533   if( dynamic_cast<zs01_device *>(secflash) )
534      secflash->sda_w( !( ( control >> 6 ) & 1 ) ); /* 0x40 */
569535
570536   if( state->flash_device[0][0] != NULL && ( control & ~0x43 ) == 0x00 )
571537   {
r10384r10385
11371103
11381104   if( ACCESSING_BITS_0_15 )
11391105   {
1140      switch( state->chiptype[ security_cart_number ] )
1141      {
1142      case 1:
1143         x76f041_sda_write( machine, security_cart_number, ( data >> 0 ) & 1 );
1144         x76f041_scl_write( machine, security_cart_number, ( data >> 1 ) & 1 );
1145         x76f041_cs_write( machine, security_cart_number, ( data >> 2 ) & 1 );
1146         x76f041_rst_write( machine, security_cart_number, ( data >> 3 ) & 1 );
1147         break;
1106      ds2401_device *ds2401 = space->machine->device<ds2401_device>(security_cart_number ? "game_id" : "install_id");
1107      device_secure_serial_flash *secflash = space->machine->device<device_secure_serial_flash>(security_cart_number ? "game_eeprom" : "install_eeprom");
11481108
1149      case 2:
1150         x76f100_sda_write( machine, security_cart_number, ( data >> 0 ) & 1 );
1151         x76f100_scl_write( machine, security_cart_number, ( data >> 1 ) & 1 );
1152         x76f100_cs_write( machine, security_cart_number, ( data >> 2 ) & 1 );
1153         x76f100_rst_write( machine, security_cart_number, ( data >> 3 ) & 1 );
1154         break;
1155
1156      case 3:
1157         zs01_scl_write( machine, security_cart_number, ( data >> 1 ) & 1 );
1158         zs01_cs_write( machine, security_cart_number, ( data >> 2 ) & 1 );
1159         zs01_rst_write( machine, security_cart_number, ( data >> 3 ) & 1 );
1160         break;
1109      if( secflash ) {
1110         if( !dynamic_cast<zs01_device *>(secflash) )
1111            secflash->sda_w(( data >> 0 ) & 1);
1112         secflash->scl_w(( data >> 1 ) & 1);
1113         secflash->cs_w(( data >> 2 ) & 1);
1114         secflash->rst_w(( data >> 3 ) & 1);
11611115      }
11621116
1163      if( state->has_ds2401[ security_cart_number ] )
1117      if(ds2401)
11641118      {
1165         ds2401_write( machine, security_cart_number, !( ( data >> 4 ) & 1 ) );
1119         ds2401->write(!( ( data >> 4 ) & 1 ));
11661120      }
11671121
11681122      if( state->security_callback != NULL )
r10384r10385
14961450   return ret;
14971451}
14981452
1499static void security_cart_init( running_machine *machine, int cart, const char *eeprom_region, const char *ds2401_region )
1500{
1501   ksys573_state *state = machine->driver_data<ksys573_state>();
1502   UINT8 *eeprom_rom = machine->region( eeprom_region )->base();
1503   int eeprom_length = machine->region( eeprom_region )->bytes();
1504   UINT8 *ds2401_rom = machine->region( ds2401_region )->base();
1505
1506   if( eeprom_rom != NULL )
1507   {
1508      switch( eeprom_length )
1509      {
1510      case 0x224:
1511         x76f041_init( machine, cart, eeprom_rom );
1512         state->chiptype[ cart ] = 1;
1513
1514         switch( cart )
1515         {
1516         case 0:
1517            state->nvram_handler_security_cart_0 = NVRAM_HANDLER_NAME(x76f041_0);
1518            break;
1519         case 1:
1520            state->nvram_handler_security_cart_1 = NVRAM_HANDLER_NAME(x76f041_1);
1521            break;
1522         }
1523
1524         break;
1525
1526      case 0x84:
1527         x76f100_init( machine, cart, eeprom_rom );
1528         state->chiptype[ cart ] = 2;
1529
1530         switch( cart )
1531         {
1532         case 0:
1533            state->nvram_handler_security_cart_0 = NVRAM_HANDLER_NAME(x76f100_0);
1534            break;
1535         case 1:
1536            state->nvram_handler_security_cart_1 = NVRAM_HANDLER_NAME(x76f100_1);
1537            break;
1538         }
1539
1540         break;
1541
1542      case 0x1014:
1543         zs01_init( machine, cart, eeprom_rom, NULL, NULL, ds2401_rom );
1544         state->chiptype[ cart ] = 3;
1545
1546         switch( cart )
1547         {
1548         case 0:
1549            state->nvram_handler_security_cart_0 = NVRAM_HANDLER_NAME(zs01_0);
1550            break;
1551         case 1:
1552            state->nvram_handler_security_cart_1 = NVRAM_HANDLER_NAME(zs01_1);
1553            break;
1554         }
1555
1556         break;
1557
1558      default:
1559         fatalerror( "security_cart_init(%d) invalid eeprom size %d\n", cart, eeprom_length );
1560         break;
1561      }
1562   }
1563   else
1564   {
1565      state->chiptype[ cart ] = 0;
1566   }
1567
1568   if( state->chiptype[ cart ] != 3 && ds2401_rom != NULL )
1569   {
1570      ds2401_init( machine, cart, ds2401_rom );
1571      state->has_ds2401[ cart ] = 1;
1572   }
1573   else
1574   {
1575      state->has_ds2401[ cart ] = 0;
1576   }
1577}
1578
15791453static DRIVER_INIT( konami573 )
15801454{
15811455   ksys573_state *state = machine->driver_data<ksys573_state>();
r10384r10385
15931467
15941468   state->save_item( NAME(state->m_n_security_control) );
15951469
1596   security_cart_init( machine, 0, "user2", "user9" );
1597   security_cart_init( machine, 1, "user8", "user10" );
1598
15991470   state_save_register_item_array( machine, "KSYS573", NULL, 0, state->m_p_n_root_count );
16001471   state_save_register_item_array( machine, "KSYS573", NULL, 0, state->m_p_n_root_mode );
16011472   state_save_register_item_array( machine, "KSYS573", NULL, 0, state->m_p_n_root_target );
r10384r10385
16101481
16111482   psx_machine_init(machine);
16121483
1613   if( state->chiptype[ 0 ] != 0 )
1484   if( state->machine->device<device_secure_serial_flash>("install_eeprom") )
16141485   {
16151486      /* security cart */
16161487      psx_sio_input( machine, 1, PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
r10384r10385
16381509   int cd = input_port_read( machine, "CD" );
16391510   SCSIInstance *new_cdrom;
16401511
1641   if( state->chiptype[ 1 ] != 0 )
1512   if( state->machine->device<device_secure_serial_flash>("game_eeprom") )
16421513   {
16431514      state->security_cart_number = cart;
16441515   }
r10384r10385
21322003
21332004/* GX894 digital i/o */
21342005
2135static const UINT8 ds2401_xid[] =
2136{
2137   0x3d, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x01
2138};
2139
2140
21412006static READ32_HANDLER( gx894pwbba_r )
21422007{
21432008   ksys573_state *state = space->machine->driver_data<ksys573_state>();
r10384r10385
22182083   case 0x3b:
22192084      if( ACCESSING_BITS_16_31 )
22202085      {
2221         data |= ds2401_read( space->machine, 2 ) << 28;
2086         data |= space->machine->device<ds2401_device>("digital_id")->read() << 28;
22222087      }
22232088      break;
22242089   case 0x3d:
r10384r10385
23912256         logerror("FPGA MPEG key 3/3 %02x\n", data & 0xff);
23922257      if( ACCESSING_BITS_16_31 )
23932258      {
2394         ds2401_write( space->machine, 2, !( ( data >> 28 ) & 1 ) );
2259         space->machine->device<ds2401_device>("digital_id")->write( !( ( data >> 28 ) & 1 ) );
23952260      }
23962261      break;
23972262   case 0x3e:
r10384r10385
24542319   state->gx894_ram_read_offset = 0;
24552320   state->gx894_ram = auto_alloc_array( machine, UINT16, gx894_ram_size/2 );
24562321
2457   ds2401_init( machine, 2, ds2401_xid ); /* todo: load this from roms */
2458
24592322   state->save_item( NAME(state->gx894pwbba_output_data) );
24602323   state->save_pointer( NAME(state->gx894_ram), gx894_ram_size / 4 );
24612324}
r10384r10385
29682831   MCFG_CPU_VBLANK_INT("screen", sys573_vblank)
29692832
29702833   MCFG_MACHINE_RESET( konami573 )
2971   MCFG_NVRAM_HANDLER( konami573 )
29722834
29732835   // onboard flash
29742836   MCFG_FUJITSU_29F016A_ADD("onboard.0")
r10384r10385
30582920   MCFG_UPD4701_ADD( "upd4701" )
30592921MACHINE_CONFIG_END
30602922
3061
30622923// Variants with additional digital sound board
30632924static MACHINE_CONFIG_DERIVED( k573d, konami573 )
30642925   MCFG_MAS3507D_ADD( "mpeg" )
2926   MCFG_DS2401_ADD( "digital_id" )
30652927MACHINE_CONFIG_END
30662928
30672929static MACHINE_CONFIG_DERIVED( pccard1d, pccard1 )
30682930   MCFG_MAS3507D_ADD( "mpeg" )
2931   MCFG_DS2401_ADD( "digital_id" )
30692932MACHINE_CONFIG_END
30702933
30712934static MACHINE_CONFIG_DERIVED( pccard2d, pccard2 )
30722935   MCFG_MAS3507D_ADD( "mpeg" )
2936   MCFG_DS2401_ADD( "digital_id" )
30732937MACHINE_CONFIG_END
30742938
2939// Security eeprom variants
2940//
2941// Suffixes are used to select them
2942//  x = x76f041
2943//  y = x76f100
2944//  z = zs01
2945//
2946//  i = also use one or two ds2401
2947//
2948// Up to two carts can be used
2949
2950static MACHINE_CONFIG_DERIVED( konami573x, konami573 )
2951   MCFG_X76F041_ADD( "install_eeprom" )
2952MACHINE_CONFIG_END
2953
2954static MACHINE_CONFIG_DERIVED( konami573xzi, konami573 )
2955   MCFG_X76F041_ADD( "install_eeprom" )
2956   MCFG_DS2401_ADD(  "install_id" )
2957   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
2958   MCFG_DS2401_ADD(  "game_id" )
2959MACHINE_CONFIG_END
2960
2961static MACHINE_CONFIG_DERIVED( konami573y, konami573 )
2962   MCFG_X76F100_ADD( "install_eeprom" )
2963MACHINE_CONFIG_END
2964
2965static MACHINE_CONFIG_DERIVED( konami573yi, konami573 )
2966   MCFG_X76F100_ADD( "install_eeprom" )
2967   MCFG_DS2401_ADD(  "install_id" )
2968MACHINE_CONFIG_END
2969
2970static MACHINE_CONFIG_DERIVED( konami573zi, konami573 )
2971   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
2972   MCFG_DS2401_ADD(  "install_id" )
2973MACHINE_CONFIG_END
2974
2975static MACHINE_CONFIG_DERIVED( k573baitx, k573bait )
2976   MCFG_X76F041_ADD( "install_eeprom" )
2977MACHINE_CONFIG_END
2978
2979static MACHINE_CONFIG_DERIVED( k573dx, k573d )
2980   MCFG_X76F041_ADD( "install_eeprom" )
2981MACHINE_CONFIG_END
2982
2983static MACHINE_CONFIG_DERIVED( k573dxi, k573d )
2984   MCFG_X76F041_ADD( "install_eeprom" )
2985   MCFG_DS2401_ADD(  "install_id" )
2986MACHINE_CONFIG_END
2987
2988static MACHINE_CONFIG_DERIVED( k573dxzi, k573d )
2989   MCFG_X76F041_ADD( "install_eeprom" )
2990   MCFG_DS2401_ADD(  "install_id" )
2991   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
2992   MCFG_DS2401_ADD(  "game_id" )
2993MACHINE_CONFIG_END
2994
2995static MACHINE_CONFIG_DERIVED( k573dyi, k573d )
2996   MCFG_X76F100_ADD( "install_eeprom" )
2997   MCFG_DS2401_ADD(  "install_id" )
2998MACHINE_CONFIG_END
2999
3000static MACHINE_CONFIG_DERIVED( k573dyyi, k573d )
3001   MCFG_X76F100_ADD( "install_eeprom" )
3002   MCFG_DS2401_ADD(  "install_id" )
3003   MCFG_X76F100_ADD( "game_eeprom" )
3004   MCFG_DS2401_ADD(  "game_id" )
3005MACHINE_CONFIG_END
3006
3007static MACHINE_CONFIG_DERIVED( k573dzi, k573d )
3008   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
3009   MCFG_DS2401_ADD(  "install_id" )
3010MACHINE_CONFIG_END
3011
3012static MACHINE_CONFIG_DERIVED( pccard1x, pccard1 )
3013   MCFG_X76F041_ADD( "install_eeprom" )
3014MACHINE_CONFIG_END
3015
3016static MACHINE_CONFIG_DERIVED( pccard1xzi, pccard1 )
3017   MCFG_X76F041_ADD( "install_eeprom" )
3018   MCFG_DS2401_ADD(  "install_id" )
3019   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
3020   MCFG_DS2401_ADD(  "game_id" )
3021MACHINE_CONFIG_END
3022
3023static MACHINE_CONFIG_DERIVED( pccard1yi, pccard1 )
3024   MCFG_X76F100_ADD( "install_eeprom" )
3025   MCFG_DS2401_ADD(  "install_id" )
3026MACHINE_CONFIG_END
3027
3028static MACHINE_CONFIG_DERIVED( pccard1zi, pccard1 )
3029   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
3030   MCFG_DS2401_ADD(  "install_id" )
3031MACHINE_CONFIG_END
3032
3033static MACHINE_CONFIG_DERIVED( pccard1dzi, pccard1d )
3034   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
3035   MCFG_DS2401_ADD(  "install_id" )
3036MACHINE_CONFIG_END
3037
3038static MACHINE_CONFIG_DERIVED( pccard2yyi, pccard2 )
3039   MCFG_X76F100_ADD( "install_eeprom" )
3040   MCFG_DS2401_ADD(  "install_id" )
3041   MCFG_X76F100_ADD( "game_eeprom" )
3042   MCFG_DS2401_ADD(  "game_id" )
3043MACHINE_CONFIG_END
3044
3045static MACHINE_CONFIG_DERIVED( pccard2dxzi, pccard2d )
3046   MCFG_X76F041_ADD( "install_eeprom" )
3047   MCFG_DS2401_ADD(  "install_id" )
3048   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
3049   MCFG_DS2401_ADD(  "game_id" )
3050MACHINE_CONFIG_END
3051
3052static MACHINE_CONFIG_DERIVED( pccard2dyyi, pccard2d )
3053   MCFG_X76F100_ADD( "install_eeprom" )
3054   MCFG_DS2401_ADD(  "install_id" )
3055   MCFG_X76F100_ADD( "game_eeprom" )
3056   MCFG_DS2401_ADD(  "game_id" )
3057MACHINE_CONFIG_END
3058
3059static MACHINE_CONFIG_DERIVED( pccard2dzi, pccard2d )
3060   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
3061   MCFG_DS2401_ADD(  "install_id" )
3062MACHINE_CONFIG_END
3063
30753064static INPUT_PORTS_START( konami573 )
30763065   PORT_START("IN0")
30773066   PORT_BIT( 0xffffffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
r10384r10385
33663355   ROM_REGION32_LE( 0x080000, "bios", 0 ) \
33673356   ROM_LOAD( "700a01.22g",   0x0000000, 0x080000, CRC(11812ef8) SHA1(e1284add4aaddd5337bd7f4e27614460d52b5b48))
33683357
3358#define SYS573_DIGITAL_ID \
3359   ROM_REGION( 0x000008, "digital_id", 0 ) /* digital board id */      \
3360   ROM_LOAD( "digital-id.bin",   0x000000, 0x000008, CRC(2b977f4d) SHA1(2b108a56653f91cb3351718c45dfcf979bc35ef1) )
3361
33693362// BIOS
33703363ROM_START( sys573 )
33713364   SYS573_BIOS_A
3365   SYS573_DIGITAL_ID
33723366ROM_END
33733367
33743368// Games
33753369ROM_START( bassangl )
33763370   SYS573_BIOS_A
33773371
3378   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3372   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
33793373   ROM_LOAD( "ge765ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(ee1b32a7) SHA1(c0f6b14b054f5a95ce474e794a3e0ca78faac681) )
33803374
33813375   DISK_REGION( "cdrom0" )
r10384r10385
33853379ROM_START( bassang2 )
33863380   SYS573_BIOS_A
33873381
3388   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3382   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
33893383   ROM_LOAD( "gc865ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(095cbfb5) SHA1(529ce0a7b0986cf7e64c37f466d6c2dac95cea7f) )
33903384
33913385   DISK_REGION( "cdrom0" )
r10384r10385
34093403ROM_START( darkhleg )
34103404   SYS573_BIOS_A
34113405
3412   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3406   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34133407   ROM_LOAD( "gx706ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(72b42574) SHA1(79dc959f0ce95ccb9ac0dbf0a72aec973e91bc56) )
34143408
34153409   DISK_REGION( "cdrom0" )
r10384r10385
34193413ROM_START( fmania )
34203414   SYS573_BIOS_A
34213415
3422   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3416   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34233417   ROM_FILL( 0x000000, 0x000224, 0xff )
34243418
34253419   DISK_REGION( "cdrom0" )
r10384r10385
34283422
34293423ROM_START( ddrextrm )
34303424   SYS573_BIOS_A
3425   SYS573_DIGITAL_ID
34313426
3432   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
3427   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
34333428   ROM_LOAD( "gcc36ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(c1601287) SHA1(929691a78f7bb6dd830f832f301116df0da1619b) )
34343429
3435   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3430   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
34363431   ROM_LOAD( "gcc36ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
34373432
34383433   DISK_REGION( "cdrom0" )
r10384r10385
34423437ROM_START( ddru )
34433438   SYS573_BIOS_A
34443439
3445   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3440   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34463441   ROM_LOAD( "gn845ua.u1",   0x000000, 0x000224, BAD_DUMP CRC(c9e7fced) SHA1(aac4dde100091bc64d397f53484a0ffbf68b8101) )
34473442
34483443   DISK_REGION( "cdrom0" )
r10384r10385
34523447ROM_START( ddrj )
34533448   SYS573_BIOS_A
34543449
3455   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3450   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34563451   ROM_LOAD( "gc845jb.u1",   0x000000, 0x000224, BAD_DUMP CRC(a16f42b8) SHA1(da4f1eb3eb2b28cb3a0bc74bb9b9945970f56ac2) )
34573452
34583453   DISK_REGION( "cdrom0" )
r10384r10385
34623457ROM_START( ddrja )
34633458   SYS573_BIOS_A
34643459
3465   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3460   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34663461   ROM_LOAD( "gc845ja.u1",   0x000000, 0x000224, NO_DUMP )
34673462
34683463   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
r10384r10385
34923487ROM_START( ddrjb )
34933488   SYS573_BIOS_A
34943489
3495   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3490   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
34963491   ROM_LOAD( "gc845ja.u1",   0x000000, 0x000224, NO_DUMP )
34973492
34983493   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
r10384r10385
35223517ROM_START( ddra )
35233518   SYS573_BIOS_A
35243519
3525   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3520   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
35263521   ROM_LOAD( "gn845aa.u1",   0x000000, 0x000224, BAD_DUMP CRC(327c4851) SHA1(f0939224af706fd103a67aae9c96518c1db90ac9) )
35273522
35283523   DISK_REGION( "cdrom0" )
r10384r10385
35323527ROM_START( ddr2m )
35333528   SYS573_BIOS_A
35343529
3535   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3530   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
35363531   ROM_LOAD( "gn895jaa.u1",  0x000000, 0x000224, BAD_DUMP CRC(363f427e) SHA1(adec886a07b9bd91f142f286b04fc6582205f037) )
35373532
35383533   DISK_REGION( "cdrom0" )
r10384r10385
35423537ROM_START( ddr2mc )
35433538   SYS573_BIOS_A
35443539
3545   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3540   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
35463541   ROM_LOAD( "gn896ja.u1",  0x000000, 0x000224, BAD_DUMP CRC(cbc984c5) SHA1(6c0cd78a41000999b4ffbd9fb3707738b50a9b50) )
35473542
35483543   DISK_REGION( "cdrom0" )
r10384r10385
35553550ROM_START( ddr2mc2 )
35563551   SYS573_BIOS_A
35573552
3558   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3553   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
35593554   ROM_LOAD( "ge984ja.u1",  0x000000, 0x000224, BAD_DUMP CRC(cbc984c5) SHA1(6c0cd78a41000999b4ffbd9fb3707738b50a9b50) )
35603555
35613556   DISK_REGION( "cdrom0" )
r10384r10385
35713566   ROM_REGION( 0x080000, "cpu2", 0 ) /* memory card reader */
35723567   ROM_LOAD( "885a01.bin",   0x000000, 0x080000, CRC(e22d093f) SHA1(927f62f63b5caa7899392decacd12fea0e6fdbea) )
35733568
3574   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3569   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
35753570   ROM_LOAD( "ge885jaa.u1",  0x000000, 0x000224, BAD_DUMP CRC(cbc984c5) SHA1(6c0cd78a41000999b4ffbd9fb3707738b50a9b50) )
35763571
35773572   DISK_REGION( "cdrom0" )
r10384r10385
35803575
35813576ROM_START( ddr3ma )
35823577   SYS573_BIOS_A
3578   SYS573_DIGITAL_ID
35833579
3584   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3580   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
35853581   ROM_LOAD( "ge887aa.u1",   0x000000, 0x000084, BAD_DUMP CRC(4ce86d32) SHA1(94cdb9873a7f7503acc3b763e9b49ec6af53533f) )
35863582
3587   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3583   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
35883584   ROM_LOAD( "gn887aa.u1",   0x000000, 0x000084, BAD_DUMP CRC(bb14f9bd) SHA1(9d0adf5a32d8bbcaaea2f701f5c7a5d51ee0b8bf) )
35893585
3590   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3586   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
35913587   ROM_LOAD( "ge887aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
35923588
3593   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3589   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
35943590   ROM_LOAD( "gn887aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
35953591
35963592   DISK_REGION( "cdrom0" )
r10384r10385
35993595
36003596ROM_START( ddr3mj )
36013597   SYS573_BIOS_A
3598   SYS573_DIGITAL_ID
36023599
3603   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3600   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
36043601   ROM_LOAD( "ge887ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(3a377cec) SHA1(5bf3107a89547bd7697d9f0ab8f67240e101a559) )
36053602
3606   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3603   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
36073604   ROM_LOAD( "gn887ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(2f633432) SHA1(bce44f20a5a7318af6aea4fdfa8af64ddb76047c) )
36083605
3609   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3606   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
36103607   ROM_LOAD( "ge887ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
36113608
3612   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3609   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
36133610   ROM_LOAD( "gn887ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
36143611
36153612   DISK_REGION( "cdrom0" )
r10384r10385
36183615
36193616ROM_START( ddr3mk )
36203617   SYS573_BIOS_A
3618   SYS573_DIGITAL_ID
36213619
3622   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3620   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
36233621   ROM_LOAD( "ge887kb.u1",   0x000000, 0x000084, BAD_DUMP CRC(4ce86d32) SHA1(94cdb9873a7f7503acc3b763e9b49ec6af53533f) )
36243622
3625   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3623   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
36263624   ROM_LOAD( "gn887kb.u1",   0x000000, 0x000084, BAD_DUMP CRC(bb14f9bd) SHA1(9d0adf5a32d8bbcaaea2f701f5c7a5d51ee0b8bf) )
36273625
3628   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3626   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
36293627   ROM_LOAD( "ge887kb.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
36303628
3631   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3629   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
36323630   ROM_LOAD( "gn887kb.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
36333631
36343632   DISK_REGION( "cdrom0" )
r10384r10385
36373635
36383636ROM_START( ddr3mka )
36393637   SYS573_BIOS_A
3638   SYS573_DIGITAL_ID
36403639
3641   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3640   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
36423641   ROM_LOAD( "ge887ka.u1",   0x000000, 0x000084, BAD_DUMP CRC(4ce86d32) SHA1(94cdb9873a7f7503acc3b763e9b49ec6af53533f) )
36433642
3644   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3643   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
36453644   ROM_LOAD( "gn887ka.u1",   0x000000, 0x000084, BAD_DUMP CRC(bb14f9bd) SHA1(9d0adf5a32d8bbcaaea2f701f5c7a5d51ee0b8bf) )
36463645
3647   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3646   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
36483647   ROM_LOAD( "ge887ka.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
36493648
3650   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3649   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
36513650   ROM_LOAD( "gn887ka.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
36523651
36533652   DISK_REGION( "cdrom0" )
r10384r10385
36563655
36573656ROM_START( ddr3mp )
36583657   SYS573_BIOS_A
3658   SYS573_DIGITAL_ID
36593659
3660   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3660   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
36613661   ROM_LOAD( "gea22ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(ef370ff7) SHA1(cb7a043f8bfa535e54ae9af728031d1018ed0734) )
36623662
3663   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3663   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
36643664   ROM_LOAD( "gca22ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(6883c82c) SHA1(6fef1dc7150066eee427db685b6c5fb350b7768d) )
36653665
3666   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3666   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
36673667   ROM_LOAD( "gea22ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
36683668
3669   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3669   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
36703670   ROM_LOAD( "gca22ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
36713671
36723672   DISK_REGION( "cdrom0" )
r10384r10385
36753675
36763676ROM_START( ddr4m )
36773677   SYS573_BIOS_A
3678   SYS573_DIGITAL_ID
36783679
3679   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3680   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
36803681   ROM_LOAD( "gea33aa.u1",   0x000000, 0x000224, BAD_DUMP CRC(7bd2a24f) SHA1(62c73a54c4ed7697cf81ddbf3d13d4b0ca827be5) )
36813682
3682   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3683   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
36833684   ROM_LOAD( "gca33aa.u1",   0x000000, 0x001014, BAD_DUMP CRC(f6feb2bd) SHA1(dfd5bd532338849289e2e4c155c0ca86e79b9ae5) )
36843685
3685   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3686   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
36863687   ROM_LOAD( "gea33aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
36873688
3688   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3689   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
36893690   ROM_LOAD( "gca33aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
36903691
36913692   DISK_REGION( "cdrom0" )
r10384r10385
36943695
36953696ROM_START( ddr4mj )
36963697   SYS573_BIOS_A
3698   SYS573_DIGITAL_ID
36973699
3698   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3700   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
36993701   ROM_LOAD( "a33jaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(10f1e9b8) SHA1(985bd26638964beebba5de4c7cda772b402d2e59) )
37003702
3701   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3703   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
37023704   ROM_LOAD( "gca33ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(e5230867) SHA1(44aea9ccc90d81e7f41e5e9a62b28fcbdd75363b) )
37033705
3704   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3706   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
37053707   ROM_LOAD( "a33jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
37063708
3707   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3709   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
37083710   ROM_LOAD( "gca33ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
37093711
37103712   DISK_REGION( "cdrom0" )
r10384r10385
37133715
37143716ROM_START( ddr4ms )
37153717   SYS573_BIOS_A
3718   SYS573_DIGITAL_ID
37163719
3717   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3720   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
37183721   ROM_LOAD( "gea33ab.u1",   0x000000, 0x000224, BAD_DUMP CRC(32fb3d13) SHA1(3ca6c77438f96b13d2c05f13a10fcff89a1403a2) )
37193722
3720   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3723   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
37213724   ROM_LOAD( "gca33ab.u1",   0x000000, 0x001014, BAD_DUMP CRC(312ac13f) SHA1(05d733edc03cfc5ea03db6c683f59ed6ff860b5a) )
37223725
3723   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3726   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
37243727   ROM_LOAD( "gea33ab.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
37253728
3726   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3729   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
37273730   ROM_LOAD( "gca33ab.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
37283731
37293732   DISK_REGION( "cdrom0" )
r10384r10385
37323735
37333736ROM_START( ddr4msj )
37343737   SYS573_BIOS_A
3738   SYS573_DIGITAL_ID
37353739
3736   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3740   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
37373741   ROM_LOAD( "a33jba.u1",    0x000000, 0x000224, BAD_DUMP CRC(babf6fdb) SHA1(a2ef6b855d42072f0d3c72c8de9aff1f867de3f7) )
37383742
3739   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3743   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
37403744   ROM_LOAD( "gca33jb.u1",   0x000000, 0x001014, BAD_DUMP CRC(00e4b531) SHA1(f421fc33642c5a3cd89fb14dc8cd601bdddd1f55) )
37413745
3742   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3746   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
37433747   ROM_LOAD( "a33jba.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
37443748
3745   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3749   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
37463750   ROM_LOAD( "gca33jb.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
37473751
37483752   DISK_REGION( "cdrom0" )
r10384r10385
37513755
37523756ROM_START( ddr4mp )
37533757   SYS573_BIOS_A
3758   SYS573_DIGITAL_ID
37543759
3755   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3760   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
37563761   ROM_LOAD( "gea34ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(10f1e9b8) SHA1(985bd26638964beebba5de4c7cda772b402d2e59) )
37573762
3758   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3763   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
37593764   ROM_LOAD( "gca34ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(e9b6ce56) SHA1(f040fba2b2b446baa840026dcd10f9785f8cc0a3) )
37603765
3761   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3766   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
37623767   ROM_LOAD( "gea34ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
37633768
3764   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3769   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
37653770   ROM_LOAD( "gca34ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
37663771
37673772   ROM_REGION( 0x002000, "m48t58", 0 ) /* timekeeper */
r10384r10385
37733778
37743779ROM_START( ddr4mps )
37753780   SYS573_BIOS_A
3781   SYS573_DIGITAL_ID
37763782
3777   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3783   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
37783784   ROM_LOAD( "gea34jb.u1",   0x000000, 0x000224, BAD_DUMP CRC(babf6fdb) SHA1(a2ef6b855d42072f0d3c72c8de9aff1f867de3f7) )
37793785
3780   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3786   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
37813787   ROM_LOAD( "gca34jb.u1",   0x000000, 0x001014, BAD_DUMP CRC(0c717300) SHA1(00d21f39fe90494ffec2f8799767cc46a9cd2b00) )
37823788
3783   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3789   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
37843790   ROM_LOAD( "gea34jb.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
37853791
3786   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3792   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
37873793   ROM_LOAD( "gca34jb.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
37883794
37893795   ROM_REGION( 0x002000, "m48t58", 0 ) /* timekeeper */
r10384r10385
37953801
37963802ROM_START( ddr5m )
37973803   SYS573_BIOS_A
3804   SYS573_DIGITAL_ID
37983805
3799   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
3806   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
38003807   ROM_LOAD( "gca27ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(ec526036) SHA1(f47d94d19268fdfa3ae9d42db9f2e2f9be318f2b) )
38013808
3802   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3809   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
38033810   ROM_LOAD( "gca27ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38043811
38053812   DISK_REGION( "cdrom0" )
r10384r10385
38093816ROM_START( ddrbocd )
38103817   SYS573_BIOS_A
38113818
3812   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3819   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
38133820   ROM_LOAD( "gn895jaa.u1",  0x000000, 0x000224, BAD_DUMP CRC(363f427e) SHA1(adec886a07b9bd91f142f286b04fc6582205f037) )
38143821
38153822   DISK_REGION( "cdrom0" )
r10384r10385
38213828
38223829ROM_START( ddrs2k )
38233830   SYS573_BIOS_A
3831   SYS573_DIGITAL_ID
38243832
3825   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3833   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
38263834   ROM_LOAD( "ge905aa.u1",   0x000000, 0x000084, BAD_DUMP CRC(36d18e2f) SHA1(e976047dfbee62de9ad9e5de8e7629a24c29d581) )
38273835
3828   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3836   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
38293837   ROM_LOAD( "gc905aa.u1",   0x000000, 0x000084, BAD_DUMP CRC(21073a3e) SHA1(afa12404ceb462b9016a41c40775da87aa09cfeb) )
38303838
3831   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3839   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
38323840   ROM_LOAD( "ge905aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
38333841
3834   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3842   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
38353843   ROM_LOAD( "gc905aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38363844
38373845   DISK_REGION( "cdrom0" )
r10384r10385
38403848
38413849ROM_START( ddrs2kj )
38423850   SYS573_BIOS_A
3851   SYS573_DIGITAL_ID
38433852
3844   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
3853   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
38453854   ROM_LOAD( "ge905ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(a077b0a1) SHA1(8f247b38c933a104a325ebf1f1691ef260480e1a) )
38463855
3847   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
3856   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
38483857   ROM_LOAD( "gc905ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(b7a104b0) SHA1(0f6901e41640f729f8a084a33148a9b900475594) )
38493858
3850   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3859   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
38513860   ROM_LOAD( "ge905ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
38523861
3853   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3862   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
38543863   ROM_LOAD( "gc905aa.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38553864
38563865   DISK_REGION( "cdrom0" )
r10384r10385
38593868
38603869ROM_START( ddrmax )
38613870   SYS573_BIOS_A
3871   SYS573_DIGITAL_ID
38623872
3863   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
3873   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
38643874   ROM_LOAD( "gcb19ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(2255626a) SHA1(cb70c4b551265ffc6cc41f7bd2678696e8067060) )
38653875
3866   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3876   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
38673877   ROM_LOAD( "gcb19ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38683878
38693879   DISK_REGION( "cdrom0" )
r10384r10385
38723882
38733883ROM_START( ddrmax2 )
38743884   SYS573_BIOS_A
3885   SYS573_DIGITAL_ID
38753886
3876   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
3887   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
38773888   ROM_LOAD( "gcb20ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(fb7e0f58) SHA1(e6da23257a2a2ba7c69e817a91a0a8864f009386) )
38783889
3879   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3890   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
38803891   ROM_LOAD( "gcb20ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38813892
38823893   DISK_REGION( "cdrom0" )
r10384r10385
38853896
38863897ROM_START( ddrsbm )
38873898   SYS573_BIOS_A
3899   SYS573_DIGITAL_ID
38883900
3889   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
3901   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
38903902   ROM_LOAD( "gq894ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(cc3a47de) SHA1(f6e2e101870370b1e295a4a9ed546aa2d8bc2010) )
38913903
3892   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3904   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
38933905   ROM_LOAD( "gq894ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
38943906
38953907   DISK_REGION( "cdrom0" )
r10384r10385
38983910
38993911ROM_START( ddrusa )
39003912   SYS573_BIOS_A
3913   SYS573_DIGITAL_ID
39013914
3902   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
3915   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
39033916   ROM_LOAD( "gka44ua.u1",   0x000000, 0x001014, BAD_DUMP CRC(2ef7c4f1) SHA1(9004d27179ece86883d01b3e6bbfeebc1b478d57) )
39043917
3905   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
3918   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
39063919   ROM_LOAD( "gka44ua.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
39073920
39083921   DISK_REGION( "cdrom0" )
r10384r10385
39123925ROM_START( drmn )
39133926   SYS573_BIOS_A
39143927
3915   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
3928   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
39163929   ROM_LOAD( "gq881ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(7dca0b3f) SHA1(db6d5c527e2a99133b516e01433024d3173848c6) )
39173930
39183931   ROM_REGION( 0x200000, "onboard.6", 0 ) /* onboard flash */
r10384r10385
39323945
39333946ROM_START( drmn2m )
39343947   SYS573_BIOS_A
3948   SYS573_DIGITAL_ID
39353949
3936   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3950   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
39373951   ROM_LOAD( "ge912ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(1246fe5b) SHA1(b58d4f4c95e13abf639d645223565544bd79a58a) )
39383952
3939   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3953   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
39403954   ROM_LOAD( "gn912ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(34deea99) SHA1(f179e22eaf30453bb94177ed9c25d7996f020c99) )
39413955
3942   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3956   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
39433957   ROM_LOAD( "ge912ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
39443958
3945   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3959   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
39463960   ROM_LOAD( "gn912ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
39473961
39483962   DISK_REGION( "cdrom0" )
r10384r10385
39513965
39523966ROM_START( drmn2mpu )
39533967   SYS573_BIOS_A
3968   SYS573_DIGITAL_ID
39543969
3955   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3970   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
39563971   ROM_LOAD( "ge912ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(1246fe5b) SHA1(b58d4f4c95e13abf639d645223565544bd79a58a) )
39573972
3958   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3973   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
39593974   ROM_LOAD( "gn912ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(34deea99) SHA1(f179e22eaf30453bb94177ed9c25d7996f020c99) )
39603975
3961   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3976   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
39623977   ROM_LOAD( "ge912ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
39633978
3964   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
3979   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
39653980   ROM_LOAD( "gn912ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
39663981
39673982   DISK_REGION( "cdrom0" )
r10384r10385
39733988
39743989ROM_START( drmn3m )
39753990   SYS573_BIOS_A
3991   SYS573_DIGITAL_ID
39763992
3977   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
3993   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
39783994   ROM_LOAD( "a23jaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(90e544fa) SHA1(1feb617c36bad41aa720a6e5d3ec9e5cb2030567) )
39793995
3980   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
3996   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
39813997   ROM_LOAD( "gca23ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(5af1b5da) SHA1(cf862ef9ab60e8da89af96266943137827e4a261) )
39823998
3983   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
3999   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
39844000   ROM_LOAD( "a23jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
39854001
3986   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4002   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
39874003   ROM_LOAD( "gca23ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
39884004
39894005   DISK_REGION( "cdrom0" )
r10384r10385
39924008
39934009ROM_START( dmx )
39944010   SYS573_BIOS_A
4011   SYS573_DIGITAL_ID
39954012
3996   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4013   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
39974014   ROM_LOAD( "ge874ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(c5536373) SHA1(1492221f7dd9485f7745ecb0a982a88c8e768e53) )
39984015
3999   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4016   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40004017   ROM_LOAD( "ge874ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40014018
40024019   DISK_REGION( "cdrom0" )
r10384r10385
40054022
40064023ROM_START( dmx2m )
40074024   SYS573_BIOS_A
4025   SYS573_DIGITAL_ID
40084026
4009   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4027   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
40104028   ROM_LOAD( "gca39ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(ecc75eb7) SHA1(af66ced28ba5e79ae32ae0ef12d2ebe4207f3822) )
40114029
4012   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4030   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40134031   ROM_LOAD( "gca39ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40144032
40154033   DISK_REGION( "cdrom0" )
r10384r10385
40184036
40194037ROM_START( dmx2majp )
40204038   SYS573_BIOS_A
4039   SYS573_DIGITAL_ID
40214040
4022   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4041   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
40234042   ROM_LOAD( "gca38ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(99a746b8) SHA1(333236e59a707ecaf840a66f9b947ceade2cf2c9) )
40244043
40254044   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
r10384r10385
40274046   ROM_REGION( 0x200000, "onboard.1", 0 ) /* onboard flash */
40284047   ROM_LOAD( "gca38ja.27m",  0x000000, 0x200000, CRC(6c3934b8) SHA1(f0e4a692b6caaf60fefaec87fd23da577439f69d) )
40294048
4030   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4049   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40314050   ROM_LOAD( "gca38ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40324051
40334052   DISK_REGION( "cdrom0" )
r10384r10385
40364055
40374056ROM_START( dncfrks )
40384057   SYS573_BIOS_A
4058   SYS573_DIGITAL_ID
40394059
4040   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4060   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
40414061   ROM_LOAD( "gk874ka.u1",   0x000000, 0x001014, BAD_DUMP CRC(7a6f4672) SHA1(2e009e57760e92f48070a69cff5597c37a4783a2) )
40424062
4043   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4063   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40444064   ROM_LOAD( "gk874ka.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40454065
40464066   DISK_REGION( "cdrom0" )
r10384r10385
40494069
40504070ROM_START( dsem )
40514071   SYS573_BIOS_A
4072   SYS573_DIGITAL_ID
40524073
4053   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4074   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
40544075   ROM_LOAD( "ge936ea.u1",   0x000000, 0x000224, BAD_DUMP CRC(0f5b7ae3) SHA1(646dd49da1216cc2d3d6920bc9b3447d55ebfbf0) )
40554076
4056   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4077   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40574078   ROM_LOAD( "ge936ea.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40584079
40594080   DISK_REGION( "cdrom0" )
r10384r10385
40624083
40634084ROM_START( dsem2 )
40644085   SYS573_BIOS_A
4086   SYS573_DIGITAL_ID
40654087
4066   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4088   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
40674089   ROM_LOAD( "gkc23ea.u1",   0x000000, 0x001014, BAD_DUMP CRC(aec2421a) SHA1(5ea9e9ce6161ebc99a50db0b7304385511bd4553) )
40684090
4069   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4091   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
40704092   ROM_LOAD( "gkc23ea.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40714093
40724094   DISK_REGION( "cdrom0" )
r10384r10385
40754097
40764098ROM_START( dsfdct )
40774099   SYS573_BIOS_A
4100   SYS573_DIGITAL_ID
40784101
4079   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
4102   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
40804103   ROM_LOAD( "ge887ja_gn887ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(08a60147) SHA1(0d39dca5e9e17fff0e64f296c8416e4ca23fdc1b) )
40814104
4082   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
4105   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
40834106   ROM_LOAD( "gc910jc.u1",   0x000000, 0x000084, BAD_DUMP CRC(3c1ca973) SHA1(32211a72e3ac88b2723f82dac0b26f93031b3a9c) )
40844107
4085   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4108   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
40864109   ROM_LOAD( "ge887ja_gn887ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40874110
4088   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4111   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
40894112   ROM_LOAD( "gc910jc.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
40904113
40914114   DISK_REGION( "cdrom0" )
r10384r10385
40954118ROM_START( dsfdcta )
40964119   SYS573_BIOS_A
40974120
4098   ROM_REGION( 0x0000084, "user2", 0 ) /* install security cart eeprom */
4121   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* install security cart eeprom */
40994122   ROM_LOAD( "gn884ja.u1",  0x000000, 0x000084, BAD_DUMP CRC(ce6b98ce) SHA1(75549d9470345ce06d2706d373b19416d97e5b9a) )
41004123
4101   ROM_REGION( 0x0000084, "user8", 0 ) /* game security cart eeprom */
4124   ROM_REGION( 0x0000084, "game_eeprom", 0 ) /* game security cart eeprom */
41024125   ROM_LOAD( "gc910ja.u1",   0x000000, 0x000084, BAD_DUMP CRC(59a23808) SHA1(fcff1c68ff6cfbd391ac997a40fb5253fc62de82) )
41034126
4104   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4127   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
41054128   ROM_LOAD( "gn884ja.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
41064129
4107   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4130   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
41084131   ROM_LOAD( "gc910ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
41094132
41104133   DISK_REGION( "cdrom0" )
r10384r10385
41134136
41144137ROM_START( dsfdr )
41154138   SYS573_BIOS_A
4139   SYS573_DIGITAL_ID
41164140
4117   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
4141   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
41184142   ROM_LOAD( "gea37ja.u1",   0x000000, 0x000224, BAD_DUMP CRC(5321055e) SHA1(d06b0dca9caba8249d71340469ad9083b02fd087) )
41194143
4120   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
4144   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
41214145   ROM_LOAD( "gca37ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(b6d9e7f9) SHA1(bc5f491de53a96d46745df09bc94e7853052296c) )
41224146
4123   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4147   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
41244148   ROM_LOAD( "gea37ja.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
41254149
4126   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4150   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
41274151   ROM_LOAD( "gca37ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
41284152
41294153   DISK_REGION( "cdrom0" )
r10384r10385
41334157ROM_START( dsftkd )
41344158   SYS573_BIOS_A
41354159
4136   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
4160   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
41374161   ROM_LOAD( "gn884ja.u1",  0x000000, 0x000084, BAD_DUMP CRC(ce6b98ce) SHA1(75549d9470345ce06d2706d373b19416d97e5b9a) )
41384162
4139   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4163   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
41404164   ROM_LOAD( "gn884ja.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
41414165
41424166   DISK_REGION( "cdrom0" )
r10384r10385
41464170ROM_START( dstage )
41474171   SYS573_BIOS_A
41484172
4149   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4173   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
41504174   ROM_LOAD( "gn845ea.u1",   0x000000, 0x000224, BAD_DUMP CRC(db643af7) SHA1(881221da640b883302e657b906ea0a4e74555679) )
41514175
41524176   DISK_REGION( "cdrom0" )
r10384r10385
41564180ROM_START( fbait2bc )
41574181   SYS573_BIOS_A
41584182
4159   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4183   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
41604184   ROM_LOAD( "gc865ua.u1", 0x000000, 0x000224, BAD_DUMP CRC(ea8f0b4b) SHA1(363b1ea1a520b239ba8bca867366bbe8a9977a43) )
41614185
41624186   DISK_REGION( "cdrom0" )
r10384r10385
41664190ROM_START( fbaitbc )
41674191   SYS573_BIOS_A
41684192
4169   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4193   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
41704194   ROM_LOAD( "ge765ua.u1", 0x000000, 0x000224, BAD_DUMP CRC(588748c6) SHA1(ea1ead61e0dcb324ef7b6106cae00bcf6702d6c4) )
41714195
41724196   DISK_REGION( "cdrom0" )
r10384r10385
41764200ROM_START( fbaitmc )
41774201   SYS573_BIOS_A
41784202
4179   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4203   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
41804204   ROM_LOAD( "gx889ea.u1", 0x000000, 0x000224, BAD_DUMP CRC(753ad84e) SHA1(e024cefaaee7c9945ccc1f9a3d896b8560adce2e) )
41814205
41824206   DISK_REGION( "cdrom0" )
r10384r10385
41864210ROM_START( fbaitmca )
41874211   SYS573_BIOS_A
41884212
4189   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4213   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
41904214   ROM_LOAD( "gx889aa.u1", 0x000000, 0x000224, BAD_DUMP CRC(9c22aae8) SHA1(c107b0bf7fa76708f2d4f6aaf2cf27b3858378a3) )
41914215
41924216   DISK_REGION( "cdrom0" )
r10384r10385
41964220ROM_START( fbaitmcj )
41974221   SYS573_BIOS_A
41984222
4199   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4223   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42004224   ROM_LOAD( "gx889ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(6278603c) SHA1(d6b59e270cfe4016e12565aedec8a4f0702e1a6f) )
42014225
42024226   DISK_REGION( "cdrom0" )
r10384r10385
42064230ROM_START( fbaitmcu )
42074231   SYS573_BIOS_A
42084232
4209   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4233   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42104234   ROM_LOAD( "gx889ua.u1", 0x000000, 0x000224, BAD_DUMP CRC(67b91e54) SHA1(4d94bfab08e2bf6e34ee606dd3c4e345d8e5d158) )
42114235
42124236   DISK_REGION( "cdrom0" )
r10384r10385
42164240ROM_START( gtrfrks )
42174241   SYS573_BIOS_A
42184242
4219   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4243   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42204244   ROM_LOAD( "gq886eac.u1",  0x000000, 0x000224, BAD_DUMP CRC(06bd6c4f) SHA1(61930e467ad135e2f31393ff5af981ed52f3bef9) )
42214245
42224246   DISK_REGION( "cdrom0" )
r10384r10385
42264250ROM_START( gtrfrksu )
42274251   SYS573_BIOS_A
42284252
4229   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4253   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42304254   ROM_LOAD( "gq886uac.u1",  0x000000, 0x000224, BAD_DUMP CRC(143eaa55) SHA1(51a4fa3693f1cb1646a8986003f9b6cc1ae8b630) )
42314255
42324256   DISK_REGION( "cdrom0" )
r10384r10385
42364260ROM_START( gtrfrksj )
42374261   SYS573_BIOS_A
42384262
4239   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4263   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42404264   ROM_LOAD( "gq886jac.u1",  0x000000, 0x000224, BAD_DUMP CRC(11ffd43d) SHA1(27f4f4d782604379254fb98c3c57e547aa4b321f) )
42414265
42424266   DISK_REGION( "cdrom0" )
r10384r10385
42464270ROM_START( gtrfrksa )
42474271   SYS573_BIOS_A
42484272
4249   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4273   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
42504274   ROM_LOAD( "gq886aac.u1",  0x000000, 0x000224, BAD_DUMP CRC(efa51ee9) SHA1(3374d936de69c287e0161bc526546441c2943555) )
42514275
42524276   DISK_REGION( "cdrom0" )
r10384r10385
42564280ROM_START( gtrfrk2m )
42574281   SYS573_BIOS_A
42584282
4259   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
4283   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
42604284   ROM_LOAD( "gq883jad.u1",  0x000000, 0x000084, BAD_DUMP CRC(687868c4) SHA1(1230e74e4cf17953febe501df56d8bbec1de9356) )
42614285
4262   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4286   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
42634287   ROM_LOAD( "gq883jad.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
42644288
42654289   DISK_REGION( "cdrom0" )
r10384r10385
42694293ROM_START( gtrfrk3m )
42704294   SYS573_BIOS_A
42714295
4272   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
4296   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
42734297   ROM_LOAD( "949jaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(96c21d71) SHA1(871f1f0429154a486e547e182534db1557008dd6) )
42744298
4275   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
4299   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
42764300   ROM_LOAD( "ge949jab.u1",  0x000000, 0x001014, BAD_DUMP CRC(8645e17f) SHA1(e8a833384cb6bdb05870fcd44e7c8ed48a03c852) )
42774301
4278   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4302   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
42794303   ROM_LOAD( "949jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
42804304
4281   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4305   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
42824306   ROM_LOAD( "ge949jab.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
42834307
42844308   DISK_REGION( "cdrom0" )
r10384r10385
42914315ROM_START( gtfrk3ma )
42924316   SYS573_BIOS_A
42934317
4294   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
4318   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
42954319   ROM_LOAD( "949jaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(96c21d71) SHA1(871f1f0429154a486e547e182534db1557008dd6) )
42964320
4297   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
4321   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
42984322   ROM_LOAD( "ge949jab.u1",  0x000000, 0x001014, BAD_DUMP CRC(8645e17f) SHA1(e8a833384cb6bdb05870fcd44e7c8ed48a03c852) )
42994323
4300   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4324   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
43014325   ROM_LOAD( "949jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
43024326
4303   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4327   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
43044328   ROM_LOAD( "ge949jab.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43054329
43064330   DISK_REGION( "cdrom0" )
r10384r10385
43104334ROM_START( gtfrk3mb )
43114335   SYS573_BIOS_A
43124336
4313   ROM_REGION( 0x0001014, "user2", 0 ) /* game security cart eeprom */
4337   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* game security cart eeprom */
43144338   ROM_LOAD( "ge949jaa.u1",  0x000000, 0x001014, BAD_DUMP CRC(61f35ee1) SHA1(0a2b66742364d76ec18647b2761590bd49229625) )
43154339
4316   ROM_REGION( 0x000008, "user9", 0 ) /* game security cart id */
4340   ROM_REGION( 0x000008, "install_id", 0 ) /* game security cart id */
43174341   ROM_LOAD( "ge949jaa.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43184342
43194343   DISK_REGION( "cdrom0" )
r10384r10385
43234347ROM_START( gtrfrk4m )
43244348   SYS573_BIOS_A
43254349
4326   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
4350   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
43274351   ROM_LOAD( "a24jaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(29e326fe) SHA1(41a600105b08accc9d7ebd2b8ae08c0863758aa0) )
43284352
4329   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
4353   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
43304354   ROM_LOAD( "gea24ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(d1fccf11) SHA1(6dcd79f3171d6e4bd7e1149901638f8ea58ff623) )
43314355
4332   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4356   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
43334357   ROM_LOAD( "a24jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
43344358
4335   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4359   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
43364360   ROM_LOAD( "gea24ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43374361
43384362   DISK_REGION( "cdrom0" )
r10384r10385
43414365
43424366ROM_START( gtrfrk5m )
43434367   SYS573_BIOS_A
4368   SYS573_DIGITAL_ID
43444369
4345   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4370   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
43464371   ROM_LOAD( "gea26jaa.u1",  0x000000, 0x001014, BAD_DUMP CRC(c2725fca) SHA1(b70a3266c61af5cbe0478a6f3dd850ebcab980dc) )
43474372
43484373   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
r10384r10385
43504375   ROM_REGION( 0x200000, "onboard.1", 0 ) /* onboard flash */
43514376   ROM_LOAD( "gea26jaa.27m", 0x000000, 0x200000, CRC(345dc5f2) SHA1(61af3fcfe6119c1e8e18b92693855ab4fe708b30) )
43524377
4353   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4378   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
43544379   ROM_LOAD( "gea26jaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43554380
43564381   DISK_REGION( "cdrom0" )
r10384r10385
43594384
43604385ROM_START( gtrfrk6m )
43614386   SYS573_BIOS_A
4387   SYS573_DIGITAL_ID
43624388
4363   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4389   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
43644390   ROM_LOAD( "gcb06ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(673c98ab) SHA1(b1d889bf4fc5e425056acb6b72b2c563966fb7d7) )
43654391
4366   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4392   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
43674393   ROM_LOAD( "gcb06ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43684394
43694395   DISK_REGION( "cdrom0" )
r10384r10385
43724398
43734399ROM_START( gtrfrk7m )
43744400   SYS573_BIOS_A
4401   SYS573_DIGITAL_ID
43754402
4376   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4403   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
43774404   ROM_LOAD( "gcb17jaa.u1",   0x000000, 0x001014, BAD_DUMP CRC(5a338c31) SHA1(0fd9ee306335858dd6bef680a62557a8bf055cc3) )
43784405
43794406   ROM_REGION( 0x200000, "onboard.0", 0 ) /* onboard flash */
r10384r10385
43814408   ROM_REGION( 0x200000, "onboard.1", 0 ) /* onboard flash */
43824409   ROM_LOAD( "gcb17jaa.27m", 0x000000, 0x200000, CRC(7e7da9a9) SHA1(1882418779a48b5aefd113895756116379a6a4f7) )
43834410
4384   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4411   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
43854412   ROM_LOAD( "gcb17jaa.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43864413
43874414   DISK_REGION( "cdrom0" )
r10384r10385
43904417
43914418ROM_START( gtfrk11m )
43924419   SYS573_BIOS_A
4420   SYS573_DIGITAL_ID
43934421
4394   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4422   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
43954423   ROM_LOAD( "gcd39ja.u1",   0x000000, 0x001014, BAD_DUMP CRC(9bd81d0a) SHA1(c95f6d7317bf88177f7217de4ba4376485d5cdbf) )
43964424
4397   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4425   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
43984426   ROM_LOAD( "gcd39ja.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
43994427
44004428   DISK_REGION( "cdrom0" )
r10384r10385
44044432ROM_START( hyperbbc )
44054433   SYS573_BIOS_A
44064434
4407   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
4435   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
44084436   ROM_LOAD( "gx908ja.u1",  0x000000, 0x000084, BAD_DUMP CRC(fb6c0635) SHA1(0d974462a0a244ffb1a651adb316242cde427756) )
44094437
44104438   DISK_REGION( "cdrom0" )
r10384r10385
44144442ROM_START( hyperbbck )
44154443   SYS573_BIOS_A
44164444
4417   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
4445   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
44184446   ROM_LOAD( "gx908ka.u1",  0x000000, 0x000084, BAD_DUMP CRC(f4f37fe1) SHA1(30f90cdb2d092e4f8d6c14cfd4ca4945e6d352cb) )
44194447
44204448   DISK_REGION( "cdrom0" )
r10384r10385
44244452ROM_START( konam80a )
44254453   SYS573_BIOS_A
44264454
4427   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4455   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44284456   ROM_LOAD( "gc826aa.u1", 0x000000, 0x000224, BAD_DUMP CRC(9b38b959) SHA1(6b4fca340a9b1c2ae21ad3903c1ac1e39ab08b1a) )
44294457
44304458   DISK_REGION( "cdrom0" )
r10384r10385
44344462ROM_START( konam80j )
44354463   SYS573_BIOS_A
44364464
4437   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4465   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44384466   ROM_LOAD( "gc826ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(e9e861e8) SHA1(45841db0b42d096213d9539a8d076d39391dca6d) )
44394467
44404468   DISK_REGION( "cdrom0" )
r10384r10385
44444472ROM_START( konam80k )
44454473   SYS573_BIOS_A
44464474
4447   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4475   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44484476   ROM_LOAD( "gc826ka.u1", 0x000000, 0x000224, BAD_DUMP CRC(d41f7e38) SHA1(73e2bb132e23be72e72ea5b0686ccad28e47574a) )
44494477
44504478   DISK_REGION( "cdrom0" )
r10384r10385
44544482ROM_START( konam80s )
44554483   SYS573_BIOS_A
44564484
4457   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4485   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44584486   ROM_LOAD( "gc826ea.u1", 0x000000, 0x000224, BAD_DUMP CRC(6ce4c619) SHA1(d2be08c213c0a74e30b7ebdd93946374cc64457f) )
44594487
44604488   DISK_REGION( "cdrom0" )
r10384r10385
44644492ROM_START( konam80u )
44654493   SYS573_BIOS_A
44664494
4467   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4495   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44684496   ROM_LOAD( "gc826ua.u1", 0x000000, 0x000224, BAD_DUMP CRC(0577379b) SHA1(3988a2a5ef1f1d5981c4767cbed05b73351be903) )
44694497
44704498   DISK_REGION( "cdrom0" )
r10384r10385
44744502ROM_START( mamboagg )
44754503   SYS573_BIOS_A
44764504
4477   ROM_REGION( 0x0001014, "user2", 0 ) /* security cart eeprom */
4505   ROM_REGION( 0x0001014, "install_eeprom", 0 ) /* security cart eeprom */
44784506   ROM_LOAD( "gqa40jab.u1",  0x000000, 0x001014, BAD_DUMP CRC(fd9e7c1f) SHA1(6dd4790589d48803f58328d099c908f0565b2c01) )
44794507
4480   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4508   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
44814509   ROM_LOAD( "gqa40jab.u6",  0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
44824510
44834511   DISK_REGION( "cdrom0" )
r10384r10385
44874515ROM_START( pbballex )
44884516   SYS573_BIOS_A
44894517
4490   ROM_REGION( 0x0000224, "user2", 0 ) /* security cart eeprom */
4518   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* security cart eeprom */
44914519   ROM_LOAD( "gx802ja.u1", 0x000000, 0x000224, BAD_DUMP CRC(ea8bdda3) SHA1(780034ab08871631ef0e3e9b779ca89e016c26a8) )
44924520
44934521   DISK_REGION( "cdrom0" )
r10384r10385
44974525ROM_START( pcnfrk3m )
44984526   SYS573_BIOS_A
44994527
4500   ROM_REGION( 0x0000224, "user2", 0 ) /* install security cart eeprom */
4528   ROM_REGION( 0x0000224, "install_eeprom", 0 ) /* install security cart eeprom */
45014529   ROM_LOAD( "a23kaa.u1",    0x000000, 0x000224, BAD_DUMP CRC(d71c4b5c) SHA1(3911c5dd933c30e6e44c8cf417bb4c284ecb4b80) )
45024530
4503   ROM_REGION( 0x0001014, "user8", 0 ) /* game security cart eeprom */
4531   ROM_REGION( 0x0001014, "game_eeprom", 0 ) /* game security cart eeprom */
45044532   ROM_LOAD( "gca23ka.u1",   0x000000, 0x001014, BAD_DUMP CRC(f392349c) SHA1(e7eb7979db276de560d5820163a70d97e6c023d8) )
45054533
4506   ROM_REGION( 0x000008, "user9", 0 ) /* install security cart id */
4534   ROM_REGION( 0x000008, "install_id", 0 ) /* install security cart id */
45074535   ROM_LOAD( "a23kaa.u6",    0x000000, 0x000008, BAD_DUMP CRC(af09e43c) SHA1(d8372f2d6e0ae07061b496a2242a63e5bc2e54dc) )
45084536
4509   ROM_REGION( 0x000008, "user10", 0 ) /* game security cart id */
4537   ROM_REGION( 0x000008, "game_id", 0 ) /* game security cart id */
45104538   ROM_LOAD( "gca23ka.u6",   0x000000, 0x000008, BAD_DUMP CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
45114539
45124540   DISK_REGION( "cdrom0" )
r10384r10385
45164544ROM_START( salarymc )
45174545   SYS573_BIOS_A
45184546
4519   ROM_REGION( 0x0000084, "user2", 0 ) /* security cart eeprom */
4547   ROM_REGION( 0x0000084, "install_eeprom", 0 ) /* security cart eeprom */
45204548   ROM_LOAD( "gca18jaa.u1",  0x000000, 0x000084, CRC(c9197f67) SHA1(8e95a89008f756a79295f2cb557c39efca1351e7) )
45214549
4522   ROM_REGION( 0x000008, "user9", 0 ) /* security cart id */
4550   ROM_REGION( 0x000008, "install_id", 0 ) /* security cart id */
45234551   ROM_LOAD( "gca18jaa.u6",  0x000000, 0x000008, CRC(ce84419e) SHA1(839e8ee080ecfc79021a06417d930e8b32dfc6a1) )
45244552
45254553   DISK_REGION( "cdrom0" )
r10384r10385
45274555ROM_END
45284556
45294557// System 573 BIOS (we're missing the later version that boots up with a pseudo-GUI)
4530GAME( 1998, sys573,   0,        konami573, konami573, konami573,  ROT0, "Konami", "System 573 BIOS", GAME_IS_BIOS_ROOT )
4558GAME( 1998, sys573,   0,        konami573,    konami573, konami573,  ROT0, "Konami", "System 573 BIOS", GAME_IS_BIOS_ROOT )
45314559
4532GAME( 1998, darkhleg, sys573,   konami573, konami573, konami573,  ROT0, "Konami", "Dark Horse Legend (GX706 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4533GAME( 1998, fbaitbc,  sys573,   k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4534GAME( 1998, bassangl, fbaitbc,  k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler (GE765 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4535GAME( 1998, pbballex, sys573,   konami573, konami573, konami573,  ROT0, "Konami", "Powerful Pro Baseball EX (GX802 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4536GAME( 1998, konam80s, sys573,   konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4537GAME( 1998, konam80u, konam80s, konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4538GAME( 1998, konam80j, konam80s, konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's Gallery (GC826 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4539GAME( 1998, konam80a, konam80s, konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4540GAME( 1998, konam80k, konam80s, konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4541GAME( 1999, dstage,   sys573,   konami573, ddr,       ddr,        ROT0, "Konami", "Dancing Stage (GN845 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4542GAME( 1999, ddru,     dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GN845 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4543GAME( 1998, ddrj,     dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution - Internet Ranking Ver (GC845 VER. JBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4544GAME( 1998, ddrja,    dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4545GAME( 1998, ddrjb,    dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4546GAME( 1999, ddra,     dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GN845 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4547GAME( 1998, fbait2bc, sys573,   k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4548GAME( 1998, bassang2, fbait2bc, k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler 2 (GE865 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4549GAME( 1999, drmn,     sys573,   konami573, drmn,      drmn,       ROT0, "Konami", "DrumMania (GQ881 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4550GAME( 1999, gtrfrks,  sys573,   konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. EAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4551GAME( 1999, gtrfrksu, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. UAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4552GAME( 1999, gtrfrksj, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. JAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4553GAME( 1999, gtrfrksa, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. AAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4554GAME( 1999, fbaitmc,  sys573,   k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. EA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4555GAME( 1999, fbaitmcu, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. UA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4556GAME( 1999, fbaitmcj, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. JA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4557GAME( 1999, fbaitmca, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. AA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4558GAME( 1999, ddr2m,    sys573,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix (GN895 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4559GAME( 1999, ddrbocd,  ddr2m,    pccard1,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution Best of Cool Dancers (GE892 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4560GAME( 1999, ddr2ml,   ddr2m,    pccard1,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix - Link Ver (GE885 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4561GAME( 1999, ddr2mc,   ddr2m,    konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix with beatmaniaIIDX CLUB VERSiON (GE896 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4562GAME( 1999, ddr2mc2,  ddr2m,    konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix with beatmaniaIIDX substream CLUB VERSiON 2 (GE984 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4563GAME( 1999, gtrfrk2m, sys573,   pccard1,   gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks 2nd Mix Ver 1.01 (GQ883 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4564GAME( 1999, dsftkd,   sys573,   konami573, ddr,       ddr,        ROT0, "Konami", "Dancing Stage featuring TRUE KiSS DESTiNATiON (G*884 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4565GAME( 1999, cr589fw,  sys573,   konami573, konami573, konami573,  ROT0, "Konami", "CD-ROM Drive Updater 2.0 (700B04)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4566GAME( 1999, cr589fwa, sys573,   konami573, konami573, konami573,  ROT0, "Konami", "CD-ROM Drive Updater (700A04)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4567GAME( 2000, ddr3mk,   sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea2 (GN887 VER. KBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4568GAME( 2000, ddr3mka,  ddr3mk,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea (GN887 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4569GAME( 1999, ddr3ma,   ddr3mk,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.1 */
4570GAME( 1999, ddr3mj,   ddr3mk,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.0 */
4571GAME( 1999, ddrsbm,   sys573,   konami573, ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo Bass Mix (GQ894 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4572GAME( 1999, ddrs2k,   sys573,   konami573, ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4573GAME( 1999, ddrs2kj,  ddrs2k,   konami573, ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.2 */
4574GAME( 1999, hyperbbc, sys573,   konami573, hyperbbc,  hyperbbc,   ROT0, "Konami", "Hyper Bishi Bashi Champ (GX908 1999/08/24 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4575GAME( 1999, hyperbbck,hyperbbc, konami573, hyperbbc,  hyperbbc,   ROT0, "Konami", "Hyper Bishi Bashi Champ (GX908 1999/08/24 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4576GAME( 1999, dsfdct,   sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JCA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4577GAME( 1999, dsfdcta,  dsfdct,   pccard2,   ddr,       ddr,        ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4578GAME( 1999, drmn2m,   sys573,   k573d,     drmn,      drmndigital,ROT0, "Konami", "DrumMania 2nd Mix (GE912 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.5 */
4579GAME( 1999, drmn2mpu, drmn2m,   k573d,     drmn,      drmndigital,ROT0, "Konami", "DrumMania 2nd Mix Session Power Up Kit (GE912 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.5 */
4580GAME( 2000, dncfrks,  sys573,   konami573, dmx,       dmx,        ROT0, "Konami", "Dance Freaks (G*874 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4581GAME( 2000, dmx,      dncfrks,  konami573, dmx,       dmx,        ROT0, "Konami", "Dance Maniax (G*874 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4582GAME( 2000, dsem,     sys573,   k573d,     ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Euro Mix (G*936 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.7 */
4583GAME( 2000, gtrfrk3m, sys573,   pccard1,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix (GE949 VER. JAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4584GAME( 2000, gtfrk3ma, gtrfrk3m, pccard1,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix (GE949 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4585GAME( 2000, gtfrk3mb, gtrfrk3m, pccard1,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix - security cassette versionup (949JAZ02)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4586GAME( 2000, salarymc, sys573,   konami573, hyperbbc,  salarymc,   ROT0, "Konami", "Salary Man Champ (GCA18 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4587GAME( 2000, ddr3mp,   sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix Plus (G*A22 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4588GAME( 2000, pcnfrk3m, sys573,   konami573, drmn,      drmndigital,ROT0, "Konami", "Percussion Freaks 3rd Mix (G*A23 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4589GAME( 2000, drmn3m,   pcnfrk3m, konami573, drmn,      drmndigital,ROT0, "Konami", "DrumMania 3rd Mix (G*A23 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4590GAME( 2000, gtrfrk4m, sys573,   pccard1,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 4th Mix (G*A24 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4591GAME( 2000, ddr4m,    sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix (G*A33 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4592GAME( 2000, ddr4mj,   ddr4m,    pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix (G*A33 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4593GAME( 2000, ddr4ms,   sys573,   pccard2,   ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Solo (G*A33 VER. ABA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4594GAME( 2000, ddr4msj,  ddr4ms,   pccard2,   ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Solo (G*A33 VER. JBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4595GAME( 2000, dsfdr,    sys573,   k573d,     ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Featuring Disney's Rave (GCA37JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4596GAME( 2000, ddrusa,   sys573,   k573d,     ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution USA (G*A44 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4597GAME( 2000, ddr4mp,   sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix Plus (G*A34 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4598GAME( 2000, ddr4mps,  sys573,   pccard2,   ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Plus Solo (G*A34 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4599GAME( 2000, dmx2m,    sys573,   konami573, dmx,       dmx,        ROT0, "Konami", "Dance Maniax 2nd Mix (G*A39 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4600GAME( 2000, fmania,   sys573,   konami573, konami573, konami573,  ROT0, "Konami", "Fighting Mania (918 xx B02)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4601GAME( 2001, gtrfrk5m, sys573,   pccard1d,  gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 5th Mix (G*A26 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4602GAME( 2001, ddr5m,    sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 5th Mix (G*A27 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4603GAME( 2001, dmx2majp, sys573,   konami573, dmx,       dmx,        ROT0, "Konami", "Dance Maniax 2nd Mix Append J-Paradise (G*A38 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4604GAME( 2001, mamboagg, sys573,   konami573, mamboagg,  mamboagg,   ROT0, "Konami", "Mambo A Go-Go (GQA40 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4605GAME( 2001, gtrfrk6m, sys573,   pccard1d,  gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 6th Mix (G*B06 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4606GAME( 2001, gtrfrk7m, sys573,   pccard1d,  gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 7th Mix (G*B17 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4607GAME( 2001, ddrmax,   sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "DDR Max - Dance Dance Revolution 6th Mix (G*B19 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4608GAME( 2002, ddrmax2,  sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "DDR Max 2 - Dance Dance Revolution 7th Mix (G*B20 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4609GAME( 2002, dsem2,    sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Euro Mix 2 (G*C23 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4610GAME( 2002, ddrextrm, sys573,   pccard2d,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution Extreme (G*C36 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4611GAME( 2004, gtfrk11m, sys573,   pccard1d,  gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 11th Mix (G*D39 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4560GAME( 1998, darkhleg, sys573,   konami573x,   konami573, konami573,  ROT0, "Konami", "Dark Horse Legend (GX706 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4561GAME( 1998, fbaitbc,  sys573,   k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4562GAME( 1998, bassangl, fbaitbc,  k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler (GE765 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4563GAME( 1998, pbballex, sys573,   konami573x,   konami573, konami573,  ROT0, "Konami", "Powerful Pro Baseball EX (GX802 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4564GAME( 1998, konam80s, sys573,   konami573x,   konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4565GAME( 1998, konam80u, konam80s, konami573x,   konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4566GAME( 1998, konam80j, konam80s, konami573x,   konami573, konami573,  ROT90, "Konami", "Konami 80's Gallery (GC826 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4567GAME( 1998, konam80a, konam80s, konami573x,   konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4568GAME( 1998, konam80k, konam80s, konami573x,   konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4569GAME( 1999, dstage,   sys573,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dancing Stage (GN845 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4570GAME( 1999, ddru,     dstage,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GN845 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4571GAME( 1998, ddrj,     dstage,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution - Internet Ranking Ver (GC845 VER. JBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4572GAME( 1998, ddrja,    dstage,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4573GAME( 1998, ddrjb,    dstage,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4574GAME( 1999, ddra,     dstage,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GN845 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4575GAME( 1998, fbait2bc, sys573,   k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4576GAME( 1998, bassang2, fbait2bc, k573baitx,    fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler 2 (GE865 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4577GAME( 1999, drmn,     sys573,   konami573x,   drmn,      drmn,       ROT0, "Konami", "DrumMania (GQ881 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4578GAME( 1999, gtrfrks,  sys573,   konami573x,   gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. EAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4579GAME( 1999, gtrfrksu, gtrfrks,  konami573x,   gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. UAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4580GAME( 1999, gtrfrksj, gtrfrks,  konami573x,   gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. JAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4581GAME( 1999, gtrfrksa, gtrfrks,  konami573x,   gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. AAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4582GAME( 1999, fbaitmc,  sys573,   k573baitx,    fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. EA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4583GAME( 1999, fbaitmcu, fbaitmc,  k573baitx,    fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. UA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4584GAME( 1999, fbaitmcj, fbaitmc,  k573baitx,    fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. JA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4585GAME( 1999, fbaitmca, fbaitmc,  k573baitx,    fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. AA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4586GAME( 1999, ddr2m,    sys573,   konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix (GN895 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4587GAME( 1999, ddrbocd,  ddr2m,    pccard1x,     ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution Best of Cool Dancers (GE892 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4588GAME( 1999, ddr2ml,   ddr2m,    pccard1x,     ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix - Link Ver (GE885 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4589GAME( 1999, ddr2mc,   ddr2m,    konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix with beatmaniaIIDX CLUB VERSiON (GE896 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4590GAME( 1999, ddr2mc2,  ddr2m,    konami573x,   ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix with beatmaniaIIDX substream CLUB VERSiON 2 (GE984 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4591GAME( 1999, gtrfrk2m, sys573,   pccard1yi,    gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks 2nd Mix Ver 1.01 (GQ883 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4592GAME( 1999, dsftkd,   sys573,   konami573yi,  ddr,       ddr,        ROT0, "Konami", "Dancing Stage featuring TRUE KiSS DESTiNATiON (G*884 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4593GAME( 1999, cr589fw,  sys573,   konami573,    konami573, konami573,  ROT0, "Konami", "CD-ROM Drive Updater 2.0 (700B04)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4594GAME( 1999, cr589fwa, sys573,   konami573,    konami573, konami573,  ROT0, "Konami", "CD-ROM Drive Updater (700A04)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4595GAME( 2000, ddr3mk,   sys573,   pccard2dyyi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea2 (GN887 VER. KBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4596GAME( 2000, ddr3mka,  ddr3mk,   pccard2dyyi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix - Ver.Korea (GN887 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4597GAME( 1999, ddr3ma,   ddr3mk,   pccard2dyyi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.1 */
4598GAME( 1999, ddr3mj,   ddr3mk,   pccard2dyyi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix (GN887 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.0 */
4599GAME( 1999, ddrsbm,   sys573,   k573dyi,      ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo Bass Mix (GQ894 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4600GAME( 1999, ddrs2k,   sys573,   k573dyyi,     ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.3 */
4601GAME( 1999, ddrs2kj,  ddrs2k,   k573dyyi,     ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution Solo 2000 (GC905 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.2 */
4602GAME( 1999, hyperbbc, sys573,   konami573y,   hyperbbc,  hyperbbc,   ROT0, "Konami", "Hyper Bishi Bashi Champ (GX908 1999/08/24 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4603GAME( 1999, hyperbbck,hyperbbc, konami573y,   hyperbbc,  hyperbbc,   ROT0, "Konami", "Hyper Bishi Bashi Champ (GX908 1999/08/24 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4604GAME( 1999, dsfdct,   sys573,   pccard2dyyi,  ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JCA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4605GAME( 1999, dsfdcta,  dsfdct,   pccard2yyi,   ddr,       ddr,        ROT0, "Konami", "Dancing Stage featuring Dreams Come True (GC910 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4606GAME( 1999, drmn2m,   sys573,   k573dxzi,     drmn,      drmndigital,ROT0, "Konami", "DrumMania 2nd Mix (GE912 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.5 */
4607GAME( 1999, drmn2mpu, drmn2m,   k573dxzi,     drmn,      drmndigital,ROT0, "Konami", "DrumMania 2nd Mix Session Power Up Kit (GE912 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.5 */
4608GAME( 2000, dncfrks,  sys573,   k573dzi,      dmx,       dmx,        ROT0, "Konami", "Dance Freaks (G*874 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4609GAME( 2000, dmx,      dncfrks,  k573dzi,      dmx,       dmx,        ROT0, "Konami", "Dance Maniax (G*874 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4610GAME( 2000, dsem,     sys573,   k573dxi,      ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Euro Mix (G*936 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.7 */
4611GAME( 2000, gtrfrk3m, sys573,   pccard1xzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix (GE949 VER. JAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4612GAME( 2000, gtfrk3ma, gtrfrk3m, pccard1xzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix (GE949 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4613GAME( 2000, gtfrk3mb, gtrfrk3m, pccard1zi,    gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 3rd Mix - security cassette versionup (949JAZ02)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.4 */
4614GAME( 2000, salarymc, sys573,   konami573yi,  hyperbbc,  salarymc,   ROT0, "Konami", "Salary Man Champ (GCA18 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4615GAME( 2000, ddr3mp,   sys573,   pccard2dxzi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 3rd Mix Plus (G*A22 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.6 */
4616GAME( 2000, pcnfrk3m, sys573,   konami573xzi, drmn,      drmndigital,ROT0, "Konami", "Percussion Freaks 3rd Mix (G*A23 VER. KAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4617GAME( 2000, drmn3m,   pcnfrk3m, k573dxzi,     drmn,      drmndigital,ROT0, "Konami", "DrumMania 3rd Mix (G*A23 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4618GAME( 2000, gtrfrk4m, sys573,   pccard1xzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 4th Mix (G*A24 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4619GAME( 2000, ddr4m,    sys573,   pccard2dxzi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix (G*A33 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4620GAME( 2000, ddr4mj,   ddr4m,    pccard2dxzi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix (G*A33 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4621GAME( 2000, ddr4ms,   sys573,   pccard2dxzi,  ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Solo (G*A33 VER. ABA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4622GAME( 2000, ddr4msj,  ddr4ms,   pccard2dxzi,  ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Solo (G*A33 VER. JBA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4623GAME( 2000, dsfdr,    sys573,   k573dxzi,     ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Featuring Disney's Rave (GCA37JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4624GAME( 2000, ddrusa,   sys573,   k573dx,       ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution USA (G*A44 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.8 */
4625GAME( 2000, ddr4mp,   sys573,   pccard2dxzi,  ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 4th Mix Plus (G*A34 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4626GAME( 2000, ddr4mps,  sys573,   pccard2dxzi,  ddrsolo,   ddrsolo,    ROT0, "Konami", "Dance Dance Revolution 4th Mix Plus Solo (G*A34 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4627GAME( 2000, dmx2m,    sys573,   k573dzi,      dmx,       dmx,        ROT0, "Konami", "Dance Maniax 2nd Mix (G*A39 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4628GAME( 2000, fmania,   sys573,   konami573x,   konami573, konami573,  ROT0, "Konami", "Fighting Mania (918 xx B02)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4629GAME( 2001, gtrfrk5m, sys573,   pccard1dzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 5th Mix (G*A26 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4630GAME( 2001, ddr5m,    sys573,   pccard2dzi,   ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution 5th Mix (G*A27 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4631GAME( 2001, dmx2majp, sys573,   konami573zi,  dmx,       dmx,        ROT0, "Konami", "Dance Maniax 2nd Mix Append J-Paradise (G*A38 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4632GAME( 2001, mamboagg, sys573,   k573dzi,      mamboagg,  mamboagg,   ROT0, "Konami", "Mambo A Go-Go (GQA40 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4633GAME( 2001, gtrfrk6m, sys573,   pccard1dzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 6th Mix (G*B06 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4634GAME( 2001, gtrfrk7m, sys573,   pccard1dzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 7th Mix (G*B17 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4635GAME( 2001, ddrmax,   sys573,   pccard2dzi,   ddr,       ddrdigital, ROT0, "Konami", "DDR Max - Dance Dance Revolution 6th Mix (G*B19 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4636GAME( 2002, ddrmax2,  sys573,   pccard2dzi,   ddr,       ddrdigital, ROT0, "Konami", "DDR Max 2 - Dance Dance Revolution 7th Mix (G*B20 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.9 */
4637GAME( 2002, dsem2,    sys573,   pccard2dzi,   ddr,       ddrdigital, ROT0, "Konami", "Dancing Stage Euro Mix 2 (G*C23 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4638GAME( 2002, ddrextrm, sys573,   pccard2dzi,   ddr,       ddrdigital, ROT0, "Konami", "Dance Dance Revolution Extreme (G*C36 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
4639GAME( 2004, gtfrk11m, sys573,   pccard1dzi,   gtrfrks,   gtrfrkdigital,ROT0, "Konami", "Guitar Freaks 11th Mix (G*D39 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) /* BOOT VER 1.95 */
src/mame/drivers/mcr68.c
r10384r10385
14711471ROM_END
14721472
14731473
1474ROM_START( pigskina ) /* Initial boot screen reports REV 2.0 7/06/90 */
1475   ROM_REGION( 0x40000, "maincpu", 0 )
1476   ROM_LOAD16_BYTE( "pigskin_la2.a5",  0x00000, 0x10000, CRC(f75d36dd) SHA1(6afc8fbc900e17f9281ee214097d8ebd651d9291) )
1477   ROM_LOAD16_BYTE( "pigskin_la2.b5",  0x00001, 0x10000, CRC(c5ffdfad) SHA1(3b234f3629c8f21199f4845df7f44c43fd775c9b) )
1478   ROM_LOAD16_BYTE( "pigskin_la2.a6",  0x20000, 0x10000, CRC(2fc91002) SHA1(64d270b78c69d3f4fb36d1233a1632d6ba3d87a5) )
1479   ROM_LOAD16_BYTE( "pigskin_la2.b6",  0x20001, 0x10000, CRC(0b93dc66) SHA1(f3b516a1d1e4abd7b0d56243949e9cd7ac79178b) )
1480
1481   ROM_REGION( 0x90000, "cvsdcpu", 0 )  /* Audio System board */
1482   ROM_LOAD( "pigskin_sl1.u4",  0x10000, 0x10000, CRC(6daf2d37) SHA1(4c8098520fe44e36b01389bcfcfe3ad1d027cbde) )
1483   ROM_RELOAD(                  0x20000, 0x10000 )
1484   ROM_LOAD( "pigskin_sl1.u19", 0x30000, 0x10000, CRC(56fd16a3) SHA1(b91aabdbd3185355f2b7177fc4d3a86fa110f51d) )
1485   ROM_RELOAD(                  0x40000, 0x10000 )
1486   ROM_LOAD( "pigskin_sl1.u20", 0x50000, 0x10000, CRC(5d032fb8) SHA1(a236cdc64856637e560bec7119b051fac13efbe0) )
1487   ROM_RELOAD(                  0x60000, 0x10000 )
1488
1489   ROM_REGION( 0x20000, "gfx1", ROMREGION_INVERT )
1490   ROM_LOAD( "pigskin_la1.e2",  0x00000, 0x10000, CRC(12d5737b) SHA1(73040233bb86eaa42257112e2f0540de1206e310) )
1491   ROM_LOAD( "pigskin_la1.e1",  0x10000, 0x10000, CRC(460202a9) SHA1(8c2f7ae3615519e13e750c99b89ccb28e9946bb8) )
1492
1493   ROM_REGION( 0x80000, "gfx2", 0 )
1494   ROM_LOAD( "pigskin_la1.h15", 0x00000, 0x20000, CRC(e43d5d93) SHA1(e7592ba11601f2d20d54d52f436a239671c4d3ac) )
1495   ROM_LOAD( "pigskin_la1.h17", 0x20000, 0x20000, CRC(6b780f1e) SHA1(a0689feb38ad31eff5604d80562d9a936b30a011) )
1496   ROM_LOAD( "pigskin_la1.h18", 0x40000, 0x20000, CRC(5e50f940) SHA1(c9593b11934fd6da2b6c971859c0581fd92a915f) )
1497   ROM_LOAD( "pigskin_la1.h14", 0x60000, 0x20000, CRC(f26279f4) SHA1(9a8cd5aa359f408c93aa7f322b6eac17be52f3d3) )
1498ROM_END
1499
1500
14741501ROM_START( trisport )
14751502   ROM_REGION( 0x40000, "maincpu", 0 )
14761503   ROM_LOAD16_BYTE( "la3.a5",  0x00000, 0x10000, CRC(fe1e9e37) SHA1(583f18531583e038ca57a592b6a6c305896bf2c5) )
r10384r10385
16541681GAME( 1989, archrivl2,archrivl, archrivl, archrivl, archrivl, ROT0,   "Bally Midway", "Arch Rivals (rev 2.0 5/03/89)", GAME_SUPPORTS_SAVE )
16551682GAME( 1989, trisport, 0,        trisport, trisport, trisport, ROT270, "Bally Midway", "Tri-Sports", GAME_SUPPORTS_SAVE )
16561683GAME( 1990, pigskin,  0,        pigskin,  pigskin,  pigskin,  ROT0,   "Midway", "Pigskin 621AD (rev 1.1K 8/01/90)", GAME_SUPPORTS_SAVE )
1684GAME( 1990, pigskina, pigskin,  pigskin,  pigskin,  pigskin,  ROT0,   "Midway", "Pigskin 621AD (rev 2.0 7/06/90)", GAME_SUPPORTS_SAVE )
src/mame/drivers/segas24.c
r10384r10385
10711071   if(!track_size || !file)
10721072      return;
10731073   if(read_or_write)
1074      mame_fwrite(file, machine->region("floppy")->base(), 2*track_size);
1074      file->write(machine->region("floppy")->base(), 2*track_size);
10751075   else
1076      mame_fread(file, machine->region("floppy")->base(), 2*track_size);
1076      file->read(machine->region("floppy")->base(), 2*track_size);
10771077}
10781078
10791079static MACHINE_START( system24 )
src/tools/chdcd.c
r10384r10385
249249   return length;
250250}
251251
252UINT16 read_uint16(FILE *infile)
253{
254   UINT16 res = 0;
255   unsigned char buffer[2];
256
257   fread(buffer, 2, 1, infile);
258
259   res = buffer[1] | buffer[0]<<8;
260
261   return res;
262}
263
264UINT32 read_uint32(FILE *infile)
265{
266   UINT32 res = 0;
267   unsigned char buffer[4];
268
269   fread(buffer, 4, 1, infile);
270
271   res = buffer[3] | buffer[2]<<8 | buffer[1]<<16 | buffer[0]<<24;
272
273   return res;
274}
275
276UINT64 read_uint64(FILE *infile)
277{
278   UINT64 res0 = U64(0), res1 = U64(0);
279   UINT64 res;
280   unsigned char buffer[8];
281
282   fread(buffer, 8, 1, infile);
283
284   res0 = buffer[3] | buffer[2]<<8 | buffer[1]<<16 | buffer[0]<<24;
285   res1 = buffer[7] | buffer[6]<<8 | buffer[5]<<16 | buffer[4]<<24;
286
287   res = res0<<32 | res1;
288
289   return res;
290}
291
252292/*-------------------------------------------------
293    chdcd_parse_toc - parse a CDRWin format CUE file
294-------------------------------------------------*/
295
296chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc *outtoc, chdcd_track_input_info *outinfo)
297{
298   FILE *infile;
299   unsigned char buffer[12];
300   UINT32 chain_offs, chunk_size;
301   int done = 0;
302
303   infile = fopen(tocfname, "rt");
304
305   if (infile == (FILE *)NULL)
306   {
307      return CHDERR_FILE_NOT_FOUND;
308   }
309
310   /* clear structures */
311   memset(outtoc, 0, sizeof(cdrom_toc));
312   memset(outinfo, 0, sizeof(chdcd_track_input_info));
313
314   // seek to 12 bytes before the end
315   fseek(infile, -12, SEEK_END);
316   fread(buffer, 12, 1, infile);
317
318   if (memcmp(buffer, "NER5", 4))
319   {
320      printf("ERROR: Not a Nero 5.5 or later image!\n");
321      return CHDERR_FILE_NOT_FOUND;
322   }
323
324   chain_offs = buffer[11] | (buffer[10]<<8) | (buffer[9]<<16) | (buffer[8]<<24);
325
326   if ((buffer[7] != 0) || (buffer[6] != 0) || (buffer[5] != 0) || (buffer[4] != 0))
327   {
328      printf("ERROR: File size is > 4GB, this version of CHDMAN cannot handle it.");
329      return CHDERR_FILE_NOT_FOUND;
330   }
331
332//   printf("NER5 detected, chain offset: %x\n", chain_offs);
333
334   while (!done)
335   {
336      UINT32 toc_type, offset;
337      UINT8 start, end;
338      int track;
339
340      fseek(infile, chain_offs, SEEK_SET);
341      fread(buffer, 8, 1, infile);
342
343      chunk_size = (buffer[7] | buffer[6]<<8 | buffer[5]<<16 | buffer[4]<<24);
344
345//      printf("Chunk type: %c%c%c%c, size %x\n", buffer[0], buffer[1], buffer[2], buffer[3], chunk_size);
346
347      // we want the DAOX chunk, which has the TOC information
348      if (!memcmp(buffer, "DAOX", 4))
349      {
350         // skip second chunk size and UPC code
351         fseek(infile, 16, SEEK_CUR);
352
353         toc_type = read_uint32(infile);
354         fread(&start, 1, 1, infile);
355         fread(&end, 1, 1, infile);
356
357//         printf("TOC type: %08x.  Start track %d  End track: %d\n", toc_type, start, end);
358
359         outtoc->numtrks = (end-start) + 1;
360
361         offset = 0;
362         for (track = start; track <= end; track++)
363         {
364            UINT32 size, mode;
365            UINT64 index0, index1, index2;
366
367            fseek(infile, 12, SEEK_CUR);   // skip ISRC code
368            size = read_uint16(infile);
369            mode = read_uint32(infile);
370            index0 = read_uint64(infile);
371            index1 = read_uint64(infile);
372            index2 = read_uint64(infile);
373
374//            printf("Track %d: sector size %d mode %x index0 %llx index1 %llx index2 %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, index2, (UINT32)(index1-index0)/size, (UINT32)(index2-index1)/size);
375
376            strcpy(outinfo->fname[track-1], tocfname);
377            outinfo->offset[track-1] = offset + (UINT32)(index1-index0);
378            outinfo->idx0offs[track-1] = 0;
379            outinfo->idx1offs[track-1] = 0;
380
381            switch (mode)
382            {
383               case 1:   // 2048 byte data
384                  outtoc->tracks[track-1].trktype = CD_TRACK_MODE1;
385                  outinfo->swap[track-1] = 0;
386                  break;
387
388               case 0x7000001:   // 2352 byte audio
389                  outtoc->tracks[track-1].trktype = CD_TRACK_AUDIO;
390                  outinfo->swap[track-1] = 1;
391                  break;
392
393               default:
394                  printf("ERROR: Unknown track type %x, contact MAMEDEV!\n", mode);
395                  break;
396            }
397
398            outtoc->tracks[track-1].datasize = size;
399
400            outtoc->tracks[track-1].subtype = CD_SUB_NONE;
401            outtoc->tracks[track-1].subsize = 0;
402
403            outtoc->tracks[track-1].pregap = (UINT32)(index1-index0)/size;
404            outtoc->tracks[track-1].frames = (UINT32)(index2-index1)/size;
405            outtoc->tracks[track-1].postgap = 0;
406            outtoc->tracks[track-1].pgtype = 0;
407            outtoc->tracks[track-1].pgsub = CD_SUB_NONE;
408            outtoc->tracks[track-1].pgdatasize = 0;
409            outtoc->tracks[track-1].pgsubsize = 0;
410
411            offset += (UINT32)index2-index1;
412         }
413      }
414
415      if (!memcmp(buffer, "END!", 4))
416      {
417         done = 1;
418      }
419      else
420      {
421         chain_offs += chunk_size + 8;
422      }
423   }
424
425
426   return CHDERR_NONE;
427}
428
429/*-------------------------------------------------
253430    chdcd_parse_gdi - parse a Sega GD-ROM rip
254431-------------------------------------------------*/
255432
r10384r10385
642819      return chdcd_parse_cue(tocfname, outtoc, outinfo);
643820   }
644821
822   if (strstr(tocfname,".nrg"))
823   {
824      return chdcd_parse_nero(tocfname, outtoc, outinfo);
825   }
826
645827   infile = fopen(tocfname, "rt");
646828
647829   if (infile == (FILE *)NULL)
src/tools/chdman.c
r10384r10385
183183   printf("   or: chdman -createhd inputhd.raw output.chd [ident.bin] [inputoffs [cylinders heads sectors [sectorsize [hunksize]]]]\n");
184184   printf("   or: chdman -createuncomphd inputhd.raw output.chd [ident.bin] [inputoffs [cylinders heads sectors [sectorsize [hunksize]]]]\n");
185185   printf("   or: chdman -createblankhd output.chd cylinders heads sectors [sectorsize [hunksize]]\n");
186   printf("   or: chdman -createcd input.(toc/cue/gdi) output.chd\n");
186   printf("   or: chdman -createcd input.(toc/cue/nrg/gdi) output.chd\n");
187187   printf("   or: chdman -createav input.avi output.chd [firstframe [numframes]]\n");
188188   printf("   or: chdman -copydata input.chd output.chd\n");
189189   printf("   or: chdman -extract input.chd output.raw\n");
src/osd/sdl/sdlos_unix.c
r10384r10385
154154   if ( info.subsystem != SDL_SYSWM_X11 )
155155      return NULL;
156156#if (SDL_VERSION_ATLEAST(1,3,0))
157   if ( (display = info.x11.display) == NULL )
157   if ( (display = info.info.x11.display) == NULL )
158158      return NULL;
159   if ( (our_win = info.x11.window) == None )
159   if ( (our_win = info.info.x11.window) == None )
160160      return NULL;
161161#else
162162   if ( (display = info.info.x11.display) == NULL )
src/osd/sdl/drawsdl.c
r10384r10385
22//
33//  drawsdl.c - SDL software and OpenGL implementation
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2011, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r10384r10385
3838
3939typedef struct _sdl_scale_mode sdl_scale_mode;
4040
41// FIXME: Only until there is a final decision from SAM on scalemodes
42#if (SDL_VERSION_ATLEAST(1,3,0))
43#define   SDL_SCALEMODE_NONE   (0)
44#define   SDL_SCALEMODE_FAST   (0)
45#define   SDL_SCALEMODE_BEST   (0)
46#endif
47
4148/* sdl_info is the information about SDL for the current screen */
4249typedef struct _sdl_info sdl_info;
4350struct _sdl_info
r10384r10385
4653   UINT32            extra_flags;
4754
4855#if (SDL_VERSION_ATLEAST(1,3,0))
49   SDL_TextureID      texture_id;
56   SDL_Texture         *texture_id;
5057#else
5158   // SDL surface
5259   SDL_Surface       *sdlsurf;
r10384r10385
8289#if (!SDL_VERSION_ATLEAST(1,3,0))
8390   int            extra_flags;      /* Texture/surface flags */
8491#else
85   SDL_ScaleMode   sdl_scale_mode;      /* sdl 1.3 scale mode    */
92   //SDL_ScaleMode   sdl_scale_mode;      /* sdl 1.3 scale mode    */
93   int            sdl_scale_mode;      /* got removed recently - trying to get it in again */
8694#endif
8795   int            pixel_format;      /* Pixel/Overlay format  */
8896   void          (*yuv_blit)(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
r10384r10385
283291      int w = sdl->hw_scale_width * sdl_sm->mult_w;
284292      int h = sdl->hw_scale_height * sdl_sm->mult_h;
285293
286      sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
294      sdl->texture_id = SDL_CreateTexture(window->sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
287295
288296   }
289297   else
290298   {
291      sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING,
299      sdl->texture_id = SDL_CreateTexture(window->sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
292300            tempwidth, tempheight);
293301   }
294302
295   SDL_SetTextureScaleMode(sdl->texture_id, sdl_sm->sdl_scale_mode);
303   //SDL_SetTextureScaleMode(window->sdl_renderer,sdl->texture_id, sdl_sm->sdl_scale_mode);
296304
297305}
298306#endif
r10384r10385
365373      const char *name;
366374   } rflist[] =
367375      {
376#if 0
368377         RF_ENTRY(SDL_RENDERER_SINGLEBUFFER),
369378         RF_ENTRY(SDL_RENDERER_PRESENTCOPY),
370379         RF_ENTRY(SDL_RENDERER_PRESENTFLIP2),
371380         RF_ENTRY(SDL_RENDERER_PRESENTFLIP3),
372381         RF_ENTRY(SDL_RENDERER_PRESENTDISCARD),
382#endif
373383         RF_ENTRY(SDL_RENDERER_PRESENTVSYNC),
374384         RF_ENTRY(SDL_RENDERER_ACCELERATED),
375385         {-1, NULL}
r10384r10385
434444   // create a texture
435445
436446   if (video_config.waitvsync)
437      SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC);
447      window->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
438448   else
439      SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD);
449      window->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
440450
441    SDL_SelectRenderer(window->sdl_window);
451    //SDL_SelectRenderer(window->sdl_window);
442452
443453    {
444454        struct SDL_RendererInfo render_info;
445       SDL_GetRendererInfo(&render_info);
455       SDL_GetRendererInfo(window->sdl_renderer, &render_info);
446456
447457       drawsdl_show_info(window, &render_info);
448458
r10384r10385
543553      return;
544554
545555#if (SDL_VERSION_ATLEAST(1,3,0))
546   SDL_SelectRenderer(window->sdl_window);
556   //SDL_SelectRenderer(window->sdl_window);
547557   SDL_DestroyTexture(sdl->texture_id);
548558   //SDL_DestroyRenderer(window->sdl_window);
549559   SDL_DestroyWindow(window->sdl_window);
r10384r10385
696706   else
697707      surfptr = (UINT8 *)sdl->sdlsurf->pixels;
698708#else
699   SDL_SelectRenderer(window->sdl_window);
709   //SDL_SelectRenderer(window->sdl_window);
700710
701711   if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight)
702712   {
r10384r10385
720730   if (sdl->blittimer > 0)
721731   {
722732      /* SDL Underlays need alpha = 0 ! */
723      SDL_SetRenderDrawColor(0,0,0,0);
724      SDL_RenderFillRect(NULL);
733      SDL_SetRenderDrawColor(window->sdl_renderer,0,0,0,0);
734      SDL_RenderFillRect(window->sdl_renderer,NULL);
725735      //SDL_RenderFill(0,0,0,0 /*255*/,NULL);
726736      sdl->blittimer--;
727737   }
728738
729   SDL_LockTexture(sdl->texture_id, NULL, 1, (void **) &surfptr, &pitch);
739   SDL_LockTexture(sdl->texture_id, NULL, (void **) &surfptr, &pitch);
730740
731741#endif
732742   // get ready to center the image
r10384r10385
856866      r.h=blitheight;
857867      //printf("blitwidth %d %d - %d %d\n", blitwidth, blitheight, window->width, window->height);
858868      //SDL_UpdateTexture(sdl->sdltex, NULL, sdl->sdlsurf->pixels, pitch);
859      SDL_RenderCopy(sdl->texture_id, NULL, &r);
860      SDL_RenderPresent();
869      SDL_RenderCopy(window->sdl_renderer,sdl->texture_id, NULL, &r);
870      SDL_RenderPresent(window->sdl_renderer);
861871   }
862872#endif
863873   return 0;
src/osd/sdl/draw13.c
r10384r10385
105105   int               pitch;
106106   int               pixels_own;         // do we own / allocated it ?
107107
108   SDL_TextureID      texture_id;
108   SDL_Texture         *texture_id;
109109
110110   copy_info         *copyinfo;
111111   Uint32            sdl_access;
r10384r10385
123123   INT32         blittimer;
124124   UINT32         extra_flags;
125125
126   SDL_Renderer   *sdl_renderer;
126127   texture_info *   texlist;            // list of active textures
127128   INT32         texture_max_width;     // texture maximum width
128129   INT32         texture_max_height;    // texture maximum height
r10384r10385
328329   return SDL_BLENDMODE_NONE;
329330}
330331
331INLINE void set_coloralphamode(SDL_TextureID texture_id, const render_color *color)
332INLINE void set_coloralphamode(SDL_Texture   *texture_id, const render_color *color)
332333{
333334   UINT32 sr = (UINT32)(255.0f * color->r);
334335   UINT32 sg = (UINT32)(255.0f * color->g);
r10384r10385
362363
363364INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive *prim, int x, int y)
364365{
365   SDL_TextureID texture_id;
366   SDL_Texture   *texture_id;
366367   SDL_Rect target_rect;
367368
368369   target_rect.x = x;
r10384r10385
375376      texture_id = texture->texture_id;
376377
377378      texture->copyinfo->time -= osd_ticks();
379#if 0
378380      if ((PRIMFLAG_GET_SCREENTEX(prim->flags)) && video_config.filter)
379381      {
380382         SDL_SetTextureScaleMode(texture->texture_id,  SDL_SCALEMODE_BEST);
r10384r10385
383385      {
384386         SDL_SetTextureScaleMode(texture->texture_id,  SDL_SCALEMODE_NONE);
385387      }
388#endif
386389      SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode);
387390      set_coloralphamode(texture_id, &prim->color);
388      SDL_RenderCopy(texture_id, NULL, &target_rect);
391      SDL_RenderCopy(sdl->sdl_renderer,  texture_id, NULL, &target_rect);
389392      texture->copyinfo->time += osd_ticks();
390393
391394      texture->copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->rawwidth * texture->rawheight));
r10384r10385
403406      UINT32 sb = (UINT32)(255.0f * prim->color.b);
404407      UINT32 sa = (UINT32)(255.0f * prim->color.a);
405408
406      SDL_SetRenderDrawBlendMode(map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
407      SDL_SetRenderDrawColor(sr, sg, sb, sa);
408      SDL_RenderFillRect(&target_rect);
409      SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
410      SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa);
411      SDL_RenderFillRect(sdl->sdl_renderer, &target_rect);
409412   }
410413}
411414
r10384r10385
426429   return 0;
427430}
428431#else
429static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat)
432static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat)
430433{
431434   int i;
432   SDL_TextureID texid;
435   SDL_Texture *texid;
433436   for (i=0; fmt_support[i].format != 0; i++)
434437   {
435438      if (format == fmt_support[i].format)
r10384r10385
440443   /* not tested yet */
441444   fmt_support[i].format = format;
442445   fmt_support[i + 1].format = 0;
443   texid = SDL_CreateTexture(format, access, 16, 16);
446   texid = SDL_CreateTexture(renderer, format, access, 16, 16);
444447   if (texid)
445448   {
446449      fmt_support[i].status = 1;
r10384r10385
486489   }
487490}
488491
489int draw13_init(sdl_draw_info *callbacks)
492int draw13_init(running_machine &machine, sdl_draw_info *callbacks)
490493{
491494   const char *stemp;
492495
r10384r10385
503506
504507   // Load the GL library now - else MT will fail
505508
506   stemp = options_get_string(mame_options(), SDLOPTION_GL_LIB);
509   stemp = options_get_string(&machine.options(), SDLOPTION_GL_LIB);
507510   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
508511      stemp = NULL;
509512
r10384r10385
563566{
564567   // allocate memory for our structures
565568   sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
566   int result;
567569
568570   mame_printf_verbose("Enter draw13_window_create\n");
569571
r10384r10385
572574   window->dxdata = sdl;
573575
574576   sdl->extra_flags = (window->fullscreen ?
575         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN: SDL_WINDOW_RESIZABLE);
577         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
576578
577579   // create the SDL window
578580   SDL_SelectVideoDisplay(window->monitor->handle);
r10384r10385
616618   // create renderer
617619
618620   if (video_config.waitvsync)
619      result = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC);
621      sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | */SDL_RENDERER_PRESENTVSYNC);
620622   else
621      result = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD);
623      sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
622624
623   if (result)
625   if (!sdl->sdl_renderer)
624626   {
625627      fatalerror("Error on creating renderer: %s \n", SDL_GetError());
626628   }
627629
628    SDL_SelectRenderer(window->sdl_window);
630    //SDL_SelectRenderer(window->sdl_window);
629631
630632   SDL_ShowWindow(window->sdl_window);
631633   //SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
r10384r10385
640642   sdl->texture_max_width = 64;
641643   sdl->texture_max_height = 64;
642644
643   SDL_RenderPresent();
645   SDL_RenderPresent(sdl->sdl_renderer);
644646   mame_printf_verbose("Leave draw13_window_create\n");
645647   return 0;
646648}
r10384r10385
723725      sdl->resize_pending = 0;
724726   }
725727
726    SDL_SelectRenderer(window->sdl_window);
728    //SDL_SelectRenderer(window->sdl_window);
727729
728730   if (sdl->blittimer > 0)
729731   {
730732      /* SDL Underlays need alpha = 0 ! */
731      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
733      SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, SDL_BLENDMODE_NONE);
732734      //SDL_SetRenderDrawColor(0,0,0,255);
733      SDL_SetRenderDrawColor(0,0,0,0);
734      SDL_RenderFillRect(NULL);
735      SDL_SetRenderDrawColor(sdl->sdl_renderer, 0,0,0,0);
736      SDL_RenderFillRect(sdl->sdl_renderer, NULL);
735737      sdl->blittimer--;
736738   }
737739
r10384r10385
781783            sb = (int)(255.0f * prim->color.b);
782784            sa = (int)(255.0f * prim->color.a);
783785
784            SDL_SetRenderDrawBlendMode(map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
785            SDL_SetRenderDrawColor(sr, sg, sb, sa);
786            SDL_RenderDrawLine(prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
786            SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
787            SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa);
788            SDL_RenderDrawLine(sdl->sdl_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
787789                  prim->bounds.x1 + hofs, prim->bounds.y1 + vofs);
788790            break;
789791         case render_primitive::QUAD:
r10384r10385
803805
804806   sdl->last_blit_pixels = blit_pixels;
805807   sdl->last_blit_time = -osd_ticks();
806   SDL_RenderPresent();
808   SDL_RenderPresent(sdl->sdl_renderer);
807809   sdl->last_blit_time += osd_ticks();
808810
809811   return 0;
r10384r10385
852854//  texture_compute_size and type
853855//============================================================
854856
855static copy_info *texture_compute_size_type(const render_texinfo *texsource, texture_info *texture, UINT32 flags)
857static copy_info *texture_compute_size_type(SDL_Renderer *renderer, const render_texinfo *texsource, texture_info *texture, UINT32 flags)
856858{
857859   copy_info *bi;
858860   copy_info *result = NULL;
r10384r10385
864866      if ((texture->is_rotated == bi->rotate)
865867            && (texture->sdl_blendmode == bi->bm_mask))
866868      {
867         if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname))
869         if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname))
868870         {
869871            if (bi->perf == 0)
870872               return bi;
r10384r10385
883885   {
884886      if ((texture->is_rotated == bi->rotate)
885887         && (texture->sdl_blendmode == bi->bm_mask))
886         if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname))
888         if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname))
887889            return bi;
888890   }
889891   //FIXME: crash implement a -do nothing handler */
r10384r10385
953955      mame_printf_warning("Trying to create texture with zero dim\n");
954956
955957   // compute the size
956   texture->copyinfo = texture_compute_size_type(texsource, texture, flags);
958   texture->copyinfo = texture_compute_size_type(sdl->sdl_renderer, texsource, texture, flags);
957959
958   texture->texture_id = SDL_CreateTexture(texture->copyinfo->dst_fmt, texture->sdl_access,
960   texture->texture_id = SDL_CreateTexture(sdl->sdl_renderer, texture->copyinfo->dst_fmt, texture->sdl_access,
959961         texture->setup.rotwidth, texture->setup.rotheight);
960962
961963   if (!texture->texture_id)
r10384r10385
9991001   }
10001002   else
10011003   {
1002      SDL_LockTexture(texture->texture_id, NULL, 1, (void **) &texture->pixels, &texture->pitch);
1004      SDL_LockTexture(texture->texture_id, NULL, (void **) &texture->pixels, &texture->pitch);
10031005      if ( texture->copyinfo->func )
10041006         texture->copyinfo->func(texture, texsource);
10051007      else
r10384r10385
10911093         /* would we choose another blitter ? */
10921094         if ((texture->copyinfo->samples & 0x1f) == 0x1f)
10931095         {
1094            if (texture->copyinfo != texture_compute_size_type(&texture->texinfo, texture, prim->flags))
1096            if (texture->copyinfo != texture_compute_size_type(sdl->sdl_renderer, &texture->texinfo, texture, prim->flags))
10951097               return NULL;
10961098#if 0
10971099            else
src/osd/sdl/video.c
r10384r10385
8888
8989static void video_exit(running_machine &machine);
9090static void init_monitors(void);
91static sdl_monitor_info *pick_monitor(int index);
91static sdl_monitor_info *pick_monitor(core_options &options, int index);
9292
9393static void check_osd_inputs(running_machine *machine);
9494
9595static void extract_video_config(running_machine *machine);
9696static void extract_window_config(running_machine *machine, int index, sdl_window_config *conf);
97static float get_aspect(const char *name, int report_error);
98static void get_resolution(const char *name, sdl_window_config *config, int report_error);
97static float get_aspect(core_options &options, const char *name, int report_error);
98static void get_resolution(core_options &options, const char *name, sdl_window_config *config, int report_error);
9999
100100
101101//============================================================
r10384r10385
116116   init_monitors();
117117
118118   // we need the beam width in a float, contrary to what the core does.
119   video_config.beamwidth = options_get_float(machine->options(), OPTION_BEAM);
119   video_config.beamwidth = options_get_float(&machine->options(), OPTION_BEAM);
120120
121121   // initialize the window system so we can make windows
122122   if (sdlwindow_init(machine))
r10384r10385
131131      memset(&conf, 0, sizeof(conf));
132132      extract_window_config(machine, index, &conf);
133133      conf.totalColors = tc;
134      if (sdlwindow_video_window_create(machine, index, pick_monitor(index), &conf))
134      if (sdlwindow_video_window_create(machine, index, pick_monitor(machine->options(), index), &conf))
135135         goto error;
136136   }
137137
r10384r10385
501501//============================================================
502502
503503#if (SDL_VERSION_ATLEAST(1,3,0)) || defined(SDLMAME_WIN32)
504static sdl_monitor_info *pick_monitor(int index)
504static sdl_monitor_info *pick_monitor(core_options &options, int index)
505505{
506506   sdl_monitor_info *monitor;
507507   const char *scrname;
r10384r10385
511511
512512   // get the screen option
513513   sprintf(option, SDLOPTION_SCREEN("%d"), index);
514   scrname = options_get_string(mame_options(), option);
514   scrname = options_get_string(&options, option);
515515
516516   // get the aspect ratio
517517   sprintf(option, SDLOPTION_ASPECT("%d"), index);
518   aspect = get_aspect(option, TRUE);
518   aspect = get_aspect(options, option, TRUE);
519519
520520   // look for a match in the name first
521521   if (scrname != NULL)
r10384r10385
543543   return monitor;
544544}
545545#else
546static sdl_monitor_info *pick_monitor(int index)
546static sdl_monitor_info *pick_monitor(core_options &options, int index)
547547{
548548   sdl_monitor_info *monitor;
549549   char option[20];
r10384r10385
551551
552552   // get the aspect ratio
553553   sprintf(option, SDLOPTION_ASPECT("%d"), index);
554   aspect = get_aspect(option, TRUE);
554   aspect = get_aspect(options, option, TRUE);
555555
556556   // return the primary just in case all else fails
557557   monitor = primary_monitor;
r10384r10385
618618
619619   sprintf(buf,SDLOPTION_RESOLUTION("%d"), index);
620620   // per-window options: extract the data
621   get_resolution(buf, conf, TRUE);
621   get_resolution(machine->options(), buf, conf, TRUE);
622622}
623623
624624//============================================================
r10384r10385
629629{
630630   const char *stemp;
631631
632   video_config.perftest    = options_get_bool(machine->options(), SDLOPTION_SDLVIDEOFPS);
632   video_config.perftest    = options_get_bool(&machine->options(), SDLOPTION_SDLVIDEOFPS);
633633
634634   // global options: extract the data
635   video_config.windowed      = options_get_bool(machine->options(), SDLOPTION_WINDOW);
636   video_config.keepaspect    = options_get_bool(machine->options(), SDLOPTION_KEEPASPECT);
637   video_config.numscreens    = options_get_int(machine->options(), SDLOPTION_NUMSCREENS);
638   video_config.fullstretch   = options_get_bool(machine->options(), SDLOPTION_UNEVENSTRETCH);
635   video_config.windowed      = options_get_bool(&machine->options(), SDLOPTION_WINDOW);
636   video_config.keepaspect    = options_get_bool(&machine->options(), SDLOPTION_KEEPASPECT);
637   video_config.numscreens    = options_get_int(&machine->options(), SDLOPTION_NUMSCREENS);
638   video_config.fullstretch   = options_get_bool(&machine->options(), SDLOPTION_UNEVENSTRETCH);
639639   #ifdef SDLMAME_X11
640   video_config.restrictonemonitor = !options_get_bool(machine->options(), SDLOPTION_USEALLHEADS);
640   video_config.restrictonemonitor = !options_get_bool(&machine->options(), SDLOPTION_USEALLHEADS);
641641   #endif
642642
643643
r10384r10385
648648   video_config.novideo = 0;
649649
650650   // d3d options: extract the data
651   stemp = options_get_string(machine->options(), SDLOPTION_VIDEO);
651   stemp = options_get_string(&machine->options(), SDLOPTION_VIDEO);
652652   if (strcmp(stemp, SDLOPTVAL_SOFT) == 0)
653653      video_config.mode = VIDEO_MODE_SOFT;
654654   else if (strcmp(stemp, SDLOPTVAL_NONE) == 0)
r10384r10385
656656      video_config.mode = VIDEO_MODE_SOFT;
657657      video_config.novideo = 1;
658658
659      if (options_get_int(machine->options(), OPTION_SECONDS_TO_RUN) == 0)
659      if (options_get_int(&machine->options(), OPTION_SECONDS_TO_RUN) == 0)
660660         mame_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
661661   }
662662   else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0))
r10384r10385
677677      video_config.mode = VIDEO_MODE_SOFT;
678678   }
679679
680   video_config.switchres     = options_get_bool(machine->options(), SDLOPTION_SWITCHRES);
681   video_config.centerh       = options_get_bool(machine->options(), SDLOPTION_CENTERH);
682   video_config.centerv       = options_get_bool(machine->options(), SDLOPTION_CENTERV);
683   video_config.waitvsync     = options_get_bool(machine->options(), SDLOPTION_WAITVSYNC);
684   video_config.syncrefresh   = options_get_bool(machine->options(), SDLOPTION_SYNCREFRESH);
680   video_config.switchres     = options_get_bool(&machine->options(), SDLOPTION_SWITCHRES);
681   video_config.centerh       = options_get_bool(&machine->options(), SDLOPTION_CENTERH);
682   video_config.centerv       = options_get_bool(&machine->options(), SDLOPTION_CENTERV);
683   video_config.waitvsync     = options_get_bool(&machine->options(), SDLOPTION_WAITVSYNC);
684   video_config.syncrefresh   = options_get_bool(&machine->options(), SDLOPTION_SYNCREFRESH);
685685   if (!video_config.waitvsync && video_config.syncrefresh)
686686   {
687687      mame_printf_warning("-syncrefresh specified without -waitsync. Reverting to -nosyncrefresh\n");
r10384r10385
690690
691691   if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0))
692692   {
693      video_config.filter        = options_get_bool(machine->options(), SDLOPTION_FILTER);
693      video_config.filter        = options_get_bool(&machine->options(), SDLOPTION_FILTER);
694694   }
695695
696696   if (USE_OPENGL)
697697   {
698      video_config.prescale      = options_get_int(machine->options(), SDLOPTION_PRESCALE);
698      video_config.prescale      = options_get_int(&machine->options(), SDLOPTION_PRESCALE);
699699      if (video_config.prescale < 1 || video_config.prescale > 3)
700700      {
701701         mame_printf_warning("Invalid prescale option, reverting to '1'\n");
r10384r10385
703703      }
704704      // default to working video please
705705      video_config.prefer16bpp_tex = 0;
706      video_config.forcepow2texture = options_get_bool(machine->options(), SDLOPTION_GL_FORCEPOW2TEXTURE)==1;
707      video_config.allowtexturerect = options_get_bool(machine->options(), SDLOPTION_GL_NOTEXTURERECT)==0;
708      video_config.vbo         = options_get_bool(machine->options(), SDLOPTION_GL_VBO);
709      video_config.pbo         = options_get_bool(machine->options(), SDLOPTION_GL_PBO);
710      video_config.glsl        = options_get_bool(machine->options(), SDLOPTION_GL_GLSL);
706      video_config.forcepow2texture = options_get_bool(&machine->options(), SDLOPTION_GL_FORCEPOW2TEXTURE)==1;
707      video_config.allowtexturerect = options_get_bool(&machine->options(), SDLOPTION_GL_NOTEXTURERECT)==0;
708      video_config.vbo         = options_get_bool(&machine->options(), SDLOPTION_GL_VBO);
709      video_config.pbo         = options_get_bool(&machine->options(), SDLOPTION_GL_PBO);
710      video_config.glsl        = options_get_bool(&machine->options(), SDLOPTION_GL_GLSL);
711711      if ( video_config.glsl )
712712      {
713713         int i;
714714         static char buffer[20]; // gl_glsl_filter[0..9]?
715715
716         video_config.glsl_filter = options_get_int (machine->options(), SDLOPTION_GLSL_FILTER);
716         video_config.glsl_filter = options_get_int (&machine->options(), SDLOPTION_GLSL_FILTER);
717717
718718         video_config.glsl_shader_mamebm_num=0;
719719
r10384r10385
721721         {
722722            snprintf(buffer, 18, SDLOPTION_SHADER_MAME("%d"), i); buffer[17]=0;
723723
724            stemp = options_get_string(machine->options(), buffer);
724            stemp = options_get_string(&machine->options(), buffer);
725725            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
726726            {
727727               video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
r10384r10385
738738         {
739739            snprintf(buffer, 20, SDLOPTION_SHADER_SCREEN("%d"), i); buffer[19]=0;
740740
741            stemp = options_get_string(machine->options(), buffer);
741            stemp = options_get_string(&machine->options(), buffer);
742742            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
743743            {
744744               video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
r10384r10385
749749            }
750750         }
751751
752         video_config.glsl_vid_attributes = options_get_int (machine->options(), SDLOPTION_GL_GLSL_VID_ATTR);
752         video_config.glsl_vid_attributes = options_get_int (&machine->options(), SDLOPTION_GL_GLSL_VID_ATTR);
753753         {
754754            // Disable feature: glsl_vid_attributes, as long we have the gamma calculation
755755            // disabled within the direct shaders .. -> too slow.
756756            // IMHO the gamma setting should be done global anyways, and for the whole system,
757757            // not just MAME ..
758            float gamma = options_get_float(machine->options(), OPTION_GAMMA);
758            float gamma = options_get_float(&machine->options(), OPTION_GAMMA);
759759            if (gamma != 1.0 && video_config.glsl_vid_attributes && video_config.glsl)
760760            {
761761               video_config.glsl_vid_attributes = FALSE;
r10384r10385
796796   }
797797#endif
798798   // yuv settings ...
799   stemp = options_get_string(machine->options(), SDLOPTION_SCALEMODE);
799   stemp = options_get_string(&machine->options(), SDLOPTION_SCALEMODE);
800800   video_config.scale_mode = drawsdl_scale_mode(stemp);
801801   if (video_config.scale_mode < 0)
802802   {
r10384r10385
815815//  get_aspect
816816//============================================================
817817
818static float get_aspect(const char *name, int report_error)
818static float get_aspect(core_options &options, const char *name, int report_error)
819819{
820   const char *defdata = options_get_string(mame_options(), SDLOPTION_ASPECT(""));
821   const char *data = options_get_string(mame_options(), name);
820   const char *defdata = options_get_string(&options, SDLOPTION_ASPECT(""));
821   const char *data = options_get_string(&options, name);
822822   int num = 0, den = 1;
823823
824824   if (strcmp(data, SDLOPTVAL_AUTO) == 0)
r10384r10385
837837//  get_resolution
838838//============================================================
839839
840static void get_resolution(const char *name, sdl_window_config *config, int report_error)
840static void get_resolution(core_options &options, const char *name, sdl_window_config *config, int report_error)
841841{
842   const char *defdata = options_get_string(mame_options(), SDLOPTION_RESOLUTION(""));
843   const char *data = options_get_string(mame_options(), name);
842   const char *defdata = options_get_string(&options, SDLOPTION_RESOLUTION(""));
843   const char *data = options_get_string(&options, name);
844844
845845   config->width = config->height = config->depth = config->refresh = 0;
846846   if (strcmp(data, SDLOPTVAL_AUTO) == 0)
src/osd/sdl/sdlmain.c
r10384r10385
22//
33//  sdlmain.c - main file for SDLMAME.
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2011, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r10384r10385
527527   const char *stemp;
528528
529529   // determine if we are benchmarking, and adjust options appropriately
530   int bench = options_get_int(machine.options(), SDLOPTION_BENCH);
530   int bench = options_get_int(&machine.options(), SDLOPTION_BENCH);
531531   if (bench > 0)
532532   {
533      options_set_bool(machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
534      options_set_bool(machine.options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM);
535      options_set_string(machine.options(), SDLOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM);
536      options_set_int(machine.options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM);
533      options_set_bool(&machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
534      options_set_bool(&machine.options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM);
535      options_set_string(&machine.options(), SDLOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM);
536      options_set_int(&machine.options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM);
537537   }
538538
539539   // Some driver options - must be before audio init!
540   stemp = options_get_string(machine.options(), SDLOPTION_AUDIODRIVER);
540   stemp = options_get_string(&machine.options(), SDLOPTION_AUDIODRIVER);
541541   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
542542   {
543543      mame_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp);
544544      osd_setenv(SDLENV_AUDIODRIVER, stemp, 1);
545545   }
546546
547   stemp = options_get_string(machine.options(), SDLOPTION_VIDEODRIVER);
547   stemp = options_get_string(&machine.options(), SDLOPTION_VIDEODRIVER);
548548   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
549549   {
550550      mame_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp);
r10384r10385
553553
554554   if (SDL_VERSION_ATLEAST(1,3,0))
555555   {
556      stemp = options_get_string(machine.options(), SDLOPTION_RENDERDRIVER);
556      stemp = options_get_string(&machine.options(), SDLOPTION_RENDERDRIVER);
557557      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
558558      {
559559         mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
r10384r10385
566566     */
567567   /* FIXME: move lib loading code from drawogl.c here */
568568
569   stemp = options_get_string(machine.options(), SDLOPTION_GL_LIB);
569   stemp = options_get_string(&machine.options(), SDLOPTION_GL_LIB);
570570   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
571571   {
572572      osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1);
r10384r10385
574574   }
575575
576576   /* get number of processors */
577   stemp = options_get_string(machine.options(), SDLOPTION_NUMPROCESSORS);
577   stemp = options_get_string(&machine.options(), SDLOPTION_NUMPROCESSORS);
578578
579579   sdl_num_processors = 0;
580580
r10384r10385
630630
631631   sdloutput_init(&machine);
632632
633   if (options_get_bool(machine.options(), SDLOPTION_OSLOG))
633   if (options_get_bool(&machine.options(), SDLOPTION_OSLOG))
634634      machine.add_logerror_callback(output_oslog);
635635
636636   /* now setup watchdog */
637637
638   int watchdog_timeout = options_get_int(machine.options(), SDLOPTION_WATCHDOG);
639   int str = options_get_int(machine.options(), OPTION_SECONDS_TO_RUN);
638   int watchdog_timeout = options_get_int(&machine.options(), SDLOPTION_WATCHDOG);
639   int str = options_get_int(&machine.options(), OPTION_SECONDS_TO_RUN);
640640
641641   /* only enable watchdog if seconds_to_run is enabled *and* relatively short (time taken from ui.c) */
642642   if ((watchdog_timeout != 0) && (str > 0) && (str < 60*5 ))
r10384r10385
941941
942942   if (!font)
943943   {
944      mame_file *t;
945
946944      mame_printf_verbose("Searching font %s in -%s\n", name.cstr(), SEARCHPATH_FONT);
947      if (mame_fopen(SEARCHPATH_FONT, name.cstr(), OPEN_FLAG_READ, &t) == FILERR_NONE)
945      emu_file file(machine().options(), SEARCHPATH_FONT, OPEN_FLAG_READ);
946      if (file.open(name) == FILERR_NONE)
948947      {
949         astring full_name = mame_file_full_name(t);
950         mame_fclose(t);
948         astring full_name = file.fullpath();
951949         font = TTF_OpenFont(full_name.cstr(), POINT_SIZE);
952950         if (font)
953951            mame_printf_verbose("Found font %s\n", full_name.cstr());
src/osd/sdl/drawogl.c
r10384r10385
22//
33//  drawogl.c - SDL software and OpenGL implementation
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2011, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r10384r10385
353353static void drawogl_destroy_all_textures(sdl_window_info *window);
354354static void drawogl_window_clear(sdl_window_info *window);
355355static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
356static void load_gl_lib(void);
356static void load_gl_lib(running_machine &machine);
357357
358358
359359
r10384r10385
429429//  drawogl_init
430430//============================================================
431431
432int drawogl_init(sdl_draw_info *callbacks)
432int drawogl_init(running_machine &machine, sdl_draw_info *callbacks)
433433{
434434   // fill in the callbacks
435435   callbacks->exit = drawogl_exit;
r10384r10385
443443      mame_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n");
444444
445445#if (SDL_VERSION_ATLEAST(1,3,0))
446   load_gl_lib();
446   load_gl_lib(machine);
447447#endif
448448
449449   return 0;
r10384r10385
502502// Load GL library
503503//============================================================
504504
505static void load_gl_lib(void)
505static void load_gl_lib(running_machine &machine)
506506{
507507#ifdef USE_DISPATCH_GL
508508   if (!dll_loaded)
r10384r10385
513513         */
514514      const char *stemp;
515515
516      stemp = options_get_string(mame_options(), SDLOPTION_GL_LIB);
516      stemp = options_get_string(&machine.options(), SDLOPTION_GL_LIB);
517517      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
518518         stemp = NULL;
519519
r10384r10385
553553
554554   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
555555   //Moved into init
556   //load_gl_lib();
556   //load_gl_lib(*window->machine);
557557
558558   // create the SDL window
559559   SDL_SelectVideoDisplay(window->monitor->handle);
r10384r10385
603603   SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0);
604604   #endif
605605
606   load_gl_lib();
606   load_gl_lib(*window->machine);
607607
608608   // create the SDL surface (which creates the window in windowed mode)
609609   sdl->sdlsurf = SDL_SetVideoMode(width, height,
r10384r10385
12411241      // we're doing nothing 3d, so the Z-buffer is currently not interesting
12421242      glDisable(GL_DEPTH_TEST);
12431243
1244      if (options_get_bool(window->machine->options(), OPTION_ANTIALIAS))
1244      if (options_get_bool(&window->machine->options(), OPTION_ANTIALIAS))
12451245      {
12461246         // enable antialiasing for lines
12471247         glEnable(GL_LINE_SMOOTH);
r10384r10385
29602960         container->get_user_settings(settings);
29612961         //FIXME: Intended behaviour
29622962#if 1
2963         vid_attributes[0] = options_get_float(window->machine->options(), OPTION_GAMMA);
2964         vid_attributes[1] = options_get_float(window->machine->options(), OPTION_CONTRAST);
2965         vid_attributes[2] = options_get_float(window->machine->options(), OPTION_BRIGHTNESS);
2963         vid_attributes[0] = options_get_float(&window->machine->options(), OPTION_GAMMA);
2964         vid_attributes[1] = options_get_float(&window->machine->options(), OPTION_CONTRAST);
2965         vid_attributes[2] = options_get_float(&window->machine->options(), OPTION_BRIGHTNESS);
29662966#else
29672967         vid_attributes[0] = settings.gamma;
29682968         vid_attributes[1] = settings.contrast;
src/osd/sdl/sound.c
r10384r10385
464464
465465   sdl_xfer_samples = obtained.samples;
466466
467   audio_latency = options_get_int(machine->options(), SDLOPTION_AUDIO_LATENCY);
467   audio_latency = options_get_int(&machine->options(), SDLOPTION_AUDIO_LATENCY);
468468
469469   // pin audio latency
470470   if (audio_latency > MAX_AUDIO_LATENCY)
src/osd/sdl/input.c
r10384r10385
22//
33//  input.c - SDL implementation of MAME input routines
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2011, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r10384r10385
638638      const char *dev_name;
639639      sprintf(defname, "%s%d", opt, dev + 1);
640640
641      dev_name = options_get_string(machine->options(), defname);
641      dev_name = options_get_string(&machine->options(), defname);
642642      if (dev_name && *dev_name && strcmp(dev_name,SDLOPTVAL_AUTO))
643643      {
644644         devmap->map[dev].name = remove_spaces(machine, dev_name);
r10384r10385
795795{
796796   int index, physical_mouse;
797797
798   mouse_enabled = options_get_bool(machine->options(), OPTION_MOUSE);
798   mouse_enabled = options_get_bool(&machine->options(), OPTION_MOUSE);
799799
800800   devmap_init(machine, &mouse_map, SDLOPTION_MOUSEINDEX, 8, "Mouse mapping");
801801
r10384r10385
855855   devinfo = generic_device_alloc(&mouse_list, "System mouse");
856856   devinfo->device = input_device_add(machine, DEVICE_CLASS_MOUSE, devinfo->name, devinfo);
857857
858   mouse_enabled = options_get_bool(machine->options(), OPTION_MOUSE);
858   mouse_enabled = options_get_bool(&machine->options(), OPTION_MOUSE);
859859
860860   // add the axes
861861   input_device_item_add(devinfo->device, "X", &devinfo->mouse.lX, ITEM_ID_XAXIS, generic_axis_get_state);
r10384r10385
942942   char sks[21];
943943   char kns[21];
944944
945   if (!options_get_bool(machine->options(), SDLOPTION_KEYMAP))
945   if (!options_get_bool(&machine->options(), SDLOPTION_KEYMAP))
946946      return sdl_key_trans_table;
947947
948   keymap_filename = (char *)options_get_string(machine->options(), SDLOPTION_KEYMAP_FILE);
948   keymap_filename = (char *)options_get_string(&machine->options(), SDLOPTION_KEYMAP_FILE);
949949   mame_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename);
950950
951951   keymap_file = fopen(keymap_filename, "r");
r10384r10385
11251125   }
11261126
11271127   // get Sixaxis special mode info
1128   sixaxis_mode = options_get_bool(machine->options(), SDLOPTION_SIXAXIS);
1128   sixaxis_mode = options_get_bool(&machine->options(), SDLOPTION_SIXAXIS);
11291129
11301130   // register the joysticks
11311131   sdlinput_register_joysticks(machine);
r10384r10385
16021602      {
16031603         // configurable UI mode switch
16041604         case IPT_UI_TOGGLE_UI:
1605            uimode = (const char *)options_get_string(mame_options(), SDLOPTION_UIMODEKEY);
1605            uimode = (const char *)options_get_string(&machine().options(), SDLOPTION_UIMODEKEY);
16061606            if(!strcmp(uimode,"auto")) {
16071607               #if defined(__APPLE__) && defined(__MACH__)
16081608               mameid_code = lookup_mame_code("ITEM_ID_INSERT");
src/osd/sdl/window.c
r10384r10385
206206{
207207   mame_printf_verbose("Enter sdlwindow_init\n");
208208   // determine if we are using multithreading or not
209   multithreading_enabled = options_get_bool(machine->options(), SDLOPTION_MULTITHREADING);
209   multithreading_enabled = options_get_bool(&machine->options(), SDLOPTION_MULTITHREADING);
210210
211211   // get the main thread ID before anything else
212212   main_threadid = SDL_ThreadID();
r10384r10385
234234#if USE_OPENGL
235235   if (video_config.mode == VIDEO_MODE_OPENGL)
236236   {
237      if (drawogl_init(&draw))
237      if (drawogl_init(*machine, &draw))
238238         video_config.mode = VIDEO_MODE_SOFT;
239239   }
240240#endif
241241#if   SDL_VERSION_ATLEAST(1,3,0)
242242   if (video_config.mode == VIDEO_MODE_SDL13)
243243   {
244      if (draw13_init(&draw))
244      if (draw13_init(*machine, &draw))
245245         video_config.mode = VIDEO_MODE_SOFT;
246246   }
247247#endif
r10384r10385
676676
677677   // set the initial maximized state
678678   // FIXME: Does not belong here
679   window->startmaximized = options_get_bool(machine->options(), SDLOPTION_MAXIMIZE);
679   window->startmaximized = options_get_bool(&machine->options(), SDLOPTION_MAXIMIZE);
680680
681681   if (!window->fullscreen)
682682   {
r10384r10385
699699
700700   // set the specific view
701701   sprintf(option, SDLOPTION_VIEW("%d"), index);
702   set_starting_view(machine, index, window, options_get_string(machine->options(), option));
702   set_starting_view(machine, index, window, options_get_string(&machine->options(), option));
703703
704704   // make the window title
705705   if (video_config.numscreens == 1)
r10384r10385
10121012
10131013static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *view)
10141014{
1015   const char *defview = options_get_string(machine->options(), SDLOPTION_VIEW( ));
1015   const char *defview = options_get_string(&machine->options(), SDLOPTION_VIEW( ));
10161016   int viewindex;
10171017
10181018   ASSERT_MAIN_THREAD();
src/osd/sdl/window.h
r10384r10385
9696#if (SDL_VERSION_ATLEAST(1,3,0))
9797   // Needs to be here as well so we can identify window
9898   SDL_Window         *sdl_window;
99   SDL_Renderer       *sdl_renderer;
99100   // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
100101   int             resize_width;
101102   int               resize_height;
r10384r10385
146147// PROTOTYPES - drawogl.c
147148//============================================================
148149
149int drawogl_init(sdl_draw_info *callbacks);
150int drawogl_init(running_machine &machine, sdl_draw_info *callbacks);
150151
151152//============================================================
152153// PROTOTYPES - draw13.c
153154//============================================================
154155
155int draw13_init(sdl_draw_info *callbacks);
156int draw13_init(running_machine &machine, sdl_draw_info *callbacks);
156157
157158#endif /* __SDLWINDOW__ */
src/osd/osdcore.h
r10384r10385
117117
118118    Notes:
119119
120        This function is called by mame_fopen and several other places in
120        This function is called by core_fopen and several other places in
121121        the core to access files. These functions will construct paths by
122122        concatenating various search paths held in the options.c options
123123        database with partial paths specified by the core. The core assumes
src/osd/windows/drawnone.c
r10384r10385
6868//  drawnone_init
6969//============================================================
7070
71int drawnone_init(win_draw_callbacks *callbacks)
71int drawnone_init(running_machine &machine, win_draw_callbacks *callbacks)
7272{
7373   // fill in the callbacks
7474   callbacks->exit = drawnone_exit;
src/osd/windows/drawgdi.c
r10384r10385
8787//  drawgdi_init
8888//============================================================
8989
90int drawgdi_init(win_draw_callbacks *callbacks)
90int drawgdi_init(running_machine &machine, win_draw_callbacks *callbacks)
9191{
9292   // fill in the callbacks
9393   callbacks->exit = drawgdi_exit;
src/osd/windows/sound.c
r10384r10385
115115void winsound_init(running_machine *machine)
116116{
117117   // if no sound, don't create anything
118   if (!options_get_bool(machine->options(), OPTION_SOUND))
118   if (!options_get_bool(&machine->options(), OPTION_SOUND))
119119      return;
120120
121121   // ensure we get called on the way out
r10384r10385
305305   stream_format.nAvgBytesPerSec   = stream_format.nSamplesPerSec * stream_format.nBlockAlign;
306306
307307   // compute the buffer size based on the output sample rate
308   stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * options_get_int(machine->options(), WINOPTION_AUDIO_LATENCY) / 10;
308   stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * options_get_int(&machine->options(), WINOPTION_AUDIO_LATENCY) / 10;
309309   stream_buffer_size = (stream_buffer_size / 1024) * 1024;
310310   if (stream_buffer_size < 1024)
311311      stream_buffer_size = 1024;
src/osd/windows/input.c
r10384r10385
508508   assert_always(input_lock != NULL, "Failed to allocate input_lock");
509509
510510   // decode the options
511   lightgun_shared_axis_mode = options_get_bool(machine->options(), WINOPTION_DUAL_LIGHTGUN);
511   lightgun_shared_axis_mode = options_get_bool(&machine->options(), WINOPTION_DUAL_LIGHTGUN);
512512
513513   // initialize RawInput and DirectInput (RawInput first so we can fall back)
514514   rawinput_init(machine);
src/osd/windows/winmain.c
r10384r10385
518518   const char *stemp;
519519
520520   // determine if we are benchmarking, and adjust options appropriately
521   int bench = options_get_int(machine.options(), WINOPTION_BENCH);
521   int bench = options_get_int(&machine.options(), WINOPTION_BENCH);
522522   if (bench > 0)
523523   {
524      options_set_bool(machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
525      options_set_bool(machine.options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM);
526      options_set_string(machine.options(), WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM);
527      options_set_int(machine.options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM);
524      options_set_bool(&machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
525      options_set_bool(&machine.options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM);
526      options_set_string(&machine.options(), WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM);
527      options_set_int(&machine.options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM);
528528   }
529529
530530   // determine if we are profiling, and adjust options appropriately
531   int profile = options_get_int(machine.options(), WINOPTION_PROFILE);
531   int profile = options_get_int(&machine.options(), WINOPTION_PROFILE);
532532   if (profile > 0)
533533   {
534      options_set_bool(machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
535      options_set_bool(machine.options(), WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM);
536      options_set_int(machine.options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM);
534      options_set_bool(&machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM);
535      options_set_bool(&machine.options(), WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM);
536      options_set_int(&machine.options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM);
537537   }
538538
539539   // thread priority
540540   if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED))
541      SetThreadPriority(GetCurrentThread(), options_get_int(machine.options(), WINOPTION_PRIORITY));
541      SetThreadPriority(GetCurrentThread(), options_get_int(&machine.options(), WINOPTION_PRIORITY));
542542
543543   // ensure we get called on the way out
544544   machine.add_notifier(MACHINE_NOTIFY_EXIT, osd_exit);
545545
546546   // get number of processors
547   stemp = options_get_string(machine.options(), WINOPTION_NUMPROCESSORS);
547   stemp = options_get_string(&machine.options(), WINOPTION_NUMPROCESSORS);
548548
549549   osd_num_processors = 0;
550550
r10384r10385
573573   }
574574
575575   // hook up the debugger log
576   if (options_get_bool(machine.options(), WINOPTION_OSLOG))
576   if (options_get_bool(&machine.options(), WINOPTION_OSLOG))
577577      machine.add_logerror_callback(output_oslog);
578578
579579   // crank up the multimedia timer resolution to its max
r10384r10385
587587//          mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index);
588588
589589   // if a watchdog thread is requested, create one
590   int watchdog = options_get_int(machine.options(), WINOPTION_WATCHDOG);
590   int watchdog = options_get_int(&machine.options(), WINOPTION_WATCHDOG);
591591   if (watchdog != 0)
592592   {
593593      watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL);
src/osd/windows/debugwin.c
r10384r10385
381381//  debugwin_init_windows
382382//============================================================
383383
384void debugwin_init_windows(void)
384void debugwin_init_windows(running_machine &machine)
385385{
386386   static int class_registered;
387387
r10384r10385
427427
428428      if (temp_dc != NULL)
429429      {
430         int size = options_get_int(mame_options(), WINOPTION_DEBUGGER_FONT_SIZE);
430         int size = options_get_int(&machine.options(), WINOPTION_DEBUGGER_FONT_SIZE);
431431         TCHAR *t_face;
432432
433433         // create a standard font
434         t_face = tstring_from_utf8(options_get_string(mame_options(), WINOPTION_DEBUGGER_FONT));
434         t_face = tstring_from_utf8(options_get_string(&machine.options(), WINOPTION_DEBUGGER_FONT));
435435         debug_font = CreateFont(-MulDiv(size, GetDeviceCaps(temp_dc, LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE,
436436                  ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, t_face);
437437         osd_free(t_face);
src/osd/windows/drawdd.c
r10384r10385
216216//  drawdd_init
217217//============================================================
218218
219int drawdd_init(win_draw_callbacks *callbacks)
219int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks)
220220{
221221   // dynamically grab the create function from ddraw.dll
222222   dllhandle = LoadLibrary(TEXT("ddraw.dll"));
r10384r10385
613613   if (window->fullscreen)
614614   {
615615      // only set the gamma if it's not 1.0f
616      float brightness = options_get_float(mame_options(), WINOPTION_FULLSCREENBRIGHTNESS);
617      float contrast = options_get_float(mame_options(), WINOPTION_FULLLSCREENCONTRAST);
618      float gamma = options_get_float(mame_options(), WINOPTION_FULLSCREENGAMMA);
616      float brightness = options_get_float(&window->machine->options(), WINOPTION_FULLSCREENBRIGHTNESS);
617      float contrast = options_get_float(&window->machine->options(), WINOPTION_FULLLSCREENCONTRAST);
618      float gamma = options_get_float(&window->machine->options(), WINOPTION_FULLSCREENGAMMA);
619619      if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f)
620620      {
621621         // see if we can get a GammaControl object
src/osd/windows/video.c
r10384r10385
9292static void winvideo_exit(running_machine &machine);
9393static void init_monitors(void);
9494static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
95static win_monitor_info *pick_monitor(int index);
95static win_monitor_info *pick_monitor(core_options &options, int index);
9696
9797static void check_osd_inputs(running_machine *machine);
9898
9999static void extract_video_config(running_machine *machine);
100static float get_aspect(const char *name, int report_error);
101static void get_resolution(const char *name, win_window_config *config, int report_error);
100static float get_aspect(core_options &options, const char *name, int report_error);
101static void get_resolution(core_options &options, const char *name, win_window_config *config, int report_error);
102102
103103
104104
r10384r10385
124124
125125   // create the windows
126126   for (index = 0; index < video_config.numscreens; index++)
127      winwindow_video_window_create(machine, index, pick_monitor(index), &video_config.window[index]);
127      winwindow_video_window_create(machine, index, pick_monitor(machine->options(), index), &video_config.window[index]);
128128   if (video_config.mode != VIDEO_MODE_NONE)
129129      SetForegroundWindow(win_window_list->hwnd);
130130
131131   // possibly create the debug window, but don't show it yet
132132   if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)
133      debugwin_init_windows();
133      debugwin_init_windows(*machine);
134134}
135135
136136
r10384r10385
300300//  pick_monitor
301301//============================================================
302302
303static win_monitor_info *pick_monitor(int index)
303static win_monitor_info *pick_monitor(core_options &options, int index)
304304{
305305   const char *scrname, *scrname2;
306306   win_monitor_info *monitor;
r10384r10385
309309   float aspect;
310310
311311   // get the screen option
312   scrname = options_get_string(mame_options(), WINOPTION_SCREEN);
312   scrname = options_get_string(&options, WINOPTION_SCREEN);
313313   sprintf(option, "screen%d", index);
314   scrname2 = options_get_string(mame_options(), option);
314   scrname2 = options_get_string(&options, option);
315315
316316   // decide which one we want to use
317317   if (strcmp(scrname2, "auto") != 0)
r10384r10385
319319
320320   // get the aspect ratio
321321   sprintf(option, "aspect%d", index);
322   aspect = get_aspect(option, TRUE);
322   aspect = get_aspect(options, option, TRUE);
323323
324324   // look for a match in the name first
325325   if (scrname[0] != 0)
r10384r10385
379379   const char *stemp;
380380
381381   // global options: extract the data
382   video_config.windowed      = options_get_bool(machine->options(), WINOPTION_WINDOW);
383   video_config.prescale      = options_get_int(machine->options(), WINOPTION_PRESCALE);
384   video_config.keepaspect    = options_get_bool(machine->options(), WINOPTION_KEEPASPECT);
385   video_config.numscreens    = options_get_int(machine->options(), WINOPTION_NUMSCREENS);
382   video_config.windowed      = options_get_bool(&machine->options(), WINOPTION_WINDOW);
383   video_config.prescale      = options_get_int(&machine->options(), WINOPTION_PRESCALE);
384   video_config.keepaspect    = options_get_bool(&machine->options(), WINOPTION_KEEPASPECT);
385   video_config.numscreens    = options_get_int(&machine->options(), WINOPTION_NUMSCREENS);
386386
387387   // if we are in debug mode, never go full screen
388388   if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)
389389      video_config.windowed = TRUE;
390390
391391   // per-window options: extract the data
392   get_resolution(WINOPTION_RESOLUTION0, &video_config.window[0], TRUE);
393   get_resolution(WINOPTION_RESOLUTION1, &video_config.window[1], TRUE);
394   get_resolution(WINOPTION_RESOLUTION2, &video_config.window[2], TRUE);
395   get_resolution(WINOPTION_RESOLUTION3, &video_config.window[3], TRUE);
392   get_resolution(machine->options(), WINOPTION_RESOLUTION0, &video_config.window[0], TRUE);
393   get_resolution(machine->options(), WINOPTION_RESOLUTION1, &video_config.window[1], TRUE);
394   get_resolution(machine->options(), WINOPTION_RESOLUTION2, &video_config.window[2], TRUE);
395   get_resolution(machine->options(), WINOPTION_RESOLUTION3, &video_config.window[3], TRUE);
396396
397397   // video options: extract the data
398   stemp = options_get_string(machine->options(), WINOPTION_VIDEO);
398   stemp = options_get_string(&machine->options(), WINOPTION_VIDEO);
399399   if (strcmp(stemp, "d3d") == 0)
400400      video_config.mode = VIDEO_MODE_D3D;
401401   else if (strcmp(stemp, "ddraw") == 0)
r10384r10385
405405   else if (strcmp(stemp, "none") == 0)
406406   {
407407      video_config.mode = VIDEO_MODE_NONE;
408      if (options_get_int(machine->options(), OPTION_SECONDS_TO_RUN) == 0)
408      if (options_get_int(&machine->options(), OPTION_SECONDS_TO_RUN) == 0)
409409         mame_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
410410   }
411411   else
r10384r10385
413413      mame_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
414414      video_config.mode = VIDEO_MODE_GDI;
415415   }
416   video_config.waitvsync     = options_get_bool(machine->options(), WINOPTION_WAITVSYNC);
417   video_config.syncrefresh   = options_get_bool(machine->options(), WINOPTION_SYNCREFRESH);
418   video_config.triplebuf     = options_get_bool(machine->options(), WINOPTION_TRIPLEBUFFER);
419   video_config.switchres     = options_get_bool(machine->options(), WINOPTION_SWITCHRES);
416   video_config.waitvsync     = options_get_bool(&machine->options(), WINOPTION_WAITVSYNC);
417   video_config.syncrefresh   = options_get_bool(&machine->options(), WINOPTION_SYNCREFRESH);
418   video_config.triplebuf     = options_get_bool(&machine->options(), WINOPTION_TRIPLEBUFFER);
419   video_config.switchres     = options_get_bool(&machine->options(), WINOPTION_SWITCHRES);
420420
421421   // ddraw options: extract the data
422   video_config.hwstretch     = options_get_bool(machine->options(), WINOPTION_HWSTRETCH);
422   video_config.hwstretch     = options_get_bool(&machine->options(), WINOPTION_HWSTRETCH);
423423
424424   // d3d options: extract the data
425   video_config.filter        = options_get_bool(machine->options(), WINOPTION_FILTER);
425   video_config.filter        = options_get_bool(&machine->options(), WINOPTION_FILTER);
426426   if (video_config.prescale == 0)
427427      video_config.prescale = 1;
428428
r10384r10385
431431   // per-window options: sanity check values
432432
433433   // d3d options: sanity check values
434   options_get_int(machine->options(), WINOPTION_D3DVERSION);
434   options_get_int(&machine->options(), WINOPTION_D3DVERSION);
435435
436   options_get_float(machine->options(), WINOPTION_FULLSCREENBRIGHTNESS);
437   options_get_float(machine->options(), WINOPTION_FULLLSCREENCONTRAST);
438   options_get_float(machine->options(), WINOPTION_FULLSCREENGAMMA);
436   options_get_float(&machine->options(), WINOPTION_FULLSCREENBRIGHTNESS);
437   options_get_float(&machine->options(), WINOPTION_FULLLSCREENCONTRAST);
438   options_get_float(&machine->options(), WINOPTION_FULLSCREENGAMMA);
439439}
440440
441441
r10384r10385
444444//  get_aspect
445445//============================================================
446446
447static float get_aspect(const char *name, int report_error)
447static float get_aspect(core_options &options, const char *name, int report_error)
448448{
449   const char *defdata = options_get_string(mame_options(), WINOPTION_ASPECT);
450   const char *data = options_get_string(mame_options(), name);
449   const char *defdata = options_get_string(&options, WINOPTION_ASPECT);
450   const char *data = options_get_string(&options, name);
451451   int num = 0, den = 1;
452452
453453   if (strcmp(data, "auto") == 0)
r10384r10385
467467//  get_resolution
468468//============================================================
469469
470static void get_resolution(const char *name, win_window_config *config, int report_error)
470static void get_resolution(core_options &options, const char *name, win_window_config *config, int report_error)
471471{
472   const char *defdata = options_get_string(mame_options(), WINOPTION_RESOLUTION);
473   const char *data = options_get_string(mame_options(), name);
472   const char *defdata = options_get_string(&options, WINOPTION_RESOLUTION);
473   const char *data = options_get_string(&options, name);
474474
475475   config->width = config->height = config->refresh = 0;
476476   if (strcmp(data, "auto") == 0)
src/osd/windows/window.c
r10384r10385
6969#include "config.h"
7070#include "winutf8.h"
7171
72extern int drawnone_init(win_draw_callbacks *callbacks);
73extern int drawgdi_init(win_draw_callbacks *callbacks);
74extern int drawdd_init(win_draw_callbacks *callbacks);
75extern int drawd3d_init(win_draw_callbacks *callbacks);
72extern int drawnone_init(running_machine &machine, win_draw_callbacks *callbacks);
73extern int drawgdi_init(running_machine &machine, win_draw_callbacks *callbacks);
74extern int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks);
75extern int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks);
7676
7777
7878//============================================================
r10384r10385
224224   size_t temp;
225225
226226   // determine if we are using multithreading or not
227   multithreading_enabled = options_get_bool(machine->options(), WINOPTION_MULTITHREADING);
227   multithreading_enabled = options_get_bool(&machine->options(), WINOPTION_MULTITHREADING);
228228
229229   // get the main thread ID before anything else
230230   main_threadid = GetCurrentThreadId();
r10384r10385
268268   // initialize the drawers
269269   if (video_config.mode == VIDEO_MODE_D3D)
270270   {
271      if (drawd3d_init(&draw))
271      if (drawd3d_init(*machine, &draw))
272272         video_config.mode = VIDEO_MODE_GDI;
273273   }
274274   if (video_config.mode == VIDEO_MODE_DDRAW)
275275   {
276      if (drawdd_init(&draw))
276      if (drawdd_init(*machine, &draw))
277277         video_config.mode = VIDEO_MODE_GDI;
278278   }
279279   if (video_config.mode == VIDEO_MODE_GDI)
280      drawgdi_init(&draw);
280      drawgdi_init(*machine, &draw);
281281   if (video_config.mode == VIDEO_MODE_NONE)
282      drawnone_init(&draw);
282      drawnone_init(*machine, &draw);
283283
284284   // set up the window list
285285   last_window_ptr = &win_window_list;
r10384r10385
636636
637637   // set the specific view
638638   sprintf(option, "view%d", index);
639   set_starting_view(index, window, options_get_string(machine->options(), option));
639   set_starting_view(index, window, options_get_string(&machine->options(), option));
640640
641641   // remember the current values in case they change
642642   window->targetview = window->target->view();
r10384r10385
650650      sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine->gamedrv->description, machine->gamedrv->name, index);
651651
652652   // set the initial maximized state
653   window->startmaximized = options_get_bool(machine->options(), WINOPTION_MAXIMIZE);
653   window->startmaximized = options_get_bool(&machine->options(), WINOPTION_MAXIMIZE);
654654
655655   // finish the window creation on the window thread
656656   if (multithreading_enabled)
r10384r10385
850850
851851static void set_starting_view(int index, win_window_info *window, const char *view)
852852{
853   const char *defview = options_get_string(mame_options(), WINOPTION_VIEW);
853   const char *defview = options_get_string(&window->machine->options(), WINOPTION_VIEW);
854854   int viewindex;
855855
856856   assert(GetCurrentThreadId() == main_threadid);
r10384r10385
11211121   monitorbounds = window->monitor->info.rcMonitor;
11221122
11231123   // create the window menu if needed
1124   if (options_get_bool(mame_options(), "menu")) {
1124   if (options_get_bool(&window->machine->options(), "menu")) {
11251125      if (win_create_menu(window->machine, &menu))
11261126         return 1;
11271127   }
src/osd/windows/debugwin.h
r10384r10385
5555//  PROTOTYPES
5656//============================================================
5757
58void debugwin_init_windows(void);
58void debugwin_init_windows(running_machine &machine);
5959void debugwin_destroy_windows(void);
6060void debugwin_show(int type);
6161void debugwin_update_during_game(running_machine *machine);
src/osd/windows/drawd3d.c
r10384r10385
478478//  drawd3d_init
479479//============================================================
480480
481int drawd3d_init(win_draw_callbacks *callbacks)
481int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks)
482482{
483   int version = options_get_int(mame_options(), WINOPTION_D3DVERSION);
483   int version = options_get_int(&machine.options(), WINOPTION_D3DVERSION);
484484   d3dintf = NULL;
485485
486486   // try Direct3D 9 if requested
r10384r10385
537537
538538   // experimental: load a PNG to use for vector rendering; it is treated
539539   // as a brightness map
540   d3d->vector_bitmap = render_load_png(OPTION_ARTPATH, NULL, "vector.png", NULL, NULL);
540   emu_file file(window->machine->options(), OPTION_ARTPATH, OPEN_FLAG_READ);
541   d3d->vector_bitmap = render_load_png(file, NULL, "vector.png", NULL, NULL);
541542   if (d3d->vector_bitmap != NULL)
542543   {
543544      bitmap_fill(d3d->vector_bitmap, NULL, MAKE_ARGB(0xff,0xff,0xff,0xff));
544      d3d->vector_bitmap = render_load_png(OPTION_ARTPATH, NULL, "vector.png", d3d->vector_bitmap, NULL);
545      d3d->vector_bitmap = render_load_png(file, NULL, "vector.png", d3d->vector_bitmap, NULL);
545546   }
546547
547548   // configure the adapter for the mode we want
r10384r10385
806807   if (window->fullscreen)
807808   {
808809      // only set the gamma if it's not 1.0f
809      float brightness = options_get_float(mame_options(), WINOPTION_FULLSCREENBRIGHTNESS);
810      float contrast = options_get_float(mame_options(), WINOPTION_FULLLSCREENCONTRAST);
811      float gamma = options_get_float(mame_options(), WINOPTION_FULLSCREENGAMMA);
810      float brightness = options_get_float(&window->machine->options(), WINOPTION_FULLSCREENBRIGHTNESS);
811      float contrast = options_get_float(&window->machine->options(), WINOPTION_FULLLSCREENCONTRAST);
812      float gamma = options_get_float(&window->machine->options(), WINOPTION_FULLSCREENGAMMA);
812813      if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f)
813814      {
814815         // warn if we can't do it
src/emu/debug/debugcpu.c
r10384r10385
359359      // flush the file
360360      if (found_comments)
361361      {
362         astring fname(machine->basename(), ".cmt");
363         mame_file *fp;
364         file_error filerr = mame_fopen(SEARCHPATH_COMMENT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
365
362         emu_file file(machine->options(), SEARCHPATH_COMMENT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
363         file_error filerr = file.open(machine->basename(), ".cmt");
366364         if (filerr == FILERR_NONE)
367         {
368            xml_file_write(root, mame_core_file(fp));
369            mame_fclose(fp);
370         }
365            xml_file_write(root, file);
371366      }
372367   }
373368   catch (emu_exception &)
r10384r10385
390385bool debug_comment_load(running_machine *machine)
391386{
392387   // open the file
393   astring fname(machine->basename(), ".cmt");
394   mame_file *fp;
395   file_error filerr = mame_fopen(SEARCHPATH_COMMENT, fname, OPEN_FLAG_READ, &fp);
388   emu_file file(machine->options(), SEARCHPATH_COMMENT, OPEN_FLAG_READ);
389   file_error filerr = file.open(machine->basename(), ".cmt");
396390
397391   // if an error, just return false
398392   if (filerr != FILERR_NONE)
399393      return false;
400394
401395   // wrap in a try/catch to handle errors
402   xml_data_node *root = xml_file_read(mame_core_file(fp), NULL);
396   xml_data_node *root = xml_file_read(file, NULL);
403397   try
404398   {
405399      // read the file
r10384r10385
436430      // clean up in case of error
437431      if (root != NULL)
438432         xml_file_free(root);
439      mame_fclose(fp);
440433      return false;
441434   }
442435
443436   // free the parser
444437   xml_file_free(root);
445   mame_fclose(fp);
446438   return true;
447439}
448440
src/emu/debug/debugcmd.c
r10384r10385
372372   machine->add_notifier(MACHINE_NOTIFY_EXIT, debug_command_exit);
373373
374374   /* set up the initial debugscript if specified */
375   name = options_get_string(machine->options(), OPTION_DEBUGSCRIPT);
375   name = options_get_string(&machine->options(), OPTION_DEBUGSCRIPT);
376376   if (name[0] != 0)
377377      debug_cpu_source_script(machine, name);
378378}
r10384r10385
24892489   /* otherwise, we have to open the file ourselves */
24902490   else
24912491   {
2492      file_error filerr;
2493      mame_file *fp;
24942492      const char *filename = param[0];
24952493      int scrnum = (params > 1) ? atoi(param[1]) : 0;
24962494
r10384r10385
25052503      astring fname(filename);
25062504      if (fname.find(0, ".png") == -1)
25072505         fname.cat(".png");
2508      filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
2506      emu_file file(machine->options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
2507      file_error filerr = file.open(fname);
25092508
25102509      if (filerr != FILERR_NONE)
25112510      {
r10384r10385
25132512         return;
25142513      }
25152514
2516      screen->machine->video().save_snapshot(screen, *fp);
2517      mame_fclose(fp);
2515      screen->machine->video().save_snapshot(screen, file);
25182516      debug_console_printf(machine, "Saved screen #%d snapshot as '%s'\n", scrnum, filename);
25192517   }
25202518}
src/emu/dinvram.h
r10384r10385
8080
8181   // public accessors... for now
8282   void nvram_reset() { nvram_default(); }
83   void nvram_load(mame_file &file) { nvram_read(file); }
84   void nvram_save(mame_file &file) { nvram_write(file); }
83   void nvram_load(emu_file &file) { nvram_read(file); }
84   void nvram_save(emu_file &file) { nvram_write(file); }
8585
8686protected:
8787   // derived class overrides
8888   virtual void nvram_default() = 0;
89   virtual void nvram_read(mame_file &file) = 0;
90   virtual void nvram_write(mame_file &file) = 0;
89   virtual void nvram_read(emu_file &file) = 0;
90   virtual void nvram_write(emu_file &file) = 0;
9191
9292   // configuration
9393   const device_config_nvram_interface &m_nvram_config;   // reference to our device_config_execute_interface
src/emu/video/vector.c
r10384r10385
175175
176176VIDEO_START( vector )
177177{
178   beam_width = options_get_float(machine->options(), OPTION_BEAM);
178   beam_width = options_get_float(&machine->options(), OPTION_BEAM);
179179
180180   /* Grab the settings for this session */
181   vector_set_flicker(options_get_float(machine->options(), OPTION_FLICKER));
181   vector_set_flicker(options_get_float(&machine->options(), OPTION_FLICKER));
182182
183183   vector_index = 0;
184184
r10384r10385
256256
257257VIDEO_UPDATE( vector )
258258{
259   UINT32 flags = PRIMFLAG_ANTIALIAS(options_get_bool(screen->machine->options(), OPTION_ANTIALIAS) ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD);
259   UINT32 flags = PRIMFLAG_ANTIALIAS(options_get_bool(&screen->machine->options(), OPTION_ANTIALIAS) ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD);
260260   const rectangle &visarea = screen->visible_area();
261261   float xscale = 1.0f / (65536 * (visarea.max_x - visarea.min_x));
262262   float yscale = 1.0f / (65536 * (visarea.max_y - visarea.min_y));
src/emu/emuopts.c
r10384r10385
213213{
214214   const char *result = NULL;
215215
216   if (options_get_bool(image->device().machine->options(), OPTION_ADDED_DEVICE_OPTIONS))
216   if (options_get_bool(&image->device().machine->options(), OPTION_ADDED_DEVICE_OPTIONS))
217217   {
218218      /* access the option */
219      result = options_get_string_priority(image->device().machine->options(),  image->image_config().instance_name(), OPTION_PRIORITY_DRIVER_INI);
219      result = options_get_string_priority(&image->device().machine->options(),  image->image_config().instance_name(), OPTION_PRIORITY_DRIVER_INI);
220220   }
221221   return result;
222222}
src/emu/uimenu.c
r10384r10385
14051405
14061406void ui_menu_force_game_select(running_machine *machine, render_container *container)
14071407{
1408   char *gamename = (char *)options_get_string(machine->options(), OPTION_GAMENAME);
1408   char *gamename = (char *)options_get_string(&machine->options(), OPTION_GAMENAME);
14091409
14101410   /* reset the menu stack */
14111411   ui_menu_stack_reset(machine);
r10384r10385
15701570      ui_menu_item_append(menu, "Crosshair Options", NULL, 0, (void *)menu_crosshair);
15711571
15721572   /* add cheat menu */
1573   if (options_get_bool(machine->options(), OPTION_CHEAT) && machine->cheat().first() != NULL)
1573   if (options_get_bool(&machine->options(), OPTION_CHEAT) && machine->cheat().first() != NULL)
15741574      ui_menu_item_append(menu, "Cheat", NULL, 0, (void *)menu_cheat);
15751575
15761576   /* add memory card menu */
r10384r10385
32543254   int player;
32553255   UINT8 use_auto = FALSE;
32563256   UINT32 flags = 0;
3257   mame_path *path;
32583257
32593258   /* loop over player and add the manual items */
32603259   for (player = 0; player < MAX_PLAYERS; player++)
r10384r10385
33003299         /* search for crosshair graphics */
33013300
33023301         /* open a path to the crosshairs */
3303         path = mame_openpath(machine->options(), OPTION_CROSSHAIRPATH);
3304         if (path != NULL)
3305         {
3306            const osd_directory_entry *dir;
3302         file_enumerator path(machine->options(), OPTION_CROSSHAIRPATH);
3303         const osd_directory_entry *dir;
3304         /* reset search flags */
3305         int using_default = FALSE;
3306         int finished = FALSE;
3307         int found = FALSE;
33073308
3308            /* reset search flags */
3309            int using_default = FALSE;
3310            int finished = FALSE;
3311            int found = FALSE;
3309         /* if we are using the default, then we just need to find the first in the list */
3310         if (strlen(settings.name) == 0)
3311            using_default = TRUE;
33123312
3313            /* if we are using the default, then we just need to find the first in the list */
3314            if (strlen(settings.name) == 0)
3315               using_default = TRUE;
3313         /* look for the current name, then remember the name before */
3314         /* and find the next name */
3315         while (((dir = path.next()) != NULL) && !finished)
3316         {
3317            int length = strlen(dir->name);
33163318
3317            /* look for the current name, then remember the name before */
3318            /* and find the next name */
3319            while (((dir = mame_readpath(path)) != NULL) && !finished)
3319            /* look for files ending in .png with a name not larger then 9 chars*/
3320            if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) &&
3321               dir->name[length - 4] == '.' &&
3322               tolower((UINT8)dir->name[length - 3]) == 'p' &&
3323               tolower((UINT8)dir->name[length - 2]) == 'n' &&
3324               tolower((UINT8)dir->name[length - 1]) == 'g')
3325
33203326            {
3321               int length = strlen(dir->name);
3327               /* remove .png from length */
3328               length -= 4;
33223329
3323               /* look for files ending in .png with a name not larger then 9 chars*/
3324               if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) &&
3325                  dir->name[length - 4] == '.' &&
3326                  tolower((UINT8)dir->name[length - 3]) == 'p' &&
3327                  tolower((UINT8)dir->name[length - 2]) == 'n' &&
3328                  tolower((UINT8)dir->name[length - 1]) == 'g')
3329
3330               if (found || using_default)
33303331               {
3331                  /* remove .png from length */
3332                  length -= 4;
3333
3334                  if (found || using_default)
3335                  {
3336                     /* get the next name */
3337                     strncpy(data->next_name, dir->name, length);
3338                     data->next_name[length] = 0;
3339                     finished = TRUE;
3340                  }
3341                  else if (!strncmp(dir->name, settings.name, length))
3342                  {
3343                     /* we found the current name */
3344                     /* so loop once more to find the next name */
3345                     found = TRUE;
3346                  }
3347                  else
3348                     /* remember last name */
3349                     /* we will do it here in case files get added to the directory */
3350                  {
3351                     strncpy(data->last_name, dir->name, length);
3352                     data->last_name[length] = 0;
3353                  }
3332                  /* get the next name */
3333                  strncpy(data->next_name, dir->name, length);
3334                  data->next_name[length] = 0;
3335                  finished = TRUE;
33543336               }
3337               else if (!strncmp(dir->name, settings.name, length))
3338               {
3339                  /* we found the current name */
3340                  /* so loop once more to find the next name */
3341                  found = TRUE;
3342               }
3343               else
3344                  /* remember last name */
3345                  /* we will do it here in case files get added to the directory */
3346               {
3347                  strncpy(data->last_name, dir->name, length);
3348                  data->last_name[length] = 0;
3349               }
33553350            }
3356            /* if name not found then next item is DEFAULT */
3357            if (!found && !using_default)
3358            {
3359               data->next_name[0] = 0;
3360               finished = TRUE;
3361            }
3362            /* setup the selection flags */
3363            flags = 0;
3364            if (finished)
3365               flags |= MENU_FLAG_RIGHT_ARROW;
3366            if (found)
3367               flags |= MENU_FLAG_LEFT_ARROW;
3368
3369            /* add CROSSHAIR_ITEM_PIC menu */
3370            sprintf(temp_text, "P%d Crosshair", player + 1);
3371            ui_menu_item_append(menu, temp_text, using_default ? "DEFAULT" : settings.name, flags, data);
33723351         }
3352         /* if name not found then next item is DEFAULT */
3353         if (!found && !using_default)
3354         {
3355            data->next_name[0] = 0;
3356            finished = TRUE;
3357         }
3358         /* setup the selection flags */
3359         flags = 0;
3360         if (finished)
3361            flags |= MENU_FLAG_RIGHT_ARROW;
3362         if (found)
3363            flags |= MENU_FLAG_LEFT_ARROW;
3364
3365         /* add CROSSHAIR_ITEM_PIC menu */
3366         sprintf(temp_text, "P%d Crosshair", player + 1);
3367         ui_menu_item_append(menu, temp_text, using_default ? "DEFAULT" : settings.name, flags, data);
33733368      }
33743369   }
33753370   if (use_auto)
r10384r10385
34673462            int audit_result;
34683463
34693464            /* audit the game first to see if we're going to work */
3470            audit_records = audit_images(menu->machine->options(), driver, AUDIT_VALIDATE_FAST, &audit);
3465            audit_records = audit_images(&menu->machine->options(), driver, AUDIT_VALIDATE_FAST, &audit);
34713466            audit_result = audit_summary(driver, audit_records, audit, FALSE);
34723467            if (audit_records > 0)
34733468               global_free(audit);
r10384r10385
36083603{
36093604   int driver_count = driver_list_get_count(drivers);
36103605   int drivnum, listnum;
3611   mame_path *path;
36123606   UINT8 *found;
36133607
36143608   /* create a sorted copy of the main driver list */
r10384r10385
36203614   memset(found, 0, (driver_count + 7) / 8);
36213615
36223616   /* open a path to the ROMs and find them in the array */
3623   path = mame_openpath(menu->machine->options(), OPTION_ROMPATH);
3624   if (path != NULL)
3617   file_enumerator path(menu->machine->options(), OPTION_ROMPATH);
3618   const osd_directory_entry *dir;
3619
3620   /* iterate while we get new objects */
3621   while ((dir = path.next()) != NULL)
36253622   {
3626      const osd_directory_entry *dir;
3623      game_driver tempdriver;
3624      game_driver *tempdriver_ptr;
3625      const game_driver **found_driver;
3626      char drivername[50];
3627      char *dst = drivername;
3628      const char *src;
36273629
3628      /* iterate while we get new objects */
3629      while ((dir = mame_readpath(path)) != NULL)
3630      {
3631         game_driver tempdriver;
3632         game_driver *tempdriver_ptr;
3633         const game_driver **found_driver;
3634         char drivername[50];
3635         char *dst = drivername;
3636         const char *src;
3630      /* build a name for it */
3631      for (src = dir->name; *src != 0 && *src != '.' && dst < &drivername[ARRAY_LENGTH(drivername) - 1]; src++)
3632         *dst++ = tolower((UINT8)*src);
3633      *dst = 0;
36373634
3638         /* build a name for it */
3639         for (src = dir->name; *src != 0 && *src != '.' && dst < &drivername[ARRAY_LENGTH(drivername) - 1]; src++)
3640            *dst++ = tolower((UINT8)*src);
3641         *dst = 0;
3635      /* find it in the array */
3636      tempdriver.name = drivername;
3637      tempdriver_ptr = &tempdriver;
3638      found_driver = (const game_driver **)bsearch(&tempdriver_ptr, menustate->driverlist, driver_count, sizeof(*menustate->driverlist), menu_select_game_driver_compare);
36423639
3643         /* find it in the array */
3644         tempdriver.name = drivername;
3645         tempdriver_ptr = &tempdriver;
3646         found_driver = (const game_driver **)bsearch(&tempdriver_ptr, menustate->driverlist, driver_count, sizeof(*menustate->driverlist), menu_select_game_driver_compare);
3647
3648         /* if found, mark the corresponding entry in the array */
3649         if (found_driver != NULL)
3650         {
3651            int index = found_driver - menustate->driverlist;
3652            found[index / 8] |= 1 << (index % 8);
3653         }
3640      /* if found, mark the corresponding entry in the array */
3641      if (found_driver != NULL)
3642      {
3643         int index = found_driver - menustate->driverlist;
3644         found[index / 8] |= 1 << (index % 8);
36543645      }
3655      mame_closepath(path);
36563646   }
36573647
36583648   /* now build the final list */
src/emu/video.c
r10384r10385
112112     m_overall_real_ticks(0),
113113     m_overall_emutime(attotime::zero),
114114     m_overall_valid_counter(0),
115     m_throttle(options_get_bool(machine.options(), OPTION_THROTTLE)),
115     m_throttle(options_get_bool(&machine.options(), OPTION_THROTTLE)),
116116     m_fastforward(false),
117     m_seconds_to_run(options_get_int(machine.options(), OPTION_SECONDS_TO_RUN)),
118     m_auto_frameskip(options_get_bool(machine.options(), OPTION_AUTOFRAMESKIP)),
117     m_seconds_to_run(options_get_int(&machine.options(), OPTION_SECONDS_TO_RUN)),
118     m_auto_frameskip(options_get_bool(&machine.options(), OPTION_AUTOFRAMESKIP)),
119119     m_speed(original_speed_setting()),
120120     m_empty_skip_count(0),
121     m_frameskip_level(options_get_int(machine.options(), OPTION_FRAMESKIP)),
121     m_frameskip_level(options_get_int(&machine.options(), OPTION_FRAMESKIP)),
122122     m_frameskip_counter(0),
123123     m_frameskip_adjust(0),
124124     m_skipping_this_frame(false),
r10384r10385
142142   update_refresh_speed();
143143
144144   // create a render target for snapshots
145   const char *viewname = options_get_string(machine.options(), OPTION_SNAPVIEW);
145   const char *viewname = options_get_string(&machine.options(), OPTION_SNAPVIEW);
146146   m_snap_native = (machine.primary_screen != NULL && (viewname[0] == 0 || strcmp(viewname, "native") == 0));
147147
148148   // the native target is hard-coded to our internal layout and has all options disabled
r10384r10385
165165   }
166166
167167   // extract snap resolution if present
168   if (sscanf(options_get_string(machine.options(), OPTION_SNAPSIZE), "%dx%d", &m_snap_width, &m_snap_height) != 2)
168   if (sscanf(options_get_string(&machine.options(), OPTION_SNAPSIZE), "%dx%d", &m_snap_width, &m_snap_height) != 2)
169169      m_snap_width = m_snap_height = 0;
170170
171171   // start recording movie if specified
172   const char *filename = options_get_string(machine.options(), OPTION_MNGWRITE);
172   const char *filename = options_get_string(&machine.options(), OPTION_MNGWRITE);
173173   if (filename[0] != 0)
174174      begin_recording(filename, MF_MNG);
175175
176   filename = options_get_string(machine.options(), OPTION_AVIWRITE);
176   filename = options_get_string(&machine.options(), OPTION_AVIWRITE);
177177   if (filename[0] != 0)
178178      begin_recording(filename, MF_AVI);
179179
r10384r10385
220220   // only render sound and video if we're in the running phase
221221   int phase = m_machine.phase();
222222   bool skipped_it = m_skipping_this_frame;
223   if (phase == MACHINE_PHASE_RUNNING && (!m_machine.paused() || options_get_bool(m_machine.options(), OPTION_UPDATEINPAUSE)))
223   if (phase == MACHINE_PHASE_RUNNING && (!m_machine.paused() || options_get_bool(&m_machine.options(), OPTION_UPDATEINPAUSE)))
224224   {
225225      bool anything_changed = finish_screen_updates();
226226
r10384r10385
325325//  file handle
326326//-------------------------------------------------
327327
328void video_manager::save_snapshot(screen_device *screen, mame_file &fp)
328void video_manager::save_snapshot(screen_device *screen, emu_file &file)
329329{
330330   // validate
331331   assert(!m_snap_native || screen != NULL);
r10384r10385
342342
343343   // now do the actual work
344344   const rgb_t *palette = (m_machine.palette != NULL) ? palette_entry_list_adjusted(m_machine.palette) : NULL;
345   png_error error = png_write_bitmap(mame_core_file(&fp), &pnginfo, m_snap_bitmap, m_machine.total_colors(), palette);
345   png_error error = png_write_bitmap(file, &pnginfo, m_snap_bitmap, m_machine.total_colors(), palette);
346346   if (error != PNGERR_NONE)
347347      mame_printf_error("Error generating PNG for snapshot: png_error = %d\n", error);
348348
r10384r10385
365365      for (screen_device *screen = m_machine.first_screen(); screen != NULL; screen = screen->next_screen())
366366         if (m_machine.render().is_live(*screen))
367367         {
368            mame_file *fp;
369            file_error filerr = mame_fopen_next(SEARCHPATH_SCREENSHOT, "png", fp);
368            emu_file file(m_machine.options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
369            file_error filerr = open_next(file, "png");
370370            if (filerr == FILERR_NONE)
371            {
372               save_snapshot(screen, *fp);
373               mame_fclose(fp);
374            }
371               save_snapshot(screen, file);
375372         }
376373   }
377374
378375   // otherwise, just write a single snapshot
379376   else
380377   {
381      mame_file *fp;
382      file_error filerr = mame_fopen_next(SEARCHPATH_SCREENSHOT, "png", fp);
378      emu_file file(m_machine.options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
379      file_error filerr = open_next(file, "png");
383380      if (filerr == FILERR_NONE)
384      {
385         save_snapshot(NULL, *fp);
386         mame_fclose(fp);
387      }
381         save_snapshot(NULL, file);
388382   }
389383}
390384
r10384r10385
427421      info.audio_samplerate = m_machine.sample_rate;
428422
429423      // create a new temporary movie file
430      mame_file *tempfile;
431424      file_error filerr;
432      if (name != NULL)
433         filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &tempfile);
434      else
435         filerr = mame_fopen_next(SEARCHPATH_MOVIE, "avi", tempfile);
425      astring fullpath;
426      {
427         emu_file tempfile(m_machine.options(), SEARCHPATH_MOVIE, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
428         if (name != NULL)
429            filerr = tempfile.open(name);
430         else
431            filerr = open_next(tempfile, "avi");
436432
437      // compute the frame time
438      m_movie_frame_period = attotime::from_seconds(1000) / info.video_timescale;
433         // compute the frame time
434         m_movie_frame_period = attotime::from_seconds(1000) / info.video_timescale;
439435
440      // if we succeeded, make a copy of the name and create the real file over top
436         // if we succeeded, make a copy of the name and create the real file over top
437         if (filerr == FILERR_NONE)
438            fullpath = tempfile.fullpath();
439      }
440
441441      if (filerr == FILERR_NONE)
442442      {
443         astring fullname(mame_file_full_name(tempfile));
444         mame_fclose(tempfile);
445
446443         // create the file and free the string
447         avi_error avierr = avi_create(fullname, &info, &m_avifile);
444         avi_error avierr = avi_create(fullpath, &info, &m_avifile);
448445         if (avierr != AVIERR_NONE)
449446            mame_printf_error("Error creating AVI: %s\n", avi_error_string(avierr));
450447      }
r10384r10385
454451   else if (format == MF_MNG)
455452   {
456453      // create a new movie file and start recording
454      m_mngfile = auto_alloc(&m_machine, emu_file(m_machine.options(), SEARCHPATH_MOVIE, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
457455      file_error filerr;
458456      if (name != NULL)
459         filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &m_mngfile);
457         filerr = m_mngfile->open(name);
460458      else
461         filerr = mame_fopen_next(SEARCHPATH_MOVIE, "mng", m_mngfile);
459         filerr = open_next(*m_mngfile, "mng");
460         
461      if (filerr == FILERR_NONE)
462      {
463         // start the capture
464         int rate = (m_machine.primary_screen != NULL) ? ATTOSECONDS_TO_HZ(m_machine.primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE;
465         png_error pngerr = mng_capture_start(*m_mngfile, m_snap_bitmap, rate);
466         if (pngerr != PNGERR_NONE)
467            return end_recording();
462468
463      // start the capture
464      int rate = (m_machine.primary_screen != NULL) ? ATTOSECONDS_TO_HZ(m_machine.primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE;
465      png_error pngerr = mng_capture_start(mame_core_file(m_mngfile), m_snap_bitmap, rate);
466      if (pngerr != PNGERR_NONE)
467         return end_recording();
468
469      // compute the frame time
470      m_movie_frame_period = attotime::from_hz(rate);
469         // compute the frame time
470         m_movie_frame_period = attotime::from_hz(rate);
471      }
472      else
473      {
474         mame_printf_error("Error creating MNG\n");
475         global_free(m_mngfile);
476         m_mngfile = NULL;
477      }
471478   }
472479}
473480
r10384r10385
488495   // close the file if it exists
489496   if (m_mngfile != NULL)
490497   {
491      mng_capture_stop(mame_core_file(m_mngfile));
492      mame_fclose(m_mngfile);
498      mng_capture_stop(*m_mngfile);
499      auto_free(&m_machine, m_mngfile);
493500      m_mngfile = NULL;
494501   }
495502
r10384r10385
642649
643650inline int video_manager::original_speed_setting() const
644651{
645   return options_get_float(mame_options(), OPTION_SPEED) * 100.0 + 0.5;
652   return options_get_float(&m_machine.options(), OPTION_SPEED) * 100.0 + 0.5;
646653}
647654
648655
r10384r10385
842849   // we're allowed to sleep via the OSD code only if we're configured to do so
843850    // and we're not frameskipping due to autoframeskip, or if we're paused
844851   bool allowed_to_sleep = false;
845    if (options_get_bool(m_machine.options(), OPTION_SLEEP) && (!effective_autoframeskip() || effective_frameskip() == 0))
852    if (options_get_bool(&m_machine.options(), OPTION_SLEEP) && (!effective_autoframeskip() || effective_frameskip() == 0))
846853       allowed_to_sleep = true;
847854    if (m_machine.paused())
848855       allowed_to_sleep = true;
r10384r10385
948955void video_manager::update_refresh_speed()
949956{
950957   // only do this if the refreshspeed option is used
951   if (options_get_bool(m_machine.options(), OPTION_REFRESHSPEED))
958   if (options_get_bool(&m_machine.options(), OPTION_REFRESHSPEED))
952959   {
953960      float minrefresh = m_machine.render().max_update_rate();
954961      if (minrefresh != 0)
r10384r10385
10341041   {
10351042      if (m_machine.primary_screen != NULL)
10361043      {
1037         astring fname(m_machine.basename(), PATH_SEPARATOR "final.png");
1038
10391044         // create a final screenshot
1040         mame_file *file;
1041         file_error filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
1045         emu_file file(m_machine.options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1046         file_error filerr = file.open(m_machine.basename(), PATH_SEPARATOR "final.png");
10421047         if (filerr == FILERR_NONE)
1043         {
1044            save_snapshot(m_machine.primary_screen, *file);
1045            mame_fclose(file);
1046         }
1048            save_snapshot(m_machine.primary_screen, file);
10471049      }
10481050
10491051      // schedule our demise
r10384r10385
10921094
10931095
10941096//-------------------------------------------------
1095//  mame_fopen_next - open the next non-existing
1096//  file of type filetype according to our
1097//  numbering scheme
1097//  open_next - open the next non-existing file of
1098//  type filetype according to our numbering
1099//  scheme
10981100//-------------------------------------------------
10991101
1100file_error video_manager::mame_fopen_next(const char *pathoption, const char *extension, mame_file *&file)
1102file_error video_manager::open_next(emu_file &file, const char *extension)
11011103{
1104   UINT32 origflags = file.openflags();
1105
11021106   // handle defaults
1103   const char *snapname = options_get_string(m_machine.options(), OPTION_SNAPNAME);
1107   const char *snapname = options_get_string(&m_machine.options(), OPTION_SNAPNAME);
11041108
11051109   if (snapname == NULL || snapname[0] == 0)
11061110      snapname = "%g/%i";
r10384r10385
12041208         fname.cpy(snapstr).replace(0, "%i", seqtext.format("%04d", seq).cstr());
12051209
12061210         // try to open the file; stop when we fail
1207         file_error filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, &file);
1211         file.set_openflags(OPEN_FLAG_READ);
1212         file_error filerr = file.open(fname);
12081213         if (filerr != FILERR_NONE)
12091214            break;
1210         mame_fclose(file);
12111215      }
12121216   }
12131217
12141218   // create the final file
1215    return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
1219   file.set_openflags(origflags);
1220    return file.open(fname);
12161221}
12171222
12181223
r10384r10385
12641269
12651270         // write the next frame
12661271         const rgb_t *palette = (m_machine.palette != NULL) ? palette_entry_list_adjusted(m_machine.palette) : NULL;
1267         png_error error = mng_capture_frame(mame_core_file(m_mngfile), &pnginfo, m_snap_bitmap, m_machine.total_colors(), palette);
1272         png_error error = mng_capture_frame(*m_mngfile, &pnginfo, m_snap_bitmap, m_machine.total_colors(), palette);
12681273         png_free(&pnginfo);
12691274         if (error != PNGERR_NONE)
12701275         {
src/emu/video.h
r10384r10385
107107   double speed_percent() const { return m_speed_percent; }
108108
109109   // snapshots
110   void save_snapshot(screen_device *screen, mame_file &file);
110   void save_snapshot(screen_device *screen, emu_file &file);
111111   void save_active_screen_snapshots();
112112
113113   // movies
r10384r10385
138138
139139   // snapshot/movie helpers
140140   void create_snapshot_bitmap(device_t *screen);
141   file_error mame_fopen_next(const char *pathoption, const char *extension, mame_file *&file);
141   file_error open_next(emu_file &file, const char *extension);
142142   void record_frame();
143143
144144   // internal state
r10384r10385
187187   INT32            m_snap_height;            // height of snapshots (0 == auto)
188188
189189   // movie recording
190   mame_file *         m_mngfile;               // handle to the open movie file
190   emu_file *         m_mngfile;               // handle to the open movie file
191191   avi_file *         m_avifile;               // handle to the open movie file
192192   attotime         m_movie_frame_period;      // period of a single movie frame
193193   attotime         m_movie_next_frame_time;   // time of next frame
src/emu/inptport.c
r10384r10385
288288   attoseconds_t            last_delta_nsec;   /* nanoseconds that passed since the previous callback */
289289
290290   /* playback/record information */
291   mame_file *               record_file;      /* recording file (NULL if not recording) */
292   mame_file *               playback_file;      /* playback file (NULL if not recording) */
291   emu_file *               record_file;      /* recording file (NULL if not recording) */
292   emu_file *               playback_file;      /* playback file (NULL if not recording) */
293293   UINT64                  playback_accumulated_speed;/* accumulated speed during playback */
294294   UINT32                  playback_accumulated_frames;/* accumulated frames during playback */
295295
r10384r10385
776776/* initialization helpers */
777777static void init_port_types(running_machine *machine);
778778static void init_port_state(running_machine *machine);
779static void init_autoselect_devices(const ioport_list &portlist, int type1, int type2, int type3, const char *option, const char *ananame);
779static void init_autoselect_devices(running_machine &machine, int type1, int type2, int type3, const char *option, const char *ananame);
780780static device_field_info *init_field_device_info(const input_field_config *field,const char *device_name);
781781static analog_field_state *init_field_analog_state(const input_field_config *field);
782782
r10384r10385
20122012
20132013static void init_port_state(running_machine *machine)
20142014{
2015   const char *joystick_map_default = options_get_string(machine->options(), OPTION_JOYSTICK_MAP);
2015   const char *joystick_map_default = options_get_string(&machine->options(), OPTION_JOYSTICK_MAP);
20162016   input_port_private *portdata = machine->input_port_data;
20172017   const input_field_config *field;
20182018   const input_port_config *port;
r10384r10385
20942094   }
20952095
20962096   /* handle autoselection of devices */
2097   init_autoselect_devices(machine->m_portlist, IPT_PADDLE,      IPT_PADDLE_V,     0,              OPTION_PADDLE_DEVICE,     "paddle");
2098   init_autoselect_devices(machine->m_portlist, IPT_AD_STICK_X,  IPT_AD_STICK_Y,   IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE,    "analog joystick");
2099   init_autoselect_devices(machine->m_portlist, IPT_LIGHTGUN_X,  IPT_LIGHTGUN_Y,   0,              OPTION_LIGHTGUN_DEVICE,   "lightgun");
2100   init_autoselect_devices(machine->m_portlist, IPT_PEDAL,       IPT_PEDAL2,       IPT_PEDAL3,     OPTION_PEDAL_DEVICE,      "pedal");
2101   init_autoselect_devices(machine->m_portlist, IPT_DIAL,        IPT_DIAL_V,       0,              OPTION_DIAL_DEVICE,       "dial");
2102   init_autoselect_devices(machine->m_portlist, IPT_TRACKBALL_X, IPT_TRACKBALL_Y,  0,              OPTION_TRACKBALL_DEVICE,  "trackball");
2103   init_autoselect_devices(machine->m_portlist, IPT_POSITIONAL,  IPT_POSITIONAL_V, 0,              OPTION_POSITIONAL_DEVICE, "positional");
2104   init_autoselect_devices(machine->m_portlist, IPT_MOUSE_X,     IPT_MOUSE_Y,      0,              OPTION_MOUSE_DEVICE,      "mouse");
2097   init_autoselect_devices(*machine, IPT_PADDLE,      IPT_PADDLE_V,     0,              OPTION_PADDLE_DEVICE,     "paddle");
2098   init_autoselect_devices(*machine, IPT_AD_STICK_X,  IPT_AD_STICK_Y,   IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE,    "analog joystick");
2099   init_autoselect_devices(*machine, IPT_LIGHTGUN_X,  IPT_LIGHTGUN_Y,   0,              OPTION_LIGHTGUN_DEVICE,   "lightgun");
2100   init_autoselect_devices(*machine, IPT_PEDAL,       IPT_PEDAL2,       IPT_PEDAL3,     OPTION_PEDAL_DEVICE,      "pedal");
2101   init_autoselect_devices(*machine, IPT_DIAL,        IPT_DIAL_V,       0,              OPTION_DIAL_DEVICE,       "dial");
2102   init_autoselect_devices(*machine, IPT_TRACKBALL_X, IPT_TRACKBALL_Y,  0,              OPTION_TRACKBALL_DEVICE,  "trackball");
2103   init_autoselect_devices(*machine, IPT_POSITIONAL,  IPT_POSITIONAL_V, 0,              OPTION_POSITIONAL_DEVICE, "positional");
2104   init_autoselect_devices(*machine, IPT_MOUSE_X,     IPT_MOUSE_Y,      0,              OPTION_MOUSE_DEVICE,      "mouse");
21052105
21062106   /* look for 4-way joysticks and change the default map if we find any */
21072107   if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0)
r10384r10385
21212121    in and the corresponding option
21222122-------------------------------------------------*/
21232123
2124static void init_autoselect_devices(const ioport_list &portlist, int type1, int type2, int type3, const char *option, const char *ananame)
2124static void init_autoselect_devices(running_machine &machine, int type1, int type2, int type3, const char *option, const char *ananame)
21252125{
2126   const char *stemp = options_get_string(mame_options(), option);
2126   const ioport_list &portlist = machine.m_portlist;
2127   const char *stemp = options_get_string(&machine.options(), option);
21272128   input_device_class autoenable = DEVICE_CLASS_KEYBOARD;
21282129   const char *autostring = "keyboard";
21292130   const input_field_config *field;
r10384r10385
28462847   }
28472848
28482849   /* skip locked-out coin inputs */
2849   if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->port->machine, field->type - IPT_COIN1) && options_get_bool(mame_options(), OPTION_COIN_LOCKOUT))
2850   if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->port->machine, field->type - IPT_COIN1) && options_get_bool(&field->port->machine->options(), OPTION_COIN_LOCKOUT))
28502851   {
28512852      ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field));
28522853      return FALSE;
r10384r10385
43244325      return 0;
43254326
43264327   /* read the value; if we fail, end playback */
4327   if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result))
4328   if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result))
43284329   {
43294330      playback_end(machine, "End of file");
43304331      return 0;
r10384r10385
43504351      return 0;
43514352
43524353   /* read the value; if we fail, end playback */
4353   if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result))
4354   if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result))
43544355   {
43554356      playback_end(machine, "End of file");
43564357      return 0;
r10384r10385
43764377      return 0;
43774378
43784379   /* read the value; if we fail, end playback */
4379   if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result))
4380   if (portdata->playback_file->read(&result, sizeof(result)) != sizeof(result))
43804381   {
43814382      playback_end(machine, "End of file");
43824383      return 0;
r10384r10385
43934394
43944395static time_t playback_init(running_machine *machine)
43954396{
4396   const char *filename = options_get_string(machine->options(), OPTION_PLAYBACK);
4397   const char *filename = options_get_string(&machine->options(), OPTION_PLAYBACK);
43974398   input_port_private *portdata = machine->input_port_data;
43984399   UINT8 header[INP_HEADER_SIZE];
4399   file_error filerr;
44004400   time_t basetime;
44014401
44024402   /* if no file, nothing to do */
r10384r10385
44044404      return 0;
44054405
44064406   /* open the playback file */
4407   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &portdata->playback_file);
4407   portdata->playback_file = auto_alloc(machine, emu_file(machine->options(), SEARCHPATH_INPUTLOG, OPEN_FLAG_READ));
4408   file_error filerr = portdata->playback_file->open(filename);
44084409   assert_always(filerr == FILERR_NONE, "Failed to open file for playback");
44094410
44104411   /* read the header and verify that it is a modern version; if not, print an error */
4411   if (mame_fread(portdata->playback_file, header, sizeof(header)) != sizeof(header))
4412   if (portdata->playback_file->read(header, sizeof(header)) != sizeof(header))
44124413      fatalerror("Input file is corrupt or invalid (missing header)");
44134414   if (memcmp(header, "MAMEINP\0", 8) != 0)
44144415      fatalerror("Input file invalid or in an older, unsupported format");
r10384r10385
44284429      mame_printf_info("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name);
44294430
44304431   /* enable compression */
4431   mame_fcompress(portdata->playback_file, FCOMPRESS_MEDIUM);
4432   portdata->playback_file->compress(FCOMPRESS_MEDIUM);
44324433
44334434   return basetime;
44344435}
r10384r10385
44464447   if (portdata->playback_file != NULL)
44474448   {
44484449      /* close the file */
4449      mame_fclose(portdata->playback_file);
4450      auto_free(machine, portdata->playback_file);
44504451      portdata->playback_file = NULL;
44514452
44524453      /* pop a message */
r10384r10385
45404541      return;
45414542
45424543   /* read the value; if we fail, end playback */
4543   if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result))
4544   if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result))
45444545      record_end(machine, "Out of space");
45454546}
45464547
r10384r10385
45604561      return;
45614562
45624563   /* read the value; if we fail, end playback */
4563   if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result))
4564   if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result))
45644565      record_end(machine, "Out of space");
45654566}
45664567
r10384r10385
45804581      return;
45814582
45824583   /* read the value; if we fail, end playback */
4583   if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result))
4584   if (portdata->record_file->write(&result, sizeof(result)) != sizeof(result))
45844585      record_end(machine, "Out of space");
45854586}
45864587
r10384r10385
45914592
45924593static void record_init(running_machine *machine)
45934594{
4594   const char *filename = options_get_string(machine->options(), OPTION_RECORD);
4595   const char *filename = options_get_string(&machine->options(), OPTION_RECORD);
45954596   input_port_private *portdata = machine->input_port_data;
45964597   UINT8 header[INP_HEADER_SIZE];
45974598   system_time systime;
4598   file_error filerr;
45994599
46004600   /* if no file, nothing to do */
46014601   if (filename[0] == 0)
46024602      return;
46034603
46044604   /* open the record file  */
4605   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &portdata->record_file);
4605   portdata->record_file = auto_alloc(machine, emu_file(machine->options(), SEARCHPATH_INPUTLOG, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
4606   file_error filerr = portdata->record_file->open(filename);
46064607   assert_always(filerr == FILERR_NONE, "Failed to open file for recording");
46074608
46084609   /* get the base time */
r10384r10385
46254626   sprintf((char *)header + 0x20, APPNAME " %s", build_version);
46264627
46274628   /* write it */
4628   mame_fwrite(portdata->record_file, header, sizeof(header));
4629   portdata->record_file->write(header, sizeof(header));
46294630
46304631   /* enable compression */
4631   mame_fcompress(portdata->record_file, FCOMPRESS_MEDIUM);
4632   portdata->record_file->compress(FCOMPRESS_MEDIUM);
46324633}
46334634
46344635
r10384r10385
46444645   if (portdata->record_file != NULL)
46454646   {
46464647      /* close the file */
4647      mame_fclose(portdata->record_file);
4648      auto_free(machine, portdata->record_file);
46484649      portdata->record_file = NULL;
46494650
46504651      /* pop a message */
src/emu/devintrf.c
r10384r10385
269269//  constructed
270270//-------------------------------------------------
271271
272bool device_config_interface::interface_validity_check(const game_driver &driver) const
272bool device_config_interface::interface_validity_check(core_options &options, const game_driver &driver) const
273273{
274274   return false;
275275}
r10384r10385
336336//  configuration has been constructed
337337//-------------------------------------------------
338338
339bool device_config::validity_check(const game_driver &driver) const
339bool device_config::validity_check(core_options &options, const game_driver &driver) const
340340{
341341   bool error = false;
342342
343343   // validate via the interfaces
344344   for (device_config_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next())
345      if (intf->interface_validity_check(driver))
345      if (intf->interface_validity_check(options, driver))
346346         error = true;
347347
348348   // let the device itself validate
349   if (device_validity_check(driver))
349   if (device_validity_check(options, driver))
350350      error = true;
351351
352352   return error;
r10384r10385
370370//  the configuration has been constructed
371371//-------------------------------------------------
372372
373bool device_config::device_validity_check(const game_driver &driver) const
373bool device_config::device_validity_check(core_options &options, const game_driver &driver) const
374374{
375375   // indicate no error by default
376376   return false;
src/emu/hashfile.c
r10384r10385
1616
1717struct _hash_file
1818{
19   mame_file *file;
19   emu_file *file;
2020   object_pool *pool;
2121   unsigned int functions[IO_COUNT];
2222
r10384r10385
341341   UINT32 len;
342342   XML_Memory_Handling_Suite memcallbacks;
343343
344   mame_fseek(hashfile->file, 0, SEEK_SET);
344   hashfile->file->seek(0, SEEK_SET);
345345
346346   memset(&state, 0, sizeof(state));
347347   state.hashfile = hashfile;
r10384r10385
364364
365365   while(!state.done)
366366   {
367      len = mame_fread(hashfile->file, buf, sizeof(buf));
368      state.done = mame_feof(hashfile->file);
367      len = hashfile->file->read(buf, sizeof(buf));
368      state.done = hashfile->file->eof();
369369      if (XML_Parse(state.parser, buf, len, state.done) == XML_STATUS_ERROR)
370370      {
371371         parse_error(&state, "[%lu:%lu]: %s\n",
r10384r10385
403403
404404
405405/*-------------------------------------------------
406    hashfile_open_options
406    hashfile_open
407407-------------------------------------------------*/
408408
409hash_file *hashfile_open_options(core_options *opts, const char *sysname, int is_preload,
409hash_file *hashfile_open(core_options &options, const char *sysname, int is_preload,
410410   void (*error_proc)(const char *message))
411411{
412   file_error filerr;
413   astring *fname;
414412   hash_file *hashfile = NULL;
415413   object_pool *pool = NULL;
414   file_error filerr;
416415
417416   /* create a pool for this hash file */
418417   pool = pool_alloc_lib(error_proc);
r10384r10385
430429   hashfile->error_proc = error_proc;
431430
432431   /* open a file */
433   fname = astring_assemble_2(astring_alloc(), sysname, ".hsi");
434   filerr = mame_fopen_options(opts, SEARCHPATH_HASH, astring_c(fname), OPEN_FLAG_READ, &hashfile->file);
435   astring_free(fname);
436
432   hashfile->file = global_alloc(emu_file(options, SEARCHPATH_HASH, OPEN_FLAG_READ));
433   filerr = hashfile->file->open(sysname, ".hsi");
437434   if (filerr != FILERR_NONE)
435   {
436      global_free(hashfile->file);
437      hashfile->file = NULL;
438438      goto error;
439   }
439440
440441   if (is_preload)
441442      hashfile_parse(hashfile, NULL, preload_use_proc, hashfile->error_proc, NULL);
r10384r10385
451452
452453
453454/*-------------------------------------------------
454    hashfile_open
455-------------------------------------------------*/
456
457hash_file *hashfile_open(const char *sysname, int is_preload,
458   void (*error_proc)(const char *message))
459{
460   return hashfile_open_options(mame_options(), sysname, is_preload, error_proc);
461}
462
463
464
465/*-------------------------------------------------
466455    hashfile_close
467456-------------------------------------------------*/
468457
469458void hashfile_close(hash_file *hashfile)
470459{
471   if (hashfile->file)
472      mame_fclose(hashfile->file);
460   global_free(hashfile->file);
473461   pool_free_lib(hashfile->pool);
474462}
475463
r10384r10385
548536    hashfile_verify
549537-------------------------------------------------*/
550538
551int hashfile_verify(const char *sysname, void (*my_error_proc)(const char *message))
539int hashfile_verify(core_options &options, const char *sysname, void (*my_error_proc)(const char *message))
552540{
553541   hash_file *hashfile;
554542
555   hashfile = hashfile_open(sysname, FALSE, my_error_proc);
543   hashfile = hashfile_open(options, sysname, FALSE, my_error_proc);
556544   if (!hashfile)
557545      return -1;
558546
src/emu/devintrf.h
r10384r10385
291291
292292   // methods that wrap both interface-level and device-level behavior
293293   void config_complete();
294   bool validity_check(const game_driver &driver) const;
294   bool validity_check(core_options &options, const game_driver &driver) const;
295295
296296   // configuration helpers
297297   static void static_set_clock(device_config *device, UINT32 clock) { device->m_clock = clock; }
r10384r10385
305305   // optional operation overrides
306306protected:
307307   virtual void device_config_complete();
308   virtual bool device_validity_check(const game_driver &driver) const;
308   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
309309
310310public:
311311   // optional information overrides
r10384r10385
359359
360360   // optional operation overrides
361361   virtual void interface_config_complete();
362   virtual bool interface_validity_check(const game_driver &driver) const;
362   virtual bool interface_validity_check(core_options &options, const game_driver &driver) const;
363363
364364protected:
365365   const device_config &      m_device_config;
src/emu/hashfile.h
r10384r10385
4040***************************************************************************/
4141
4242/* opens a hash file; if is_preload is non-zero, the entire file is preloaded */
43hash_file *hashfile_open(const char *sysname, int is_preload, hashfile_error_func error_proc);
43hash_file *hashfile_open(core_options &options, const char *sysname, int is_preload, hashfile_error_func error_proc);
4444
45/* opens a hash file; if is_preload is non-zero, the entire file is preloaded */
46hash_file *hashfile_open_options(core_options *opts, const char *sysname, int is_preload,
47   hashfile_error_func error_proc);
48
4945/* closes a hash file and associated resources */
5046void hashfile_close(hash_file *hashfile);
5147
src/emu/rendlay.c
r10384r10385
596596     m_type(CTYPE_INVALID),
597597     m_state(0),
598598     m_bitmap(NULL),
599     m_file(NULL),
599600     m_hasalpha(false)
600601{
601602   // fetch common data
r10384r10385
610611      m_dirname = dirname;
611612      m_imagefile = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
612613      m_alphafile = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
614      m_file = global_alloc(emu_file(machine.options(), OPTION_ARTPATH, OPEN_FLAG_READ));
613615   }
614616
615617   // text nodes
r10384r10385
663665
664666layout_element::component::~component()
665667{
668   global_free(m_file);
666669   global_free(m_bitmap);
667670}
668671
r10384r10385
898901bitmap_t *layout_element::component::load_bitmap()
899902{
900903   // load the basic bitmap
901   bitmap_t *bitmap = render_load_png(OPTION_ARTPATH, m_dirname, m_imagefile, NULL, &m_hasalpha);
904   assert(m_file != NULL);
905   bitmap_t *bitmap = render_load_png(*m_file, m_dirname, m_imagefile, NULL, &m_hasalpha);
902906   if (bitmap != NULL && m_alphafile)
903907
904908      // load the alpha bitmap if specified
905      if (render_load_png(OPTION_ARTPATH, m_dirname, m_alphafile, bitmap, &m_hasalpha) == NULL)
909      if (render_load_png(*m_file, m_dirname, m_alphafile, bitmap, &m_hasalpha) == NULL)
906910      {
907911         global_free(bitmap);
908912         bitmap = NULL;
src/emu/diimage.c
r10384r10385
531531    const hash_info *info = NULL;
532532
533533    /* open the hash file */
534    hashfile = hashfile_open(sysname, FALSE, NULL);
534    hashfile = hashfile_open(device().machine->options(), sysname, FALSE, NULL);
535535    if (!hashfile)
536536        goto done;
537537
r10384r10385
652652{
653653    astring *fname = astring_assemble_4(astring_alloc(), device().machine->gamedrv->name, PATH_SEPARATOR, m_basename_noext, ".nv");
654654
655    image_battery_load_by_name(astring_c(fname), buffer, length, fill);
655    image_battery_load_by_name(device().machine->options(), astring_c(fname), buffer, length, fill);
656656    astring_free(fname);
657657}
658658
r10384r10385
666666{
667667    astring *fname = astring_assemble_4(astring_alloc(), device().machine->gamedrv->name, PATH_SEPARATOR, m_basename_noext, ".nv");
668668
669    image_battery_save_by_name(astring_c(fname), buffer, length);
669    image_battery_save_by_name(device().machine->options(), astring_c(fname), buffer, length);
670670    astring_free(fname);
671671}
672672
src/emu/rendlay.h
r10384r10385
152152      astring            m_string;      // string for text components
153153      bitmap_t *         m_bitmap;      // source bitmap for images
154154      astring            m_dirname;      // directory name of image file (for lazy loading)
155      emu_file *          m_file;         // file object for reading image/alpha files
155156      astring            m_imagefile;   // name of the image file (for lazy loading)
156157      astring            m_alphafile;   // name of the alpha file (for lazy loading)
157158      bool            m_hasalpha;      // is there any alpha component present?
src/emu/machine.c
r10384r10385
114114#include "uiinput.h"
115115#include "crsshair.h"
116116#include "validity.h"
117#include "unzip.h"
117118#include "debug/debugcon.h"
118119
119120#include <time.h>
r10384r10385
260261void running_machine::start()
261262{
262263   // initialize basic can't-fail systems here
263   fileio_init(this);
264264   config_init(this);
265265   input_init(this);
266266   output_init(this);
r10384r10385
361361      // if we have a logfile, set up the callback
362362      if (options_get_bool(&m_options, OPTION_LOG))
363363      {
364         file_error filerr = mame_fopen(SEARCHPATH_DEBUGLOG, "error.log", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &m_logfile);
364         m_logfile = auto_alloc(this, emu_file(m_options, SEARCHPATH_DEBUGLOG, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
365         file_error filerr = m_logfile->open("error.log");
365366         assert_always(filerr == FILERR_NONE, "unable to open log file");
366367         add_logerror_callback(logfile_callback);
367368      }
r10384r10385
429430
430431   // call all exit callbacks registered
431432   call_notifiers(MACHINE_NOTIFY_EXIT);
433   zip_file_cache_clear();
432434
433435   // close the logfile
434   if (m_logfile != NULL)
435      mame_fclose(m_logfile);
436   auto_free(this, m_logfile);
436437   return error;
437438}
438439
r10384r10385
770771   file_error filerr = FILERR_NONE;
771772
772773   // if no name, bail
774   emu_file file(m_options, m_saveload_searchpath, openflags);
773775   if (!m_saveload_pending_file)
774776      goto cancel;
775777
r10384r10385
787789   }
788790
789791   // open the file
790   mame_file *file;
791   filerr = mame_fopen(m_saveload_searchpath, m_saveload_pending_file, openflags, &file);
792   filerr = file.open(m_saveload_pending_file);
792793   if (filerr == FILERR_NONE)
793794   {
794      astring fullname(mame_file_full_name(file));
795
796795      // read/write the save state
797796      state_save_error staterr = (m_saveload_schedule == SLS_LOAD) ? m_state.read_file(file) : m_state.write_file(file);
798797
r10384r10385
828827      }
829828
830829      // close and perhaps delete the file
831      mame_fclose(file);
832830      if (staterr != STATERR_NONE && m_saveload_schedule == SLS_SAVE)
833         osd_rmfile(fullname);
831         file.remove_on_close();
834832   }
835833   else
836834      popmessage("Error: Failed to open file for %s operation.", opname);
r10384r10385
871869void running_machine::logfile_callback(running_machine &machine, const char *buffer)
872870{
873871   if (machine.m_logfile != NULL)
874      mame_fputs(machine.m_logfile, buffer);
872      machine.m_logfile->puts(buffer);
875873}
876874
877875
src/emu/diimage.h
r10384r10385
295295
296296    /* variables that are only non-zero when an image is mounted */
297297   core_file *m_file;
298   mame_file *m_mame_file;
298   emu_file *m_mame_file;
299299   astring m_name;
300300   astring m_basename;
301301   astring m_basename_noext;
src/emu/sound/okim9810.c
r10384r10385
1818const device_type OKIM9810 = okim9810_device_config::static_alloc_device_config;
1919
2020
21// volume lookup table. The manual lists a full 16 steps, 2dB per step.
22// Given the dB values, that seems to map to a 7-bit volume control.
23const UINT8 okim9810_device::s_volume_table[16] =
24{
25   0x80,   //  0 dB
26   0x65,   // -2 dB
27   0x50,   // -4 dB
28   0x40,   // -6 dB
29   0x32,   // -8.0 dB
30   0x28,   // -10.5 dB
31   0x20,   // -12.0 dB
32   0x19,   // -14.5 dB
33   0x14,   // -16.0 dB
34   0x10,   // -18.0 dB
35   0x0c,   // -20.0 dB
36   0x0a,   // -22.0 dB
37   0x08,   // -24.0 dB
38   0x06,   // -26.0 dB
39   0x05,   // -28.0 dB
40   0x04,   // -30.0 dB
41};
42
2143// default address map
2244static ADDRESS_MAP_START( okim9810, 0, 8 )
2345    AM_RANGE(0x000000, 0xffffff) AM_ROM
r10384r10385
293315        case 0x07:  // CVOL (channel volume)
294316        {
295317            mame_printf_verbose("CVOL  channel %d volume level %02x\n", channel, m_TMP_register);
296            mame_printf_verbose("\tChannel %d -> volume %d.\n", channel, m_TMP_register);
318            mame_printf_verbose("\tChannel %d -> volume %d.\n", channel, s_volume_table[m_TMP_register & 0x0f]);
297319
298            // TODO: Use the proper volume table p37
299            m_voice[channel].m_volume = m_TMP_register;
320            m_voice[channel].m_volume = s_volume_table[m_TMP_register & 0x0f];
300321            break;
301322        }
302323        case 0x08:  // PAN
r10384r10385
373394      int nibble = direct.read_raw_byte(m_base_offset + m_sample / 2) >> (((m_sample & 1) << 2) ^ 4);
374395
375396      // output to the buffer, scaling by the volume
376      // signal in range -2048..2047, volume in range 2..32 => signal * volume / 2 in range -32768..32767
377      *buffer++ += m_adpcm.clock(nibble); //TODO * m_volume / 2;
397      // signal in range -2048..2047, volume in range 2..128 => signal * volume / 8 in range -32768..32767
398      *buffer++ += (INT32)m_adpcm.clock(nibble) * (INT32)m_volume / 8;
378399
379400      // next!
380401      if (++m_sample >= m_count)
src/emu/sound/okim9810.h
r10384r10385
153153
154154   static const int OKIM9810_VOICES = 8;
155155   okim_voice m_voice[OKIM9810_VOICES];
156
157   static const UINT8 s_volume_table[16];
156158};
157159
158160
src/emu/sound/tms5110r.c
r10384r10385
2424 * (remember, 1 is the FIRST entry!)
2525 *
2626 * Instead,  { 1, 8, 8, 8, 4, 4, 4, 2 }
27 * will calculate those coefficients and this has been used below.
28 * LN:
29 * The real chip uses shifters and not true division to achieve those factors,
30 * so they have been replaced by the shifting coefficients:
31 * { 0, 3, 3, 3, 2, 2, 2, 1 }
27 * will calculate those coefficients.
28 * Howeever, after simulating the actual circuit from the patent in pspice,
29 * the { 1, 8, 8, 8, 4, 4, 2, 2 } pattern is revealed as the correct one.
30 * Since the real chip uses shifters and not true division to achieve those
31 * factors, they have been replaced by the shifting coefficients:
32 * { 0, 3, 3, 3, 2, 2, 1, 1 }
3233 */
3334
3435 /* quick note on derivative analysis:
r10384r10385
124125       1,  0,    0,  0,   0,  0,  0,  0,
125126       0,  0,    0,  0 },
126127   /* interpolation coefficients */
127   { 3, 3, 3, 2, 2, 2, 1, 0 }
128   { 3, 3, 3, 2, 2, 1, 1, 0 }
128129};
129130
130131/* The following CD2802 coefficients come from US Patents 4,403,965 and 4,946,391; They have not yet been verified using derivatives. The M58817 seems to work best with these coefficients, so its possible the engineers of that chip copied them from the TI patents.
r10384r10385
188189       1,  0,    0,  0,  0,  0,  0,  0,
189190       0,  0,    0,  0 },
190191   /* interpolation coefficients */
191   { 3, 3, 3, 2, 2, 2, 1, 0 }
192   { 3, 3, 3, 2, 2, 1, 1, 0 }
192193};
193194
194195/* The following TMS5110A LPC coefficients were directly read from an actual TMS5110A chip by Jarek Burczynski using the PROMOUT pin, and can be regarded as established fact. However, the chirp table and the interpolation coefficients still come from the patents as there doesn't seem to be an easy way to read those out from the chip without decapping it.
r10384r10385
251252       1,  0,    0,  0,   0,  0,  0,  0,
252253       0,  0,    0,  0 },
253254   /* interpolation coefficients */
254   { 3, 3, 3, 2, 2, 2, 1, 0 }
255   { 3, 3, 3, 2, 2, 1, 1, 0 }
255256};
256257
257258/* The following coefficients come from US Patent 4,335,277 and 4,581,757. However, the K10 row of coefficients are entirely missing from both of those patents.
r10384r10385
320321       1,  0,    0,  0,   0,  0,  0,  0,
321322       0,  0,    0,  0 },
322323   /* interpolation coefficients */
323   { 3, 3, 3, 2, 2, 2, 1, 0 }
324   { 3, 3, 3, 2, 2, 1, 1, 0 }
324325};
325326
326327/* The following TMS5200/TMC0285 coefficients were directly read from an actual TMS5200 chip by Lord Nightmare using the PROMOUT pin, and can be regarded as established fact. However, the chirp table and the interpolation coefficients still come from the patents as there doesn't seem to be an easy way to read those out from the chip without decapping it.
r10384r10385
388389       1,  0,    0,  0,   0,  0,  0,  0,
389390       0,  0,    0,  0 },
390391   /* interpolation coefficients */
391   { 0, 3, 3, 3, 2, 2, 2, 1 }
392   { 0, 3, 3, 3, 2, 2, 1, 1 }
392393};
393394
394395/* The following TMS5220 coefficients were directly read from an actual TMS5220 chip by Lord Nightmare using the PROMOUT pin, and can be regarded as established fact. However, the chirp table and the interpolation coefficients still come from the patents as there doesn't seem to be an easy way to read those out from the chip without decapping it.
r10384r10385
457458       1,  0,    0,  0,   0,  0,  0,  0,
458459       0,  0,    0,  0 },
459460   /* interpolation coefficients */
460   { 0, 3, 3, 3, 2, 2, 2, 1 }
461   { 0, 3, 3, 3, 2, 2, 1, 1 }
461462};
462463
463464/* The following TMS5220C coefficients come from the tables in QBOXPRO, a program written at least in part by George "Larry" Brantingham of Quadravox, formerly of Texas Instruments, who had laid out the silicon for the TMS5100/TMC0280/CD2801. It is the same as the TMS5220 but has a change in the energy table (is this actually correct? or is this one correct for both 5220s? or is this the wrong table and the TMS5220 one correct for both?)
r10384r10385
530531       1,  0,    0,  0,   0,  0,  0,  0,
531532       0,  0,    0,  0 },
532533   /* interpolation coefficients */
533   { 0, 3, 3, 3, 2, 2, 2, 1 }
534   { 0, 3, 3, 3, 2, 2, 1, 1 }
534535};
src/emu/sound/samples.c
r10384r10385
4848    read_wav_sample - read a WAV file as a sample
4949-------------------------------------------------*/
5050
51static int read_wav_sample(running_machine *machine, mame_file *f, loaded_sample *sample)
51static int read_wav_sample(running_machine *machine, emu_file &file, loaded_sample *sample)
5252{
5353   unsigned long offset = 0;
5454   UINT32 length, rate, filesize;
r10384r10385
5757   UINT32 sindex;
5858
5959   /* read the core header and make sure it's a WAVE file */
60   offset += mame_fread(f, buf, 4);
60   offset += file.read(buf, 4);
6161   if (offset < 4)
6262      return 0;
6363   if (memcmp(&buf[0], "RIFF", 4) != 0)
6464      return 0;
6565
6666   /* get the total size */
67   offset += mame_fread(f, &filesize, 4);
67   offset += file.read(&filesize, 4);
6868   if (offset < 8)
6969      return 0;
7070   filesize = LITTLE_ENDIANIZE_INT32(filesize);
7171
7272   /* read the RIFF file type and make sure it's a WAVE file */
73   offset += mame_fread(f, buf, 4);
73   offset += file.read(buf, 4);
7474   if (offset < 12)
7575      return 0;
7676   if (memcmp(&buf[0], "WAVE", 4) != 0)
r10384r10385
7979   /* seek until we find a format tag */
8080   while (1)
8181   {
82      offset += mame_fread(f, buf, 4);
83      offset += mame_fread(f, &length, 4);
82      offset += file.read(buf, 4);
83      offset += file.read(&length, 4);
8484      length = LITTLE_ENDIANIZE_INT32(length);
8585      if (memcmp(&buf[0], "fmt ", 4) == 0)
8686         break;
8787
8888      /* seek to the next block */
89      mame_fseek(f, length, SEEK_CUR);
89      file.seek(length, SEEK_CUR);
9090      offset += length;
9191      if (offset >= filesize)
9292         return 0;
9393   }
9494
9595   /* read the format -- make sure it is PCM */
96   offset += mame_fread(f, &temp16, 2);
96   offset += file.read(&temp16, 2);
9797   temp16 = LITTLE_ENDIANIZE_INT16(temp16);
9898   if (temp16 != 1)
9999      return 0;
100100
101101   /* number of channels -- only mono is supported */
102   offset += mame_fread(f, &temp16, 2);
102   offset += file.read(&temp16, 2);
103103   temp16 = LITTLE_ENDIANIZE_INT16(temp16);
104104   if (temp16 != 1)
105105      return 0;
106106
107107   /* sample rate */
108   offset += mame_fread(f, &rate, 4);
108   offset += file.read(&rate, 4);
109109   rate = LITTLE_ENDIANIZE_INT32(rate);
110110
111111   /* bytes/second and block alignment are ignored */
112   offset += mame_fread(f, buf, 6);
112   offset += file.read(buf, 6);
113113
114114   /* bits/sample */
115   offset += mame_fread(f, &bits, 2);
115   offset += file.read(&bits, 2);
116116   bits = LITTLE_ENDIANIZE_INT16(bits);
117117   if (bits != 8 && bits != 16)
118118      return 0;
119119
120120   /* seek past any extra data */
121   mame_fseek(f, length - 16, SEEK_CUR);
121   file.seek(length - 16, SEEK_CUR);
122122   offset += length - 16;
123123
124124   /* seek until we find a data tag */
125125   while (1)
126126   {
127      offset += mame_fread(f, buf, 4);
128      offset += mame_fread(f, &length, 4);
127      offset += file.read(buf, 4);
128      offset += file.read(&length, 4);
129129      length = LITTLE_ENDIANIZE_INT32(length);
130130      if (memcmp(&buf[0], "data", 4) == 0)
131131         break;
132132
133133      /* seek to the next block */
134      mame_fseek(f, length, SEEK_CUR);
134      file.seek(length, SEEK_CUR);
135135      offset += length;
136136      if (offset >= filesize)
137137         return 0;
r10384r10385
152152      int sindex;
153153
154154      sample->data = auto_alloc_array(machine, INT16, length);
155      mame_fread(f, sample->data, length);
155      file.read(sample->data, length);
156156
157157      /* convert 8-bit data to signed samples */
158158      tempptr = (unsigned char *)sample->data;
r10384r10385
163163   {
164164      /* 16-bit data is fine as-is */
165165      sample->data = auto_alloc_array(machine, INT16, length/2);
166      mame_fread(f, sample->data, length);
166      file.read(sample->data, length);
167167      sample->length /= 2;
168168      if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE)
169169         for (sindex = 0; sindex < sample->length; sindex++)
r10384r10385
184184   int i;
185185
186186   /* if the user doesn't want to use samples, bail */
187   if (!options_get_bool(machine->options(), OPTION_SAMPLES))
187   if (!options_get_bool(&machine->options(), OPTION_SAMPLES))
188188      return NULL;
189189   if (samplenames == 0 || samplenames[0] == 0)
190190      return NULL;
r10384r10385
206206   for (i = 0; i < samples->total; i++)
207207      if (samplenames[i+skipfirst][0])
208208      {
209         file_error filerr;
210         mame_file *f;
209         emu_file file(machine->options(), SEARCHPATH_SAMPLE, OPEN_FLAG_READ);
211210
212         astring fname(basename, PATH_SEPARATOR, samplenames[i+skipfirst]);
213         filerr = mame_fopen(SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ, &f);
214
211         file_error filerr = file.open(basename, PATH_SEPARATOR, samplenames[i+skipfirst]);
215212         if (filerr != FILERR_NONE && skipfirst)
216         {
217            astring fname(samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]);
218            filerr = mame_fopen(SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ, &f);
219         }
213            filerr = file.open(samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]);
214
220215         if (filerr == FILERR_NONE)
221         {
222            read_wav_sample(machine, f, &samples->sample[i]);
223            mame_fclose(f);
224         }
216            read_wav_sample(machine, file, &samples->sample[i]);
225217      }
226218
227219   return samples;
src/emu/machine.h
r10384r10385
347347
348348   // getters
349349   const char *basename() const { return m_basename; }
350   core_options *options() const { return &m_options; }
350   core_options &options() const { return m_options; }
351351   machine_phase phase() const { return m_current_phase; }
352352   bool paused() const { return m_paused || (m_current_phase != MACHINE_PHASE_RUNNING); }
353353   bool scheduled_event_pending() const { return m_exit_pending || m_hard_reset_pending; }
r10384r10385
500500   bool               m_exit_to_game_select;
501501   const game_driver *      m_new_driver_pending;
502502   emu_timer *            m_soft_reset_timer;
503   mame_file *            m_logfile;
503   emu_file *            m_logfile;
504504
505505   // load/save
506506   enum saveload_schedule
src/emu/ui.c
r10384r10385
247247   single_step = FALSE;
248248   ui_set_handler(handler_messagebox, 0);
249249   /* retrieve options */
250   ui_use_natural_keyboard = options_get_bool(machine->options(), OPTION_NATURAL_KEYBOARD);
250   ui_use_natural_keyboard = options_get_bool(&machine->options(), OPTION_NATURAL_KEYBOARD);
251251
252252   return 0;
253253}
r10384r10385
273273int ui_display_startup_screens(running_machine *machine, int first_time, int show_disclaimer)
274274{
275275   const int maxstate = 3;
276   int str = options_get_int(machine->options(), OPTION_SECONDS_TO_RUN);
277   int show_gameinfo = !options_get_bool(machine->options(), OPTION_SKIP_GAMEINFO);
276   int str = options_get_int(&machine->options(), OPTION_SECONDS_TO_RUN);
277   int show_gameinfo = !options_get_bool(&machine->options(), OPTION_SKIP_GAMEINFO);
278278   int show_warnings = TRUE;
279279   int state;
280280
r10384r10385
375375   /* if we're paused, dim the whole screen */
376376   if (machine->phase() >= MACHINE_PHASE_RESET && (single_step || machine->paused()))
377377   {
378      int alpha = (1.0f - options_get_float(machine->options(), OPTION_PAUSE_BRIGHTNESS)) * 255.0f;
378      int alpha = (1.0f - options_get_float(&machine->options(), OPTION_PAUSE_BRIGHTNESS)) * 255.0f;
379379      if (ui_menu_is_force_game_select())
380380         alpha = 255;
381381      if (alpha > 255)
r10384r10385
412412{
413413   /* allocate the font and messagebox string */
414414   if (ui_font == NULL)
415      ui_font = machine.render().font_alloc(options_get_string(machine.options(), OPTION_UI_FONT));
415      ui_font = machine.render().font_alloc(options_get_string(&machine.options(), OPTION_UI_FONT));
416416   return ui_font;
417417}
418418
r10384r10385
16401640         }
16411641
16421642   /* add CPU overclocking (cheat only) */
1643   if (options_get_bool(machine->options(), OPTION_CHEAT))
1643   if (options_get_bool(&machine->options(), OPTION_CHEAT))
16441644   {
16451645      device_execute_interface *exec = NULL;
16461646      for (bool gotone = machine->m_devicelist.first(exec); gotone; gotone = exec->next(exec))
r10384r10385
16621662      void *param = (void *)screen;
16631663
16641664      /* add refresh rate tweaker */
1665      if (options_get_bool(machine->options(), OPTION_CHEAT))
1665      if (options_get_bool(&machine->options(), OPTION_CHEAT))
16661666      {
16671667         string.printf("%s Refresh Rate", slider_get_screen_desc(*screen));
16681668         *tailptr = slider_alloc(machine, string, -10000, 0, 10000, 1000, slider_refresh, param);
r10384r10385
22142214void ui_set_use_natural_keyboard(running_machine *machine, int use_natural_keyboard)
22152215{
22162216   ui_use_natural_keyboard = use_natural_keyboard;
2217   options_set_bool(machine->options(), OPTION_NATURAL_KEYBOARD, use_natural_keyboard, OPTION_PRIORITY_CMDLINE);
2217   options_set_bool(&machine->options(), OPTION_NATURAL_KEYBOARD, use_natural_keyboard, OPTION_PRIORITY_CMDLINE);
22182218}
22192219
src/emu/crsshair.c
r10384r10385
158158   global_free(global.bitmap[player]);
159159   machine->render().texture_free(global.texture[player]);
160160
161   emu_file crossfile(machine->options(), OPTION_CROSSHAIRPATH, OPEN_FLAG_READ);
161162   if (global.name[player][0] != 0)
162163   {
163164      /* look for user specified file */
164165      sprintf(filename, "%s.png", global.name[player]);
165      global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, NULL, filename, NULL, NULL);
166      global.bitmap[player] = render_load_png(crossfile, NULL, filename, NULL, NULL);
166167   }
167168   else
168169   {
169170      /* look for default cross?.png in crsshair\game dir */
170171      sprintf(filename, "cross%d.png", player + 1);
171      global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, machine->gamedrv->name, filename, NULL, NULL);
172      global.bitmap[player] = render_load_png(crossfile, machine->gamedrv->name, filename, NULL, NULL);
172173
173174      /* look for default cross?.png in crsshair dir */
174175      if (global.bitmap[player] == NULL)
175         global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, NULL, filename, NULL, NULL);
176         global.bitmap[player] = render_load_png(crossfile, NULL, filename, NULL, NULL);
176177   }
177178
178179   /* if that didn't work, use the built-in one */
src/emu/devlegcy.c
r10384r10385
192192//  checks on a device configuration
193193//-------------------------------------------------
194194
195bool legacy_device_config_base::device_validity_check(const game_driver &driver) const
195bool legacy_device_config_base::device_validity_check(core_options &options, const game_driver &driver) const
196196{
197197   device_validity_check_func validity_func = reinterpret_cast<device_validity_check_func>(get_legacy_config_fct(DEVINFO_FCT_VALIDITY_CHECK));
198198   if (validity_func != NULL)
199      return (*validity_func)(&driver, this);
199      return (*validity_func)(&driver, this, options);
200200   return false;
201201}
202202
r10384r10385
402402//  nvram_read - read NVRAM from the given file
403403//-------------------------------------------------
404404
405void legacy_nvram_device_base::nvram_read(mame_file &file)
405void legacy_nvram_device_base::nvram_read(emu_file &file)
406406{
407407   device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM));
408408   (*nvram_func)(this, &file, FALSE);
r10384r10385
413413//  nvram_write - write NVRAM to the given file
414414//-------------------------------------------------
415415
416void legacy_nvram_device_base::nvram_write(mame_file &file)
416void legacy_nvram_device_base::nvram_write(emu_file &file)
417417{
418418   device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM));
419419   (*nvram_func)(this, &file, TRUE);
src/emu/devlegcy.h
r10384r10385
247247#define DEVICE_GET_INFO_CALL(name)   DEVICE_GET_INFO_NAME(name)(device, state, info)
248248
249249#define DEVICE_VALIDITY_CHECK_NAME(name)   device_validity_check_##name
250#define DEVICE_VALIDITY_CHECK(name)         int DEVICE_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const device_config *device)
250#define DEVICE_VALIDITY_CHECK(name)         int DEVICE_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const device_config *device, core_options &options)
251251#define DEVICE_VALIDITY_CHECK_CALL(name)   DEVICE_VALIDITY_CHECK_NAME(name)(driver, device)
252252
253253#define DEVICE_START_NAME(name)      device_start_##name
r10384r10385
267267#define DEVICE_EXECUTE_CALL(name)   DEVICE_EXECUTE_NAME(name)(device, clocks)
268268
269269#define DEVICE_NVRAM_NAME(name)      device_nvram_##name
270#define DEVICE_NVRAM(name)         void DEVICE_NVRAM_NAME(name)(device_t *device, mame_file *file, int read_or_write)
270#define DEVICE_NVRAM(name)         void DEVICE_NVRAM_NAME(name)(device_t *device, emu_file *file, int read_or_write)
271271#define DEVICE_NVRAM_CALL(name)      DEVICE_NVRAM_NAME(name)(device, file, read_or_write)
272272
273273
r10384r10385
382382
383383// device interface function types
384384typedef void (*device_get_config_func)(const device_config *device, UINT32 state, deviceinfo *info);
385typedef int (*device_validity_check_func)(const game_driver *driver, const device_config *device);
385typedef int (*device_validity_check_func)(const game_driver *driver, const device_config *device, core_options &options);
386386
387387typedef void (*device_start_func)(device_t *device);
388388typedef void (*device_stop_func)(device_t *device);
389389typedef INT32 (*device_execute_func)(device_t *device, INT32 clocks);
390390typedef void (*device_reset_func)(device_t *device);
391typedef void (*device_nvram_func)(device_t *device, mame_file *file, int read_or_write);
391typedef void (*device_nvram_func)(device_t *device, emu_file *file, int read_or_write);
392392
393393// the actual deviceinfo union
394394union deviceinfo
r10384r10385
447447
448448protected:
449449   // overrides
450   virtual bool device_validity_check(const game_driver &driver) const;
450   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
451451
452452   // access to legacy configuration info
453453   INT64 get_legacy_config_int(UINT32 state) const;
r10384r10385
577577
578578   // device_nvram_interface overrides
579579   virtual void nvram_default();
580   virtual void nvram_read(mame_file &file);
581   virtual void nvram_write(mame_file &file);
580   virtual void nvram_read(emu_file &file);
581   virtual void nvram_write(emu_file &file);
582582};
583583
584584// ======================> legacy_image_device_config
src/emu/render.c
r10384r10385
721721   {
722722      // set the initial orientation and brightness/contrast/gamma
723723      m_user.m_orientation = manager.machine().gamedrv->flags & ORIENTATION_MASK;
724      m_user.m_brightness = options_get_float(manager.machine().options(), OPTION_BRIGHTNESS);
725      m_user.m_contrast = options_get_float(manager.machine().options(), OPTION_CONTRAST);
726      m_user.m_gamma = options_get_float(manager.machine().options(), OPTION_GAMMA);
724      m_user.m_brightness = options_get_float(&manager.machine().options(), OPTION_BRIGHTNESS);
725      m_user.m_contrast = options_get_float(&manager.machine().options(), OPTION_CONTRAST);
726      m_user.m_gamma = options_get_float(&manager.machine().options(), OPTION_GAMMA);
727727   }
728728
729729   // allocate a client to the main palette
r10384r10385
10661066     m_debug_containers(manager.machine().m_respool)
10671067{
10681068   // determine the base layer configuration based on options
1069   m_base_layerconfig.set_backdrops_enabled(options_get_bool(manager.machine().options(), OPTION_USE_BACKDROPS));
1070   m_base_layerconfig.set_overlays_enabled(options_get_bool(manager.machine().options(), OPTION_USE_OVERLAYS));
1071   m_base_layerconfig.set_bezels_enabled(options_get_bool(manager.machine().options(), OPTION_USE_BEZELS));
1072   m_base_layerconfig.set_zoom_to_screen(options_get_bool(manager.machine().options(), OPTION_ARTWORK_CROP));
1069   m_base_layerconfig.set_backdrops_enabled(options_get_bool(&manager.machine().options(), OPTION_USE_BACKDROPS));
1070   m_base_layerconfig.set_overlays_enabled(options_get_bool(&manager.machine().options(), OPTION_USE_OVERLAYS));
1071   m_base_layerconfig.set_bezels_enabled(options_get_bool(&manager.machine().options(), OPTION_USE_BEZELS));
1072   m_base_layerconfig.set_zoom_to_screen(options_get_bool(&manager.machine().options(), OPTION_ARTWORK_CROP));
10731073
10741074   // determine the base orientation based on options
10751075   m_orientation = ROT0;
1076   if (!options_get_bool(manager.machine().options(), OPTION_ROTATE))
1076   if (!options_get_bool(&manager.machine().options(), OPTION_ROTATE))
10771077      m_base_orientation = orientation_reverse(manager.machine().gamedrv->flags & ORIENTATION_MASK);
10781078
10791079   // rotate left/right
1080   if (options_get_bool(manager.machine().options(), OPTION_ROR) || (options_get_bool(manager.machine().options(), OPTION_AUTOROR) && (manager.machine().gamedrv->flags & ORIENTATION_SWAP_XY)))
1080   if (options_get_bool(&manager.machine().options(), OPTION_ROR) || (options_get_bool(&manager.machine().options(), OPTION_AUTOROR) && (manager.machine().gamedrv->flags & ORIENTATION_SWAP_XY)))
10811081      m_base_orientation = orientation_add(ROT90, m_base_orientation);
1082   if (options_get_bool(manager.machine().options(), OPTION_ROL) || (options_get_bool(manager.machine().options(), OPTION_AUTOROL) && (manager.machine().gamedrv->flags & ORIENTATION_SWAP_XY)))
1082   if (options_get_bool(&manager.machine().options(), OPTION_ROL) || (options_get_bool(&manager.machine().options(), OPTION_AUTOROL) && (manager.machine().gamedrv->flags & ORIENTATION_SWAP_XY)))
10831083      m_base_orientation = orientation_add(ROT270, m_base_orientation);
10841084
10851085   // flip X/Y
1086   if (options_get_bool(manager.machine().options(), OPTION_FLIPX))
1086   if (options_get_bool(&manager.machine().options(), OPTION_FLIPX))
10871087      m_base_orientation ^= ORIENTATION_FLIP_X;
1088   if (options_get_bool(manager.machine().options(), OPTION_FLIPY))
1088   if (options_get_bool(&manager.machine().options(), OPTION_FLIPY))
10891089      m_base_orientation ^= ORIENTATION_FLIP_Y;
10901090
10911091   // set the orientation and layerconfig equal to the base
r10384r10385
16801680         fname.ins(0, PATH_SEPARATOR).ins(0, dirname);
16811681
16821682      // attempt to open the file; bail if we can't
1683      mame_file *layoutfile;
1684      file_error filerr = mame_fopen(SEARCHPATH_ARTWORK, fname, OPEN_FLAG_READ, &layoutfile);
1683      emu_file layoutfile(manager().machine().options(), SEARCHPATH_ARTWORK, OPEN_FLAG_READ);
1684      file_error filerr = layoutfile.open(fname);
16851685      if (filerr != FILERR_NONE)
16861686         return false;
16871687
16881688      // read the file
1689      rootnode = xml_file_read(mame_core_file(layoutfile), NULL);
1690      mame_fclose(layoutfile);
1689      rootnode = xml_file_read(layoutfile, NULL);
16911690   }
16921691
16931692   // if we didn't get a properly-formatted XML file, record a warning and exit
r10384r10385
27972796         container->get_user_settings(settings);
27982797
27992798         // output the color controls
2800         if (settings.m_brightness != options_get_float(m_machine.options(), OPTION_BRIGHTNESS))
2799         if (settings.m_brightness != options_get_float(&m_machine.options(), OPTION_BRIGHTNESS))
28012800         {
28022801            xml_set_attribute_float(screennode, "brightness", settings.m_brightness);
28032802            changed = true;
28042803         }
28052804
2806         if (settings.m_contrast != options_get_float(m_machine.options(), OPTION_CONTRAST))
2805         if (settings.m_contrast != options_get_float(&m_machine.options(), OPTION_CONTRAST))
28072806         {
28082807            xml_set_attribute_float(screennode, "contrast", settings.m_contrast);
28092808            changed = true;
28102809         }
28112810
2812         if (settings.m_gamma != options_get_float(m_machine.options(), OPTION_GAMMA))
2811         if (settings.m_gamma != options_get_float(&m_machine.options(), OPTION_GAMMA))
28132812         {
28142813            xml_set_attribute_float(screennode, "gamma", settings.m_gamma);
28152814            changed = true;
src/emu/state.c
r10384r10385
237237//  state
238238//-------------------------------------------------
239239
240state_save_error state_manager::check_file(running_machine *machine, mame_file *file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...))
240state_save_error state_manager::check_file(running_machine *machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...))
241241{
242242   // if we want to validate the signature, compute it
243243   UINT32 sig = 0;
r10384r10385
245245      sig = machine->state().signature();
246246
247247   // seek to the beginning and read the header
248   mame_fcompress(file, FCOMPRESS_NONE);
249   mame_fseek(file, 0, SEEK_SET);
248   file.compress(FCOMPRESS_NONE);
249   file.seek(0, SEEK_SET);
250250   UINT8 header[HEADER_SIZE];
251   if (mame_fread(file, header, sizeof(header)) != sizeof(header))
251   if (file.read(header, sizeof(header)) != sizeof(header))
252252   {
253253      if (errormsg != NULL)
254254         (*errormsg)("Could not read " APPNAME " save file header");
r10384r10385
264264//  read_file - read the data from a file
265265//-------------------------------------------------
266266
267state_save_error state_manager::read_file(mame_file *file)
267state_save_error state_manager::read_file(emu_file &file)
268268{
269269   // if we have illegal registrations, return an error
270270   if (m_illegal_regs > 0)
271271      return STATERR_ILLEGAL_REGISTRATIONS;
272272
273273   // read the header and turn on compression for the rest of the file
274   mame_fcompress(file, FCOMPRESS_NONE);
275   mame_fseek(file, 0, SEEK_SET);
274   file.compress(FCOMPRESS_NONE);
275   file.seek(0, SEEK_SET);
276276   UINT8 header[HEADER_SIZE];
277   if (mame_fread(file, header, sizeof(header)) != sizeof(header))
277   if (file.read(header, sizeof(header)) != sizeof(header))
278278      return STATERR_READ_ERROR;
279   mame_fcompress(file, FCOMPRESS_MEDIUM);
279   file.compress(FCOMPRESS_MEDIUM);
280280
281281   // verify the header and report an error if it doesn't match
282282   UINT32 sig = signature();
r10384r10385
290290   for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next())
291291   {
292292      UINT32 totalsize = entry->m_typesize * entry->m_typecount;
293      if (mame_fread(file, entry->m_data, totalsize) != totalsize)
293      if (file.read(entry->m_data, totalsize) != totalsize)
294294         return STATERR_READ_ERROR;
295295
296296      // handle flipping
r10384r10385
310310//  write_file - writes the data to a file
311311//-------------------------------------------------
312312
313state_save_error state_manager::write_file(mame_file *file)
313state_save_error state_manager::write_file(emu_file &file)
314314{
315315   // if we have illegal registrations, return an error
316316   if (m_illegal_regs > 0)
r10384r10385
326326   *(UINT32 *)&header[0x1c] = LITTLE_ENDIANIZE_INT32(sig);
327327
328328   // write the header and turn on compression for the rest of the file
329   mame_fcompress(file, FCOMPRESS_NONE);
330   mame_fseek(file, 0, SEEK_SET);
331   if (mame_fwrite(file, header, sizeof(header)) != sizeof(header))
329   file.compress(FCOMPRESS_NONE);
330   file.seek(0, SEEK_SET);
331   if (file.write(header, sizeof(header)) != sizeof(header))
332332      return STATERR_WRITE_ERROR;
333   mame_fcompress(file, FCOMPRESS_MEDIUM);
333   file.compress(FCOMPRESS_MEDIUM);
334334
335335   // call the pre-save functions
336336   for (state_callback *func = m_presave_list.first(); func != NULL; func = func->next())
r10384r10385
340340   for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next())
341341   {
342342      UINT32 totalsize = entry->m_typesize * entry->m_typecount;
343      if (mame_fwrite(file, entry->m_data, totalsize) != totalsize)
343      if (file.write(entry->m_data, totalsize) != totalsize)
344344         return STATERR_WRITE_ERROR;
345345   }
346346   return STATERR_NONE;
src/emu/clifront.c
r10384r10385
251251
252252   /* validate? */
253253   if (options_get_bool(options, CLIOPTION_VALIDATE))
254   {
255      set_mame_options(options);
256      return mame_validitychecks(NULL);
257   }
254      return mame_validitychecks(*options, NULL);
258255
259256   return -1;
260257}
r10384r10385
293290   /* createconfig? */
294291   if (options_get_bool(options, CLIOPTION_CREATECONFIG))
295292   {
296      file_error filerr;
297      mame_file *file;
293      emu_file file(*options, NULL, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
298294
299295      /* parse any relevant INI files before proceeding */
300296      mame_parse_ini_files(options, driver);
301297
302298      /* make the output filename */
303      filerr = mame_fopen_options(options, NULL, CONFIGNAME ".ini", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
299      file_error filerr = file.open(CONFIGNAME ".ini");
304300
305301      /* error if unable to create the file */
306302      if (filerr != FILERR_NONE)
r10384r10385
310306      }
311307
312308      /* output the configuration and exit cleanly */
313      options_output_ini_file(options, mame_core_file(file));
314      mame_fclose(file);
309      options_output_ini_file(options, file);
315310      return MAMERR_NONE;
316311   }
317312
r10384r10385
905900            {
906901               if ( swlist->list_name[i] && *swlist->list_name[i] && (swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM))
907902               {
908                  software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL );
903                  software_list *list = software_list_open( *options, swlist->list_name[i], FALSE, NULL );
909904
910905                  if ( list )
911906                  {
r10384r10385
11031098         {
11041099            if ( swlist->list_name[i] )
11051100            {
1106               software_list *list = software_list_open( options, swlist->list_name[i], FALSE, NULL );
1101               software_list *list = software_list_open( *options, swlist->list_name[i], FALSE, NULL );
11071102
11081103               for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) )
11091104               {
src/emu/cheat.c
r10384r10385
230230//  save - save a single cheat parameter
231231//-------------------------------------------------
232232
233void cheat_parameter::save(mame_file &cheatfile) const
233void cheat_parameter::save(emu_file &cheatfile) const
234234{
235235   // output the parameter tag
236   mame_fprintf(&cheatfile, "\t\t<parameter");
236   cheatfile.printf("\t\t<parameter");
237237
238238   // if no items, just output min/max/step
239239   astring string;
240240   if (!has_itemlist())
241241   {
242242      if (m_minval != 0)
243         mame_fprintf(&cheatfile, " min=\"%s\"", m_minval.format(string));
243         cheatfile.printf(" min=\"%s\"", m_minval.format(string));
244244      if (m_maxval != 0)
245         mame_fprintf(&cheatfile, " max=\"%s\"", m_maxval.format(string));
245         cheatfile.printf(" max=\"%s\"", m_maxval.format(string));
246246      if (m_stepval != 1)
247         mame_fprintf(&cheatfile, " step=\"%s\"", m_stepval.format(string));
248      mame_fprintf(&cheatfile, "/>\n");
247         cheatfile.printf(" step=\"%s\"", m_stepval.format(string));
248      cheatfile.printf("/>\n");
249249   }
250250
251251   // iterate over items
252252   else
253253   {
254254      for (const item *curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next())
255         mame_fprintf(&cheatfile, "\t\t\t<item value=\"%s\">%s</item>\n", curitem->value().format(string), curitem->text());
256      mame_fprintf(&cheatfile, "\t\t</parameter>\n");
255         cheatfile.printf("\t\t\t<item value=\"%s\">%s</item>\n", curitem->value().format(string), curitem->text());
256      cheatfile.printf("\t\t</parameter>\n");
257257   }
258258}
259259
r10384r10385
402402//  save - save a single cheat script
403403//-------------------------------------------------
404404
405void cheat_script::save(mame_file &cheatfile) const
405void cheat_script::save(emu_file &cheatfile) const
406406{
407407   // output the script tag
408   mame_fprintf(&cheatfile, "\t\t<script");
408   cheatfile.printf("\t\t<script");
409409   switch (m_state)
410410   {
411      case SCRIPT_STATE_OFF:      mame_fprintf(&cheatfile, " state=\"off\"");      break;
412      case SCRIPT_STATE_ON:      mame_fprintf(&cheatfile, " state=\"on\"");      break;
411      case SCRIPT_STATE_OFF:      cheatfile.printf(" state=\"off\"");      break;
412      case SCRIPT_STATE_ON:      cheatfile.printf(" state=\"on\"");      break;
413413      default:
414      case SCRIPT_STATE_RUN:      mame_fprintf(&cheatfile, " state=\"run\"");      break;
415      case SCRIPT_STATE_CHANGE:   mame_fprintf(&cheatfile, " state=\"change\"");   break;
414      case SCRIPT_STATE_RUN:      cheatfile.printf(" state=\"run\"");      break;
415      case SCRIPT_STATE_CHANGE:   cheatfile.printf(" state=\"change\"");   break;
416416   }
417   mame_fprintf(&cheatfile, ">\n");
417   cheatfile.printf(">\n");
418418
419419   // output entries
420420   for (const script_entry *entry = m_entrylist.first(); entry != NULL; entry = entry->next())
421421      entry->save(cheatfile);
422422
423423   // close the tag
424   mame_fprintf(&cheatfile, "\t\t</script>\n");
424   cheatfile.printf("\t\t</script>\n");
425425}
426426
427427
r10384r10385
557557//  save - save a single action or output
558558//-------------------------------------------------
559559
560void cheat_script::script_entry::save(mame_file &cheatfile) const
560void cheat_script::script_entry::save(emu_file &cheatfile) const
561561{
562562   astring tempstring;
563563
564564   // output an action
565565   if (!m_format)
566566   {
567      mame_fprintf(&cheatfile, "\t\t\t<action");
567      cheatfile.printf("\t\t\t<action");
568568      if (!m_condition.is_empty())
569         mame_fprintf(&cheatfile, " condition=\"%s\"", cheat_manager::quote_expression(tempstring, m_condition));
570      mame_fprintf(&cheatfile, ">%s</action>\n", cheat_manager::quote_expression(tempstring, m_expression));
569         cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(tempstring, m_condition));
570      cheatfile.printf(">%s</action>\n", cheat_manager::quote_expression(tempstring, m_expression));
571571   }
572572
573573   // output an output
574574   else
575575   {
576      mame_fprintf(&cheatfile, "\t\t\t<output format=\"%s\"", m_format.cstr());
576      cheatfile.printf("\t\t\t<output format=\"%s\"", m_format.cstr());
577577      if (!m_condition.is_empty())
578         mame_fprintf(&cheatfile, " condition=\"%s\"", cheat_manager::quote_expression(tempstring, m_condition));
578         cheatfile.printf(" condition=\"%s\"", cheat_manager::quote_expression(tempstring, m_condition));
579579      if (m_line != 0)
580         mame_fprintf(&cheatfile, " line=\"%d\"", m_line);
580         cheatfile.printf(" line=\"%d\"", m_line);
581581      if (m_justify == JUSTIFY_CENTER)
582         mame_fprintf(&cheatfile, " align=\"center\"");
582         cheatfile.printf(" align=\"center\"");
583583      else if (m_justify == JUSTIFY_RIGHT)
584         mame_fprintf(&cheatfile, " align=\"right\"");
584         cheatfile.printf(" align=\"right\"");
585585      if (m_arglist.count() == 0)
586         mame_fprintf(&cheatfile, " />\n");
586         cheatfile.printf(" />\n");
587587
588588      // output arguments
589589      else
590590      {
591         mame_fprintf(&cheatfile, ">\n");
591         cheatfile.printf(">\n");
592592         for (const output_argument *curarg = m_arglist.first(); curarg != NULL; curarg = curarg->next())
593593            curarg->save(cheatfile);
594         mame_fprintf(&cheatfile, "\t\t\t</output>\n");
594         cheatfile.printf("\t\t\t</output>\n");
595595      }
596596   }
597597}
r10384r10385
691691//  save - save a single output argument
692692//-------------------------------------------------
693693
694void cheat_script::script_entry::output_argument::save(mame_file &cheatfile) const
694void cheat_script::script_entry::output_argument::save(emu_file &cheatfile) const
695695{
696696   astring tempstring;
697697
698   mame_fprintf(&cheatfile, "\t\t\t\t<argument");
698   cheatfile.printf("\t\t\t\t<argument");
699699   if (m_count != 1)
700      mame_fprintf(&cheatfile, " count=\"%d\"", (int)m_count);
701   mame_fprintf(&cheatfile, ">%s</argument>\n", cheat_manager::quote_expression(tempstring, m_expression));
700      cheatfile.printf(" count=\"%d\"", (int)m_count);
701   cheatfile.printf(">%s</argument>\n", cheat_manager::quote_expression(tempstring, m_expression));
702702}
703703
704704
r10384r10385
815815//  save - save a single cheat entry
816816//-------------------------------------------------
817817
818void cheat_entry::save(mame_file &cheatfile) const
818void cheat_entry::save(emu_file &cheatfile) const
819819{
820820   // determine if we have scripts
821821   bool has_scripts = (m_off_script != NULL || m_on_script != NULL || m_run_script != NULL || m_change_script != NULL);
822822
823823   // output the cheat tag
824   mame_fprintf(&cheatfile, "\t<cheat desc=\"%s\"", m_description.cstr());
824   cheatfile.printf("\t<cheat desc=\"%s\"", m_description.cstr());
825825   if (m_numtemp != DEFAULT_TEMP_VARIABLES)
826      mame_fprintf(&cheatfile, " tempvariables=\"%d\"", m_numtemp);
826      cheatfile.printf(" tempvariables=\"%d\"", m_numtemp);
827827   if (!m_comment && m_parameter == NULL && !has_scripts)
828      mame_fprintf(&cheatfile, " />\n");
828      cheatfile.printf(" />\n");
829829   else
830830   {
831      mame_fprintf(&cheatfile, ">\n");
831      cheatfile.printf(">\n");
832832
833833      // save the comment
834834      if (m_comment)
835         mame_fprintf(&cheatfile, "\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", m_comment.cstr());
835         cheatfile.printf("\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", m_comment.cstr());
836836
837837      // output the parameter, if present
838838      if (m_parameter != NULL)
r10384r10385
849849         m_run_script->save(cheatfile);
850850
851851      // close the cheat tag
852      mame_fprintf(&cheatfile, "\t</cheat>\n");
852      cheatfile.printf("\t</cheat>\n");
853853   }
854854}
855855
r10384r10385
10931093     m_symtable(&machine)
10941094{
10951095   // if the cheat engine is disabled, we're done
1096   if (!options_get_bool(machine.options(), OPTION_CHEAT))
1096   if (!options_get_bool(&machine.options(), OPTION_CHEAT))
10971097      return;
10981098
10991099   // request a callback
r10384r10385
11251125void cheat_manager::set_enable(bool enable)
11261126{
11271127   // if the cheat engine is disabled, we're done
1128   if (!options_get_bool(m_machine.options(), OPTION_CHEAT))
1128   if (!options_get_bool(&m_machine.options(), OPTION_CHEAT))
11291129      return;
11301130
11311131   // if we're enabled currently and we don't want to be, turn things off
r10384r10385
11601160void cheat_manager::reload()
11611161{
11621162   // if the cheat engine is disabled, we're done
1163   if (!options_get_bool(m_machine.options(), OPTION_CHEAT))
1163   if (!options_get_bool(&m_machine.options(), OPTION_CHEAT))
11641164      return;
11651165
11661166   // free everything
r10384r10385
12151215bool cheat_manager::save_all(const char *filename)
12161216{
12171217   // open the file with the proper name
1218   astring fname(filename, ".xml");
1219   mame_file *cheatfile;
1220   file_error filerr = mame_fopen(SEARCHPATH_CHEAT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &cheatfile);
1218   emu_file cheatfile(m_machine.options(), SEARCHPATH_CHEAT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1219   file_error filerr = cheatfile.open(filename, ".xml");
12211220
12221221   // if that failed, return nothing
12231222   if (filerr != FILERR_NONE)
r10384r10385
12271226   try
12281227   {
12291228      // output the outer layers
1230      mame_fprintf(cheatfile, "<?xml version=\"1.0\"?>\n");
1231      mame_fprintf(cheatfile, "<!-- This file is autogenerated; comments and unknown tags will be stripped -->\n");
1232      mame_fprintf(cheatfile, "<mamecheat version=\"%d\">\n", CHEAT_VERSION);
1229      cheatfile.printf("<?xml version=\"1.0\"?>\n");
1230      cheatfile.printf("<!-- This file is autogenerated; comments and unknown tags will be stripped -->\n");
1231      cheatfile.printf("<mamecheat version=\"%d\">\n", CHEAT_VERSION);
12331232
12341233      // iterate over cheats in the list and save them
12351234      for (cheat_entry *cheat = m_cheatlist.first(); cheat != NULL; cheat = cheat->next())
1236         cheat->save(*cheatfile);
1235         cheat->save(cheatfile);
12371236
12381237      // close out the file
1239      mame_fprintf(cheatfile, "</mamecheat>\n");
1240      mame_fclose(cheatfile);
1238      cheatfile.printf("</mamecheat>\n");
12411239      return true;
12421240   }
12431241
r10384r10385
12451243   catch (emu_fatalerror &err)
12461244   {
12471245      mame_printf_error("%s\n", err.string());
1248      mame_fclose(cheatfile);
1249      osd_rmfile(filename);
1246      cheatfile.remove_on_close();
12501247   }
12511248   return false;
12521249}
r10384r10385
14141411void cheat_manager::load_cheats(const char *filename)
14151412{
14161413   xml_data_node *rootnode = NULL;
1417   mame_file *cheatfile = NULL;
1414   emu_file cheatfile(m_machine.options(), SEARCHPATH_CHEAT, OPEN_FLAG_READ);
14181415   try
14191416   {
14201417      // open the file with the proper name
1421      astring fname(filename, ".xml");
1422      file_error filerr = mame_fopen(SEARCHPATH_CHEAT, fname, OPEN_FLAG_READ, &cheatfile);
1418      file_error filerr = cheatfile.open(filename, ".xml");
14231419
14241420      // loop over all instrances of the files found in our search paths
14251421      while (filerr == FILERR_NONE)
14261422      {
1427         mame_printf_verbose("Loading cheats file from %s\n", mame_file_full_name(cheatfile).cstr());
1423         mame_printf_verbose("Loading cheats file from %s\n", cheatfile.fullpath());
14281424
14291425         // read the XML file into internal data structures
14301426         xml_parse_options options = { 0 };
14311427         xml_parse_error error;
14321428         options.error = &error;
1433         rootnode = xml_file_read(mame_core_file(cheatfile), &options);
1429         rootnode = xml_file_read(cheatfile, &options);
14341430
14351431         // if unable to parse the file, just bail
14361432         if (rootnode == NULL)
r10384r10385
14581454               for (scannode = m_cheatlist.first(); scannode != NULL; scannode = scannode->next())
14591455                  if (strcmp(scannode->description(), curcheat->description()) == 0)
14601456                  {
1461                     mame_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", curcheat->description(), mame_file_full_name(cheatfile).cstr());
1457                     mame_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", curcheat->description(), cheatfile.fullpath());
14621458                     break;
14631459                  }
14641460
r10384r10385
14731469         xml_file_free(rootnode);
14741470
14751471         // open the next file in sequence
1476         filerr = mame_fclose_and_open_next(&cheatfile, fname, OPEN_FLAG_READ);
1472         filerr = cheatfile.open_next();
14771473      }
14781474   }
14791475
r10384r10385
14841480      m_cheatlist.reset();
14851481      if (rootnode != NULL)
14861482         xml_file_free(rootnode);
1487      if (cheatfile != NULL)
1488         mame_fclose(cheatfile);
14891483   }
14901484}
src/emu/validity.c
r10384r10385
10771077    checks
10781078-------------------------------------------------*/
10791079
1080static bool validate_devices(const machine_config &config, const ioport_list &portlist, region_array *rgninfo)
1080static bool validate_devices(const machine_config &config, const ioport_list &portlist, region_array *rgninfo, core_options &options)
10811081{
10821082   bool error = false;
10831083   const game_driver &driver = config.gamedrv();
r10384r10385
11001100         mame_printf_warning("Device %s does not have short name defined\n", devconfig->name());
11011101      }
11021102      /* check for device-specific validity check */
1103      if (devconfig->validity_check(driver))
1103      if (devconfig->validity_check(options, driver))
11041104         error = true;
11051105
11061106   }
r10384r10385
11121112    mame_validitychecks - master validity checker
11131113-------------------------------------------------*/
11141114
1115bool mame_validitychecks(const game_driver *curdriver)
1115bool mame_validitychecks(core_options &options, const game_driver *curdriver)
11161116{
11171117   osd_ticks_t prep = 0;
11181118   osd_ticks_t expansion = 0;
r10384r10385
12191219
12201220         /* validate devices */
12211221         device_checks -= get_profile_ticks();
1222         error = validate_devices(config, portlist, &rgninfo) || error;
1222         error = validate_devices(config, portlist, &rgninfo, options) || error;
12231223         device_checks += get_profile_ticks();
12241224      }
12251225      catch (emu_fatalerror &err)
src/emu/state.h
r10384r10385
202202   void save_pointer(T *value, const char *valname, UINT32 count, int index = 0) { save_pointer("global", NULL, index, value, valname, count); }
203203
204204   // file processing
205   static state_save_error check_file(running_machine *machine, mame_file *file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...));
206   state_save_error write_file(mame_file *file);
207   state_save_error read_file(mame_file *file);
205   static state_save_error check_file(running_machine *machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...));
206   state_save_error write_file(emu_file &file);
207   state_save_error read_file(emu_file &file);
208208
209209private:
210210   // internal helpers
src/emu/cheat.h
r10384r10385
115115   bool set_next_state();
116116
117117   // actions
118   void save(mame_file &cheatfile) const;
118   void save(emu_file &cheatfile) const;
119119
120120private:
121121   // a single item in a parameter item list
r10384r10385
168168
169169   // actions
170170   void execute(cheat_manager &manager, UINT64 &argindex);
171   void save(mame_file &cheatfile) const;
171   void save(emu_file &cheatfile) const;
172172
173173private:
174174   // an entry within the script
r10384r10385
185185
186186      // actions
187187      void execute(cheat_manager &manager, UINT64 &argindex);
188      void save(mame_file &cheatfile) const;
188      void save(emu_file &cheatfile) const;
189189
190190   private:
191191      // an argument for output
r10384r10385
203203         int values(UINT64 &argindex, UINT64 *result);
204204
205205         // actions
206         void save(mame_file &cheatfile) const;
206         void save(emu_file &cheatfile) const;
207207
208208      private:
209209         // internal state
r10384r10385
278278   bool select_default_state();
279279   bool select_previous_state();
280280   bool select_next_state();
281   void save(mame_file &cheatfile) const;
281   void save(emu_file &cheatfile) const;
282282
283283   // UI helpers
284284   void menu_text(astring &description, astring &state, UINT32 &flags);
src/emu/validity.h
r10384r10385
1414#ifndef __VALIDITY_H__
1515#define __VALIDITY_H__
1616
17bool mame_validitychecks(const game_driver *driver);
17bool mame_validitychecks(core_options &options, const game_driver *driver);
1818bool validate_tag(const game_driver &driver, const char *object, const char *tag);
1919
2020#endif
src/emu/romload.c
r10384r10385
4040   open_chd *         next;               /* pointer to next in the list */
4141   const char *      region;               /* disk region we came from */
4242   chd_file *         origchd;            /* handle to the original CHD */
43   mame_file *         origfile;            /* file handle to the original CHD file */
43   emu_file *         origfile;            /* file handle to the original CHD file */
4444   chd_file *         diffchd;            /* handle to the diff CHD */
45   mame_file *         difffile;            /* file handle to the diff CHD file */
45   emu_file *         difffile;            /* file handle to the diff CHD file */
4646};
4747
4848
r10384r10385
6161   UINT32         romsloadedsize;      /* total size of ROMs loaded so far */
6262   UINT32         romstotalsize;      /* total size of ROMs to read */
6363
64   mame_file *      file;            /* current file */
64   emu_file *      file;            /* current file */
6565   open_chd *      chd_list;         /* disks */
6666   open_chd **      chd_list_tailptr;
6767
r10384r10385
8181    HELPERS (also used by devimage.c)
8282 ***************************************************************************/
8383
84file_error common_process_file_options(core_options *options, const char *location, const char *ext, const rom_entry *romp, mame_file **image_file)
84file_error common_process_file(core_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file **image_file)
8585{
86   *image_file = global_alloc(emu_file(options, SEARCHPATH_IMAGE, OPEN_FLAG_READ));
87   file_error filerr;
88
8689   if (location != NULL && strcmp(location, "") != 0)
87   {
88      astring fname(location, PATH_SEPARATOR, ROM_GETNAME(romp));
89      fname.cat(ext);
90      return mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
91   }
90      filerr = (*image_file)->open(location, PATH_SEPARATOR, ROM_GETNAME(romp), ext);
9291   else
92      filerr = (*image_file)->open(ROM_GETNAME(romp), ext);
93
94   if (filerr != FILERR_NONE)
9395   {
94      astring fname(ROM_GETNAME(romp));
95      fname.cat(ext);
96      return mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
96      global_free(*image_file);
97      *image_file = NULL;
9798   }
98
99   return FILERR_NOT_FOUND;
99   return filerr;
100100}
101101
102file_error common_process_file(const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, mame_file **image_file)
102file_error common_process_file(core_options &options, const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, emu_file **image_file)
103103{
104   *image_file = global_alloc(emu_file(options, SEARCHPATH_IMAGE, OPEN_FLAG_READ));
104105   file_error filerr;
105   astring fname(location, PATH_SEPARATOR, ROM_GETNAME(romp));
106106
107107   if (has_crc)
108      filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, image_file);
108      filerr = (*image_file)->open(location, PATH_SEPARATOR, ROM_GETNAME(romp), crc);
109109   else
110      filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, image_file);
110      filerr = (*image_file)->open(location, PATH_SEPARATOR, ROM_GETNAME(romp));
111111
112   if (filerr != FILERR_NONE)
113   {
114      global_free(*image_file);
115      *image_file = NULL;
116   }
112117   return filerr;
113118}
114119
r10384r10385
153158    file associated with the given region
154159-------------------------------------------------*/
155160
156void set_disk_handle(running_machine *machine, const char *region, mame_file *file, chd_file *chdfile)
161void set_disk_handle(running_machine &machine, const char *region, emu_file &file, chd_file &chdfile)
157162{
158163   open_chd chd = { 0 };
159164
160165   /* note the region we are in */
161166   chd.region = region;
162   chd.origchd = chdfile;
163   chd.origfile = file;
167   chd.origchd = &chdfile;
168   chd.origfile = &file;
164169
165170   /* we're okay, add to the list of disks */
166   add_disk_handle(machine, &chd);
171   add_disk_handle(&machine, &chd);
167172}
168173
169174
r10384r10385
325330
326331static void determine_bios_rom(rom_load_data *romdata)
327332{
328   const char *specbios = options_get_string(romdata->machine->options(), OPTION_BIOS);
333   const char *specbios = options_get_string(&romdata->machine->options(), OPTION_BIOS);
329334   const char *defaultname = NULL;
330335   const rom_entry *rom;
331336   int default_no = 1;
r10384r10385
508513      return;
509514
510515   /* get the length and CRC from the file */
511   actlength = mame_fsize(romdata->file);
512   acthash = mame_fhash(romdata->file, hash_data_used_functions(hash));
516   actlength = romdata->file->size();
517   acthash = romdata->file->hash_string(hash_data_used_functions(hash));
513518
514519   /* verify length */
515520   if (explength != actlength)
r10384r10385
658663   romdata->file = NULL;
659664   for (drv = romdata->machine->gamedrv; romdata->file == NULL && drv != NULL; drv = driver_get_clone(drv))
660665      if (drv->name != NULL && *drv->name != 0)
661         filerr = common_process_file(drv->name, has_crc, crc, romp, &romdata->file);
666         filerr = common_process_file(romdata->machine->options(), drv->name, has_crc, crc, romp, &romdata->file);
662667
663668   /* if the region is load by name, load the ROM from there */
664669   if (romdata->file == NULL && regiontag != NULL)
r10384r10385
708713      // - if we are not using lists, we have regiontag only;
709714      // - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname
710715      if (!is_list)
711         filerr = common_process_file(tag1.cstr(), has_crc, crc, romp, &romdata->file);
716         filerr = common_process_file(romdata->machine->options(), tag1.cstr(), has_crc, crc, romp, &romdata->file);
712717      else
713718      {
714719         // try to load from list/setname
715720         if ((romdata->file == NULL) && (tag2.cstr() != NULL))
716            filerr = common_process_file(tag2.cstr(), has_crc, crc, romp, &romdata->file);
721            filerr = common_process_file(romdata->machine->options(), tag2.cstr(), has_crc, crc, romp, &romdata->file);
717722         // try to load from list/parentname
718723         if ((romdata->file == NULL) && has_parent && (tag3.cstr() != NULL))
719            filerr = common_process_file(tag3.cstr(), has_crc, crc, romp, &romdata->file);
724            filerr = common_process_file(romdata->machine->options(), tag3.cstr(), has_crc, crc, romp, &romdata->file);
720725         // try to load from setname
721726         if ((romdata->file == NULL) && (tag4.cstr() != NULL))
722            filerr = common_process_file(tag4.cstr(), has_crc, crc, romp, &romdata->file);
727            filerr = common_process_file(romdata->machine->options(), tag4.cstr(), has_crc, crc, romp, &romdata->file);
723728         // try to load from parentname
724729         if ((romdata->file == NULL) && has_parent && (tag5.cstr() != NULL))
725            filerr = common_process_file(tag5.cstr(), has_crc, crc, romp, &romdata->file);
730            filerr = common_process_file(romdata->machine->options(), tag5.cstr(), has_crc, crc, romp, &romdata->file);
726731      }
727732   }
728733
r10384r10385
744749{
745750   /* files just pass through */
746751   if (romdata->file != NULL)
747      return mame_fread(romdata->file, buffer, length);
752      return romdata->file->read(buffer, length);
748753
749754   /* otherwise, fill with randomness */
750755   else
r10384r10385
10071012
10081013            /* reseek to the start and clear the baserom so we don't reverify */
10091014            if (romdata->file != NULL)
1010               mame_fseek(romdata->file, 0, SEEK_SET);
1015               romdata->file->seek(0, SEEK_SET);
10111016            baserom = NULL;
10121017            explength = 0;
10131018         }
r10384r10385
10171022         if (romdata->file != NULL)
10181023         {
10191024            LOG(("Closing ROM file\n"));
1020            mame_fclose(romdata->file);
1025            global_free(romdata->file);
10211026            romdata->file = NULL;
10221027         }
10231028      }
r10384r10385
10301035
10311036
10321037/*-------------------------------------------------
1033    open_disk_image - open a disk image, searching
1034    up the parent and loading by checksum
1035-------------------------------------------------*/
1036
1037chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd, const char *locationtag)
1038{
1039   return open_disk_image_options(mame_options(), gamedrv, romp, image_file, image_chd, locationtag);
1040}
1041
1042
1043/*-------------------------------------------------
1044    open_disk_image_options - open a disk image,
1038    open_disk_image - open a disk image,
10451039    searching up the parent and loading by
10461040    checksum
10471041-------------------------------------------------*/
10481042
1049chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd, const char *locationtag)
1043chd_error open_disk_image(core_options &options, const game_driver *gamedrv, const rom_entry *romp, emu_file **image_file, chd_file **image_chd, const char *locationtag)
10501044{
10511045   const game_driver *drv, *searchdrv;
10521046   const rom_entry *region, *rom;
r10384r10385
10601054   /* attempt to open the properly named file, scanning up through parent directories */
10611055   filerr = FILERR_NOT_FOUND;
10621056   for (searchdrv = gamedrv; searchdrv != NULL && filerr != FILERR_NONE; searchdrv = driver_get_clone(searchdrv))
1063      filerr = common_process_file_options(options, searchdrv->name, ".chd", romp, image_file);
1057      filerr = common_process_file(options, searchdrv->name, ".chd", romp, image_file);
10641058
10651059   if (filerr != FILERR_NONE)
1066      filerr = common_process_file_options(options, NULL, ".chd", romp, image_file);
1060      filerr = common_process_file(options, NULL, ".chd", romp, image_file);
10671061
10681062   /* look for the disk in the locationtag too */
10691063   if (filerr != FILERR_NONE && locationtag != NULL)
r10384r10385
11131107      // - if we are not using lists, we have locationtag only;
11141108      // - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname
11151109      if (!is_list)
1116         filerr = common_process_file_options(options, locationtag, ".chd", romp, image_file);
1110         filerr = common_process_file(options, locationtag, ".chd", romp, image_file);
11171111      else
11181112      {
11191113         // try to load from list/setname
11201114         if ((filerr != FILERR_NONE) && (tag2.cstr() != NULL))
1121            filerr = common_process_file_options(options, tag2.cstr(), ".chd", romp, image_file);
1115            filerr = common_process_file(options, tag2.cstr(), ".chd", romp, image_file);
11221116         // try to load from list/parentname (if any)
11231117         if ((filerr != FILERR_NONE) && has_parent && (tag3.cstr() != NULL))
1124            filerr = common_process_file_options(options, tag3.cstr(), ".chd", romp, image_file);
1118            filerr = common_process_file(options, tag3.cstr(), ".chd", romp, image_file);
11251119         // try to load from setname
11261120         if ((filerr != FILERR_NONE) && (tag4.cstr() != NULL))
1127            filerr = common_process_file_options(options, tag4.cstr(), ".chd", romp, image_file);
1121            filerr = common_process_file(options, tag4.cstr(), ".chd", romp, image_file);
11281122         // try to load from parentname (if any)
11291123         if ((filerr != FILERR_NONE) && has_parent && (tag5.cstr() != NULL))
1130            filerr = common_process_file_options(options, tag5.cstr(), ".chd", romp, image_file);
1124            filerr = common_process_file(options, tag5.cstr(), ".chd", romp, image_file);
11311125         // only for CHD we also try to load from list/
11321126         if ((filerr != FILERR_NONE) && (tag1.cstr() != NULL))
11331127         {
11341128            tag1.del(tag1.len() - 1, 1);   // remove the PATH_SEPARATOR
1135            filerr = common_process_file_options(options, tag1.cstr(), ".chd", romp, image_file);
1129            filerr = common_process_file(options, tag1.cstr(), ".chd", romp, image_file);
11361130         }
11371131      }
11381132   }
r10384r10385
11411135   if (filerr == FILERR_NONE)
11421136   {
11431137      /* try to open the CHD */
1144      err = chd_open_file(mame_core_file(*image_file), CHD_OPEN_READ, NULL, image_chd);
1138      err = chd_open_file(**image_file, CHD_OPEN_READ, NULL, image_chd);
11451139      if (err == CHDERR_NONE)
11461140         return err;
11471141
11481142      /* close the file on failure */
1149      mame_fclose(*image_file);
1143      global_free(*image_file);
11501144      *image_file = NULL;
11511145   }
11521146   else
r10384r10385
11691163                     /* attempt to open the properly named file, scanning up through parent directories */
11701164                     filerr = FILERR_NOT_FOUND;
11711165                     for (searchdrv = drv; searchdrv != NULL && filerr != FILERR_NONE; searchdrv = driver_get_clone(searchdrv))
1172                        filerr = common_process_file_options(options, searchdrv->name, ".chd", rom, image_file);
1166                        filerr = common_process_file(options, searchdrv->name, ".chd", rom, image_file);
11731167
11741168                     if (filerr != FILERR_NONE)
1175                        filerr = common_process_file_options(options, NULL, ".chd", rom, image_file);
1169                        filerr = common_process_file(options, NULL, ".chd", rom, image_file);
11761170
11771171                     /* did the file open succeed? */
11781172                     if (filerr == FILERR_NONE)
11791173                     {
11801174                        /* try to open the CHD */
1181                        err = chd_open_file(mame_core_file(*image_file), CHD_OPEN_READ, NULL, image_chd);
1175                        err = chd_open_file(**image_file, CHD_OPEN_READ, NULL, image_chd);
11821176                        if (err == CHDERR_NONE)
11831177                           return err;
11841178
11851179                        /* close the file on failure */
1186                        mame_fclose(*image_file);
1180                        global_free(*image_file);
11871181                        *image_file = NULL;
11881182                     }
11891183                  }
r10384r10385
11971191    open_disk_diff - open a DISK diff file
11981192-------------------------------------------------*/
11991193
1200static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, chd_file *source, mame_file **diff_file, chd_file **diff_chd)
1194static chd_error open_disk_diff(core_options &options, const rom_entry *romp, chd_file *source, emu_file **diff_file, chd_file **diff_chd)
12011195{
12021196   astring fname(ROM_GETNAME(romp), ".dif");
1203   file_error filerr;
12041197   chd_error err;
12051198
12061199   *diff_file = NULL;
r10384r10385
12081201
12091202   /* try to open the diff */
12101203   LOG(("Opening differencing image file: %s\n", fname.cstr()));
1211   filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, fname, OPEN_FLAG_READ | OPEN_FLAG_WRITE, diff_file);
1204   *diff_file = global_alloc(emu_file(options, SEARCHPATH_IMAGE_DIFF, OPEN_FLAG_READ | OPEN_FLAG_WRITE));
1205   file_error filerr = (*diff_file)->open(fname);
12121206   if (filerr != FILERR_NONE)
12131207   {
12141208      /* didn't work; try creating it instead */
12151209      LOG(("Creating differencing image: %s\n", fname.cstr()));
1216      filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, fname, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, diff_file);
1210      (*diff_file)->set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1211      filerr = (*diff_file)->open(fname);
12171212      if (filerr != FILERR_NONE)
12181213      {
12191214         err = CHDERR_FILE_NOT_FOUND;
r10384r10385
12211216      }
12221217
12231218      /* create the CHD */
1224      err = chd_create_file(mame_core_file(*diff_file), 0, 0, CHDCOMPRESSION_NONE, source);
1219      err = chd_create_file(**diff_file, 0, 0, CHDCOMPRESSION_NONE, source);
12251220      if (err != CHDERR_NONE)
12261221         goto done;
12271222   }
12281223
12291224   LOG(("Opening differencing image file: %s\n", fname.cstr()));
1230   err = chd_open_file(mame_core_file(*diff_file), CHD_OPEN_READWRITE, source, diff_chd);
1225   err = chd_open_file(**diff_file, CHD_OPEN_READWRITE, source, diff_chd);
12311226   if (err != CHDERR_NONE)
12321227      goto done;
12331228
12341229done:
12351230   if ((err != CHDERR_NONE) && (*diff_file != NULL))
12361231   {
1237      mame_fclose(*diff_file);
1232      global_free(*diff_file);
12381233      *diff_file = NULL;
12391234   }
12401235   return err;
r10384r10385
12671262
12681263         /* first open the source drive */
12691264         LOG(("Opening disk image: %s\n", filename.cstr()));
1270         err = open_disk_image(romdata->machine->gamedrv, romp, &chd.origfile, &chd.origchd, locationtag);
1265         err = open_disk_image(romdata->machine->options(), romdata->machine->gamedrv, romp, &chd.origfile, &chd.origchd, locationtag);
12711266         if (err != CHDERR_NONE)
12721267         {
12731268            if (err == CHDERR_FILE_NOT_FOUND)
r10384r10385
13071302         if (!DISK_ISREADONLY(romp))
13081303         {
13091304            /* try to open or create the diff */
1310            err = open_disk_diff(romdata->machine->gamedrv, romp, chd.origchd, &chd.difffile, &chd.diffchd);
1305            err = open_disk_diff(romdata->machine->options(), romp, chd.origchd, &chd.difffile, &chd.diffchd);
13111306            if (err != CHDERR_NONE)
13121307            {
13131308               romdata->errorstring.catprintf("%s DIFF CHD ERROR: %s\n", filename.cstr(), chd_error_string(err));
r10384r10385
13841379   // " swlist % clonename % parentname "
13851380   // open_rom_file contains the code to split the elements and to create paths to load from
13861381
1387   software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
1382   software_list *software_list_ptr = software_list_open(device->machine->options(), swlist, FALSE, NULL);
13881383   if (software_list_ptr)
13891384   {
13901385      locationtag.cat(breakstr);
r10384r10385
13981393            locationtag.cat(breakstr);
13991394            // printf("%s\n", locationtag.cstr());
14001395         }
1401         const char *parentname = software_get_clone(swlist, swinfo->shortname);
1396         const char *parentname = software_get_clone(device->machine->options(), swlist, swinfo->shortname);
14021397         if (parentname != NULL)
14031398            swinfo = software_list_find(software_list_ptr, parentname, NULL);
14041399         else
r10384r10385
14141409
14151410   romdata->errorstring.reset();
14161411
1417   if (software_get_support(swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
1412   if (software_get_support(device->machine->options(), swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
14181413   {
14191414      romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist);
14201415      romdata->warnings++;
14211416   }
1422   if (software_get_support(swlist, swname) == SOFTWARE_SUPPORTED_NO)
1417   if (software_get_support(device->machine->options(), swlist, swname) == SOFTWARE_SUPPORTED_NO)
14231418   {
14241419      romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist);
14251420      romdata->warnings++;
r10384r10385
15931588      if (curchd->diffchd != NULL)
15941589         chd_close(curchd->diffchd);
15951590      if (curchd->difffile != NULL)
1596         mame_fclose(curchd->difffile);
1591         global_free(curchd->difffile);
15971592      if (curchd->origchd != NULL)
15981593         chd_close(curchd->origchd);
15991594      if (curchd->origfile != NULL)
1600         mame_fclose(curchd->origfile);
1595         global_free(curchd->origfile);
16011596   }
16021597}
16031598
src/emu/imagedev/multcart.h
r10384r10385
9292***************************************************************************/
9393
9494/* opens a multicart */
95multicart_open_error multicart_open(const char *filename, const char *drvname, multicart_load_flags load_flags, multicart_t **cart);
95multicart_open_error multicart_open(core_options &options, const char *filename, const char *drvname, multicart_load_flags load_flags, multicart_t **cart);
9696
9797/* closes a multicart */
98void multicart_close(multicart_t *cart);
98void multicart_close(core_options &options, multicart_t *cart);
9999
100100#endif /* __MULTCART_H__ */
src/emu/imagedev/cartslot.c
r10384r10385
303303      return (*config->device_load)(image);
304304
305305   /* try opening this as if it were a multicart */
306   multicart_open(image.filename(), device->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
306   multicart_open(device->machine->options(), image.filename(), device->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
307307   if (cart->mc == NULL)
308308   {
309309
r10384r10385
337337
338338   if (cart->mc != NULL)
339339   {
340      multicart_close(cart->mc);
340      multicart_close(device->machine->options(), cart->mc);
341341      cart->mc = NULL;
342342   }
343343
r10384r10385
360360   if (image.software_entry() == NULL && image.exists())
361361   {
362362      /* try opening this as if it were a multicart */
363      multicart_open_error me = multicart_open(image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_DONT_LOAD_RESOURCES, &mc);
363      multicart_open_error me = multicart_open(image.device().machine->options(), image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_DONT_LOAD_RESOURCES, &mc);
364364      if (me == MCERR_NONE)
365365      {
366366         /* this was a multicart - read from it */
367367         astring_cpyc(&pcb_name, mc->pcb_type);
368         multicart_close(mc);
368         multicart_close(image.device().machine->options(), mc);
369369      }
370370      else
371371      {
src/emu/imagedev/multcart.c
r10384r10385
66
77*********************************************************************/
88
9#include "emu.h"
910#include "multcart.h"
1011#include "pool.h"
1112#include "unzip.h"
1213#include "corestr.h"
1314#include "xmlfile.h"
14#include "emu.h"
1515#include "hash.h"
1616#include "machine/ram.h"
1717
r10384r10385
212212    load_ram_resource
213213-------------------------------------------------*/
214214
215static multicart_open_error load_ram_resource(multicart_load_state *state, xml_data_node *resource_node,
215static multicart_open_error load_ram_resource(core_options &options, multicart_load_state *state, xml_data_node *resource_node,
216216   multicart_resource *resource)
217217{
218218   const char *length_string;
r10384r10385
258258         if (resource->filename == NULL)
259259            return MCERR_OUT_OF_MEMORY;
260260
261         image_battery_load_by_name(resource->filename, resource->ptr, resource->length, 0x00);
261         image_battery_load_by_name(options, resource->filename, resource->ptr, resource->length, 0x00);
262262      }
263263      /* else this type is volatile, in which case we just have
264264            a memory expansion */
r10384r10385
271271    load_resource
272272-------------------------------------------------*/
273273
274static multicart_open_error load_resource(multicart_load_state *state, xml_data_node *resource_node,
274static multicart_open_error load_resource(core_options &options, multicart_load_state *state, xml_data_node *resource_node,
275275   multicart_resource_type resource_type)
276276{
277277   const char *id;
r10384r10385
305305         break;
306306
307307      case MULTICART_RESOURCE_TYPE_RAM:
308         err = load_ram_resource(state, resource_node, resource);
308         err = load_ram_resource(options, state, resource_node, resource);
309309         if (err != MCERR_NONE)
310310            return err;
311311         break;
r10384r10385
327327    load_all_resources
328328-------------------------------------------------*/
329329
330static multicart_open_error load_all_resources(multicart_load_state *state)
330static multicart_open_error load_all_resources(core_options &options, multicart_load_state *state)
331331{
332332   multicart_open_error err;
333333   xml_data_node *resource_node;
r10384r10385
338338      resource_type = get_resource_type(resource_node->name);
339339      if (resource_type != MULTICART_RESOURCE_TYPE_INVALID)
340340      {
341         err = load_resource(state, resource_node, resource_type);
341         err = load_resource(options, state, resource_node, resource_type);
342342         if (err != MCERR_NONE)
343343            return err;
344344      }
r10384r10385
354354    be freed on multicart_close.
355355-------------------------------------------------*/
356356
357static multicart_open_error save_ram_resources(multicart_t *cart)
357static multicart_open_error save_ram_resources(core_options &options, multicart_t *cart)
358358{
359359   const multicart_resource *resource;
360360
r10384r10385
362362   {
363363      if ((resource->type == MULTICART_RESOURCE_TYPE_RAM) && (resource->filename != NULL))
364364      {
365         image_battery_save_by_name(resource->filename, resource->ptr, resource->length);
365         image_battery_save_by_name(options, resource->filename, resource->ptr, resource->length);
366366      }
367367   }
368368   return MCERR_NONE;
r10384r10385
460460    multicart_open - opens a multicart
461461-------------------------------------------------*/
462462
463multicart_open_error multicart_open(const char *filename, const char *gamedrv, multicart_load_flags load_flags, multicart_t **cart)
463multicart_open_error multicart_open(core_options &options, const char *filename, const char *gamedrv, multicart_load_flags load_flags, multicart_t **cart)
464464{
465465   multicart_open_error err;
466466   zip_error ziperr;
r10384r10385
565565   /* do we have to load resources? */
566566   if (load_flags & MULTICART_FLAGS_LOAD_RESOURCES)
567567   {
568      err = load_all_resources(&state);
568      err = load_all_resources(options, &state);
569569      if (err != MCERR_NONE)
570570         goto done;
571571
r10384r10385
588588
589589   if ((err != MCERR_NONE) && (state.multicart != NULL))
590590   {
591      multicart_close(state.multicart);
591      multicart_close(options, state.multicart);
592592      state.multicart = NULL;
593593   }
594594   *cart = state.multicart;
r10384r10385
600600    multicart_close - closes a multicart
601601-------------------------------------------------*/
602602
603void multicart_close(multicart_t *cart)
603void multicart_close(core_options &options, multicart_t *cart)
604604{
605   save_ram_resources(cart);
605   save_ram_resources(options, cart);
606606   pool_free_lib(cart->data->pool);
607607}
src/emu/romload.h
r10384r10385
285285
286286/* ----- Helpers ----- */
287287
288file_error common_process_file_options(core_options *options, const char *location, const char *ext, const rom_entry *romp, mame_file **image_file);
289file_error common_process_file(const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, mame_file **image_file);
288file_error common_process_file(core_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file **image_file);
289file_error common_process_file(core_options &options, const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, emu_file **image_file);
290290
291291
292292/* ----- ROM iteration ----- */
r10384r10385
323323/* ----- disk handling ----- */
324324
325325/* open a disk image, searching up the parent and loading by checksum */
326chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag);
326chd_error open_disk_image(core_options &options, const game_driver *gamedrv, const rom_entry *romp, emu_file **image_file, chd_file **image_chd,const char *locationtag);
327327
328/* open a disk image, searching up the parent and loading by checksum */
329chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag);
330
331328/* return a pointer to the CHD file associated with the given region */
332329chd_file *get_disk_handle(running_machine *machine, const char *region);
333330
334331/* set a pointer to the CHD file associated with the given region */
335void set_disk_handle(running_machine *machine, const char *region, mame_file *file, chd_file *chd);
332void set_disk_handle(running_machine &machine, const char *region, emu_file &file, chd_file &chdfile);
336333
337334void load_software_part_region(device_t *device, char *swlist, char *swname, rom_entry *start_region);
338335
src/emu/disound.c
r10384r10385
104104//  constructed
105105//-------------------------------------------------
106106
107bool device_config_sound_interface::interface_validity_check(const game_driver &driver) const
107bool device_config_sound_interface::interface_validity_check(core_options &options, const game_driver &driver) const
108108{
109109   bool error = false;
110110
src/emu/config.c
r10384r10385
4646    FUNCTION PROTOTYPES
4747***************************************************************************/
4848
49static int config_load_xml(running_machine *machine, mame_file *file, int type);
50static int config_save_xml(running_machine *machine, mame_file *file, int type);
49static int config_load_xml(running_machine *machine, emu_file &file, int type);
50static int config_save_xml(running_machine *machine, emu_file &file, int type);
5151
5252
5353
r10384r10385
102102
103103int config_load_settings(running_machine *machine)
104104{
105   const char *controller = options_get_string(machine->options(), OPTION_CTRLR);
106   file_error filerr;
105   const char *controller = options_get_string(&machine->options(), OPTION_CTRLR);
107106   config_type *type;
108   mame_file *file;
109107   int loaded = 0;
110108
111109   /* loop over all registrants and call their init function */
r10384r10385
116114   if (controller[0] != 0)
117115   {
118116      /* open the config file */
119      astring fname(controller, ".cfg");
120      filerr = mame_fopen(SEARCHPATH_CTRLR, fname, OPEN_FLAG_READ, &file);
117      emu_file file(machine->options(), SEARCHPATH_CTRLR, OPEN_FLAG_READ);
118      file_error filerr = file.open(controller, ".cfg");
121119
122120      if (filerr != FILERR_NONE)
123121         throw emu_fatalerror("Could not load controller file %s.cfg", controller);
r10384r10385
125123      /* load the XML */
126124      if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER))
127125         throw emu_fatalerror("Could not load controller file %s.cfg", controller);
128      mame_fclose(file);
129126   }
130127
131128   /* next load the defaults file */
132   filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_READ, &file);
129   emu_file file(machine->options(), SEARCHPATH_CONFIG, OPEN_FLAG_READ);
130   file_error filerr = file.open("default.cfg");
133131   if (filerr == FILERR_NONE)
134   {
135132      config_load_xml(machine, file, CONFIG_TYPE_DEFAULT);
136      mame_fclose(file);
137   }
138133
139134   /* finally, load the game-specific file */
140   astring fname(machine->basename(), ".cfg");
141   filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_READ, &file);
142
135   filerr = file.open(machine->basename(), ".cfg");
143136   if (filerr == FILERR_NONE)
144   {
145137      loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME);
146      mame_fclose(file);
147   }
148138
149139   /* loop over all registrants and call their final function */
150140   for (type = typelist; type; type = type->next)
r10384r10385
158148
159149void config_save_settings(running_machine *machine)
160150{
161   file_error filerr;
162151   config_type *type;
163   mame_file *file;
164152
165153   /* loop over all registrants and call their init function */
166154   for (type = typelist; type; type = type->next)
167155      (*type->save)(machine, CONFIG_TYPE_INIT, NULL);
168156
169157   /* save the defaults file */
170   filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
158   emu_file file(machine->options(), SEARCHPATH_CONFIG, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
159   file_error filerr = file.open("default.cfg");
171160   if (filerr == FILERR_NONE)
172   {
173161      config_save_xml(machine, file, CONFIG_TYPE_DEFAULT);
174      mame_fclose(file);
175   }
176162
177163   /* finally, save the game-specific file */
178   astring fname(machine->basename(), ".cfg");
179   filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
180
164   filerr = file.open(machine->basename(), ".cfg");
181165   if (filerr == FILERR_NONE)
182   {
183166      config_save_xml(machine, file, CONFIG_TYPE_GAME);
184      mame_fclose(file);
185   }
186167
187168   /* loop over all registrants and call their final function */
188169   for (type = typelist; type; type = type->next)
r10384r10385
197178 *
198179 *************************************/
199180
200static int config_load_xml(running_machine *machine, mame_file *file, int which_type)
181static int config_load_xml(running_machine *machine, emu_file &file, int which_type)
201182{
202183   xml_data_node *root, *confignode, *systemnode;
203184   config_type *type;
r10384r10385
205186   int version, count;
206187
207188   /* read the file */
208   root = xml_file_read(mame_core_file(file), NULL);
189   root = xml_file_read(file, NULL);
209190   if (!root)
210191      goto error;
211192
r10384r10385
298279 *
299280 *************************************/
300281
301static int config_save_xml(running_machine *machine, mame_file *file, int which_type)
282static int config_save_xml(running_machine *machine, emu_file &file, int which_type)
302283{
303284   xml_data_node *root = xml_file_create();
304285   xml_data_node *confignode, *systemnode;
r10384r10385
335316   }
336317
337318   /* flush the file */
338   xml_file_write(root, mame_core_file(file));
319   xml_file_write(root, file);
339320
340321   /* free and get out of here */
341322   xml_file_free(root);
src/emu/softlist.c
r10384r10385
4141
4242struct _software_list
4343{
44   mame_file   *file;
44   emu_file   *file;
4545   object_pool   *pool;
4646   parse_state   state;
4747   const char *description;
r10384r10385
824824    parent software, if any
825825 -------------------------------------------------*/
826826
827const char *software_get_clone(char *swlist, const char *swname)
827const char *software_get_clone(core_options &options, char *swlist, const char *swname)
828828{
829   software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
829   software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
830830   const char *retval = NULL;
831831   if (software_list_ptr)
832832   {
r10384r10385
844844    the software
845845 -------------------------------------------------*/
846846
847UINT32 software_get_support(char *swlist, const char *swname)
847UINT32 software_get_support(core_options &options, char *swlist, const char *swname)
848848{
849   software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
849   software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
850850   UINT32 retval = 0;
851851
852852   if (software_list_ptr)
r10384r10385
872872   UINT32 len;
873873   XML_Memory_Handling_Suite memcallbacks;
874874
875   mame_fseek(swlist->file, 0, SEEK_SET);
875   swlist->file->seek(0, SEEK_SET);
876876
877877   memset(&swlist->state, 0, sizeof(swlist->state));
878878   swlist->state.error_proc = error_proc;
r10384r10385
892892
893893   while(!swlist->state.done)
894894   {
895      len = mame_fread(swlist->file, buf, sizeof(buf));
896      swlist->state.done = mame_feof(swlist->file);
895      len = swlist->file->read(buf, sizeof(buf));
896      swlist->state.done = swlist->file->eof();
897897      if (XML_Parse(swlist->state.parser, buf, len, swlist->state.done) == XML_STATUS_ERROR)
898898      {
899899         parse_error(&swlist->state, "[%lu:%lu]: %s\n",
r10384r10385
917917    software_list_open
918918-------------------------------------------------*/
919919
920software_list *software_list_open(core_options *options, const char *listname, int is_preload,
920software_list *software_list_open(core_options &options, const char *listname, int is_preload,
921921   void (*error_proc)(const char *message))
922922{
923   file_error filerr;
924   astring *fname;
925923   software_list *swlist = NULL;
926924   object_pool *pool = NULL;
925   file_error filerr;
927926
928927   /* create a pool for this software list file */
929928   pool = pool_alloc_lib(error_proc);
r10384r10385
941940   swlist->error_proc = error_proc;
942941
943942   /* open a file */
944   fname = astring_assemble_2(astring_alloc(), listname, ".xml");
945   filerr = mame_fopen_options(options, SEARCHPATH_HASH, astring_c(fname), OPEN_FLAG_READ, &swlist->file);
946   astring_free(fname);
947
943   swlist->file = global_alloc(emu_file(options, SEARCHPATH_HASH, OPEN_FLAG_READ));
944   filerr = swlist->file->open(listname, ".xml");
948945   if (filerr != FILERR_NONE)
949946      goto error;
950947
r10384r10385
972969   if (swlist == NULL)
973970      return;
974971
975   if (swlist->file)
976      mame_fclose(swlist->file);
972   if (swlist->file != NULL)
973      global_free(swlist->file);
977974   pool_free_lib(swlist->pool);
978975}
979976
r10384r10385
12901287   if ( swlist_name )
12911288   {
12921289      /* Try to open the software list xml file explicitly named by the user */
1293      software_list_ptr = software_list_open( mame_options(), swlist_name, FALSE, NULL );
1290      software_list_ptr = software_list_open( image->device().machine->options(), swlist_name, FALSE, NULL );
12941291
12951292      if ( software_list_ptr )
12961293      {
r10384r10385
15621559   {
15631560      if (swlist->list_name[i])
15641561      {
1565         if (mame_options() == NULL)
1566            return FALSE;
1562         software_list *list = software_list_open(options, swlist->list_name[i], FALSE, NULL);
15671563
1568         software_list *list = software_list_open(mame_options(), swlist->list_name[i], FALSE, NULL);
1569
15701564         /* if no .xml list is found, then return (this happens e.g. if you moved/renamed the xml list) */
15711565         if (list == NULL)
15721566            return FALSE;
r10384r10385
19041898   {
19051899      device_image_interface *image = sw_state->image;
19061900      software_entry_state *entry = (software_entry_state *) event->itemref;
1907      software_list *tmp_list = software_list_open(mame_options(), sw_state->list_name, FALSE, NULL);
1901      software_list *tmp_list = software_list_open(machine->options(), sw_state->list_name, FALSE, NULL);
19081902      software_info *tmp_info = software_list_find(tmp_list, entry->short_name, NULL);
19091903
19101904      // if the selected software has multiple parts that can be loaded, open the submenu
r10384r10385
19441938      {
19451939         if (swlist->list_name[i] && (swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM))
19461940         {
1947            software_list *list = software_list_open(mame_options(), swlist->list_name[i], FALSE, NULL);
1941            software_list *list = software_list_open(machine->options(), swlist->list_name[i], FALSE, NULL);
19481942
19491943            if (list)
19501944            {
r10384r10385
19741968      {
19751969         if (swlist->list_name[i] && (swlist->list_type == SOFTWARE_LIST_COMPATIBLE_SYSTEM))
19761970         {
1977            software_list *list = software_list_open(mame_options(), swlist->list_name[i], FALSE, NULL);
1971            software_list *list = software_list_open(machine->options(), swlist->list_name[i], FALSE, NULL);
19781972
19791973            if (list)
19801974            {
src/emu/disound.h
r10384r10385
127127
128128protected:
129129   // optional operation overrides
130   virtual bool interface_validity_check(const game_driver &driver) const;
130   virtual bool interface_validity_check(core_options &options, const game_driver &driver) const;
131131
132132   // internal state
133133   simple_list<sound_route> m_route_list;      // list of sound routes
src/emu/softlist.h
r10384r10385
5555typedef struct _software_list software_list;
5656
5757/* Handling a software list */
58software_list *software_list_open(core_options *options, const char *listname, int is_preload, void (*error_proc)(const char *message));
58software_list *software_list_open(core_options &options, const char *listname, int is_preload, void (*error_proc)(const char *message));
5959void software_list_close(software_list *swlist);
6060software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev);
6161const char *software_list_get_description(software_list *swlist);
r10384r10385
6565software_part *software_part_next(software_part *part);
6666
6767/* helpers */
68const char *software_get_clone(char *swlist, const char *swname);
69UINT32 software_get_support(char *swlist, const char *swname);
68const char *software_get_clone(core_options &options, char *swlist, const char *swname);
69UINT32 software_get_support(core_options &options, char *swlist, const char *swname);
7070const char *software_part_get_feature(software_part *part, const char *feature_name);
7171
7272bool load_software_part(device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name);
src/emu/devimage.c
r10384r10385
325325            // " swlist % clonename % parentname "
326326            // below, we have the code to split the elements and to create paths to load from
327327
328            software_list *software_list_ptr = software_list_open(mame_options(), swlist, FALSE, NULL);
328            software_list *software_list_ptr = software_list_open(m_machine.options(), swlist, FALSE, NULL);
329329            if (software_list_ptr)
330330            {
331331               for (software_info *swinfo = software_list_find(software_list_ptr, swname, NULL); swinfo != NULL; )
r10384r10385
337337                     locationtag.cat(breakstr);
338338                     //printf("%s\n", locationtag.cstr());
339339                  }
340                  const char *parentname = software_get_clone(swlist, swinfo->shortname);
340                  const char *parentname = software_get_clone(m_machine.options(), swlist, swinfo->shortname);
341341                  if (parentname != NULL)
342342                     swinfo = software_list_find(software_list_ptr, parentname, NULL);
343343                  else
r10384r10385
348348               software_list_close(software_list_ptr);
349349            }
350350
351            if (software_get_support(swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
351            if (software_get_support(m_machine.options(), swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
352352               mame_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist);
353353
354            if (software_get_support(swlist, swname) == SOFTWARE_SUPPORTED_NO)
354            if (software_get_support(m_machine.options(), swlist, swname) == SOFTWARE_SUPPORTED_NO)
355355               mame_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist);
356356
357357            // check if locationtag actually contains two locations separated by '%'
r10384r10385
381381            // - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname
382382            // try to load from list/setname
383383            if ((m_mame_file == NULL) && (tag2.cstr() != NULL))
384               filerr = common_process_file(tag2.cstr(), has_crc, crc, romp, &m_mame_file);
384               filerr = common_process_file(m_machine.options(), tag2.cstr(), has_crc, crc, romp, &m_mame_file);
385385            // try to load from list/parentname
386386            if ((m_mame_file == NULL) && (tag3.cstr() != NULL))
387               filerr = common_process_file(tag3.cstr(), has_crc, crc, romp, &m_mame_file);
387               filerr = common_process_file(m_machine.options(), tag3.cstr(), has_crc, crc, romp, &m_mame_file);
388388            // try to load from setname
389389            if ((m_mame_file == NULL) && (tag4.cstr() != NULL))
390               filerr = common_process_file(tag4.cstr(), has_crc, crc, romp, &m_mame_file);
390               filerr = common_process_file(m_machine.options(), tag4.cstr(), has_crc, crc, romp, &m_mame_file);
391391            // try to load from parentname
392392            if ((m_mame_file == NULL) && (tag5.cstr() != NULL))
393               filerr = common_process_file(tag5.cstr(), has_crc, crc, romp, &m_mame_file);
393               filerr = common_process_file(m_machine.options(), tag5.cstr(), has_crc, crc, romp, &m_mame_file);
394394
395395            if (filerr == FILERR_NONE)
396396            {
397               m_file = mame_core_file(m_mame_file);
397               m_file = *m_mame_file;
398398               retVal = TRUE;
399399            }
400400
r10384r10385
588588{
589589   if (m_mame_file)
590590    {
591      mame_fclose(m_mame_file);
591      global_free(m_mame_file);
592592      m_mame_file = NULL;
593593      m_file = NULL;
594594   } else {
src/emu/image.c
r10384r10385
125125    INI files
126126-------------------------------------------------*/
127127
128static int write_config(const char *filename, const game_driver *gamedrv)
128static int write_config(core_options &options, const char *filename, const game_driver *gamedrv)
129129{
130   file_error filerr;
131   mame_file *f;
132130   char buffer[128];
133131   int retval = 1;
134132
r10384r10385
138136      filename = buffer;
139137   }
140138
141   filerr = mame_fopen(SEARCHPATH_INI, buffer, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &f);
142   if (filerr != FILERR_NONE)
143      goto done;
144
145   options_output_ini_file(mame_options(), mame_core_file(f));
146   retval = 0;
147
148done:
149   if (f != NULL)
150      mame_fclose(f);
139   emu_file file(options, SEARCHPATH_INI, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
140   file_error filerr = file.open(filename);
141   if (filerr == FILERR_NONE)
142   {
143      options_output_ini_file(&options, file);
144      retval = 0;
145   }
151146   return retval;
152147}
153148
r10384r10385
159154static void image_options_extract(running_machine *machine)
160155{
161156   /* only extract the device options if we've added them */
162   if (options_get_bool(machine->options(), OPTION_ADDED_DEVICE_OPTIONS)) {
157   if (options_get_bool(&machine->options(), OPTION_ADDED_DEVICE_OPTIONS)) {
163158      int index = 0;
164159      device_image_interface *image = NULL;
165160
r10384r10385
168163         const char *filename = image->filename();
169164
170165         /* and set the option */
171         options_set_string(machine->options(), image->image_config().instance_name() , filename ? filename : "", OPTION_PRIORITY_CMDLINE);
166         options_set_string(&machine->options(), image->image_config().instance_name() , filename ? filename : "", OPTION_PRIORITY_CMDLINE);
172167
173168         index++;
174169      }
175170   }
176171
177172   /* write the config, if appropriate */
178   if (options_get_bool(machine->options(), OPTION_WRITECONFIG))
179      write_config(NULL, machine->gamedrv);
173   if (options_get_bool(&machine->options(), OPTION_WRITECONFIG))
174      write_config(machine->options(), NULL, machine->gamedrv);
180175}
181176
182177/*-------------------------------------------------
r10384r10385
303298  image; typically for cartridges.
304299****************************************************************************/
305300
306/*-------------------------------------------------
307    open_battery_file_by_name - opens the battery backed
308    NVRAM file for an image
309-------------------------------------------------*/
310
311static file_error open_battery_file_by_name(const char *filename, UINT32 openflags, mame_file **file)
312{
313    file_error filerr;
314    filerr = mame_fopen(SEARCHPATH_NVRAM, filename, openflags, file);
315    return filerr;
316}
317
318301static char *stripspace(const char *src)
319302{
320303   static char buff[512];
r10384r10385
444427    to the function.
445428-------------------------------------------------*/
446429
447void image_battery_load_by_name(const char *filename, void *buffer, int length, int fill)
430void image_battery_load_by_name(core_options &options, const char *filename, void *buffer, int length, int fill)
448431{
449432    file_error filerr;
450    mame_file *file;
451433    int bytes_read = 0;
452434
453435    assert_always(buffer && (length > 0), "Must specify sensical buffer/length");
454436
455437    /* try to open the battery file and read it in, if possible */
456    filerr = open_battery_file_by_name(filename, OPEN_FLAG_READ, &file);
438    emu_file file(options, SEARCHPATH_NVRAM, OPEN_FLAG_READ);
439    filerr = file.open(filename);
457440    if (filerr == FILERR_NONE)
458    {
459        bytes_read = mame_fread(file, buffer, length);
460        mame_fclose(file);
461    }
441        bytes_read = file.read(buffer, length);
462442
463443    /* fill remaining bytes (if necessary) */
464444    memset(((char *) buffer) + bytes_read, fill, length - bytes_read);
r10384r10385
469449    backed RAM for an image. A filename may be supplied
470450    to the function.
471451-------------------------------------------------*/
472void image_battery_save_by_name(const char *filename, const void *buffer, int length)
452void image_battery_save_by_name(core_options &options, const char *filename, const void *buffer, int length)
473453{
474    file_error filerr;
475    mame_file *file;
476
477454    assert_always(buffer && (length > 0), "Must specify sensical buffer/length");
478455
479456    /* try to open the battery file and write it out, if possible */
480    filerr = open_battery_file_by_name(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
457    emu_file file(options, SEARCHPATH_NVRAM, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
458    file_error filerr = file.open(filename);
481459    if (filerr == FILERR_NONE)
482    {
483        mame_fwrite(file, buffer, length);
484        mame_fclose(file);
485    }
460        file.write(buffer, length);
486461}
487462
488463/*-------------------------------------------------
src/emu/image.h
r10384r10385
2525
2626extern struct io_procs image_ioprocs;
2727
28void image_battery_load_by_name(const char *filename, void *buffer, int length, int fill);
29void image_battery_save_by_name(const char *filename, const void *buffer, int length);
28void image_battery_load_by_name(core_options &options, const char *filename, void *buffer, int length, int fill);
29void image_battery_save_by_name(core_options &options, const char *filename, const void *buffer, int length);
3030
3131astring *image_info_astring(running_machine *machine, astring *string);
3232
src/emu/audit.c
r10384r10385
192192                  sharedname = &intf->samplenames[sampnum][1];
193193               else
194194               {
195                  file_error filerr;
196                  mame_file *file;
197
198195                  /* attempt to access the file from the game driver name */
199                  astring fname(gamedrv->name, PATH_SEPARATOR, intf->samplenames[sampnum]);
200                  filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
196                  emu_file file(*options, SEARCHPATH_SAMPLE, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
197                  file_error filerr = file.open(gamedrv->name, PATH_SEPARATOR, intf->samplenames[sampnum]);
201198
202199                  /* attempt to access the file from the shared driver name */
203200                  if (filerr != FILERR_NONE && sharedname != NULL)
204                  {
205                     fname.cpy(sharedname).cat(PATH_SEPARATOR).cat(intf->samplenames[sampnum]);
206                     filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
207                  }
201                     filerr = file.open(sharedname, PATH_SEPARATOR, intf->samplenames[sampnum]);
208202
209203                  /* fill in the record */
210204                  record->type = AUDIT_FILE_SAMPLE;
211205                  record->name = intf->samplenames[sampnum];
212206                  if (filerr == FILERR_NONE)
213                  {
214207                     set_status(record++, AUDIT_STATUS_GOOD, SUBSTATUS_GOOD);
215                     mame_fclose(file);
216                  }
217208                  else
218209                     set_status(record++, AUDIT_STATUS_NOT_FOUND, SUBSTATUS_NOT_FOUND);
219210               }
r10384r10385
350341   /* find the file and checksum it, getting the file length along the way */
351342   for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv))
352343   {
353      file_error filerr;
354      mame_file *file;
344      emu_file file(*options, SEARCHPATH_ROM, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
355345
356346      /* open the file if we can */
357      astring fname(drv->name, PATH_SEPARATOR, ROM_GETNAME(rom));
358       if (has_crc)
359         filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
347      file_error filerr;
348      if (has_crc)
349         filerr = file.open(drv->name, PATH_SEPARATOR, ROM_GETNAME(rom), crc);
360350      else
361         filerr = mame_fopen_options(options, SEARCHPATH_ROM, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
362
363      /* if we got it, extract the hash and length */
351         filerr = file.open(drv->name, PATH_SEPARATOR, ROM_GETNAME(rom));
364352      if (filerr == FILERR_NONE)
365353      {
366         hash_data_copy(record->hash, mame_fhash(file, validation));
367         record->length = (UINT32)mame_fsize(file);
368         mame_fclose(file);
354         hash_data_copy(record->hash, file.hash_string(validation));
355         record->length = (UINT32)file.size();
369356         break;
370357      }
371358   }
r10384r10385
373360   /* if not found, check the region as a backup */
374361   if (record->length == 0 && regiontag != NULL)
375362   {
376      file_error filerr;
377      mame_file *file;
363      emu_file file(*options, SEARCHPATH_ROM, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
378364
379365      /* open the file if we can */
380      astring fname(regiontag, PATH_SEPARATOR, ROM_GETNAME(rom));
366       file_error filerr;
381367       if (has_crc)
382         filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
383      else
384         filerr = mame_fopen_options(options, SEARCHPATH_ROM, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
385
386      /* if we got it, extract the hash and length */
368          filerr = file.open(regiontag, PATH_SEPARATOR, ROM_GETNAME(rom), crc);
369       else
370          filerr = file.open(regiontag, PATH_SEPARATOR, ROM_GETNAME(rom));
387371      if (filerr == FILERR_NONE)
388372      {
389         hash_data_copy(record->hash, mame_fhash(file, validation));
390         record->length = (UINT32)mame_fsize(file);
391         mame_fclose(file);
373         hash_data_copy(record->hash, file.hash_string(validation));
374         record->length = (UINT32)file.size();
392375      }
393376   }
394377
r10384r10385
446429
447430static void audit_one_disk(core_options *options, const rom_entry *rom, const game_driver *gamedrv, UINT32 validation, audit_record *record)
448431{
449   mame_file *source_file;
432   emu_file *source_file;
450433   chd_file *source;
451434   chd_error err;
452435
r10384r10385
456439   record->exphash = ROM_GETHASHDATA(rom);
457440
458441   /* open the disk */
459   err = open_disk_image_options(options, gamedrv, rom, &source_file, &source, NULL);
442   err = open_disk_image(*options, gamedrv, rom, &source_file, &source, NULL);
460443
461444   /* if we failed, report the error */
462445   if (err != CHDERR_NONE)
r10384r10385
507490         set_status(record, AUDIT_STATUS_GOOD, SUBSTATUS_GOOD);
508491
509492      chd_close(source);
510      mame_fclose(source_file);
493      global_free(source_file);
511494   }
512495}
513496
src/emu/emu.mak
r10384r10385
135135
136136EMUMACHINEOBJS = \
137137   $(EMUMACHINE)/53c810.o \
138   $(EMUMACHINE)/6532riot.o \
139138   $(EMUMACHINE)/6522via.o \
140139   $(EMUMACHINE)/6526cia.o \
140   $(EMUMACHINE)/6532riot.o \
141141   $(EMUMACHINE)/6821pia.o \
142142   $(EMUMACHINE)/6840ptm.o \
143143   $(EMUMACHINE)/6850acia.o \
144144   $(EMUMACHINE)/68681.o \
145   $(EMUMACHINE)/7474.o \
146145   $(EMUMACHINE)/74123.o \
147146   $(EMUMACHINE)/74148.o \
148147   $(EMUMACHINE)/74153.o \
149148   $(EMUMACHINE)/74181.o \
149   $(EMUMACHINE)/7474.o \
150150   $(EMUMACHINE)/8042kbdc.o \
151151   $(EMUMACHINE)/8237dma.o \
152   $(EMUMACHINE)/8255ppi.o \
152153   $(EMUMACHINE)/8257dma.o \
153   $(EMUMACHINE)/8255ppi.o \
154154   $(EMUMACHINE)/adc083x.o \
155155   $(EMUMACHINE)/adc1038.o \
156156   $(EMUMACHINE)/adc1213x.o \
157157   $(EMUMACHINE)/am53cf96.o \
158158   $(EMUMACHINE)/at28c16.o \
159159   $(EMUMACHINE)/cdp1852.o \
160   $(EMUMACHINE)/cr589.o \
160161   $(EMUMACHINE)/ds1302.o \
161162   $(EMUMACHINE)/ds2401.o \
162163   $(EMUMACHINE)/ds2404.o \
r10384r10385
164165   $(EMUMACHINE)/er2055.o \
165166   $(EMUMACHINE)/f3853.o \
166167   $(EMUMACHINE)/generic.o \
168   $(EMUMACHINE)/i2cmem.o \
167169   $(EMUMACHINE)/i8243.o \
168170   $(EMUMACHINE)/i8255a.o \
169   $(EMUMACHINE)/i2cmem.o \
170171   $(EMUMACHINE)/idectrl.o \
171172   $(EMUMACHINE)/ins8154.o   \
172173   $(EMUMACHINE)/ins8250.o \
r10384r10385
188189   $(EMUMACHINE)/nvram.o \
189190   $(EMUMACHINE)/pc16552d.o \
190191   $(EMUMACHINE)/pci.o \
192   $(EMUMACHINE)/pd4990a.o \
191193   $(EMUMACHINE)/pic8259.o \
192194   $(EMUMACHINE)/pit8253.o \
193   $(EMUMACHINE)/pd4990a.o \
194195   $(EMUMACHINE)/ram.o \
195196   $(EMUMACHINE)/roc10937.o \
196197   $(EMUMACHINE)/rp5h01.o \
r10384r10385
202203   $(EMUMACHINE)/scsicd.o \
203204   $(EMUMACHINE)/scsidev.o \
204205   $(EMUMACHINE)/scsihd.o \
205   $(EMUMACHINE)/cr589.o \
206   $(EMUMACHINE)/secflash.o \
206207   $(EMUMACHINE)/smc91c9x.o \
207208   $(EMUMACHINE)/timekpr.o \
208209   $(EMUMACHINE)/tmp68301.o \
src/emu/mame.c
r10384r10385
9696    GLOBAL VARIABLES
9797***************************************************************************/
9898
99/* the current options */
100static core_options *mame_opts;
101
10299/* started empty? */
103100static bool started_empty;
104101
102static bool print_verbose = false;
103
105104static running_machine *global_machine;
106105
107106/* output channels */
r10384r10385
153152   bool firstgame = true;
154153   bool firstrun = true;
155154
155   // extract the verbose printing option
156   if (options_get_bool(options, OPTION_VERBOSE))
157      print_verbose = true;
158
156159   // loop across multiple hard resets
157160   bool exit_pending = false;
158161   int error = MAMERR_NONE;
159162   while (error == MAMERR_NONE && !exit_pending)
160163   {
161      // specify the global mame_options
162      mame_opts = options;
163
164164      // convert the specified gamename to a driver
165165      astring gamename;
166166      core_filename_extract_base(&gamename, options_get_string(options, OPTION_GAMENAME), true);
r10384r10385
175175      }
176176
177177      // otherwise, perform validity checks before anything else
178      else if (mame_validitychecks(driver) != 0)
178      else if (mame_validitychecks(*options, driver) != 0)
179179         return MAMERR_FAILED_VALIDITY;
180180
181181      firstgame = false;
r10384r10385
217217         // clear flag for added devices
218218         options_set_bool(options, OPTION_ADDED_DEVICE_OPTIONS, FALSE, OPTION_PRIORITY_CMDLINE);
219219      }
220
221      // reset the options
222      mame_opts = NULL;
223220   }
224221
225222   // return an error
r10384r10385
227224}
228225
229226
230/*-------------------------------------------------
231    mame_options - accesses the options for the
232    currently running emulation
233-------------------------------------------------*/
234
235core_options *mame_options(void)
236{
237   assert(mame_opts != NULL);
238   return mame_opts;
239}
240
241
242
243/*-------------------------------------------------
244    set_mame_options - set mame options, used by
245    validate option
246-------------------------------------------------*/
247
248void set_mame_options(core_options *options)
249{
250   mame_opts = options;
251}
252
253
254227/***************************************************************************
255228    OUTPUT MANAGEMENT
256229***************************************************************************/
r10384r10385
377350   va_list argptr;
378351
379352   /* if we're not verbose, skip it */
380   if (mame_opts == NULL || !options_get_bool(mame_options(), OPTION_VERBOSE))
353   if (!print_verbose)
381354      return;
382355
383356   /* by default, we go to stdout */
r10384r10385
567540
568541static int parse_ini_file(core_options *options, const char *name, int priority)
569542{
570   file_error filerr;
571   mame_file *file;
572
573543   /* update game name so depending callback options could be added */
574   if (priority==OPTION_PRIORITY_DRIVER_INI || priority==OPTION_PRIORITY_SOURCE_INI) {
544   if (priority == OPTION_PRIORITY_DRIVER_INI || priority == OPTION_PRIORITY_SOURCE_INI)
575545      options_force_option_callback(options, OPTION_GAMENAME, name, priority);
576   }
577546
578547   /* don't parse if it has been disabled */
579548   if (!options_get_bool(options, OPTION_READCONFIG))
580549      return FALSE;
581550
582551   /* open the file; if we fail, that's ok */
583   astring fname(name, ".ini");
584   filerr = mame_fopen_options(options, SEARCHPATH_INI, fname, OPEN_FLAG_READ, &file);
552   emu_file file(*options, SEARCHPATH_INI, OPEN_FLAG_READ);
553   file_error filerr = file.open(name, ".ini");
585554   if (filerr != FILERR_NONE)
586555      return FALSE;
587556
588557   /* parse the file and close it */
589558   mame_printf_verbose("Parsing %s.ini\n", name);
590   options_parse_ini_file(options, mame_core_file(file), priority, OPTION_PRIORITY_DRIVER_INI);
591   mame_fclose(file);
559   options_parse_ini_file(options, file, priority, OPTION_PRIORITY_DRIVER_INI);
592560   return TRUE;
593561}
src/emu/rendfont.c
r10384r10385
139139      return;
140140
141141   // load the raw data instead
142   mame_file *ramfile;
143   file_error filerr = mame_fopen_ram(font_uismall, sizeof(font_uismall), OPEN_FLAG_READ, &ramfile);
142   emu_file ramfile(manager.machine().options(), NULL, OPEN_FLAG_READ);
143   file_error filerr = ramfile.open_ram(font_uismall, sizeof(font_uismall));
144144   if (filerr == FILERR_NONE)
145   {
146145      load_cached(ramfile, 0);
147      mame_fclose(ramfile);
148   }
149146}
150147
151148
r10384r10385
415412bool render_font::load_cached_bdf(const char *filename)
416413{
417414   // first try to open the BDF itself
418   mame_file *file;
419   file_error filerr = mame_fopen(SEARCHPATH_FONT, filename, OPEN_FLAG_READ, &file);
415   emu_file file(manager().machine().options(), SEARCHPATH_FONT, OPEN_FLAG_READ);
416   file_error filerr = file.open(filename);
420417   if (filerr != FILERR_NONE)
421418      return false;
422419
423420   // determine the file size and allocate memory
424   m_rawsize = mame_fsize(file);
421   m_rawsize = file.size();
425422   char *data = auto_alloc_array_clear(&m_manager.machine(), char, m_rawsize + 1);
426423
427424   // read the first chunk
428   UINT32 bytes = mame_fread(file, data, MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
425   UINT32 bytes = file.read(data, MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
429426   if (bytes != MIN(CACHED_BDF_HASH_SIZE, m_rawsize))
430   {
431      mame_fclose(file);
432427      return false;
433   }
434428
435429   // has the chunk
436430   UINT32 hash = crc32(0, (const UINT8 *)data, bytes) ^ (UINT32)m_rawsize;
r10384r10385
440434   cachedname.del(cachedname.len() - 3, 3).cat("bdc");
441435
442436   // attempt to open the cached version of the font
443   mame_file *cachefile;
444   filerr = mame_fopen(SEARCHPATH_FONT, cachedname, OPEN_FLAG_READ, &cachefile);
445   if (filerr == FILERR_NONE)
446437   {
447      // if we have a cached version, load it
448      bool result = load_cached(cachefile, hash);
449      mame_fclose(cachefile);
450
451      // if that worked, we're done
452      if (result)
438      emu_file cachefile(manager().machine().options(), SEARCHPATH_FONT, OPEN_FLAG_READ);
439      filerr = cachefile.open(cachedname);
440      if (filerr == FILERR_NONE)
453441      {
454         mame_fclose(file);
455         auto_free(&m_manager.machine(), data);
456         return true;
442         // if we have a cached version, load it
443         bool result = load_cached(cachefile, hash);
444
445         // if that worked, we're done
446         if (result)
447         {
448            auto_free(&m_manager.machine(), data);
449            return true;
450         }
457451      }
458452   }
459453
460454   // read in the rest of the font
461455   if (bytes < m_rawsize)
462456   {
463      UINT32 read = mame_fread(file, data + bytes, m_rawsize - bytes);
457      UINT32 read = file.read(data + bytes, m_rawsize - bytes);
464458      if (read != m_rawsize - bytes)
465459      {
466         mame_fclose(file);
467460         auto_free(&m_manager.machine(), data);
468461         return false;
469462      }
r10384r10385
481474      save_cached(cachedname, hash);
482475
483476   // close the file
484   mame_fclose(file);
485477   return result;
486478}
487479
r10384r10385
604596//  load_cached - load a font in cached format
605597//-------------------------------------------------
606598
607bool render_font::load_cached(mame_file *file, UINT32 hash)
599bool render_font::load_cached(emu_file &file, UINT32 hash)
608600{
609601   // get the file size
610   UINT64 filesize = mame_fsize(file);
602   UINT64 filesize = file.size();
611603
612604   // first read the header
613605   UINT8 header[CACHED_HEADER_SIZE];
614   UINT32 bytes_read = mame_fread(file, header, CACHED_HEADER_SIZE);
606   UINT32 bytes_read = file.read(header, CACHED_HEADER_SIZE);
615607   if (bytes_read != CACHED_HEADER_SIZE)
616608      return false;
617609
r10384r10385
629621
630622   // now read the rest of the data
631623   UINT8 *data = auto_alloc_array(&m_manager.machine(), UINT8, filesize - CACHED_HEADER_SIZE);
632   bytes_read = mame_fread(file, data, filesize - CACHED_HEADER_SIZE);
624   bytes_read = file.read(data, filesize - CACHED_HEADER_SIZE);
633625   if (bytes_read != filesize - CACHED_HEADER_SIZE)
634626   {
635627      auto_free(&m_manager.machine(), data);
r10384r10385
681673   mame_printf_warning("Generating cached BDF font...\n");
682674
683675   // attempt to open the file
684   mame_file *file;
685   file_error filerr = mame_fopen(SEARCHPATH_FONT, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
676   emu_file file(manager().machine().options(), SEARCHPATH_FONT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
677   file_error filerr = file.open(filename);
686678   if (filerr != FILERR_NONE)
687679      return false;
688680
r10384r10385
728720      *dest++ = numchars >> 8;
729721      *dest++ = numchars & 0xff;
730722      assert(dest - tempbuffer == CACHED_HEADER_SIZE);
731      UINT32 bytes_written = mame_fwrite(file, tempbuffer, dest - tempbuffer);
723      UINT32 bytes_written = file.write(tempbuffer, dest - tempbuffer);
732724      if (bytes_written != dest - tempbuffer)
733725         throw emu_fatalerror("Error writing cached file");
734726
735727      // write the empty table to the beginning of the file
736      bytes_written = mame_fwrite(file, chartable, numchars * CACHED_CHAR_SIZE);
728      bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE);
737729      if (bytes_written != numchars * CACHED_CHAR_SIZE)
738730         throw emu_fatalerror("Error writing cached file");
739731
r10384r10385
775767                  *dest++ = accum;
776768
777769               // write the data
778               bytes_written = mame_fwrite(file, tempbuffer, dest - tempbuffer);
770               bytes_written = file.write(tempbuffer, dest - tempbuffer);
779771               if (bytes_written != dest - tempbuffer)
780772                  throw emu_fatalerror("Error writing cached file");
781773
r10384r10385
804796      }
805797
806798      // seek back to the beginning and rewrite the table
807      mame_fseek(file, CACHED_HEADER_SIZE, SEEK_SET);
808      bytes_written = mame_fwrite(file, chartable, numchars * CACHED_CHAR_SIZE);
799      file.seek(CACHED_HEADER_SIZE, SEEK_SET);
800      bytes_written = file.write(chartable, numchars * CACHED_CHAR_SIZE);
809801      if (bytes_written != numchars * CACHED_CHAR_SIZE)
810802         throw emu_fatalerror("Error writing cached file");
811803
812804      // all done
813      mame_fclose(file);
814805      auto_free(&m_manager.machine(), tempbuffer);
815806      auto_free(&m_manager.machine(), chartable);
816807      return true;
817808   }
818809   catch (...)
819810   {
820      mame_fclose(file);
821      osd_rmfile(filename);
811      file.remove_on_close();
822812      auto_free(&m_manager.machine(), tempbuffer);
823813      auto_free(&m_manager.machine(), chartable);
824814      return false;
src/emu/machine/mc146818.h
r10384r10385
8787
8888   // device_mc146818_interface overrides
8989   virtual void nvram_default();
90   virtual void nvram_read(mame_file &file);
91   virtual void nvram_write(mame_file &file);
90   virtual void nvram_read(emu_file &file);
91   virtual void nvram_write(emu_file &file);
9292
9393   // internal helpers
9494   int dec_2_local(int a);
src/emu/machine/timekpr.c
r10384r10385
471471//  .nv file
472472//-------------------------------------------------
473473
474void timekeeper_device::nvram_read(mame_file &file)
474void timekeeper_device::nvram_read(emu_file &file)
475475{
476   mame_fread( &file, m_data, m_size );
476   file.read( m_data, m_size );
477477
478478   counters_to_ram();
479479}
r10384r10385
484484//  .nv file
485485//-------------------------------------------------
486486
487void timekeeper_device::nvram_write(mame_file &file)
487void timekeeper_device::nvram_write(emu_file &file)
488488{
489   mame_fwrite( &file, m_data, m_size );
489   file.write( m_data, m_size );
490490}
491491
492492
src/emu/machine/x76f100.c
r10384r10385
1212#include "emu.h"
1313#include "machine/x76f100.h"
1414
15#define VERBOSE_LEVEL ( 0 )
15#define VERBOSE_LEVEL 0
1616
17INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
17inline void ATTR_PRINTF(3,4) x76f100_device::verboselog(int n_level, const char *s_fmt, ...)
1818{
19   if( VERBOSE_LEVEL >= n_level )
19   if(VERBOSE_LEVEL >= n_level)
2020   {
2121      va_list v;
22      char buf[ 32768 ];
23      va_start( v, s_fmt );
24      vsprintf( buf, s_fmt, v );
25      va_end( v );
26      logerror( "%s: %s", machine->describe_context(), buf );
22      char buf[32768];
23      va_start(v, s_fmt);
24      vsprintf(buf, s_fmt, v);
25      va_end(v);
26      logerror("x76f100 %s %s: %s", config.tag(), machine->describe_context(), buf);
2727   }
2828}
2929
30#define SIZE_WRITE_BUFFER ( 8 )
30const device_type X76F100 = x76f100_device_config::static_alloc_device_config;
3131
32struct x76f100_chip
32x76f100_device_config::x76f100_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
33   : device_secure_serial_flash_config(mconfig, static_alloc_device_config, "X76F100", tag, owner, clock)
3334{
34   int cs;
35   int rst;
36   int scl;
37   int sdaw;
38   int sdar;
39   int state;
40   int shift;
41   int bit;
42   int byte;
43   int command;
44   UINT8 write_buffer[ SIZE_WRITE_BUFFER ];
45   UINT8 *response_to_reset;
46   UINT8 *write_password;
47   UINT8 *read_password;
48   UINT8 *data;
49};
35}
5036
51#define SIZE_RESPONSE_TO_RESET ( 4 )
52#define SIZE_WRITE_PASSWORD ( SIZE_WRITE_BUFFER )
53#define SIZE_READ_PASSWORD ( SIZE_WRITE_BUFFER )
54#define SIZE_DATA ( 112 )
37device_config *x76f100_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
38{
39   return global_alloc(x76f100_device_config(mconfig, tag, owner, clock));
40}
5541
56static struct x76f100_chip x76f100[ X76F100_MAXCHIP ];
42device_t *x76f100_device_config::alloc_device(running_machine &machine) const
43{
44   return auto_alloc(&machine, x76f100_device(machine, *this));
45}
5746
58#define COMMAND_WRITE ( 0x80 )
59#define COMMAND_READ ( 0x81 )
60#define COMMAND_CHANGE_WRITE_PASSWORD ( 0xfc )
61#define COMMAND_CHANGE_READ_PASSWORD ( 0xfe )
62#define COMMAND_ACK_PASSWORD ( 0x55 )
47x76f100_device::x76f100_device(running_machine &_machine, const x76f100_device_config &_config)
48   : device_secure_serial_flash(_machine, _config),
49     config(_config)
50{
51}
6352
64#define STATE_STOP ( 0 )
65#define STATE_RESPONSE_TO_RESET ( 1 )
66#define STATE_LOAD_COMMAND ( 2 )
67#define STATE_LOAD_PASSWORD ( 4 )
68#define STATE_VERIFY_PASSWORD ( 5 )
69#define STATE_READ_DATA ( 6 )
70#define STATE_WRITE_DATA ( 7 )
53void x76f100_device::device_start()
54{
55   device_secure_serial_flash::device_start();
56   save_item(NAME(state));
57   save_item(NAME(shift));
58   save_item(NAME(bit));
59   save_item(NAME(byte));
60   save_item(NAME(command));
61   save_item(NAME(write_buffer));
62   save_item(NAME(response_to_reset));
63   save_item(NAME(write_password));
64   save_item(NAME(read_password));
65   save_item(NAME(data));
66}
7167
72void x76f100_init( running_machine *machine, int chip, UINT8 *data )
68void x76f100_device::device_reset()
7369{
74   int offset;
75   struct x76f100_chip *c;
70   device_secure_serial_flash::device_reset();
71   state = STATE_STOP;
72   shift = 0;
73   bit = 0;
74   byte = 0;
75   command = 0;
76   memset(write_buffer, 0, SIZE_WRITE_BUFFER);
77}
7678
77   if( chip >= X76F100_MAXCHIP )
79void x76f100_device::nvram_default()
80{
81   // region always wins
82   if(m_region)
7883   {
79      verboselog( machine, 0, "x76f100_init( %d ) chip out of range\n", chip );
80      return;
84      // Ensure the size is correct though
85      if(m_region->bytes() != SIZE_RESPONSE_TO_RESET+SIZE_WRITE_PASSWORD+SIZE_READ_PASSWORD+SIZE_DATA)
86         logerror("x76f100 %s: Wrong region length for initialization data, expected 0x%x, got 0x%x\n",
87                config.tag(),
88                SIZE_RESPONSE_TO_RESET+SIZE_WRITE_PASSWORD+SIZE_READ_PASSWORD+SIZE_DATA,
89                m_region->bytes());
90      else {
91         UINT8 *rb = m_region->base();
92         int offset = 0;
93         memcpy(response_to_reset, rb + offset, SIZE_RESPONSE_TO_RESET); offset += SIZE_RESPONSE_TO_RESET;
94         memcpy(write_password,    rb + offset, SIZE_WRITE_PASSWORD); offset += SIZE_WRITE_PASSWORD;
95         memcpy(read_password,     rb + offset, SIZE_READ_PASSWORD); offset += SIZE_READ_PASSWORD;
96         memcpy(data,              rb + offset, SIZE_DATA); offset += SIZE_DATA;
97         return;
98      }
8199   }
82100
83   c = &x76f100[ chip ];
84
85   if( data == NULL )
86   {
87      data = auto_alloc_array( machine, UINT8,
88         SIZE_RESPONSE_TO_RESET +
89         SIZE_READ_PASSWORD +
90         SIZE_WRITE_PASSWORD +
91         SIZE_DATA );
92   }
93
94   c->cs = 0;
95   c->rst = 0;
96   c->scl = 0;
97   c->sdaw = 0;
98   c->sdar = 0;
99   c->state = STATE_STOP;
100   c->shift = 0;
101   c->bit = 0;
102   c->byte = 0;
103   c->command = 0;
104   memset( c->write_buffer, 0, SIZE_WRITE_BUFFER );
105
106   offset = 0;
107   c->response_to_reset = &data[ offset ]; offset += SIZE_RESPONSE_TO_RESET;
108   c->write_password = &data[ offset ]; offset += SIZE_WRITE_PASSWORD;
109   c->read_password = &data[ offset ]; offset += SIZE_READ_PASSWORD;
110   c->data = &data[ offset ]; offset += SIZE_DATA;
111
112   state_save_register_item( machine, "x76f100", NULL, chip, c->cs );
113   state_save_register_item( machine, "x76f100", NULL, chip, c->rst );
114   state_save_register_item( machine, "x76f100", NULL, chip, c->scl );
115   state_save_register_item( machine, "x76f100", NULL, chip, c->sdaw );
116   state_save_register_item( machine, "x76f100", NULL, chip, c->sdar );
117   state_save_register_item( machine, "x76f100", NULL, chip, c->state );
118   state_save_register_item( machine, "x76f100", NULL, chip, c->shift );
119   state_save_register_item( machine, "x76f100", NULL, chip, c->bit );
120   state_save_register_item( machine, "x76f100", NULL, chip, c->byte );
121   state_save_register_item( machine, "x76f100", NULL, chip, c->command );
122   state_save_register_item_array( machine, "x76f100", NULL, chip, c->write_buffer );
123   state_save_register_item_pointer( machine, "x76f100", NULL, chip, c->response_to_reset, SIZE_RESPONSE_TO_RESET );
124   state_save_register_item_pointer( machine, "x76f100", NULL, chip, c->write_password, SIZE_WRITE_PASSWORD );
125   state_save_register_item_pointer( machine, "x76f100", NULL, chip, c->read_password, SIZE_READ_PASSWORD );
126   state_save_register_item_pointer( machine, "x76f100", NULL, chip, c->data, SIZE_DATA );
101   // That chip isn't really usable without the passwords, so bitch
102   // if there's no region
103   logerror("x76f100 %s: Warning, no default data provided, chip is unusable.\n", config.tag());
104   memset(response_to_reset, 0, SIZE_RESPONSE_TO_RESET);
105   memset(write_password,    0, SIZE_WRITE_PASSWORD);
106   memset(read_password,     0, SIZE_READ_PASSWORD);
107   memset(data,              0, SIZE_DATA);
127108}
128109
129void x76f100_cs_write( running_machine *machine, int chip, int cs )
110void x76f100_device::cs_0()
130111{
131   struct x76f100_chip *c;
112   /* enable chip */
113   state = STATE_STOP;
114}
132115
133   if( chip >= X76F100_MAXCHIP )
134   {
135      verboselog( machine, 0, "x76f100_cs_write( %d ) chip out of range\n", chip );
136      return;
137   }
138
139   c = &x76f100[ chip ];
140
141   if( c->cs != cs )
142   {
143      verboselog( machine, 2, "x76f100(%d) cs=%d\n", chip, cs );
144   }
145   if( c->cs != 0 && cs == 0 )
146   {
147      /* enable chip */
148      c->state = STATE_STOP;
149   }
150   if( c->cs == 0 && cs != 0 )
151   {
152      /* disable chip */
153      c->state = STATE_STOP;
154      /* high impendence? */
155      c->sdar = 0;
156   }
157   c->cs = cs;
116void x76f100_device::cs_1()
117{
118   /* disable chip */
119   state = STATE_STOP;
120   /* high impendence? */
121   sdar = 0;
158122}
159123
160void x76f100_rst_write( running_machine *machine, int chip, int rst )
124void x76f100_device::rst_0()
161125{
162   struct x76f100_chip *c;
126}
163127
164   if( chip >= X76F100_MAXCHIP )
165   {
166      verboselog( machine, 0, "x76f100_rst_write( %d ) chip out of range\n", chip );
167      return;
128void x76f100_device::rst_1()
129{
130   if(!cs) {
131      verboselog(1, "goto response to reset\n");
132      state = STATE_RESPONSE_TO_RESET;
133      bit = 0;
134      byte = 0;
168135   }
169
170   c = &x76f100[ chip ];
171
172   if( c->rst != rst )
173   {
174      verboselog( machine, 2, "x76f100(%d) rst=%d\n", chip, rst );
175   }
176   if( c->rst == 0 && rst != 0 && c->cs == 0 )
177   {
178      verboselog( machine, 1, "x76f100(%d) goto response to reset\n", chip );
179      c->state = STATE_RESPONSE_TO_RESET;
180      c->bit = 0;
181      c->byte = 0;
182   }
183   c->rst = rst;
184136}
185137
186static UINT8 *x76f100_password( struct x76f100_chip *c )
138UINT8 *x76f100_device::password()
187139{
188   if( ( c->command & 0xe1 ) == COMMAND_READ )
140   if((command & 0xe1) == COMMAND_READ)
189141   {
190      return c->read_password;
142      return read_password;
191143   }
192144
193   return c->write_password;
145   return write_password;
194146}
195147
196static void x76f100_password_ok( struct x76f100_chip *c )
148void x76f100_device::password_ok()
197149{
198   if( ( c->command & 0xe1 ) == COMMAND_READ )
150   if((command & 0xe1) == COMMAND_READ)
199151   {
200      c->state = STATE_READ_DATA;
152      state = STATE_READ_DATA;
201153   }
202   else if( ( c->command & 0xe1 ) == COMMAND_WRITE )
154   else if((command & 0xe1) == COMMAND_WRITE)
203155   {
204      c->state = STATE_WRITE_DATA;
156      state = STATE_WRITE_DATA;
205157   }
206158   else
207159   {
r10384r10385
209161   }
210162}
211163
212static int x76f100_data_offset( struct x76f100_chip *c )
164int x76f100_device::data_offset()
213165{
214   int block_offset = ( c->command >> 1 ) & 0x0f;
166   int block_offset = (command >> 1) & 0x0f;
215167
216   return ( block_offset * SIZE_WRITE_BUFFER ) + c->byte;
168   return block_offset * SIZE_WRITE_BUFFER + byte;
217169}
218170
219void x76f100_scl_write( running_machine *machine, int chip, int scl )
171void x76f100_device::scl_0()
220172{
221   struct x76f100_chip *c;
222
223   if( chip >= X76F100_MAXCHIP )
224   {
225      verboselog( machine, 0, "x76f100_scl_write( %d ) chip out of range\n", chip );
173   if(cs)
226174      return;
227   }
228175
229   c = &x76f100[ chip ];
176   switch(state) {
177   case STATE_RESPONSE_TO_RESET:
178      if(bit == 0) {
179         shift = response_to_reset[byte];
180         verboselog(1, "<- response_to_reset[%d]: %02x\n", byte, shift);
181      }
230182
231   if( c->scl != scl )
232   {
233      verboselog( machine, 2, "x76f100(%d) scl=%d\n", chip, scl );
234   }
235   if( c->cs == 0 )
236   {
237      switch( c->state )
238      {
239      case STATE_STOP:
240         break;
241
242      case STATE_RESPONSE_TO_RESET:
243         if( c->scl != 0 && scl == 0 )
244         {
245            if( c->bit == 0 )
246            {
247               c->shift = c->response_to_reset[ c->byte ];
248               verboselog( machine, 1, "x76f100(%d) <- response_to_reset[%d]: %02x\n", chip, c->byte, c->shift );
249            }
250
251            c->sdar = c->shift & 1;
252            c->shift >>= 1;
253            c->bit++;
254
255            if( c->bit == 8 )
256            {
257               c->bit = 0;
258               c->byte++;
259               if( c->byte == 4 )
260               {
261                  c->byte = 0;
262               }
263            }
264         }
265         break;
266
267      case STATE_LOAD_COMMAND:
268      case STATE_LOAD_PASSWORD:
269      case STATE_VERIFY_PASSWORD:
270      case STATE_WRITE_DATA:
271         if( c->scl == 0 && scl != 0 )
272         {
273            if( c->bit < 8 )
274            {
275               verboselog( machine, 2, "x76f100(%d) clock\n", chip );
276               c->shift <<= 1;
277               if( c->sdaw != 0 )
278               {
279                  c->shift |= 1;
280               }
281               c->bit++;
282            }
283            else
284            {
285               c->sdar = 0;
286
287               switch( c->state )
288               {
289               case STATE_LOAD_COMMAND:
290                  c->command = c->shift;
291                  verboselog( machine, 1, "x76f100(%d) -> command: %02x\n", chip, c->command );
292                  /* todo: verify command is valid? */
293                  c->state = STATE_LOAD_PASSWORD;
294                  break;
295
296               case STATE_LOAD_PASSWORD:
297                  verboselog( machine, 1, "x76f100(%d) -> password: %02x\n", chip, c->shift );
298                  c->write_buffer[ c->byte++ ] = c->shift;
299                  if( c->byte == SIZE_WRITE_BUFFER )
300                  {
301                     c->state = STATE_VERIFY_PASSWORD;
302                  }
303                  break;
304
305               case STATE_VERIFY_PASSWORD:
306                  verboselog( machine, 1, "x76f100(%d) -> verify password: %02x\n", chip, c->shift );
307                  /* todo: this should probably be handled as a command */
308                  if( c->shift == COMMAND_ACK_PASSWORD )
309                  {
310                     /* todo: this should take 10ms before it returns ok. */
311                     if( memcmp( x76f100_password( c ), c->write_buffer, SIZE_WRITE_BUFFER ) == 0 )
312                     {
313                        x76f100_password_ok( c );
314                     }
315                     else
316                     {
317                        c->sdar = 1;
318                     }
319                  }
320                  break;
321
322               case STATE_WRITE_DATA:
323                  verboselog( machine, 1, "x76f100(%d) -> data: %02x\n", chip, c->shift );
324                  c->write_buffer[ c->byte++ ] = c->shift;
325                  if( c->byte == SIZE_WRITE_BUFFER )
326                  {
327                     for( c->byte = 0; c->byte < SIZE_WRITE_BUFFER; c->byte++ )
328                     {
329                        c->data[ x76f100_data_offset( c ) ] = c->write_buffer[ c->byte ];
330                     }
331                     c->byte = 0;
332
333                     verboselog( machine, 1, "x76f100(%d) data flushed\n", chip );
334                  }
335                  break;
336               }
337
338               c->bit = 0;
339               c->shift = 0;
340            }
341         }
342         break;
343
344      case STATE_READ_DATA:
345         if( c->scl == 0 && scl != 0 )
346         {
347            if( c->bit < 8 )
348            {
349               if( c->bit == 0 )
350               {
351                  switch( c->state )
352                  {
353                  case STATE_READ_DATA:
354                     c->shift = c->data[ x76f100_data_offset( c ) ];
355                     verboselog( machine, 1, "x76f100(%d) <- data: %02x\n", chip, c->shift );
356                     break;
357                  }
358               }
359               c->sdar = ( c->shift >> 7 ) & 1;
360               c->shift <<= 1;
361               c->bit++;
362            }
363            else
364            {
365               c->bit = 0;
366               c->sdar = 0;
367               if( c->sdaw == 0 )
368               {
369                  verboselog( machine, 2, "x76f100(%d) ack <-\n", chip );
370                  c->byte++;
371               }
372               else
373               {
374                  verboselog( machine, 2, "x76f100(%d) nak <-\n", chip );
375               }
376            }
377         }
378         break;
183      sdar = shift & 1;
184      shift >>= 1;
185      bit++;
186     
187      if(bit == 8) {
188         bit = 0;
189         byte++;
190         if(byte == 4)
191            byte = 0;
379192      }
193      break;
380194   }
381   c->scl = scl;
382195}
383196
384void x76f100_sda_write( running_machine *machine, int chip, int sda )
197void x76f100_device::scl_1()
385198{
386   struct x76f100_chip *c;
387
388   if( chip >= X76F100_MAXCHIP )
389   {
390      verboselog( machine, 0, "x76f100_sda_write( %d ) chip out of range\n", chip );
199   if(cs)
391200      return;
392   }
393201
394   c = &x76f100[ chip ];
202   switch(state) {
203   case STATE_RESPONSE_TO_RESET:
204      break;
395205
396   if( c->sdaw != sda )
397   {
398      verboselog( machine, 2, "x76f100(%d) sdaw=%d\n", chip, sda );
399   }
400   if( c->cs == 0 && c->scl != 0 )
401   {
402      if( c->sdaw == 0 && sda != 0 )
403      {
404         verboselog( machine, 1, "x76f100(%d) goto stop\n", chip );
405         c->state = STATE_STOP;
406         c->sdar = 0;
407      }
408      if( c->sdaw != 0 && sda == 0 )
409      {
410         switch( c->state )
411         {
412         case STATE_STOP:
413            verboselog( machine, 1, "x76f100(%d) goto start\n", chip );
414            c->state = STATE_LOAD_COMMAND;
206   case STATE_LOAD_COMMAND:
207   case STATE_LOAD_PASSWORD:
208   case STATE_VERIFY_PASSWORD:
209   case STATE_WRITE_DATA:
210      if(bit < 8) {
211         verboselog(2, "clock\n");
212         shift <<= 1;
213         if(sdaw)
214            shift |= 1;
215         bit++;
216      } else {
217         switch(state) {
218         case STATE_LOAD_COMMAND:
219            verboselog(1, "-> command: %02x\n", command);
220            sdar = false;
221            command = shift;
222            /* todo: verify command is valid? */
223            state = STATE_LOAD_PASSWORD;
224            bit = 0;
225            shift = 0;
415226            break;
416227
417228         case STATE_LOAD_PASSWORD:
418            /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
419            verboselog( machine, 1, "x76f100(%d) goto start\n", chip );
229            verboselog(1, "-> password: %02x\n", shift);
230            sdar = false;
231            write_buffer[byte++] = shift;
232            if(byte == SIZE_WRITE_BUFFER)
233               state = STATE_VERIFY_PASSWORD;
234            bit = 0;
235            shift = 0;
420236            break;
421237
422         case STATE_READ_DATA:
423            verboselog( machine, 1, "x76f100(%d) continue reading??\n", chip );
424//              verboselog( machine, 1, "x76f100(%d) goto load address\n", chip );
425//              c->state = STATE_LOAD_ADDRESS;
238         case STATE_VERIFY_PASSWORD:
239            verboselog(1, "-> verify password: %02x\n", shift);
240            sdar = false;
241            /* todo: this should probably be handled as a command */
242            if(shift == COMMAND_ACK_PASSWORD) {
243               /* todo: this should take 10ms before it returns ok. */
244               if(!memcmp(password(), write_buffer, SIZE_WRITE_BUFFER))
245                  password_ok();
246               else
247                  sdar = true;
248            }
249            bit = 0;
250            shift = 0;
426251            break;
427252
428         default:
429            verboselog( machine, 1, "x76f100(%d) skipped start (default)\n", chip );
253         case STATE_WRITE_DATA:
254            verboselog(1, "-> data: %02x\n", shift );
255            sdar = false;
256            write_buffer[byte++] = shift;
257            if(byte == SIZE_WRITE_BUFFER) {
258               for(byte = 0; byte < SIZE_WRITE_BUFFER; byte++)
259                  data[data_offset()] = write_buffer[byte];
260               byte = 0;
261            }
262            bit = 0;
263            shift = 0;
430264            break;
431265         }
432
433         c->bit = 0;
434         c->byte = 0;
435         c->shift = 0;
436         c->sdar = 0;
437266      }
267      break;
268     
269   case STATE_READ_DATA:
270      if(bit < 8) {
271         if(bit == 0) {
272            shift = data[data_offset()];
273            verboselog(1, "<- data: %02x\n", shift );
274         }
275         sdar = (shift >> 7) & 1;
276         shift <<= 1;
277         bit++;
278      } else {
279         bit = 0;
280         sdar = false;
281         if(!sdaw) {
282            verboselog(2, "ack <-\n");
283            byte++;
284         } else {
285            verboselog(2, "nak <-\n");
286         }
287      }
288      break;
438289   }
439   c->sdaw = sda;
440290}
441291
442int x76f100_sda_read( running_machine *machine, int chip )
292void x76f100_device::sda_0()
443293{
444   struct x76f100_chip *c;
294   if(cs || !scl)
295      return;
445296
446   if( chip >= X76F100_MAXCHIP )
447   {
448      verboselog( machine, 0, "x76f100_sda_read( %d ) chip out of range\n", chip );
449      return 1;
450   }
297   switch(state) {
298   case STATE_STOP:
299      state = STATE_LOAD_COMMAND;
300      break;
451301
452   c = &x76f100[ chip ];
302   case STATE_LOAD_PASSWORD:
303      /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
304      break;
453305
454   if( c->cs != 0 )
455   {
456      verboselog( machine, 2, "x76f100(%d) not selected\n", chip );
457      return 1;
306   case STATE_READ_DATA:
307      //              c->state = STATE_LOAD_ADDRESS;
308      break;
309
310   default:
311      break;
458312   }
459   verboselog( machine, 2, "x76f100(%d) sdar=%d\n", chip, c->sdar );
460   return c->sdar;
313
314   bit = 0;
315   byte = 0;
316   shift = 0;
317   sdar = false;
461318}
462319
463static void nvram_handler_x76f100( running_machine *machine, mame_file *file, int read_or_write, int chip )
320void x76f100_device::sda_1()
464321{
465   struct x76f100_chip *c;
466
467   if( chip >= X76F100_MAXCHIP )
468   {
469      verboselog( machine, 0, "nvram_handler_x76f100( %d ) chip out of range\n", chip );
322   if(cs || !scl)
470323      return;
471   }
472324
473   c = &x76f100[ chip ];
325   state = STATE_STOP;
326   sdar = false;
327}
474328
475   if( read_or_write )
476   {
477      mame_fwrite( file, c->write_password, SIZE_WRITE_PASSWORD );
478      mame_fwrite( file, c->read_password, SIZE_READ_PASSWORD );
479      mame_fwrite( file, c->data, SIZE_DATA );
480   }
481   else if( file )
482   {
483      mame_fread( file, c->write_password, SIZE_WRITE_PASSWORD );
484      mame_fread( file, c->read_password, SIZE_READ_PASSWORD );
485      mame_fread( file, c->data, SIZE_DATA );
486   }
329void x76f100_device::nvram_read(emu_file &file)
330{
331   file.read(response_to_reset, SIZE_RESPONSE_TO_RESET);
332   file.read(write_password,    SIZE_WRITE_PASSWORD);
333   file.read(read_password,     SIZE_READ_PASSWORD);
334   file.read(data,              SIZE_DATA);
487335}
488336
489NVRAM_HANDLER( x76f100_0 ) { nvram_handler_x76f100( machine, file, read_or_write, 0 ); }
490NVRAM_HANDLER( x76f100_1 ) { nvram_handler_x76f100( machine, file, read_or_write, 1 ); }
337void x76f100_device::nvram_write(emu_file &file)
338{
339   file.write(response_to_reset, SIZE_RESPONSE_TO_RESET);
340   file.write(write_password,    SIZE_WRITE_PASSWORD);
341   file.write(read_password,     SIZE_READ_PASSWORD);
342   file.write(data,              SIZE_DATA);
343}
src/emu/machine/timekpr.h
r10384r10385
100100
101101   // device_nvram_interface overrides
102102   virtual void nvram_default();
103   virtual void nvram_read(mame_file &file);
104   virtual void nvram_write(mame_file &file);
103   virtual void nvram_read(emu_file &file);
104   virtual void nvram_write(emu_file &file);
105105
106106   // internal state
107107   const timekeeper_device_config &m_config;
src/emu/machine/x76f100.h
r10384r10385
55 *
66 */
77
8#if !defined( X76F100_H )
8#ifndef __X76F100_H__
9#define __X76F100_H__
910
10#define X76F100_MAXCHIP ( 2 )
11#define MCFG_X76F100_ADD(_tag) \
12   MCFG_DEVICE_ADD(_tag, X76F100, 0)
1113
12extern void x76f100_init( running_machine *machine, int chip, UINT8 *data );
13extern void x76f100_cs_write( running_machine *machine, int chip, int cs );
14extern void x76f100_rst_write( running_machine *machine, int chip, int rst );
15extern void x76f100_scl_write( running_machine *machine, int chip, int scl );
16extern void x76f100_sda_write( running_machine *machine, int chip, int sda );
17extern int x76f100_sda_read( running_machine *machine, int chip );
18extern NVRAM_HANDLER( x76f100_0 );
19extern NVRAM_HANDLER( x76f100_1 );
14#include "machine/secflash.h"
2015
21#define X76F100_H
16class x76f100_device_config : public device_secure_serial_flash_config
17{
18   friend class x76f100_device;
19
20   // construction/destruction
21   x76f100_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
22
23public:
24   // allocators
25   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
26   virtual device_t *alloc_device(running_machine &machine) const;
27};
28
29class x76f100_device : public device_secure_serial_flash
30{
31   friend class x76f100_device_config;
32
33   // construction/destruction
34   x76f100_device(running_machine &_machine, const x76f100_device_config &config);
35
36protected:
37   // device-level overrides
38   virtual void device_start();
39   virtual void device_reset();
40
41   // device_nvram_interface overrides
42   virtual void nvram_default();
43   virtual void nvram_read(emu_file &file);
44   virtual void nvram_write(emu_file &file);
45
46   // device_secure_serial_flash implementations
47   virtual void cs_0();
48   virtual void cs_1();
49   virtual void rst_0();
50   virtual void rst_1();
51   virtual void scl_0();
52   virtual void scl_1();
53   virtual void sda_0();
54   virtual void sda_1();
55
56   // internal state
57   const x76f100_device_config &config;
58
59   enum {
60      SIZE_WRITE_BUFFER = 8,
61      SIZE_RESPONSE_TO_RESET = 4,
62      SIZE_WRITE_PASSWORD = 8,
63      SIZE_READ_PASSWORD = 8,
64      SIZE_DATA = 112,
65
66      COMMAND_WRITE = 0x80,
67      COMMAND_READ = 0x81,
68      COMMAND_CHANGE_WRITE_PASSWORD = 0xfc,
69      COMMAND_CHANGE_READ_PASSWORD = 0xfe,
70      COMMAND_ACK_PASSWORD = 0x55
71   };
72
73   enum {
74      STATE_STOP,
75      STATE_RESPONSE_TO_RESET,
76      STATE_LOAD_COMMAND,
77      STATE_LOAD_PASSWORD,
78      STATE_VERIFY_PASSWORD,
79      STATE_READ_DATA,
80      STATE_WRITE_DATA
81   };
82
83   int state, bit, byte;
84   UINT8 command, shift;
85   UINT8 write_buffer[SIZE_WRITE_BUFFER];
86   UINT8 response_to_reset[SIZE_RESPONSE_TO_RESET];
87   UINT8 write_password[SIZE_WRITE_PASSWORD];
88   UINT8 read_password[SIZE_READ_PASSWORD];
89   UINT8 data[SIZE_DATA];
90
91   UINT8 *password();
92   void password_ok();
93   int data_offset();
94
95private:
96   inline void ATTR_PRINTF(3,4) verboselog(int n_level, const char *s_fmt, ...);
97};
98
99
100// device type definition
101extern const device_type X76F100;
102
22103#endif
src/emu/machine/ds2401.c
r10384r10385
99#include "emu.h"
1010#include "machine/ds2401.h"
1111
12#define VERBOSE_LEVEL ( 0 )
12#define VERBOSE_LEVEL 0
1313
14INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
14inline void ATTR_PRINTF(3,4) ds2401_device::verboselog(int n_level, const char *s_fmt, ...)
1515{
16   if( VERBOSE_LEVEL >= n_level )
16   if(VERBOSE_LEVEL >= n_level)
1717   {
1818      va_list v;
19      char buf[ 32768 ];
20      va_start( v, s_fmt );
21      vsprintf( buf, s_fmt, v );
22      va_end( v );
23      logerror( "%s: %s", machine->describe_context(), buf );
19      char buf[32768];
20      va_start(v, s_fmt);
21      vsprintf(buf, s_fmt, v);
22      va_end(v);
23      logerror("ds2401 %s %s: %s", config.tag(), machine->describe_context(), buf);
2424   }
2525}
2626
27struct ds2401_chip
27const device_type DS2401 = ds2401_device_config::static_alloc_device_config;
28
29ds2401_device_config::ds2401_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
30   : device_config(mconfig, static_alloc_device_config, "DS2401", tag, owner, clock)
2831{
29   int state;
30   int bit;
31   int byte;
32   int shift;
33   int rx;
34   int tx;
35   const UINT8 *data;
36   emu_timer *timer;
37   emu_timer *reset_timer;
38   attotime t_samp;
39   attotime t_rdv;
40   attotime t_rstl;
41   attotime t_pdh;
42   attotime t_pdl;
43};
32}
4433
45#define SIZE_DATA ( 8 )
34device_config *ds2401_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
35{
36   return global_alloc(ds2401_device_config(mconfig, tag, owner, clock));
37}
4638
47#define STATE_IDLE ( 0 )
48#define STATE_RESET ( 1 )
49#define STATE_RESET1 ( 2 )
50#define STATE_RESET2 ( 3 )
51#define STATE_COMMAND ( 4 )
52#define STATE_READROM ( 5 )
39device_t *ds2401_device_config::alloc_device(running_machine &machine) const
40{
41   return auto_alloc(&machine, ds2401_device(machine, *this));
42}
5343
54#define COMMAND_READROM ( 0x33 )
44ds2401_device::ds2401_device(running_machine &_machine, const ds2401_device_config &_config)
45   : device_t(_machine, _config),
46     config(_config)
47{
48}
5549
56static struct ds2401_chip ds2401[ DS2401_MAXCHIP ];
57
58static TIMER_CALLBACK( ds2401_reset )
50void ds2401_device::device_start()
5951{
60   int which = param;
61   struct ds2401_chip *c = &ds2401[ which ];
52   t_samp = attotime::from_usec( 15);
53   t_rdv  = attotime::from_usec( 15);
54   t_rstl = attotime::from_usec(480);
55   t_pdh  = attotime::from_usec( 15);
56   t_pdl  = attotime::from_usec( 60);
6257
63   verboselog( machine, 1, "ds2401_reset(%d)\n", which );
58   save_item(NAME(state));
59   save_item(NAME(bit));
60   save_item(NAME(byte));
61   save_item(NAME(shift));
62   save_item(NAME(rx));
63   save_item(NAME(tx));
6464
65   c->state = STATE_RESET;
66   c->timer->adjust( attotime::never, which );
65   timer_main  = timer_alloc(TIMER_MAIN);
66   timer_reset = timer_alloc(TIMER_RESET);
6767}
6868
69static TIMER_CALLBACK( ds2401_tick )
69void ds2401_device::device_reset()
7070{
71   int which = param;
72   struct ds2401_chip *c = &ds2401[ which ];
71   state = STATE_IDLE;
72   bit = 0;
73   byte = 0;
74   shift = 0;
75   rx = true;
76   tx = true;
7377
74   switch( c->state )
78   if(m_region)
7579   {
76   case STATE_RESET1:
77      verboselog( machine, 2, "ds2401_tick(%d) state_reset1 %d\n", which, c->rx );
78      c->tx = 0;
79      c->state = STATE_RESET2;
80      c->timer->adjust( c->t_pdl, which );
81      break;
82   case STATE_RESET2:
83      verboselog( machine, 2, "ds2401_tick(%d) state_reset2 %d\n", which, c->rx );
84      c->tx = 1;
85      c->bit = 0;
86      c->shift = 0;
87      c->state = STATE_COMMAND;
88      break;
89   case STATE_COMMAND:
90      verboselog( machine, 2, "ds2401_tick(%d) state_command %d\n", which, c->rx );
91      c->shift >>= 1;
92      if( c->rx != 0 )
93      {
94         c->shift |= 0x80;
80      // Ensure the size is correct though
81      if(m_region->bytes() != SIZE_DATA)
82         logerror("ds2401 %s: Wrong region length for id data, expected 0x%x, got 0x%x\n",
83                config.tag(),
84                SIZE_DATA,
85                m_region->bytes());
86      else {
87         UINT8 *rb = m_region->base();
88         memcpy(data, rb, SIZE_DATA);
89         return;
9590      }
96      c->bit++;
97      if( c->bit == 8 )
98      {
99         switch( c->shift )
100         {
101         case COMMAND_READROM:
102            verboselog( machine, 1, "ds2401_tick(%d) readrom\n", which );
103            c->bit = 0;
104            c->byte = 0;
105            c->state = STATE_READROM;
106            break;
107         default:
108            verboselog( machine, 0, "ds2401_tick(%d) command not handled %02x\n", which, c->shift );
109            c->state = STATE_IDLE;
110            break;
111         }
112      }
113      break;
114   case STATE_READROM:
115      c->tx = 1;
116      if( c->byte == 8 )
117      {
118         verboselog( machine, 1, "ds2401_tick(%d) readrom finished\n", which );
119         c->state = STATE_IDLE;
120      }
121      else
122      {
123         verboselog( machine, 2, "ds2401_tick(%d) readrom window closed\n", which );
124      }
125      break;
126   default:
127      verboselog( machine, 0, "ds2401_tick(%d) state not handled: %d\n", which, c->state );
128      break;
12991   }
92
93   // That chip is useless without an id, so bitch if there
94   // isn't one
95   logerror("ds2401 %s: Warning, no id provided, answer will be all zeroes.\n", config.tag());
96   memset(data, 0, SIZE_DATA);
13097}
13198
132void ds2401_init( running_machine *machine, int which, const UINT8 *data )
99void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
133100{
134   struct ds2401_chip *c = &ds2401[ which ];
101   switch(id) {
102   case TIMER_RESET:
103      verboselog(1, "timer_reset\n");
104      state = STATE_RESET;
105      timer_reset->adjust(attotime::never);
106      break;
135107
136   c->state = STATE_IDLE;
137   c->bit = 0;
138   c->byte = 0;
139   c->shift = 0;
140   c->rx = 1;
141   c->tx = 1;
142   c->data = data;
143   c->t_samp = attotime::from_usec( 15 );
144   c->t_rdv = attotime::from_usec( 15 );
145   c->t_rstl = attotime::from_usec( 480 );
146   c->t_pdh = attotime::from_usec( 15 );
147   c->t_pdl = attotime::from_usec( 60 );
108   case TIMER_MAIN:
109      switch(state) {
110      case STATE_RESET1:
111         verboselog(2, "timer_main state_reset1 %d\n", rx);
112         tx = false;
113         state = STATE_RESET2;
114         timer_main->adjust(t_pdl);
115         break;
148116
149   state_save_register_item(machine,  "ds2401", NULL, which, c->state );
150   state_save_register_item(machine,  "ds2401", NULL, which, c->bit );
151   state_save_register_item(machine,  "ds2401", NULL, which, c->byte );
152   state_save_register_item(machine,  "ds2401", NULL, which, c->shift );
153   state_save_register_item(machine,  "ds2401", NULL, which, c->rx );
154   state_save_register_item(machine,  "ds2401", NULL, which, c->tx );
117      case STATE_RESET2:
118         verboselog(2, "timer_main state_reset2 %d\n", rx);
119         tx = true;
120         bit = 0;
121         shift = 0;
122         state = STATE_COMMAND;
123         break;
155124
156   c->timer = machine->scheduler().timer_alloc(FUNC(ds2401_tick ));
157   c->reset_timer = machine->scheduler().timer_alloc(FUNC(ds2401_reset ));
125      case STATE_COMMAND:
126         verboselog(2, "timer_main state_command %d\n", rx);
127         shift >>= 1;
128         if(rx)
129            shift |= 0x80;
130         bit++;
131         if(bit == 8) {
132            switch(shift) {
133            case COMMAND_READROM:
134               verboselog(1, "timer_main readrom\n");
135               bit = 0;
136               byte = 0;
137               state = STATE_READROM;
138               break;
139            default:
140               verboselog(0, "timer_main command not handled %02x\n", shift);
141               state = STATE_IDLE;
142               break;
143            }
144         }
145         break;
146
147      case STATE_READROM:
148         tx = true;
149         if(byte == SIZE_DATA) {
150            verboselog(1, "timer_main readrom finished\n");
151            state = STATE_IDLE;
152         } else {
153            verboselog(2, "timer_main readrom window closed\n");
154         }
155         break;
156      default:
157         verboselog(0, "timer_main state not handled: %d\n", state);
158         break;
159      }
160   }
158161}
159162
160void ds2401_write( running_machine *machine, int which, int data )
163void ds2401_device::write(bool line)
161164{
162   struct ds2401_chip *c = &ds2401[ which ];
165   verboselog(1, "write(%d)\n", line);
163166
164   verboselog( machine, 1, "ds2401_write( %d, %d )\n", which, data );
165
166   if( data == 0 && c->rx != 0 )
167   {
168      switch( c->state )
169      {
167   if(!line && rx) {
168      switch(state) {
170169      case STATE_IDLE:
171170         break;
172171      case STATE_COMMAND:
173         verboselog( machine, 2, "ds2401_write(%d) state_command\n", which );
174         c->timer->adjust( c->t_samp, which );
172         verboselog(2, "state_command\n");
173         timer_main->adjust(t_samp);
175174         break;
176175      case STATE_READROM:
177         if( c->bit == 0 )
178         {
179            c->shift = c->data[ 7 - c->byte ];
180            verboselog( machine, 1, "ds2401_write(%d) <- data %02x\n", which, c->shift );
176         if(!bit) {
177            shift = data[7 - byte];
178            verboselog(1, "<- data %02x\n", shift);
181179         }
182         c->tx = c->shift & 1;
183         c->shift >>= 1;
184         c->bit++;
185         if( c->bit == 8 )
186         {
187            c->bit = 0;
188            c->byte++;
180         tx = shift & 1;
181         shift >>= 1;
182         bit++;
183         if(bit == 8) {
184            bit = 0;
185            byte++;
189186         }
190         verboselog( machine, 2, "ds2401_write(%d) state_readrom %d\n", which, c->tx );
191         c->timer->adjust( c->t_rdv, which );
187         verboselog(2, "state_readrom %d\n", tx);
188         timer_main->adjust(t_rdv);
192189         break;
193190      default:
194         verboselog( machine, 0, "ds2401_write(%d) state not handled: %d\n", which, c->state );
191         verboselog(0, "state not handled: %d\n", state );
195192         break;
196193      }
197      c->reset_timer->adjust( c->t_rstl, which );
198   }
199   else if( data == 1 && c->rx == 0 )
200   {
201      switch( c->state )
202      {
194      timer_reset->adjust(t_rstl);
195   } else if(line && !rx) {
196      switch(state) {
203197      case STATE_RESET:
204         c->state = STATE_RESET1;
205         c->timer->adjust( c->t_pdh, which );
198         state = STATE_RESET1;
199         timer_main->adjust(t_pdh);
206200         break;
207201      }
208      c->reset_timer->adjust( attotime::never, which );
202      timer_reset->adjust(attotime::never);
209203   }
210   c->rx = data;
204   rx = line;
211205}
212206
213int ds2401_read( running_machine *machine, int which )
207bool ds2401_device::read()
214208{
215   struct ds2401_chip *c = &ds2401[ which ];
209   verboselog(2, "read %d\n", tx && rx);
210   return tx && rx;
211}
216212
217   verboselog( machine, 2, "ds2401_read( %d ) %d\n", which, c->tx & c->rx );
218   return c->tx & c->rx;
213UINT8 ds2401_device::direct_read(int index)
214{
215   return data[index];
219216}
220217
221218/*
src/emu/machine/ram.c
r10384r10385
100100   /* the device named 'ram' can get ram options from command line */
101101   if (strcmp(device->tag(), RAM_TAG) == 0)
102102   {
103      const char *ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
103      const char *ramsize_string = options_get_string(&device->machine->options(), OPTION_RAMSIZE);
104104
105105      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
106106         ram->size = ram_parse_string(ramsize_string);
r10384r10385
140140   /* command line options are only parsed for the device named RAM_TAG */
141141   if (device->tag()!=NULL && strcmp(device->tag(), RAM_TAG) == 0)
142142   {
143      if (mame_options()==NULL) return FALSE;
144143      /* verify command line ram option */
145      ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
146      gamename_option = options_get_string(mame_options(), OPTION_GAMENAME);
144      ramsize_string = options_get_string(&options, OPTION_RAMSIZE);
145      gamename_option = options_get_string(&options, OPTION_GAMENAME);
147146
148147      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
149148      {
src/emu/machine/ds2401.h
r10384r10385
66 *
77 */
88
9#if !defined( DS2401_H )
10#define DS2401_H ( 1 )
9#ifndef __DS2401_H__
10#define __DS2401_H__
1111
12#define DS2401_MAXCHIP ( 3 )
12#define MCFG_DS2401_ADD(_tag) \
13   MCFG_DEVICE_ADD(_tag, DS2401, 0)
1314
14extern void ds2401_init( running_machine *machine, int which, const UINT8 *data );
15extern void ds2401_write( running_machine *machine, int which, int data );
16extern int ds2401_read( running_machine *machine, int which );
15#include "emu.h"
1716
17class ds2401_device_config : public device_config
18{
19   friend class ds2401_device;
20
21   // construction/destruction
22   ds2401_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
23
24public:
25   // allocators
26   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
27   virtual device_t *alloc_device(running_machine &machine) const;
28};
29
30class ds2401_device : public device_t
31{
32   friend class ds2401_device_config;
33
34   // construction/destruction
35   ds2401_device(running_machine &_machine, const ds2401_device_config &config);
36
37public:
38   void write(bool line);
39   bool read();
40   UINT8 direct_read(int index);
41
42protected:
43   enum {
44      SIZE_DATA = 8,
45
46      COMMAND_READROM = 0x33
47   };
48
49   enum {
50      STATE_IDLE,
51      STATE_RESET,
52      STATE_RESET1,
53      STATE_RESET2,
54      STATE_COMMAND,
55      STATE_READROM
56   };
57
58   enum {
59      TIMER_MAIN,
60      TIMER_RESET
61   };
62
63   // device-level overrides
64   virtual void device_start();
65   virtual void device_reset();
66   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
67
68   // internal state
69   const ds2401_device_config &config;
70
71   int state, bit, shift;
72   UINT8 byte;
73   bool rx, tx;
74   UINT8 data[SIZE_DATA];
75   emu_timer *timer_main, *timer_reset;
76   attotime t_samp, t_rdv, t_rstl, t_pdh, t_pdl;
77
78private:
79   inline void ATTR_PRINTF(3,4) verboselog(int n_level, const char *s_fmt, ...);
80};
81
82
83// device type definition
84extern const device_type DS2401;
85
1886#endif
src/emu/machine/er2055.c
r10384r10385
167167//  .nv file
168168//-------------------------------------------------
169169
170void er2055_device::nvram_read(mame_file &file)
170void er2055_device::nvram_read(emu_file &file)
171171{
172172   UINT8 buffer[SIZE_DATA];
173   mame_fread(&file, buffer, sizeof(buffer));
173   file.read(buffer, sizeof(buffer));
174174   for (int byte = 0; byte < SIZE_DATA; byte++)
175175      m_addrspace[0]->write_byte(byte, buffer[byte]);
176176}
r10384r10385
181181//  .nv file
182182//-------------------------------------------------
183183
184void er2055_device::nvram_write(mame_file &file)
184void er2055_device::nvram_write(emu_file &file)
185185{
186186   UINT8 buffer[SIZE_DATA];
187187   for (int byte = 0; byte < SIZE_DATA; byte++)
188188      buffer[byte] = m_addrspace[0]->read_byte(byte);
189   mame_fwrite(&file, buffer, sizeof(buffer));
189   file.write(buffer, sizeof(buffer));
190190}
191191
192192
src/emu/machine/er2055.h
r10384r10385
109109
110110   // device_nvram_interface overrides
111111   virtual void nvram_default();
112   virtual void nvram_read(mame_file &file);
113   virtual void nvram_write(mame_file &file);
112   virtual void nvram_read(emu_file &file);
113   virtual void nvram_write(emu_file &file);
114114
115115   static const int SIZE_DATA = 0x40;
116116
src/emu/machine/secflash.c
r0r10385
1#include "emu.h"
2#include "machine/secflash.h"
3
4device_secure_serial_flash_config::device_secure_serial_flash_config(const machine_config &mconfig,
5                                                    device_type type,
6                                                    const char *name, const char *tag,
7                                                    const device_config *owner, UINT32 clock, UINT32 param)
8   : device_config(mconfig, type, name, tag, owner, clock, param),
9     device_config_nvram_interface(mconfig, *this)
10{
11}
12
13device_secure_serial_flash::device_secure_serial_flash(running_machine &_machine, const device_secure_serial_flash_config &config) : device_t(_machine, config),
14                                                                                                    device_nvram_interface(_machine, config, *this)
15{
16}
17
18void device_secure_serial_flash::device_start()
19{
20   save_item(NAME(cs));
21   save_item(NAME(rst));
22   save_item(NAME(scl));
23   save_item(NAME(sdaw));
24   save_item(NAME(sdar));
25}
26
27void device_secure_serial_flash::device_reset()
28{
29   cs = rst = scl = sdaw = sdar = false;
30}
31
32void device_secure_serial_flash::cs_w(bool _cs)
33{
34   if(cs == _cs)
35      return;
36   cs = _cs;
37   if(cs)
38      cs_1();
39   else
40      cs_0();
41}
42
43void device_secure_serial_flash::rst_w(bool _rst)
44{
45   if(rst == _rst)
46      return;
47   rst = _rst;
48   if(rst)
49      rst_1();
50   else
51      rst_0();
52}
53
54void device_secure_serial_flash::scl_w(bool _scl)
55{
56   if(scl == _scl)
57      return;
58   scl = _scl;
59   if(scl)
60      scl_1();
61   else
62      scl_0();
63}
64
65void device_secure_serial_flash::sda_w(bool _sda)
66{
67   if(sdaw == _sda)
68      return;
69   sdaw = _sda;
70   if(sdaw)
71      sda_1();
72   else
73      sda_0();
74}
75
76bool device_secure_serial_flash::sda_r()
77{
78   return cs ? true : sdar;
79}
src/emu/machine/secflash.h
r0r10385
1// Common interface for all secure serial flashes
2
3#ifndef __SECFLASH_H__
4#define __SECFLASH_H__
5
6#include "emu.h"
7
8class device_secure_serial_flash_config : public device_config,
9                                public device_config_nvram_interface
10{
11public:
12   device_secure_serial_flash_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 param = 0);
13};
14   
15class device_secure_serial_flash : public device_t,
16                           public device_nvram_interface
17{
18public:
19   void cs_w(bool cs);
20   void rst_w(bool rst);
21   void scl_w(bool scl);
22   void sda_w(bool sda);
23   bool sda_r();
24
25protected:
26   bool cs, rst, scl, sdaw, sdar;
27
28   virtual void cs_0() = 0;
29   virtual void cs_1() = 0;
30   virtual void rst_0() = 0;
31   virtual void rst_1() = 0;
32   virtual void scl_0() = 0;
33   virtual void scl_1() = 0;
34   virtual void sda_0() = 0;
35   virtual void sda_1() = 0;
36
37   device_secure_serial_flash(running_machine &_machine, const device_secure_serial_flash_config &config);
38   virtual void device_start();
39   virtual void device_reset();
40};
41
42#endif
src/emu/machine/generic.c
r10384r10385
312312***************************************************************************/
313313
314314/*-------------------------------------------------
315    nvram_fopen - open an NVRAM file directly
316-------------------------------------------------*/
317
318mame_file *nvram_fopen(running_machine *machine, UINT32 openflags)
319{
320   file_error filerr;
321   mame_file *file;
322
323   astring fname(machine->basename(), ".nv");
324   filerr = mame_fopen(SEARCHPATH_NVRAM, fname, openflags, &file);
325
326   return (filerr == FILERR_NONE) ? file : NULL;
327}
328
329
330/*-------------------------------------------------
331315    nvram_load - load a system's NVRAM
332316-------------------------------------------------*/
333317
r10384r10385
339323      return;
340324
341325   // open the file; if it exists, call everyone to read from it
342   mame_file *nvram_file = nvram_fopen(machine, OPEN_FLAG_READ);
343   if (nvram_file != NULL)
326   emu_file file(machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_READ);
327   if (file.open(machine->basename(), ".nv") == FILERR_NONE)
344328   {
345329      // read data from general NVRAM handler first
346330      if (machine->config->m_nvram_handler != NULL)
347         (*machine->config->m_nvram_handler)(machine, nvram_file, FALSE);
331         (*machine->config->m_nvram_handler)(machine, &file, FALSE);
348332
349333      // find all devices with NVRAM handlers, and read from them next
350334      for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
351         nvram->nvram_load(*nvram_file);
352
353      // close the file
354      mame_fclose(nvram_file);
335         nvram->nvram_load(file);
355336   }
356337
357338   // otherwise, tell everyone to initialize their NVRAM areas
r10384r10385
380361      return;
381362
382363   // open the file; if it exists, call everyone to read from it
383   mame_file *nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
384   if (nvram_file != NULL)
364   emu_file file(machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
365   if (file.open(machine->basename(), ".nv") == FILERR_NONE)
385366   {
386367      // write data via general NVRAM handler first
387368      if (machine->config->m_nvram_handler != NULL)
388         (*machine->config->m_nvram_handler)(machine, nvram_file, TRUE);
369         (*machine->config->m_nvram_handler)(machine, &file, TRUE);
389370
390371      // find all devices with NVRAM handlers, and tell them to write next
391372      for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
392         nvram->nvram_save(*nvram_file);
393
394      // close the file
395      mame_fclose(nvram_file);
373         nvram->nvram_save(file);
396374   }
397375}
398376
r10384r10385
420398
421399int memcard_create(running_machine *machine, int index, int overwrite)
422400{
423   file_error filerr;
424   mame_file *file;
425401   char name[16];
426402
427403   /* create a name */
r10384r10385
431407   astring fname(machine->basename(), PATH_SEPARATOR, name);
432408   if (!overwrite)
433409   {
434      filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_READ, &file);
435      if (filerr == FILERR_NONE)
436      {
437         mame_fclose(file);
410      emu_file testfile(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
411      if (testfile.open(fname) == FILERR_NONE)
438412         return 1;
439      }
440413   }
441414
442415   /* create a new file */
443   filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
416   emu_file file(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
417   file_error filerr = file.open(fname);
444418   if (filerr != FILERR_NONE)
445419      return 1;
446420
r10384r10385
449423      (*machine->config->m_memcard_handler)(machine, file, MEMCARD_CREATE);
450424
451425   /* close the file */
452   mame_fclose(file);
453426   return 0;
454427}
455428
r10384r10385
462435int memcard_insert(running_machine *machine, int index)
463436{
464437   generic_machine_private *state = machine->generic_machine_data;
465   file_error filerr;
466   mame_file *file;
467438   char name[16];
468439
469440   /* if a card is already inserted, eject it first */
r10384r10385
473444
474445   /* create a name */
475446   memcard_name(index, name);
476   astring fname(machine->basename(), PATH_SEPARATOR, name);
477447
478448   /* open the file; if we can't, it's an error */
479   filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_READ, &file);
449   emu_file file(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
450   file_error filerr = file.open(machine->basename(), PATH_SEPARATOR, name);
480451   if (filerr != FILERR_NONE)
481452      return 1;
482453
r10384r10385
485456      (*machine->config->m_memcard_handler)(machine, file, MEMCARD_INSERT);
486457
487458   /* close the file */
488   mame_fclose(file);
489459   state->memcard_inserted = index;
490460   return 0;
491461}
r10384r10385
499469void memcard_eject(running_machine &machine)
500470{
501471   generic_machine_private *state = machine.generic_machine_data;
502   file_error filerr;
503   mame_file *file;
504472   char name[16];
505473
506474   /* if no card is preset, just ignore */
r10384r10385
509477
510478   /* create a name */
511479   memcard_name(state->memcard_inserted, name);
512   astring fname(machine.basename(), PATH_SEPARATOR, name);
513480
514481   /* open the file; if we can't, it's an error */
515   filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
482   emu_file file(machine.options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
483   file_error filerr = file.open(machine.basename(), PATH_SEPARATOR, name);
516484   if (filerr != FILERR_NONE)
517   {
518      mame_fclose(file);
519485      return;
520   }
521486
522487   /* initialize and then load the card */
523488   if (machine.m_config.m_memcard_handler)
524489      (*machine.m_config.m_memcard_handler)(&machine, file, MEMCARD_EJECT);
525490
526491   /* close the file */
527   mame_fclose(file);
528492   state->memcard_inserted = -1;
529493}
530494
src/emu/machine/x76f041.c
r10384r10385
1414#include "emu.h"
1515#include "machine/x76f041.h"
1616
17#define VERBOSE_LEVEL ( 0 )
17#define VERBOSE_LEVEL 0
1818
19INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
19inline void ATTR_PRINTF(3,4) x76f041_device::verboselog(int n_level, const char *s_fmt, ...)
2020{
21   if( VERBOSE_LEVEL >= n_level )
21   if(VERBOSE_LEVEL >= n_level)
2222   {
2323      va_list v;
24      char buf[ 32768 ];
25      va_start( v, s_fmt );
26      vsprintf( buf, s_fmt, v );
27      va_end( v );
28      logerror( "%s: %s", machine->describe_context(), buf );
24      char buf[32768];
25      va_start(v, s_fmt);
26      vsprintf(buf, s_fmt, v);
27      va_end(v);
28      logerror("x76f041 %s %s: %s", config.tag(), machine->describe_context(), buf);
2929   }
3030}
3131
32#define SIZE_WRITE_BUFFER ( 8 )
32const device_type X76F041 = x76f041_device_config::static_alloc_device_config;
3333
34struct x76f041_chip
34x76f041_device_config::x76f041_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
35   : device_secure_serial_flash_config(mconfig, static_alloc_device_config, "X76F041", tag, owner, clock)
3536{
36   int cs;
37   int rst;
38   int scl;
39   int sdaw;
40   int sdar;
41   int state;
42   int shift;
43   int bit;
44   int byte;
45   int command;
46   int address;
47   UINT8 write_buffer[ SIZE_WRITE_BUFFER ];
48   UINT8 *response_to_reset;
49   UINT8 *write_password;
50   UINT8 *read_password;
51   UINT8 *configuration_password;
52   UINT8 *configuration_registers;
53   UINT8 *data;
54};
37}
5538
56#define SIZE_RESPONSE_TO_RESET ( 4 )
57#define SIZE_WRITE_PASSWORD ( SIZE_WRITE_BUFFER )
58#define SIZE_READ_PASSWORD ( SIZE_WRITE_BUFFER )
59#define SIZE_CONFIGURATION_PASSWORD ( SIZE_WRITE_BUFFER )
60#define SIZE_CONFIGURATION_REGISTERS ( SIZE_WRITE_BUFFER )
61#define SIZE_DATA ( 512 )
39device_config *x76f041_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
40{
41   return global_alloc(x76f041_device_config(mconfig, tag, owner, clock));
42}
6243
63#define CONFIG_BCR1 ( 0 )
64#define CONFIG_BCR2 ( 1 )
65#define CONFIG_CR ( 2 )
66#define CONFIG_RR ( 3 )
67#define CONFIG_RC ( 4 )
44device_t *x76f041_device_config::alloc_device(running_machine &machine) const
45{
46   return auto_alloc(&machine, x76f041_device(machine, *this));
47}
6848
69#define BCR_X ( 8 )
70#define BCR_Y ( 4 )
71#define BCR_Z ( 2 )
72#define BCR_T ( 1 )
49x76f041_device::x76f041_device(running_machine &_machine, const x76f041_device_config &_config)
50   : device_secure_serial_flash(_machine, _config),
51     config(_config)
52{
53}
7354
74static struct x76f041_chip x76f041[ X76F041_MAXCHIP ];
55void x76f041_device::device_start()
56{
57   device_secure_serial_flash::device_start();
58   save_item(NAME(state));
59   save_item(NAME(shift));
60   save_item(NAME(bit));
61   save_item(NAME(byte));
62   save_item(NAME(command));
63   save_item(NAME(address));
64   save_item(NAME(write_buffer));
65   save_item(NAME(response_to_reset));
66   save_item(NAME(write_password));
67   save_item(NAME(read_password));
68   save_item(NAME(configuration_password));
69   save_item(NAME(configuration_registers));
70   save_item(NAME(data));
71}
7572
76#define COMMAND_WRITE ( 0x00 )
77#define COMMAND_READ ( 0x20 )
78#define COMMAND_WRITE_USE_CONFIGURATION_PASSWORD ( 0x40 )
79#define COMMAND_READ_USE_CONFIGURATION_PASSWORD ( 0x60 )
80#define COMMAND_CONFIGURATION ( 0x80 )
81
82#define CONFIGURATION_PROGRAM_WRITE_PASSWORD ( 0x00 )
83#define CONFIGURATION_PROGRAM_READ_PASSWORD ( 0x10 )
84#define CONFIGURATION_PROGRAM_CONFIGURATION_PASSWORD ( 0x20 )
85#define CONFIGURATION_RESET_WRITE_PASSWORD ( 0x30 )
86#define CONFIGURATION_RESET_READ_PASSWORD ( 0x40 )
87#define CONFIGURATION_PROGRAM_CONFIGURATION_REGISTERS ( 0x50 )
88#define CONFIGURATION_READ_CONFIGURATION_REGISTERS ( 0x60 )
89#define CONFIGURATION_MASS_PROGRAM ( 0x70 )
90#define CONFIGURATION_MASS_ERASE ( 0x80 )
91
92#define STATE_STOP ( 0 )
93#define STATE_RESPONSE_TO_RESET ( 1 )
94#define STATE_LOAD_COMMAND ( 2 )
95#define STATE_LOAD_ADDRESS ( 3 )
96#define STATE_LOAD_PASSWORD ( 4 )
97#define STATE_VERIFY_PASSWORD ( 5 )
98#define STATE_READ_DATA ( 6 )
99#define STATE_WRITE_DATA ( 7 )
100#define STATE_READ_CONFIGURATION_REGISTERS ( 8 )
101#define STATE_WRITE_CONFIGURATION_REGISTERS ( 9 )
102
103void x76f041_init( running_machine *machine, int chip, UINT8 *data )
73void x76f041_device::device_reset()
10474{
105   int offset;
106   struct x76f041_chip *c;
75   device_secure_serial_flash::device_reset();
76   state = STATE_STOP;
77   shift = 0;
78   bit = 0;
79   byte = 0;
80   command = 0;
81   address = 0;
82   memset(write_buffer, 0, SIZE_WRITE_BUFFER);
83}
10784
108   if( chip >= X76F041_MAXCHIP )
85void x76f041_device::nvram_default()
86{
87   // region always wins
88   if(m_region)
10989   {
110      verboselog( machine, 0, "x76f041_init( %d ) chip out of range\n", chip );
111      return;
90      // Ensure the size is correct though
91      if(m_region->bytes() != SIZE_RESPONSE_TO_RESET+SIZE_WRITE_PASSWORD+
92         SIZE_READ_PASSWORD+SIZE_CONFIGURATION_PASSWORD+SIZE_CONFIGURATION_REGISTERS+SIZE_DATA)
93         logerror("X76F041: Wrong region length for initialization data, expected 0x%x, got 0x%x\n",
94                SIZE_RESPONSE_TO_RESET+SIZE_WRITE_PASSWORD+
95                SIZE_READ_PASSWORD+SIZE_CONFIGURATION_PASSWORD+SIZE_CONFIGURATION_REGISTERS+SIZE_DATA,
96                m_region->bytes());
97      else {
98         UINT8 *rb = m_region->base();
99         int offset = 0;
100         memcpy(response_to_reset,       rb + offset, SIZE_RESPONSE_TO_RESET); offset += SIZE_RESPONSE_TO_RESET;
101         memcpy(write_password,          rb + offset, SIZE_WRITE_PASSWORD); offset += SIZE_WRITE_PASSWORD;
102         memcpy(read_password,           rb + offset, SIZE_READ_PASSWORD); offset += SIZE_READ_PASSWORD;
103         memcpy(configuration_password,  rb + offset, SIZE_CONFIGURATION_PASSWORD); offset += SIZE_CONFIGURATION_PASSWORD;
104         memcpy(configuration_registers, rb + offset, SIZE_CONFIGURATION_REGISTERS); offset += SIZE_CONFIGURATION_REGISTERS;
105         memcpy(data,                    rb + offset, SIZE_DATA); offset += SIZE_DATA;
106         return;
107      }
112108   }
113109
114   c = &x76f041[ chip ];
115
116   if( data == NULL )
117   {
118      data = auto_alloc_array( machine, UINT8,
119         SIZE_RESPONSE_TO_RESET +
120         SIZE_READ_PASSWORD +
121         SIZE_WRITE_PASSWORD +
122         SIZE_CONFIGURATION_PASSWORD +
123         SIZE_CONFIGURATION_REGISTERS +
124         SIZE_DATA );
125   }
126
127   c->cs = 0;
128   c->rst = 0;
129   c->scl = 0;
130   c->sdaw = 0;
131   c->sdar = 0;
132   c->state = STATE_STOP;
133   c->shift = 0;
134   c->bit = 0;
135   c->byte = 0;
136   c->command = 0;
137   c->address = 0;
138   memset( c->write_buffer, 0, SIZE_WRITE_BUFFER );
139
140   offset = 0;
141   c->response_to_reset = &data[ offset ]; offset += SIZE_RESPONSE_TO_RESET;
142   c->write_password = &data[ offset ]; offset += SIZE_WRITE_PASSWORD;
143   c->read_password = &data[ offset ]; offset += SIZE_READ_PASSWORD;
144   c->configuration_password = &data[ offset ]; offset += SIZE_CONFIGURATION_PASSWORD;
145   c->configuration_registers = &data[ offset ]; offset += SIZE_CONFIGURATION_REGISTERS;
146   c->data = &data[ offset ]; offset += SIZE_DATA;
147
148   state_save_register_item( machine, "x76f041", NULL, chip, c->cs );
149   state_save_register_item( machine, "x76f041", NULL, chip, c->rst );
150   state_save_register_item( machine, "x76f041", NULL, chip, c->scl );
151   state_save_register_item( machine, "x76f041", NULL, chip, c->sdaw );
152   state_save_register_item( machine, "x76f041", NULL, chip, c->sdar );
153   state_save_register_item( machine, "x76f041", NULL, chip, c->state );
154   state_save_register_item( machine, "x76f041", NULL, chip, c->shift );
155   state_save_register_item( machine, "x76f041", NULL, chip, c->bit );
156   state_save_register_item( machine, "x76f041", NULL, chip, c->byte );
157   state_save_register_item( machine, "x76f041", NULL, chip, c->command );
158   state_save_register_item( machine, "x76f041", NULL, chip, c->address );
159   state_save_register_item_array( machine, "x76f041", NULL, chip, c->write_buffer );
160   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->response_to_reset, SIZE_RESPONSE_TO_RESET );
161   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->write_password, SIZE_WRITE_PASSWORD );
162   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->read_password, SIZE_READ_PASSWORD );
163   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->configuration_password, SIZE_CONFIGURATION_PASSWORD );
164   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->configuration_registers, SIZE_CONFIGURATION_REGISTERS );
165   state_save_register_item_pointer( machine, "x76f041", NULL, chip, c->data, SIZE_DATA );
110   // That chip isn't really usable without the passwords, so bitch
111   // if there's no region
112   logerror("X76F041: Warning, no default data provided, chip is unusable.\n");
113   memset(response_to_reset,       0, SIZE_RESPONSE_TO_RESET);
114   memset(write_password,          0, SIZE_WRITE_PASSWORD);
115   memset(read_password,           0, SIZE_READ_PASSWORD);
116   memset(configuration_password,  0, SIZE_CONFIGURATION_PASSWORD);
117   memset(configuration_registers, 0, SIZE_CONFIGURATION_REGISTERS);
118   memset(data,                    0, SIZE_DATA);
166119}
167120
168void x76f041_cs_write( running_machine *machine, int chip, int cs )
121void x76f041_device::cs_0()
169122{
170   struct x76f041_chip *c;
123   /* enable chip */
124   state = STATE_STOP;
125}
171126
172   if( chip >= X76F041_MAXCHIP )
173   {
174      verboselog( machine, 0, "x76f041_cs_write( %d ) chip out of range\n", chip );
175      return;
176   }
177
178   c = &x76f041[ chip ];
179
180   if( c->cs != cs )
181   {
182      verboselog( machine, 2, "x76f041(%d) cs=%d\n", chip, cs );
183   }
184   if( c->cs != 0 && cs == 0 )
185   {
186      /* enable chip */
187      c->state = STATE_STOP;
188   }
189   if( c->cs == 0 && cs != 0 )
190   {
191      /* disable chip */
192      c->state = STATE_STOP;
193      /* high impendence? */
194      c->sdar = 0;
195   }
196   c->cs = cs;
127void x76f041_device::cs_1()
128{
129   /* disable chip */
130   state = STATE_STOP;
131   /* high impendence? */
132   sdar = false;
197133}
198134
199void x76f041_rst_write( running_machine *machine, int chip, int rst )
135void x76f041_device::rst_0()
200136{
201   struct x76f041_chip *c;
137}
202138
203   if( chip >= X76F041_MAXCHIP )
204   {
205      verboselog( machine, 0, "x76f041_rst_write( %d ) chip out of range\n", chip );
206      return;
139void x76f041_device::rst_1()
140{
141   if(!cs) {
142      verboselog(1, "goto response to reset\n");
143      state = STATE_RESPONSE_TO_RESET;
144      bit = 0;
145      byte = 0;
207146   }
208
209   c = &x76f041[ chip ];
210
211   if( c->rst != rst )
212   {
213      verboselog( machine, 2, "x76f041(%d) rst=%d\n", chip, rst );
214   }
215   if( c->rst == 0 && rst != 0 && c->cs == 0 )
216   {
217      verboselog( machine, 1, "x76f041(%d) goto response to reset\n", chip );
218      c->state = STATE_RESPONSE_TO_RESET;
219      c->bit = 0;
220      c->byte = 0;
221   }
222   c->rst = rst;
223147}
224148
225static UINT8 *x76f041_password( struct x76f041_chip *c )
149UINT8 *x76f041_device::password()
226150{
227   switch( c->command & 0xe0 )
228   {
151   switch(command & 0xe0) {
229152   case COMMAND_WRITE:
230      return c->write_password;
153      return write_password;
231154   case COMMAND_READ:
232      return c->read_password;
155      return read_password;
233156   default:
234      return c->configuration_password;
157      return configuration_password;
235158   }
236159}
237160
238static void x76f041_password_ok( struct x76f041_chip *c )
161void x76f041_device::password_ok()
239162{
240   switch( c->command & 0xe0 )
241   {
163   switch(command & 0xe0) {
242164   case COMMAND_WRITE:
243      c->state = STATE_WRITE_DATA;
165      state = STATE_WRITE_DATA;
244166      break;
245167   case COMMAND_READ:
246      c->state = STATE_READ_DATA;
168      state = STATE_READ_DATA;
247169      break;
248170   case COMMAND_WRITE_USE_CONFIGURATION_PASSWORD:
249      c->state = STATE_WRITE_DATA;
171      state = STATE_WRITE_DATA;
250172      break;
251173   case COMMAND_READ_USE_CONFIGURATION_PASSWORD:
252      c->state = STATE_READ_DATA;
174      state = STATE_READ_DATA;
253175      break;
254176   case COMMAND_CONFIGURATION:
255      switch( c->address )
256      {
177      switch( address ) {
257178      case CONFIGURATION_PROGRAM_WRITE_PASSWORD:
258179         break;
259180      case CONFIGURATION_PROGRAM_READ_PASSWORD:
r10384r10385
265186      case CONFIGURATION_RESET_READ_PASSWORD:
266187         break;
267188      case CONFIGURATION_PROGRAM_CONFIGURATION_REGISTERS:
268         c->state = STATE_WRITE_CONFIGURATION_REGISTERS;
269         c->byte = 0;
189         state = STATE_WRITE_CONFIGURATION_REGISTERS;
190         byte = 0;
270191         break;
271192      case CONFIGURATION_READ_CONFIGURATION_REGISTERS:
272         c->state = STATE_READ_CONFIGURATION_REGISTERS;
273         c->byte = 0;
193         state = STATE_READ_CONFIGURATION_REGISTERS;
194         byte = 0;
274195         break;
275196      case CONFIGURATION_MASS_PROGRAM:
276197         break;
r10384r10385
282203   }
283204}
284205
285static void x76f041_load_address( running_machine *machine, int chip )
206void x76f041_device::load_address()
286207{
287208   /* todo: handle other bcr bits */
288   struct x76f041_chip *c = &x76f041[ chip ];
289209   int bcr;
290210
291   c->address = c->shift;
211   address = shift;
292212
293   verboselog( machine, 1, "x76f041(%d) -> address: %02x\n", chip, c->address );
213   verboselog(1, "-> address: %02x\n", address);
294214
295   if( ( c->command & 1 ) == 0 )
296   {
297      bcr = c->configuration_registers[ CONFIG_BCR1 ];
298   }
215   if(!(command & 1 ))
216      bcr = configuration_registers[CONFIG_BCR1];
299217   else
300   {
301      bcr = c->configuration_registers[ CONFIG_BCR2 ];
302   }
303   if( ( c->address & 0x80 ) != 0 )
304   {
218      bcr = configuration_registers[CONFIG_BCR2];
219
220   if(address & 0x80)
305221      bcr >>= 4;
306   }
307222
308   if( ( ( c->command & 0xe0 ) == COMMAND_READ && ( bcr & BCR_Z ) != 0 && ( bcr & BCR_T ) != 0 ) ||
309      ( ( c->command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_Z ) != 0 ) )
310   {
223   if(((command & 0xe0) == COMMAND_READ && (bcr & BCR_Z) && (bcr & BCR_T)) ||
224      ((command & 0xe0) == COMMAND_WRITE && (bcr & BCR_Z))) {
311225      /* todo: find out when this is really checked. */
312      verboselog( machine, 1, "x76f041(%d) command not allowed\n", chip );
313      c->state = STATE_STOP;
314      c->sdar = 0;
226      verboselog(1, "command not allowed\n");
227      state = STATE_STOP;
228      sdar = false;
229
230   } else if(((command & 0xe0) == COMMAND_WRITE && !(bcr & BCR_X)) ||
231           ((command & 0xe0) == COMMAND_READ && !(bcr & BCR_Y))) {
232      verboselog(1, "password not required\n");
233      password_ok();
234
235   } else {
236      verboselog(1, "send password\n");
237      state = STATE_LOAD_PASSWORD;
238      byte = 0;
315239   }
316   else if( ( ( c->command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_X ) == 0 ) ||
317      ( ( c->command & 0xe0 ) == COMMAND_READ && ( bcr & BCR_Y ) == 0 ) )
318   {
319      verboselog( machine, 1, "x76f041(%d) password not required\n", chip );
320      x76f041_password_ok( c );
321   }
322   else
323   {
324      verboselog( machine, 1, "x76f041(%d) send password\n", chip );
325      c->state = STATE_LOAD_PASSWORD;
326      c->byte = 0;
327   }
328240}
329241
330static int x76f041_data_offset( struct x76f041_chip *c )
242int x76f041_device::data_offset()
331243{
332   int block_offset = ( ( c->command & 1 ) << 8 ) + c->address;
244   int block_offset = ((command & 1) << 8) + address;
333245
334246   // TODO: confirm block_start doesn't wrap.
335247
336   return ( block_offset & 0x180 ) | ( ( block_offset + c->byte ) & 0x7f );
248   return (block_offset & 0x180) | ((block_offset + byte) & 0x7f);
337249}
338250
339void x76f041_scl_write( running_machine *machine, int chip, int scl )
251void x76f041_device::scl_0()
340252{
341   struct x76f041_chip *c;
342
343   if( chip >= X76F041_MAXCHIP )
344   {
345      verboselog( machine, 0, "x76f041_scl_write( %d ) chip out of range\n", chip );
346      return;
253   if(!cs) {
254      switch(state) {
255      case STATE_RESPONSE_TO_RESET:
256         sdar = (response_to_reset[byte] >> bit) & 1;
257         verboselog(2, "in response to reset %d (%d/%d)\n", sdar, byte, bit);
258         bit++;
259         if(bit == 8) {
260            bit = 0;
261            byte++;
262            if( byte == 4 )
263               byte = 0;
264         }
265         break;
266      }
347267   }
268}
348269
349   c = &x76f041[ chip ];
350
351   if( c->scl != scl )
352   {
353      verboselog( machine, 2, "x76f041(%d) scl=%d\n", chip, scl );
354   }
355   if( c->cs == 0 )
356   {
357      switch( c->state )
358      {
270void x76f041_device::scl_1()
271{
272   if(!cs) {
273      switch(state) {
359274      case STATE_STOP:
360275         break;
361276      case STATE_RESPONSE_TO_RESET:
362         if( c->scl != 0 && scl == 0 )
363         {
364            c->sdar = ( c->response_to_reset[ c->byte ] >> c->bit ) & 1;
365            verboselog( machine, 2, "x76f041(%d) in response to reset %d (%d/%d)\n", chip, c->sdar, c->byte, c->bit );
366            c->bit++;
367            if( c->bit == 8 )
368            {
369               c->bit = 0;
370               c->byte++;
371               if( c->byte == 4 )
372               {
373                  c->byte = 0;
374               }
375            }
376         }
377277         break;
378278      case STATE_LOAD_COMMAND:
379279      case STATE_LOAD_ADDRESS:
r10384r10385
381281      case STATE_VERIFY_PASSWORD:
382282      case STATE_WRITE_DATA:
383283      case STATE_WRITE_CONFIGURATION_REGISTERS:
384         if( c->scl == 0 && scl != 0 )
385         {
386            if( c->bit < 8 )
387            {
388               verboselog( machine, 2, "x76f041(%d) clock\n", chip );
389               c->shift <<= 1;
390               if( c->sdaw != 0 )
391               {
392                  c->shift |= 1;
393               }
394               c->bit++;
395            }
396            else
397            {
398               c->sdar = 0;
284         if(bit < 8) {
285            verboselog(2, "clock\n");
286            shift <<= 1;
287            if(sdaw)
288               shift |= 1;
289            bit++;
290         } else {
291            sdar = false;
399292
400               switch( c->state )
401               {
402               case STATE_LOAD_COMMAND:
403                  c->command = c->shift;
404                  verboselog( machine, 1, "x76f041(%d) -> command: %02x\n", chip, c->command );
405                  /* todo: verify command is valid? */
406                  c->state = STATE_LOAD_ADDRESS;
407                  break;
408               case STATE_LOAD_ADDRESS:
409                  x76f041_load_address( machine, chip );
410                  break;
411               case STATE_LOAD_PASSWORD:
412                  verboselog( machine, 1, "x76f041(%d) -> password: %02x\n", chip, c->shift );
413                  c->write_buffer[ c->byte++ ] = c->shift;
414                  if( c->byte == SIZE_WRITE_BUFFER )
415                  {
416                     c->state = STATE_VERIFY_PASSWORD;
417                  }
418                  break;
419               case STATE_VERIFY_PASSWORD:
420                  verboselog( machine, 1, "x76f041(%d) -> verify password: %02x\n", chip, c->shift );
421                  /* todo: this should probably be handled as a command */
422                  if( c->shift == 0xc0 )
423                  {
424                     /* todo: this should take 10ms before it returns ok. */
425                     if( memcmp( x76f041_password( c ), c->write_buffer, SIZE_WRITE_BUFFER ) == 0 )
426                     {
427                        x76f041_password_ok( c );
428                     }
429                     else
430                     {
431                        c->sdar = 1;
432                     }
433                  }
434                  break;
435               case STATE_WRITE_DATA:
436                  verboselog( machine, 1, "x76f041(%d) -> data: %02x\n", chip, c->shift );
437                  c->write_buffer[ c->byte++ ] = c->shift;
438                  if( c->byte == SIZE_WRITE_BUFFER )
439                  {
440                     for( c->byte = 0; c->byte < SIZE_WRITE_BUFFER; c->byte++ )
441                     {
442                        c->data[ x76f041_data_offset( c ) ] = c->write_buffer[ c->byte ];
443                     }
444                     c->byte = 0;
445
446                     verboselog( machine, 1, "x76f041(%d) data flushed\n", chip );
447                  }
448                  break;
449               case STATE_WRITE_CONFIGURATION_REGISTERS:
450                  verboselog( machine, 1, "x76f041(%d) -> configuration register: %02x\n", chip, c->shift );
451                  /* todo: write after all bytes received? */
452                  c->configuration_registers[ c->byte++ ] = c->shift;
453                  if( c->byte == SIZE_CONFIGURATION_REGISTERS )
454                  {
455                     c->byte = 0;
456                  }
457                  break;
293            switch(state) {
294            case STATE_LOAD_COMMAND:
295               command = shift;
296               verboselog(1, "-> command: %02x\n", command);
297               /* todo: verify command is valid? */
298               state = STATE_LOAD_ADDRESS;
299               break;
300            case STATE_LOAD_ADDRESS:
301               load_address();
302               break;
303            case STATE_LOAD_PASSWORD:
304               verboselog(1, "-> password: %02x\n", shift );
305               write_buffer[byte++] = shift;
306               if(byte == SIZE_WRITE_BUFFER)
307                  state = STATE_VERIFY_PASSWORD;
308               break;
309            case STATE_VERIFY_PASSWORD:
310               verboselog(1, "-> verify password: %02x\n", shift);
311               /* todo: this should probably be handled as a command */
312               if(shift == 0xc0) {
313                  /* todo: this should take 10ms before it returns ok. */
314                  if(!memcmp(password(), write_buffer, SIZE_WRITE_BUFFER))
315                     password_ok();
316                  else
317                     sdar = true;
458318               }
459
460               c->bit = 0;
461               c->shift = 0;
319               break;
320            case STATE_WRITE_DATA:
321               verboselog(1, "-> data: %02x\n", shift);
322               write_buffer[byte++] = shift;
323               if(byte == SIZE_WRITE_BUFFER) {
324                  for(byte = 0; byte < SIZE_WRITE_BUFFER; byte++)
325                     data[data_offset()] = write_buffer[byte];
326                  byte = 0;
327                  verboselog(1, "data flushed\n");
328               }
329               break;
330            case STATE_WRITE_CONFIGURATION_REGISTERS:
331               verboselog(1, "-> configuration register: %02x\n", shift);
332               /* todo: write after all bytes received? */
333               configuration_registers[byte++] = shift;
334               if(byte == SIZE_CONFIGURATION_REGISTERS)
335                  byte = 0;
336               break;
462337            }
338               
339            bit = 0;
340            shift = 0;
463341         }
464342         break;
465343      case STATE_READ_DATA:
466344      case STATE_READ_CONFIGURATION_REGISTERS:
467         if( c->scl == 0 && scl != 0 )
468         {
469            if( c->bit < 8 )
470            {
471               if( c->bit == 0 )
472               {
473                  switch( c->state )
474                  {
475                  case STATE_READ_DATA:
476                     c->shift = c->data[ x76f041_data_offset( c ) ];
477                     verboselog( machine, 1, "x76f041(%d) <- data: %02x\n", chip, c->shift );
478                     break;
479                  case STATE_READ_CONFIGURATION_REGISTERS:
480                     c->shift = c->configuration_registers[ c->byte & 7 ];
481                     verboselog( machine, 1, "x76f041(%d) <- configuration register: %02x\n", chip, c->shift );
482                     break;
483                  }
345         if(bit < 8) {
346            if(bit == 0) {
347               switch(state) {
348               case STATE_READ_DATA:
349                  shift = data[data_offset()];
350                  verboselog(1, "<- data: %02x\n", shift);
351                  break;
352               case STATE_READ_CONFIGURATION_REGISTERS:
353                  shift = configuration_registers[byte & 7];
354                  verboselog(1, "<- configuration register: %02x\n", shift );
355                  break;
484356               }
485               c->sdar = ( c->shift >> 7 ) & 1;
486               c->shift <<= 1;
487               c->bit++;
488357            }
489            else
490            {
491               c->bit = 0;
492               c->sdar = 0;
493               if( c->sdaw == 0 )
494               {
495                  verboselog( machine, 2, "x76f041(%d) ack <-\n", chip );
496                  c->byte++;
497               }
498               else
499               {
500                  verboselog( machine, 2, "x76f041(%d) nak <-\n", chip );
501               }
358            sdar = ( shift >> 7 ) & 1;
359            shift <<= 1;
360            bit++;
361         } else {
362            bit = 0;
363            sdar = false;
364            if(!sdaw) {
365               verboselog(2, "ack <-\n");
366               byte++;
367            } else {
368               verboselog(2, "nak <-\n");
502369            }
503370         }
504371         break;
505372      }
506373   }
507   c->scl = scl;
508374}
509375
510void x76f041_sda_write( running_machine *machine, int chip, int sda )
376void x76f041_device::sda_0()
511377{
512   struct x76f041_chip *c;
513
514   if( chip >= X76F041_MAXCHIP )
515   {
516      verboselog( machine, 0, "x76f041_sda_write( %d ) chip out of range\n", chip );
517      return;
518   }
519
520   c = &x76f041[ chip ];
521
522   if( c->sdaw != sda )
523   {
524      verboselog( machine, 2, "x76f041(%d) sdaw=%d\n", chip, sda );
525   }
526   if( c->cs == 0 && c->scl != 0 )
527   {
528      if( c->sdaw == 0 && sda != 0 )
529      {
530         verboselog( machine, 1, "x76f041(%d) goto stop\n", chip );
531         c->state = STATE_STOP;
532         c->sdar = 0;
378   if(!cs && scl) {
379      switch(state) {
380      case STATE_STOP:
381         verboselog(1, "goto start (1)\n");
382         state = STATE_LOAD_COMMAND;
383         break;
384      case STATE_LOAD_PASSWORD:
385         /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
386         verboselog(1, "goto start (2)\n");
387         break;
388      case STATE_READ_DATA:
389         verboselog(1, "goto load address\n");
390         state = STATE_LOAD_ADDRESS;
391         break;
392      default:
393         verboselog(1, "skipped start (default)\n");
394         break;
533395      }
534      if( c->sdaw != 0 && sda == 0 )
535      {
536         switch( c->state )
537         {
538         case STATE_STOP:
539            verboselog( machine, 1, "x76f041(%d) goto start\n", chip );
540            c->state = STATE_LOAD_COMMAND;
541            break;
542         case STATE_LOAD_PASSWORD:
543            /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */
544            verboselog( machine, 1, "x76f041(%d) goto start\n", chip );
545            break;
546         case STATE_READ_DATA:
547            verboselog( machine, 1, "x76f041(%d) goto load address\n", chip );
548            c->state = STATE_LOAD_ADDRESS;
549            break;
550         default:
551            verboselog( machine, 1, "x76f041(%d) skipped start (default)\n", chip );
552            break;
553         }
554396
555         c->bit = 0;
556         c->byte = 0;
557         c->shift = 0;
558         c->sdar = 0;
559      }
397      bit = 0;
398      byte = 0;
399      shift = 0;
400      sdar = false;
560401   }
561   c->sdaw = sda;
562402}
563403
564int x76f041_sda_read( running_machine *machine, int chip )
404void x76f041_device::sda_1()
565405{
566   struct x76f041_chip *c;
567
568   if( chip >= X76F041_MAXCHIP )
569   {
570      verboselog( machine, 0, "x76f041_sda_read( %d ) chip out of range\n", chip );
571      return 1;
406   if(!cs && scl) {
407      verboselog(1, "goto stop\n");
408      state = STATE_STOP;
409      sdar = false;
572410   }
573
574   c = &x76f041[ chip ];
575
576   if( c->cs != 0 )
577   {
578      verboselog( machine, 2, "x76f041(%d) not selected\n", chip );
579      return 1;
580   }
581   verboselog( machine, 2, "x76f041(%d) sdar=%d\n", chip, c->sdar );
582   return c->sdar;
583411}
584412
585static void nvram_handler_x76f041( running_machine *machine, mame_file *file, int read_or_write, int chip )
413void x76f041_device::nvram_read(emu_file &file)
586414{
587   struct x76f041_chip *c;
588
589   if( chip >= X76F041_MAXCHIP )
590   {
591      verboselog( machine, 0, "nvram_handler_x76f041( %d ) chip out of range\n", chip );
592      return;
593   }
594
595   c = &x76f041[ chip ];
596
597   if( read_or_write )
598   {
599      mame_fwrite( file, c->write_password, SIZE_WRITE_PASSWORD );
600      mame_fwrite( file, c->read_password, SIZE_READ_PASSWORD );
601      mame_fwrite( file, c->configuration_password, SIZE_CONFIGURATION_PASSWORD );
602      mame_fwrite( file, c->configuration_registers, SIZE_CONFIGURATION_REGISTERS );
603      mame_fwrite( file, c->data, SIZE_DATA );
604   }
605   else if( file )
606   {
607      mame_fread( file, c->write_password, SIZE_WRITE_PASSWORD );
608      mame_fread( file, c->read_password, SIZE_READ_PASSWORD );
609      mame_fread( file, c->configuration_password, SIZE_CONFIGURATION_PASSWORD );
610      mame_fread( file, c->configuration_registers, SIZE_CONFIGURATION_REGISTERS );
611      mame_fread( file, c->data, SIZE_DATA );
612   }
415   file.read(response_to_reset, SIZE_RESPONSE_TO_RESET);
416   file.read(write_password, SIZE_WRITE_PASSWORD);
417   file.read(read_password, SIZE_READ_PASSWORD);
418   file.read(configuration_password, SIZE_CONFIGURATION_PASSWORD);
419   file.read(configuration_registers, SIZE_CONFIGURATION_REGISTERS);
420   file.read(data, SIZE_DATA);
613421}
614422
615NVRAM_HANDLER( x76f041_0 ) { nvram_handler_x76f041( machine, file, read_or_write, 0 ); }
616NVRAM_HANDLER( x76f041_1 ) { nvram_handler_x76f041( machine, file, read_or_write, 1 ); }
423void x76f041_device::nvram_write(emu_file &file)
424{
425   file.write(response_to_reset, SIZE_RESPONSE_TO_RESET);
426   file.write(write_password, SIZE_WRITE_PASSWORD);
427   file.write(read_password, SIZE_READ_PASSWORD);
428   file.write(configuration_password, SIZE_CONFIGURATION_PASSWORD);
429   file.write(configuration_registers, SIZE_CONFIGURATION_REGISTERS);
430   file.write(data, SIZE_DATA);
431}
src/emu/machine/generic.h
r10384r10385
7373
7474/* ----- NVRAM management ----- */
7575
76/* open an NVRAM file directly */
77mame_file *nvram_fopen(running_machine *machine, UINT32 openflags);
78
7976/* load NVRAM from a file */
8077void nvram_load(running_machine *machine);
8178
src/emu/machine/nvram.c
r10384r10385
196196//  .nv file
197197//-------------------------------------------------
198198
199void nvram_device::nvram_read(mame_file &file)
199void nvram_device::nvram_read(emu_file &file)
200200{
201201   // make sure we have a valid base pointer
202202   determine_final_base();
203203
204   mame_fread(&file, m_base, m_length);
204   file.read(m_base, m_length);
205205}
206206
207207
r10384r10385
210210//  .nv file
211211//-------------------------------------------------
212212
213void nvram_device::nvram_write(mame_file &file)
213void nvram_device::nvram_write(emu_file &file)
214214{
215   mame_fwrite(&file, m_base, m_length);
215   file.write(m_base, m_length);
216216}
217217
218218
src/emu/machine/x76f041.h
r10384r10385
55 *
66 */
77
8#if !defined( X76F041_H )
8#ifndef __X76F041_H__
9#define __X76F041_H__
910
10#define X76F041_MAXCHIP ( 2 )
11#define MCFG_X76F041_ADD(_tag) \
12   MCFG_DEVICE_ADD(_tag, X76F041, 0)
1113
12extern void x76f041_init( running_machine *machine, int chip, UINT8 *data );
13extern void x76f041_cs_write( running_machine *machine, int chip, int cs );
14extern void x76f041_rst_write( running_machine *machine, int chip, int rst );
15extern void x76f041_scl_write( running_machine *machine, int chip, int scl );
16extern void x76f041_sda_write( running_machine *machine, int chip, int sda );
17extern int x76f041_sda_read( running_machine *machine, int chip );
18extern NVRAM_HANDLER( x76f041_0 );
19extern NVRAM_HANDLER( x76f041_1 );
14#include "machine/secflash.h"
2015
21#define X76F041_H
16class x76f041_device_config : public device_secure_serial_flash_config
17{
18   friend class x76f041_device;
19
20   // construction/destruction
21   x76f041_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
22
23public:
24   // allocators
25   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
26   virtual device_t *alloc_device(running_machine &machine) const;
27};
28
29class x76f041_device : public device_secure_serial_flash
30{
31   friend class x76f041_device_config;
32
33   // construction/destruction
34   x76f041_device(running_machine &_machine, const x76f041_device_config &config);
35
36protected:
37   // device-level overrides
38   virtual void device_start();
39   virtual void device_reset();
40
41   // device_nvram_interface overrides
42   virtual void nvram_default();
43   virtual void nvram_read(emu_file &file);
44   virtual void nvram_write(emu_file &file);
45
46   // device_secure_serial_flash implementations
47   virtual void cs_0();
48   virtual void cs_1();
49   virtual void rst_0();
50   virtual void rst_1();
51   virtual void scl_0();
52   virtual void scl_1();
53   virtual void sda_0();
54   virtual void sda_1();
55
56   // internal state
57   const x76f041_device_config &config;
58
59   enum {
60      SIZE_WRITE_BUFFER = 8,
61      SIZE_RESPONSE_TO_RESET = 4,
62      SIZE_WRITE_PASSWORD = 8,
63      SIZE_READ_PASSWORD = 8,
64      SIZE_CONFIGURATION_PASSWORD = 8,
65      SIZE_CONFIGURATION_REGISTERS = 8,
66      SIZE_DATA = 512,
67
68      CONFIG_BCR1 = 0,
69      CONFIG_BCR2 = 1,
70      CONFIG_CR = 2,
71      CONFIG_RR = 3,
72      CONFIG_RC = 4,
73
74      BCR_X = 8,
75      BCR_Y = 4,
76      BCR_Z = 2,
77      BCR_T = 1,
78
79      COMMAND_WRITE = 0x00,
80      COMMAND_READ = 0x20,
81      COMMAND_WRITE_USE_CONFIGURATION_PASSWORD = 0x40,
82      COMMAND_READ_USE_CONFIGURATION_PASSWORD = 0x60,
83      COMMAND_CONFIGURATION = 0x80,
84
85      CONFIGURATION_PROGRAM_WRITE_PASSWORD = 0x00,
86      CONFIGURATION_PROGRAM_READ_PASSWORD = 0x10,
87      CONFIGURATION_PROGRAM_CONFIGURATION_PASSWORD = 0x20,
88      CONFIGURATION_RESET_WRITE_PASSWORD = 0x30,
89      CONFIGURATION_RESET_READ_PASSWORD = 0x40,
90      CONFIGURATION_PROGRAM_CONFIGURATION_REGISTERS = 0x50,
91      CONFIGURATION_READ_CONFIGURATION_REGISTERS = 0x60,
92      CONFIGURATION_MASS_PROGRAM = 0x70,
93      CONFIGURATION_MASS_ERASE = 0x80
94   };
95
96   enum {
97      STATE_STOP,
98      STATE_RESPONSE_TO_RESET,
99      STATE_LOAD_COMMAND,
100      STATE_LOAD_ADDRESS,
101      STATE_LOAD_PASSWORD,
102      STATE_VERIFY_PASSWORD,
103      STATE_READ_DATA,
104      STATE_WRITE_DATA,
105      STATE_READ_CONFIGURATION_REGISTERS,
106      STATE_WRITE_CONFIGURATION_REGISTERS
107   };
108
109   int state, bit, byte, address;
110   UINT8 command, shift;
111   UINT8 write_buffer[SIZE_WRITE_BUFFER];
112   UINT8 response_to_reset[SIZE_RESPONSE_TO_RESET];
113   UINT8 write_password[SIZE_WRITE_PASSWORD];
114   UINT8 read_password[SIZE_READ_PASSWORD];
115   UINT8 configuration_password[SIZE_CONFIGURATION_PASSWORD];
116   UINT8 configuration_registers[SIZE_CONFIGURATION_REGISTERS];
117   UINT8 data[SIZE_DATA];
118
119   UINT8 *password();
120   void password_ok();
121   void load_address();
122   int data_offset();
123
124private:
125   inline void ATTR_PRINTF(3,4) verboselog(int n_level, const char *s_fmt, ...);
126};
127
128
129// device type definition
130extern const device_type X76F041;
131
22132#endif
src/emu/machine/nvram.h
r10384r10385
150150
151151   // device_nvram_interface overrides
152152   virtual void nvram_default();
153   virtual void nvram_read(mame_file &file);
154   virtual void nvram_write(mame_file &file);
153   virtual void nvram_read(emu_file &file);
154   virtual void nvram_write(emu_file &file);
155155
156156   // internal helpers
157157   void determine_final_base();
src/emu/machine/i2cmem.c
r10384r10385
139139//  on this device
140140//-------------------------------------------------
141141
142bool i2cmem_device_config::device_validity_check( const game_driver &driver ) const
142bool i2cmem_device_config::device_validity_check( core_options &options, const game_driver &driver ) const
143143{
144144   bool error = false;
145145   return error;
r10384r10385
259259//  .nv file
260260//-------------------------------------------------
261261
262void i2cmem_device::nvram_read( mame_file &file )
262void i2cmem_device::nvram_read( emu_file &file )
263263{
264264   int i2cmem_bytes = m_config.m_data_size;
265265   UINT8 *buffer = auto_alloc_array( &m_machine, UINT8, i2cmem_bytes );
266266
267   mame_fread( &file, buffer, i2cmem_bytes );
267   file.read( buffer, i2cmem_bytes );
268268
269269   for( offs_t offs = 0; offs < i2cmem_bytes; offs++ )
270270   {
r10384r10385
279279//  .nv file
280280//-------------------------------------------------
281281
282void i2cmem_device::nvram_write( mame_file &file )
282void i2cmem_device::nvram_write( emu_file &file )
283283{
284284   int i2cmem_bytes = m_config.m_data_size;
285285   UINT8 *buffer = auto_alloc_array( &m_machine, UINT8, i2cmem_bytes );
r10384r10385
289289      buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
290290   }
291291
292   mame_fwrite( &file, buffer, i2cmem_bytes );
292   file.write( buffer, i2cmem_bytes );
293293
294294   auto_free( &m_machine, buffer );
295295}
src/emu/machine/i2cmem.h
r10384r10385
6767protected:
6868   // device_config overrides
6969   virtual void device_config_complete();
70   virtual bool device_validity_check( const game_driver &driver ) const;
70   virtual bool device_validity_check( core_options &options, const game_driver &driver ) const;
7171
7272   // device_config_memory_interface overrides
7373   virtual const address_space_config *memory_space_config( int spacenum = 0 ) const;
r10384r10385
107107
108108   // device_nvram_interface overrides
109109   virtual void nvram_default();
110   virtual void nvram_read( mame_file &file );
111   virtual void nvram_write( mame_file &file );
110   virtual void nvram_read( emu_file &file );
111   virtual void nvram_write( emu_file &file );
112112
113113   // internal helpers
114114   int address_mask();
src/emu/machine/mb3773.c
r10384r10385
7676//  on this device
7777//-------------------------------------------------
7878
79bool mb3773_device_config::device_validity_check( const game_driver &driver ) const
79bool mb3773_device_config::device_validity_check( core_options &options, const game_driver &driver ) const
8080{
8181   return false;
8282}
src/emu/machine/mb3773.h
r10384r10385
3838protected:
3939   // device_config overrides
4040   virtual void device_config_complete();
41   virtual bool device_validity_check( const game_driver &driver ) const;
41   virtual bool device_validity_check( core_options &options, const game_driver &driver ) const;
4242};
4343
4444
src/emu/machine/intelfsh.c
r10384r10385
333333//  .nv file
334334//-------------------------------------------------
335335
336void intelfsh_device::nvram_read(mame_file &file)
336void intelfsh_device::nvram_read(emu_file &file)
337337{
338338   UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size);
339   mame_fread(&file, buffer, m_config.m_size);
339   file.read(buffer, m_config.m_size);
340340   for (int byte = 0; byte < m_config.m_size; byte++)
341341      m_addrspace[0]->write_byte(byte, buffer[byte]);
342342   global_free(buffer);
r10384r10385
348348//  .nv file
349349//-------------------------------------------------
350350
351void intelfsh_device::nvram_write(mame_file &file)
351void intelfsh_device::nvram_write(emu_file &file)
352352{
353353   UINT8 *buffer = global_alloc_array(UINT8, m_config.m_size);
354354   for (int byte = 0; byte < m_config.m_size; byte++)
355355      buffer[byte] = m_addrspace[0]->read_byte(byte);
356   mame_fwrite(&file, buffer, m_config.m_size);
356   file.write(buffer, m_config.m_size);
357357   global_free(buffer);
358358}
359359
src/emu/machine/x2212.c
r10384r10385
155155//  .nv file
156156//-------------------------------------------------
157157
158void x2212_device::nvram_read(mame_file &file)
158void x2212_device::nvram_read(emu_file &file)
159159{
160160   UINT8 buffer[SIZE_DATA];
161   mame_fread(&file, buffer, sizeof(buffer));
161   file.read(buffer, sizeof(buffer));
162162   for (int byte = 0; byte < SIZE_DATA; byte++)
163163   {
164164      m_sram->write_byte(byte, 0xff);
r10384r10385
172172//  .nv file
173173//-------------------------------------------------
174174
175void x2212_device::nvram_write(mame_file &file)
175void x2212_device::nvram_write(emu_file &file)
176176{
177177   // auto-save causes an implicit store prior to exiting (writing)
178178   if (m_config.m_auto_save)
r10384r10385
181181   UINT8 buffer[SIZE_DATA];
182182   for (int byte = 0; byte < SIZE_DATA; byte++)
183183      buffer[byte] = m_e2prom->read_byte(byte);
184   mame_fwrite(&file, buffer, sizeof(buffer));
184   file.write(buffer, sizeof(buffer));
185185}
186186
187187
src/emu/machine/intelfsh.h
r10384r10385
116116
117117   // device_config_nvram_interface overrides
118118   virtual void nvram_default();
119   virtual void nvram_read(mame_file &file);
120   virtual void nvram_write(mame_file &file);
119   virtual void nvram_read(emu_file &file);
120   virtual void nvram_write(emu_file &file);
121121
122122   // derived helpers
123123   UINT32 read_full(UINT32 offset);
src/emu/machine/x2212.h
r10384r10385
9494
9595   // device_nvram_interface overrides
9696   virtual void nvram_default();
97   virtual void nvram_read(mame_file &file);
98   virtual void nvram_write(mame_file &file);
97   virtual void nvram_read(emu_file &file);
98   virtual void nvram_write(emu_file &file);
9999
100100   static const int SIZE_DATA = 0x100;
101101
src/emu/machine/at28c16.c
r10384r10385
8484//  on this device
8585//-------------------------------------------------
8686
87bool at28c16_device_config::device_validity_check( const game_driver &driver ) const
87bool at28c16_device_config::device_validity_check( core_options &options, const game_driver &driver ) const
8888{
8989   return false;
9090}
r10384r10385
185185//  .nv file
186186//-------------------------------------------------
187187
188void at28c16_device::nvram_read( mame_file &file )
188void at28c16_device::nvram_read( emu_file &file )
189189{
190190   UINT8 *buffer = auto_alloc_array( &m_machine, UINT8, AT28C16_TOTAL_BYTES );
191191
192   mame_fread( &file, buffer, AT28C16_TOTAL_BYTES );
192   file.read( buffer, AT28C16_TOTAL_BYTES );
193193
194194   for( offs_t offs = 0; offs < AT28C16_TOTAL_BYTES; offs++ )
195195   {
r10384r10385
204204//  .nv file
205205//-------------------------------------------------
206206
207void at28c16_device::nvram_write( mame_file &file )
207void at28c16_device::nvram_write( emu_file &file )
208208{
209209   UINT8 *buffer = auto_alloc_array( &m_machine, UINT8, AT28C16_TOTAL_BYTES );
210210
r10384r10385
213213      buffer[ offs ] = m_addrspace[ 0 ]->read_byte( offs );
214214   }
215215
216   mame_fwrite( &file, buffer, AT28C16_TOTAL_BYTES );
216   file.write( buffer, AT28C16_TOTAL_BYTES );
217217
218218   auto_free( &m_machine, buffer );
219219}
src/emu/machine/at28c16.h
r10384r10385
5858protected:
5959   // device_config overrides
6060   virtual void device_config_complete();
61   virtual bool device_validity_check( const game_driver &driver ) const;
61   virtual bool device_validity_check( core_options &options, const game_driver &driver ) const;
6262
6363   // device_config_memory_interface overrides
6464   virtual const address_space_config *memory_space_config( int spacenum = 0 ) const;
r10384r10385
9494
9595   // device_nvram_interface overrides
9696   virtual void nvram_default();
97   virtual void nvram_read( mame_file &file );
98   virtual void nvram_write( mame_file &file );
97   virtual void nvram_read( emu_file &file );
98   virtual void nvram_write( emu_file &file );
9999
100100   // internal helpers
101101   static TIMER_CALLBACK( write_finished );
src/emu/machine/eeprom.c
r10384r10385
164164//  on this device
165165//-------------------------------------------------
166166
167bool eeprom_device_config::device_validity_check(const game_driver &driver) const
167bool eeprom_device_config::device_validity_check(core_options &options, const game_driver &driver) const
168168{
169169   bool error = false;
170170
r10384r10385
297297//  .nv file
298298//-------------------------------------------------
299299
300void eeprom_device::nvram_read(mame_file &file)
300void eeprom_device::nvram_read(emu_file &file)
301301{
302302   UINT32 eeprom_length = 1 << m_config.m_address_bits;
303303   UINT32 eeprom_bytes = eeprom_length * m_config.m_data_bits / 8;
304304
305305   UINT8 *buffer = auto_alloc_array(&m_machine, UINT8, eeprom_bytes);
306   mame_fread(&file, buffer, eeprom_bytes);
306   file.read(buffer, eeprom_bytes);
307307   for (offs_t offs = 0; offs < eeprom_bytes; offs++)
308308      m_addrspace[0]->write_byte(offs, buffer[offs]);
309309   auto_free(&m_machine, buffer);
r10384r10385
315315//  .nv file
316316//-------------------------------------------------
317317
318void eeprom_device::nvram_write(mame_file &file)
318void eeprom_device::nvram_write(emu_file &file)
319319{
320320   UINT32 eeprom_length = 1 << m_config.m_address_bits;
321321   UINT32 eeprom_bytes = eeprom_length * m_config.m_data_bits / 8;
r10384r10385
323323   UINT8 *buffer = auto_alloc_array(&m_machine, UINT8, eeprom_bytes);
324324   for (offs_t offs = 0; offs < eeprom_bytes; offs++)
325325      buffer[offs] = m_addrspace[0]->read_byte(offs);
326   mame_fwrite(&file, buffer, eeprom_bytes);
326   file.write(buffer, eeprom_bytes);
327327   auto_free(&m_machine, buffer);
328328}
329329
src/emu/machine/eeprom.h
r10384r10385
8383
8484protected:
8585   // device_config overrides
86   virtual bool device_validity_check(const game_driver &driver) const;
86   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
8787
8888   // device_config_memory_interface overrides
8989   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
r10384r10385
123123
124124   // device_nvram_interface overrides
125125   virtual void nvram_default();
126   virtual void nvram_read(mame_file &file);
127   virtual void nvram_write(mame_file &file);
126   virtual void nvram_read(emu_file &file);
127   virtual void nvram_write(emu_file &file);
128128
129129   // internal helpers
130130   void write(int bit);
src/emu/machine/ds2404.c
r10384r10385
409409//  .nv file
410410//-------------------------------------------------
411411
412void ds2404_device::nvram_read(mame_file &file)
412void ds2404_device::nvram_read(emu_file &file)
413413{
414   mame_fread(&file, m_sram, sizeof(m_sram));
414   file.read(m_sram, sizeof(m_sram));
415415}
416416
417417
r10384r10385
420420//  .nv file
421421//-------------------------------------------------
422422
423void ds2404_device::nvram_write(mame_file &file)
423void ds2404_device::nvram_write(emu_file &file)
424424{
425   mame_fwrite(&file, m_sram, sizeof(m_sram));
425   file.write(m_sram, sizeof(m_sram));
426426}
src/emu/machine/ds2404.h
r10384r10385
102102
103103   // device_nvram_interface overrides
104104   virtual void nvram_default();
105   virtual void nvram_read(mame_file &file);
106   virtual void nvram_write(mame_file &file);
105   virtual void nvram_read(emu_file &file);
106   virtual void nvram_write(emu_file &file);
107107
108108   static TIMER_CALLBACK( ds2404_tick_callback );
109109
src/emu/machine/mc146818.c
r10384r10385
348348//  .nv file
349349//-------------------------------------------------
350350
351void mc146818_device::nvram_read(mame_file &file)
351void mc146818_device::nvram_read(emu_file &file)
352352{
353   mame_fread(&file, m_data, sizeof(m_data));
353   file.read(m_data, sizeof(m_data));
354354   set_base_datetime();
355355}
356356
r10384r10385
360360//  .nv file
361361//-------------------------------------------------
362362
363void mc146818_device::nvram_write(mame_file &file)
363void mc146818_device::nvram_write(emu_file &file)
364364{
365   mame_fwrite(&file, m_data, sizeof(m_data));
365   file.write(m_data, sizeof(m_data));
366366}
367367
368368
src/emu/machine/rtc65271.c
r10384r10385
193193/*
194194    load the SRAM and register contents from file
195195*/
196static int rtc65271_file_load(device_t *device, mame_file *file)
196static int rtc65271_file_load(device_t *device, emu_file &file)
197197{
198198   rtc65271_state *state = get_safe_token(device);
199199   UINT8 buf;
200200
201201
202202   /* version flag */
203   if (mame_fread(file, & buf, 1) != 1)
203   if (file.read(&buf, 1) != 1)
204204      return 1;
205205   if (buf != 0)
206206      return 1;
207207
208208   /* control registers */
209   if (mame_fread(file, &buf, 1) != 1)
209   if (file.read(&buf, 1) != 1)
210210      return 1;
211211   state->regs[reg_A] = buf & (reg_A_DV /*| reg_A_RS*/);
212   if (mame_fread(file, &buf, 1) != 1)
212   if (file.read(&buf, 1) != 1)
213213      return 1;
214214   state->regs[reg_B] = buf & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
215215
216216   /* alarm registers */
217   if (mame_fread(file, &state->regs[reg_alarm_second], 1) != 1)
217   if (file.read(&state->regs[reg_alarm_second], 1) != 1)
218218      return 1;
219   if (mame_fread(file, &state->regs[reg_alarm_minute], 1) != 1)
219   if (file.read(&state->regs[reg_alarm_minute], 1) != 1)
220220      return 1;
221   if (mame_fread(file, &state->regs[reg_alarm_hour], 1) != 1)
221   if (file.read(&state->regs[reg_alarm_hour], 1) != 1)
222222      return 1;
223223
224224   /* user RAM */
225   if (mame_fread(file, state->regs+14, 50) != 50)
225   if (file.read(state->regs+14, 50) != 50)
226226      return 1;
227227
228228   /* extended RAM */
229   if (mame_fread(file, state->xram, 4096) != 4096)
229   if (file.read(state->xram, 4096) != 4096)
230230      return 1;
231231
232232   state->regs[reg_D] |= reg_D_VRT;   /* the data was backed up successfully */
r10384r10385
277277/*
278278    save the SRAM and register contents to file
279279*/
280static int rtc65271_file_save(device_t *device, mame_file *file)
280static int rtc65271_file_save(device_t *device, emu_file &file)
281281{
282282   rtc65271_state *state = get_safe_token(device);
283283   UINT8 buf;
r10384r10385
285285
286286   /* version flag */
287287   buf = 0;
288   if (mame_fwrite(file, & buf, 1) != 1)
288   if (file.write(& buf, 1) != 1)
289289      return 1;
290290
291291   /* control registers */
292292   buf = state->regs[reg_A] & (reg_A_DV | reg_A_RS);
293   if (mame_fwrite(file, &buf, 1) != 1)
293   if (file.write(&buf, 1) != 1)
294294      return 1;
295295   buf = state->regs[reg_B] & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
296   if (mame_fwrite(file, &buf, 1) != 1)
296   if (file.write(&buf, 1) != 1)
297297      return 1;
298298
299299   /* alarm registers */
300   if (mame_fwrite(file, &state->regs[reg_alarm_second], 1) != 1)
300   if (file.write(&state->regs[reg_alarm_second], 1) != 1)
301301      return 1;
302   if (mame_fwrite(file, &state->regs[reg_alarm_minute], 1) != 1)
302   if (file.write(&state->regs[reg_alarm_minute], 1) != 1)
303303      return 1;
304   if (mame_fwrite(file, &state->regs[reg_alarm_hour], 1) != 1)
304   if (file.write(&state->regs[reg_alarm_hour], 1) != 1)
305305      return 1;
306306
307307   /* user RAM */
308   if (mame_fwrite(file, state->regs+14, 50) != 50)
308   if (file.write(state->regs+14, 50) != 50)
309309      return 1;
310310
311311   /* extended RAM */
312   if (mame_fwrite(file, state->xram, 4096) != 4096)
312   if (file.write(state->xram, 4096) != 4096)
313313      return 1;
314314
315315   return 0;
r10384r10385
704704static DEVICE_NVRAM( rtc65271 )
705705{
706706   if (read_or_write)
707      rtc65271_file_save(device, file);
707      rtc65271_file_save(device, *file);
708708   else if (file)
709      rtc65271_file_load(device, file);
709      rtc65271_file_load(device, *file);
710710}
711711
712712
src/emu/mame.h
r10384r10385
9898/* execute as configured by the OPTION_GAMENAME option on the specified options */
9999int mame_execute(osd_interface &osd, core_options *options);
100100
101/* accesses the core_options for the currently running emulation */
102core_options *mame_options(void);
103
104/* set mame options, used by validate option */
105void set_mame_options(core_options *options);
106
107101/* return true if the given machine is valid */
108102int mame_is_valid_machine(running_machine *machine);
109103
src/emu/rendfont.h
r10384r10385
101101   void char_expand(unicode_char chnum, glyph &ch);
102102   bool load_cached_bdf(const char *filename);
103103   bool load_bdf();
104   bool load_cached(mame_file *file, UINT32 hash);
104   bool load_cached(emu_file &file, UINT32 hash);
105105   bool save_cached(const char *filename, UINT32 hash);
106106
107107   // internal state
src/emu/rendutil.c
r10384r10385
560560    bitmap_t
561561-------------------------------------------------*/
562562
563bitmap_t *render_load_png(const char *path, const char *dirname, const char *filename, bitmap_t *alphadest, bool *hasalpha)
563bitmap_t *render_load_png(emu_file &file, const char *dirname, const char *filename, bitmap_t *alphadest, bool *hasalpha)
564564{
565565   bitmap_t *bitmap = NULL;
566   file_error filerr;
567   mame_file *file;
568566   png_info png;
569567   png_error result;
570568
r10384r10385
574572      fname.cpy(filename);
575573   else
576574      fname.cpy(dirname).cat(PATH_SEPARATOR).cat(filename);
577   filerr = mame_fopen(path, fname, OPEN_FLAG_READ, &file);
575   file_error filerr = file.open(fname);
578576   if (filerr != FILERR_NONE)
579577      return NULL;
580578
581579   /* read the PNG data */
582   result = png_read_file(mame_core_file(file), &png);
583   mame_fclose(file);
580   result = png_read_file(file, &png);
581   file.close();
584582   if (result != PNGERR_NONE)
585583      return NULL;
586584
src/emu/rendutil.h
r10384r10385
2828int render_clip_line(render_bounds *bounds, const render_bounds *clip);
2929int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords);
3030void render_line_to_quad(const render_bounds *bounds, float width, render_bounds *bounds0, render_bounds *bounds1);
31bitmap_t *render_load_png(const char *path, const char *dirname, const char *filename, bitmap_t *alphadest, bool *hasalpha);
31bitmap_t *render_load_png(emu_file &file, const char *dirname, const char *filename, bitmap_t *alphadest, bool *hasalpha);
3232
3333
3434
src/emu/diexec.c
r10384r10385
211211//  constructed
212212//-------------------------------------------------
213213
214bool device_config_execute_interface::interface_validity_check(const game_driver &driver) const
214bool device_config_execute_interface::interface_validity_check(core_options &options, const game_driver &driver) const
215215{
216216   const device_config *devconfig = crosscast<const device_config *>(this);
217217   bool error = false;
src/emu/diexec.h
r10384r10385
177177   virtual UINT32 execute_default_irq_vector() const;
178178
179179   // optional operation overrides
180   virtual bool interface_validity_check(const game_driver &driver) const;
180   virtual bool interface_validity_check(core_options &options, const game_driver &driver) const;
181181
182182   bool               m_disabled;
183183   device_interrupt_func   m_vblank_interrupt;            // for interrupts tied to VBLANK
src/emu/screen.c
r10384r10385
226226//  configuration
227227//-------------------------------------------------
228228
229bool screen_device_config::device_validity_check(const game_driver &driver) const
229bool screen_device_config::device_validity_check(core_options &options, const game_driver &driver) const
230230{
231231   bool error = false;
232232
r10384r10385
363363      m_scanline_timer->adjust(time_until_pos(0));
364364
365365   // create burn-in bitmap
366   if (options_get_int(machine->options(), OPTION_BURNIN) > 0)
366   if (options_get_int(&machine->options(), OPTION_BURNIN) > 0)
367367   {
368368      int width, height;
369      if (sscanf(options_get_string(machine->options(), OPTION_SNAPSIZE), "%dx%d", &width, &height) != 2 || width == 0 || height == 0)
369      if (sscanf(options_get_string(&machine->options(), OPTION_SNAPSIZE), "%dx%d", &width, &height) != 2 || width == 0 || height == 0)
370370         width = height = 300;
371371      m_burnin = auto_alloc(machine, bitmap_t(width, height, BITMAP_FORMAT_INDEXED64));
372372      if (m_burnin == NULL)
r10384r10385
375375   }
376376
377377   // load the effect overlay
378   const char *overname = options_get_string(machine->options(), OPTION_EFFECT);
378   const char *overname = options_get_string(&machine->options(), OPTION_EFFECT);
379379   if (overname != NULL && strcmp(overname, "none") != 0)
380380      load_effect_overlay(overname);
381381
r10384r10385
10271027   // write the final PNG
10281028
10291029   // compute the name and create the file
1030   astring fname;
1031   fname.printf("%s" PATH_SEPARATOR "burnin-%s.png", machine->basename(), tag());
1032   mame_file *file;
1033   file_error filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
1030   emu_file file(m_machine.options(), SEARCHPATH_SCREENSHOT, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
1031   file_error filerr = file.open(machine->basename(), PATH_SEPARATOR "burnin-", tag());
10341032   if (filerr == FILERR_NONE)
10351033   {
10361034      png_info pnginfo = { 0 };
r10384r10385
10441042      png_add_text(&pnginfo, "System", text);
10451043
10461044      // now do the actual work
1047      pngerr = png_write_bitmap(mame_core_file(file), &pnginfo, finalmap, 0, NULL);
1045      pngerr = png_write_bitmap(file, &pnginfo, finalmap, 0, NULL);
10481046
10491047      // free any data allocated
10501048      png_free(&pnginfo);
1051      mame_fclose(file);
10521049   }
10531050}
10541051
r10384r10385
10671064   fullname.cat(".png");
10681065
10691066   // load the file
1070   m_screen_overlay_bitmap = render_load_png(OPTION_ARTPATH, NULL, fullname, NULL, NULL);
1067   emu_file file(m_machine.options(), OPTION_ARTPATH, OPEN_FLAG_READ);
1068   m_screen_overlay_bitmap = render_load_png(file, NULL, fullname, NULL, NULL);
10711069   if (m_screen_overlay_bitmap != NULL)
10721070      m_container->set_overlay(m_screen_overlay_bitmap);
10731071   else
src/emu/screen.h
r10384r10385
120120
121121private:
122122   // device_config overrides
123   virtual bool device_validity_check(const game_driver &driver) const;
123   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
124124
125125   // inline configuration data
126126   screen_type_enum   m_type;                  // type of screen
src/emu/sound.c
r10384r10385
773773     m_rightmix(NULL),
774774     m_muted(0),
775775     m_attenuation(0),
776     m_nosound_mode(!options_get_bool(machine.options(), OPTION_SOUND)),
776     m_nosound_mode(!options_get_bool(&machine.options(), OPTION_SOUND)),
777777     m_wavfile(NULL),
778778     m_stream_list(machine.m_respool),
779779     m_update_attoseconds(STREAMS_UPDATE_ATTOTIME.attoseconds),
780780     m_last_update(attotime::zero)
781781{
782782   // get filename for WAV file or AVI file if specified
783   const char *wavfile = options_get_string(machine.options(), OPTION_WAVWRITE);
784   const char *avifile = options_get_string(machine.options(), OPTION_AVIWRITE);
783   const char *wavfile = options_get_string(&machine.options(), OPTION_WAVWRITE);
784   const char *avifile = options_get_string(&machine.options(), OPTION_AVIWRITE);
785785
786786   // handle -nosound and lower sample rate if not recording WAV or AVI
787787   if (m_nosound_mode && wavfile[0] == 0 && avifile[0] == 0)
r10384r10385
809809   state_save_register_global(&machine, m_last_update);
810810
811811   // set the starting attenuation
812   set_attenuation(options_get_int(machine.options(), OPTION_VOLUME));
812   set_attenuation(options_get_int(&machine.options(), OPTION_VOLUME));
813813
814814   // start the periodic update flushing timer
815815   m_update_timer->adjust(STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME);
src/emu/input.c
r10384r10385
591591
592592   /* read input enable options */
593593   device_list[DEVICE_CLASS_KEYBOARD].enabled = TRUE;
594   device_list[DEVICE_CLASS_MOUSE].enabled = options_get_bool(machine->options(), OPTION_MOUSE);
595   device_list[DEVICE_CLASS_LIGHTGUN].enabled = options_get_bool(machine->options(), OPTION_LIGHTGUN);
596   device_list[DEVICE_CLASS_JOYSTICK].enabled = options_get_bool(machine->options(), OPTION_JOYSTICK);
594   device_list[DEVICE_CLASS_MOUSE].enabled = options_get_bool(&machine->options(), OPTION_MOUSE);
595   device_list[DEVICE_CLASS_LIGHTGUN].enabled = options_get_bool(&machine->options(), OPTION_LIGHTGUN);
596   device_list[DEVICE_CLASS_JOYSTICK].enabled = options_get_bool(&machine->options(), OPTION_JOYSTICK);
597597
598598   /* read input device multi options */
599   device_list[DEVICE_CLASS_KEYBOARD].multi = options_get_bool(machine->options(), OPTION_MULTIKEYBOARD);
600   device_list[DEVICE_CLASS_MOUSE].multi = options_get_bool(machine->options(), OPTION_MULTIMOUSE);
599   device_list[DEVICE_CLASS_KEYBOARD].multi = options_get_bool(&machine->options(), OPTION_MULTIKEYBOARD);
600   device_list[DEVICE_CLASS_MOUSE].multi = options_get_bool(&machine->options(), OPTION_MULTIMOUSE);
601601   device_list[DEVICE_CLASS_LIGHTGUN].multi = TRUE;
602602   device_list[DEVICE_CLASS_JOYSTICK].multi = TRUE;
603603
604604   /* read other input options */
605   state->steadykey_enabled = options_get_bool(machine->options(), OPTION_STEADYKEY);
606   state->lightgun_reload_button = options_get_bool(machine->options(), OPTION_OFFSCREEN_RELOAD);
607   state->joystick_deadzone = (INT32)(options_get_float(machine->options(), OPTION_JOYSTICK_DEADZONE) * INPUT_ABSOLUTE_MAX);
608   state->joystick_saturation = (INT32)(options_get_float(machine->options(), OPTION_JOYSTICK_SATURATION) * INPUT_ABSOLUTE_MAX);
605   state->steadykey_enabled = options_get_bool(&machine->options(), OPTION_STEADYKEY);
606   state->lightgun_reload_button = options_get_bool(&machine->options(), OPTION_OFFSCREEN_RELOAD);
607   state->joystick_deadzone = (INT32)(options_get_float(&machine->options(), OPTION_JOYSTICK_DEADZONE) * INPUT_ABSOLUTE_MAX);
608   state->joystick_saturation = (INT32)(options_get_float(&machine->options(), OPTION_JOYSTICK_SATURATION) * INPUT_ABSOLUTE_MAX);
609609
610610   /* get the default joystick map */
611   state->joystick_map_default = options_get_string(machine->options(), OPTION_JOYSTICK_MAP);
611   state->joystick_map_default = options_get_string(&machine->options(), OPTION_JOYSTICK_MAP);
612612   if (state->joystick_map_default[0] == 0 || strcmp(state->joystick_map_default, "auto") == 0)
613613      state->joystick_map_default = joystick_map_8way;
614614   if (!joystick_map_parse(state->joystick_map_default, &map))
src/emu/fileio.c
r10384r10385
44
55    File access functions.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1038***************************************************************************/
1139
1240#include "emu.h"
r10384r10385
1644#include "fileio.h"
1745
1846
19/***************************************************************************
20    CONSTANTS
21***************************************************************************/
47const UINT32 OPEN_FLAG_HAS_CRC   = 0x10000;
2248
23#define PLAIN_FILE            0
24#define ZIPPED_FILE            1
2549
26#define OPEN_FLAG_HAS_CRC      0x10000
2750
28#ifdef MAME_DEBUG
29#define DEBUG_COOKIE         0xbaadf00d
30#endif
51//**************************************************************************
52//  PATH ITERATOR
53//**************************************************************************
3154
55//-------------------------------------------------
56//  path_iterator - constructor
57//-------------------------------------------------
3258
33
34/***************************************************************************
35    TYPE DEFINITIONS
36***************************************************************************/
37
38typedef struct _path_iterator path_iterator;
39struct _path_iterator
59path_iterator::path_iterator(core_options &opts, const char *searchpath)
60   : m_base((searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(&opts, searchpath) : ""),
61     m_current(m_base),
62     m_index(0)
4063{
41   const char *   base;
42   const char *   cur;
43   int            index;
44};
64}
4565
4666
47/* typedef struct _mame_file mame_file -- declared in fileio.h */
48struct _mame_file
49{
50#ifdef DEBUG_COOKIE
51   UINT32         debug_cookie;               /* sanity checking for debugging */
52#endif
53   astring         filename;                  /* full filename */
54   core_file *      file;                     /* core file pointer */
55   path_iterator   iterator;                  /* iterator for paths */
56   UINT32         openflags;                  /* flags we used for the open */
57   char         hash[HASH_BUF_SIZE];         /* hash data for the file */
58   zip_file *      zipfile;                  /* ZIP file pointer */
59   UINT8 *         zipdata;                  /* ZIP file data */
60   UINT64         ziplength;                  /* ZIP file length */
61};
67//-------------------------------------------------
68//  path_iterator_get_next - get the next entry
69//  in a multipath sequence
70//-------------------------------------------------
6271
63
64/* typedef struct _mame_path mame_path -- declared in fileio.h */
65struct _mame_path
72bool path_iterator::next(astring &buffer)
6673{
67   path_iterator   iterator;
68   osd_directory *   curdir;
69   astring         pathbuffer;
70   int            buflen;
71};
74   // if none left, return FALSE to indicate we are done
75   if (m_index != 0 && *m_current == 0)
76      return false;
7277
78   // copy up to the next semicolon
79   const char *semi = strchr(m_current, ';');
80   if (semi == NULL)
81      semi = m_current + strlen(m_current);
82   buffer.cpy(m_current, semi - m_current);
83   m_current = (*semi == 0) ? semi : semi + 1;
7384
85   // bump the index and return TRUE
86   m_index++;
87   return true;
88}
7489
75/***************************************************************************
76    FUNCTION PROTOTYPES
77***************************************************************************/
7890
79/* core functions */
80static void fileio_exit(running_machine &machine);
8191
82/* file open/close */
83static file_error fopen_internal(core_options *opts, path_iterator *iterator, const char *filename, UINT32 crc, UINT32 flags, mame_file **file);
84static file_error fopen_attempt_zipped(astring &fullname, UINT32 crc, UINT32 openflags, mame_file *file);
92//**************************************************************************
93//  FILE ENUMERATOR
94//**************************************************************************
8595
86/* path iteration */
87static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath);
88static int path_iterator_get_next(path_iterator *iterator, astring &buffer);
96//-------------------------------------------------
97//  file_enumerator - constructor
98//-------------------------------------------------
8999
90/* misc helpers */
91static file_error load_zipped_file(mame_file *file);
92static int zip_filename_match(const zip_file_header *header, const astring &afilename);
93static int zip_header_is_path(const zip_file_header *header);
100file_enumerator::file_enumerator(core_options &options, const char *searchpath)
101   : m_iterator(options, searchpath),
102     m_curdir(NULL),
103     m_buflen(0)
104{
105}
94106
95107
108//-------------------------------------------------
109//  ~file_enumerator - destructor
110//-------------------------------------------------
96111
97/***************************************************************************
98    CORE FUNCTIONS
99***************************************************************************/
100
101/*-------------------------------------------------
102    fileio_init - initialize the internal file
103    I/O system; note that the OS layer is free to
104    call mame_fopen before fileio_init
105-------------------------------------------------*/
106
107void fileio_init(running_machine *machine)
112file_enumerator::~file_enumerator()
108113{
109   machine->add_notifier(MACHINE_NOTIFY_EXIT, fileio_exit);
114   // close anything open
115   if (m_curdir != NULL)
116      osd_closedir(m_curdir);
110117}
111118
112119
113/*-------------------------------------------------
114    fileio_exit - clean up behind ourselves
115-------------------------------------------------*/
120//-------------------------------------------------
121//  next - return information about the next file
122//  in the search path
123//-------------------------------------------------
116124
117static void fileio_exit(running_machine &machine)
125const osd_directory_entry *file_enumerator::next()
118126{
119   zip_file_cache_clear();
127   // loop over potentially empty directories
128   while (1)
129   {
130      // if no open directory, get the next path
131      while (m_curdir == NULL)
132      {
133         // if we fail to get anything more, we're done
134         if (!m_iterator.next(m_pathbuffer))
135            return NULL;
136
137         // open the path
138         m_curdir = osd_opendir(m_pathbuffer);
139      }
140
141      // get the next entry from the current directory
142      const osd_directory_entry *result = osd_readdir(m_curdir);
143      if (result != NULL)
144         return result;
145
146      // we're done; close this directory
147      osd_closedir(m_curdir);
148      m_curdir = NULL;
149   }
120150}
121151
122152
123153
124/***************************************************************************
125    FILE OPEN/CLOSE
126***************************************************************************/
154//**************************************************************************
155//  EMU FILE
156//**************************************************************************
127157
128/*-------------------------------------------------
129    mame_fopen - open a file for access and
130    return an error code
131-------------------------------------------------*/
158//-------------------------------------------------
159//  emu_file - constructor
160//-------------------------------------------------
132161
133file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
162emu_file::emu_file(core_options &options, const char *searchpath, UINT32 openflags)
163   : m_file(NULL),
164     m_iterator(options, searchpath),
165     m_crc(0),
166     m_openflags(openflags),
167     m_zipfile(NULL),
168     m_zipdata(NULL),
169     m_ziplength(0),
170     m_remove_on_close(false)
134171{
135   path_iterator iterator;
136   path_iterator_init(&iterator, mame_options(), searchpath);
137   return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
172   // sanity check the open flags
173   if ((m_openflags & OPEN_FLAG_HAS_CRC) && (m_openflags & OPEN_FLAG_WRITE))
174      throw emu_fatalerror("Attempted to open a file for write with OPEN_FLAG_HAS_CRC");
138175}
139176
140177
141/*-------------------------------------------------
142    mame_fopen_crc - open a file by name or CRC
143    and return an error code
144-------------------------------------------------*/
178//-------------------------------------------------
179//  ~emu_file - destructor
180//-------------------------------------------------
145181
146file_error mame_fopen_crc(const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
182emu_file::~emu_file()
147183{
148   path_iterator iterator;
149   path_iterator_init(&iterator, mame_options(), searchpath);
150   return mame_fopen_crc_options(mame_options(), searchpath, filename, crc, openflags, file);
184   // close in the standard way
185   close();
151186}
152187
153188
154/*-------------------------------------------------
155    mame_fopen_options - open a file for access and
156    return an error code
157-------------------------------------------------*/
189//-------------------------------------------------
190//  operator core_file - automatically convert
191//  ourselves to a core_file pointer
192//-------------------------------------------------
158193
159file_error mame_fopen_options(core_options *opts, const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
194emu_file::operator core_file *()
160195{
161   path_iterator iterator;
162   path_iterator_init(&iterator, opts, searchpath);
163   return fopen_internal(opts, &iterator, filename, 0, openflags, file);
196   // load the ZIP file now if we haven't yet
197   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
198      return NULL;
199
200   // return the core file
201   return m_file;
164202}
165203
166204
167/*-------------------------------------------------
168    mame_fopen_crc_options - open a file by name
169    or CRC and return an error code
170-------------------------------------------------*/
205//-------------------------------------------------
206//  hash - returns the hash for a file
207//-------------------------------------------------
171208
172file_error mame_fopen_crc_options(core_options *opts, const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
209const char *emu_file::hash_string(UINT32 functions)
173210{
174   path_iterator iterator;
175   path_iterator_init(&iterator, opts, searchpath);
176   return fopen_internal(opts, &iterator, filename, crc, openflags | OPEN_FLAG_HAS_CRC, file);
211   // if we already have the functions we need, just return
212   UINT32 wehave = hash_data_used_functions(m_hash);
213   if ((wehave & functions) == functions)
214      return m_hash;
215
216   // load the ZIP file now if we haven't yet
217   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
218      return m_hash;
219   if (m_file == NULL)
220      return m_hash;
221
222   // read the data if we can
223   const UINT8 *filedata = (const UINT8 *)core_fbuffer(m_file);
224   if (filedata == NULL)
225      return m_hash;
226
227   // compute the hash
228   hash_compute(m_hash, filedata, core_fsize(m_file), wehave | functions);
229   return m_hash;
177230}
178231
179232
180/*-------------------------------------------------
181    mame_fopen_ram - open a "file" which is
182    actually just an array of data in RAM
183-------------------------------------------------*/
233//-------------------------------------------------
234//  open - open a file by searching paths
235//-------------------------------------------------
184236
185file_error mame_fopen_ram(const void *data, UINT32 length, UINT32 openflags, mame_file **file)
237file_error emu_file::open(const char *name)
186238{
187   file_error filerr;
239   // remember the filename and CRC info
240   m_filename = name;
241   m_crc = 0;
242   m_openflags &= ~OPEN_FLAG_HAS_CRC;
188243
189   /* allocate the file itself */
190   *file = global_alloc_clear(mame_file);
244   // reset the iterator and open_next
245   m_iterator.reset();
246   return open_next();
247}
191248
192   /* reset the file handle */
193   (*file)->openflags = openflags;
194#ifdef DEBUG_COOKIE
195   (*file)->debug_cookie = DEBUG_COOKIE;
196#endif
249file_error emu_file::open(const char *name1, const char *name2)
250{
251   // concatenate the strings and do a standard open
252   astring name(name1, name2);
253   return open(name);
254}
197255
198   /* attempt to open the file directly */
199   filerr = core_fopen_ram(data, length, openflags, &(*file)->file);
200   if (filerr == FILERR_NONE)
201      goto error;
256file_error emu_file::open(const char *name1, const char *name2, const char *name3)
257{
258   // concatenate the strings and do a standard open
259   astring name(name1, name2, name3);
260   return open(name);
261}
202262
203   /* handle errors and return */
204error:
205   if (filerr != FILERR_NONE)
206   {
207      mame_fclose(*file);
208      *file = NULL;
209   }
210   return filerr;
263file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4)
264{
265   // concatenate the strings and do a standard open
266   astring name(name1, name2, name3, name4);
267   return open(name);
211268}
212269
270file_error emu_file::open(const char *name, UINT32 crc)
271{
272   // remember the filename and CRC info
273   m_filename = name;
274   m_crc = crc;
275   m_openflags |= OPEN_FLAG_HAS_CRC;
213276
214/*-------------------------------------------------
215    fopen_internal - open a file
216-------------------------------------------------*/
277   // reset the iterator and open_next
278   m_iterator.reset();
279   return open_next();
280}
217281
218static file_error fopen_internal(core_options *opts, path_iterator *iterator, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file)
282file_error emu_file::open(const char *name1, const char *name2, UINT32 crc)
219283{
220   file_error filerr = FILERR_NOT_FOUND;
284   // concatenate the strings and do a standard open
285   astring name(name1, name2);
286   return open(name, crc);
287}
221288
222   /* can either have a hash or open for write, but not both */
223   if ((openflags & OPEN_FLAG_HAS_CRC) && (openflags & OPEN_FLAG_WRITE))
224      return FILERR_INVALID_ACCESS;
289file_error emu_file::open(const char *name1, const char *name2, const char *name3, UINT32 crc)
290{
291   // concatenate the strings and do a standard open
292   astring name(name1, name2, name3);
293   return open(name, crc);
294}
225295
226   /* allocate the file itself */
227   *file = global_alloc_clear(mame_file);
296file_error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc)
297{
298   // concatenate the strings and do a standard open
299   astring name(name1, name2, name3, name4);
300   return open(name, crc);
301}
228302
229   /* reset the file handle */
230   (*file)->openflags = openflags;
231#ifdef DEBUG_COOKIE
232   (*file)->debug_cookie = DEBUG_COOKIE;
233#endif
234303
235   /* loop over paths */
236   while (path_iterator_get_next(iterator, (*file)->filename))
304//-------------------------------------------------
305//  open_next - open the next file that matches
306//  the filename by iterating over paths
307//-------------------------------------------------
308
309file_error emu_file::open_next()
310{
311   // if we're open from a previous attempt, close up now
312   if (m_file != NULL)
313      close();
314   
315   // loop over paths
316   file_error filerr = FILERR_NOT_FOUND;
317   while (m_iterator.next(m_fullpath))
237318   {
238      /* compute the full pathname */
239      if ((*file)->filename.len() > 0)
240         (*file)->filename.cat(PATH_SEPARATOR);
241      (*file)->filename.cat(filename);
319      // compute the full pathname
320      if (m_fullpath.len() > 0)
321         m_fullpath.cat(PATH_SEPARATOR);
322      m_fullpath.cat(m_filename);
242323
243      /* attempt to open the file directly */
244      filerr = core_fopen((*file)->filename, openflags, &(*file)->file);
324      // attempt to open the file directly
325      filerr = core_fopen(m_fullpath, m_openflags, &m_file);
245326      if (filerr == FILERR_NONE)
246327         break;
247328
248      /* if we're opening for read-only we have other options */
249      if ((openflags & (OPEN_FLAG_READ | OPEN_FLAG_WRITE)) == OPEN_FLAG_READ)
329      // if we're opening for read-only we have other options
330      if ((m_openflags & (OPEN_FLAG_READ | OPEN_FLAG_WRITE)) == OPEN_FLAG_READ)
250331      {
251         filerr = fopen_attempt_zipped((*file)->filename, crc, openflags, *file);
332         filerr = attempt_zipped();
252333         if (filerr == FILERR_NONE)
253334            break;
254335      }
255336   }
256
257   /* if we succeeded, save the iterator */
258   if (filerr == FILERR_NONE)
259      (*file)->iterator = *iterator;
260
261   /* handle errors and return */
262   else
263   {
264      mame_fclose(*file);
265      *file = NULL;
266   }
267337   return filerr;
268338}
269339
270340
271/*-------------------------------------------------
272    fopen_attempt_zipped - attempt to open a
273    ZIPped file
274-------------------------------------------------*/
341//-------------------------------------------------
342//  open_ram - open a "file" which is actually
343//  just an array of data in RAM
344//-------------------------------------------------
275345
276static file_error fopen_attempt_zipped(astring &fullname, UINT32 crc, UINT32 openflags, mame_file *file)
346file_error emu_file::open_ram(const void *data, UINT32 length)
277347{
278   astring filename;
279   zip_error ziperr;
280   zip_file *zip;
281
282   /* loop over directory parts up to the start of filename */
283   while (1)
284   {
285      const zip_file_header *header;
286      int dirsep;
287
288      /* find the final path separator */
289      dirsep = fullname.rchr(0, PATH_SEPARATOR[0]);
290      if (dirsep == -1)
291         return FILERR_NOT_FOUND;
292
293      /* insert the part from the right of the separator into the head of the filename */
294      if (filename.len() > 0)
295         filename.ins(0, "/");
296      filename.inssubstr(0, fullname, dirsep + 1, -1);
297
298      /* remove this part of the filename and append a .zip extension */
299      fullname.substr(0, dirsep).cat(".zip");
300
301      /* attempt to open the ZIP file */
302      ziperr = zip_file_open(fullname, &zip);
303
304      /* chop the .zip back off the filename before continuing */
305      fullname.substr(0, dirsep);
306
307      /* if we failed to open this file, continue scanning */
308      if (ziperr != ZIPERR_NONE)
309         continue;
310
311      /* see if we can find a file with the right name and (if available) crc */
312      for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
313         if (zip_filename_match(header, filename) && (!(openflags & OPEN_FLAG_HAS_CRC) || header->crc == crc))
314            break;
315
316      /* if that failed, look for a file with the right crc, but the wrong filename */
317      if (header == NULL && (openflags & OPEN_FLAG_HAS_CRC))
318         for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
319            if (header->crc == crc && (!zip_header_is_path(header)))
320               break;
321
322      /* if that failed, look for a file with the right name; reporting a bad checksum */
323      /* is more helpful and less confusing than reporting "rom not found" */
324      if (header == NULL)
325         for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
326            if (zip_filename_match(header, filename))
327               break;
328
329      /* if we got it, read the data */
330      if (header != NULL)
331      {
332         UINT8 crcs[4];
333
334         file->zipfile = zip;
335         file->ziplength = header->uncompressed_length;
336
337         /* build a hash with just the CRC */
338         hash_data_clear(file->hash);
339         crcs[0] = header->crc >> 24;
340         crcs[1] = header->crc >> 16;
341         crcs[2] = header->crc >> 8;
342         crcs[3] = header->crc >> 0;
343         hash_data_insert_binary_checksum(file->hash, HASH_CRC, crcs);
344
345         if (openflags & OPEN_FLAG_NO_PRELOAD)
346            return FILERR_NONE;
347         else
348            return load_zipped_file(file);
349      }
350
351      /* close up the ZIP file and try the next level */
352      zip_file_close(zip);
353   }
348   // set a fake filename and CRC
349   m_filename = "RAM";
350   m_crc = 0;
351   
352   // use the core_file's built-in RAM support
353   return core_fopen_ram(data, length, m_openflags, &m_file);
354354}
355355
356356
357/*-------------------------------------------------
358    mame_fclose - closes a file
359-------------------------------------------------*/
357//-------------------------------------------------
358//  close - close a file and free all data; also
359//  remove the file if requested
360//-------------------------------------------------
360361
361void mame_fclose(mame_file *file)
362void emu_file::close()
362363{
363#ifdef DEBUG_COOKIE
364   assert(file->debug_cookie == DEBUG_COOKIE);
365   file->debug_cookie = 0;
366#endif
367
368   /* close files and free memory */
369   if (file->zipfile != NULL)
370      zip_file_close(file->zipfile);
371   if (file->file != NULL)
372      core_fclose(file->file);
373   if (file->zipdata != NULL)
374      global_free(file->zipdata);
375   global_free(file);
364   // close files and free memory
365   if (m_zipfile != NULL)
366      zip_file_close(m_zipfile);
367   m_zipfile = NULL;
368   
369   if (m_file != NULL)
370      core_fclose(m_file);
371   m_file = NULL;
372   
373   if (m_zipdata != NULL)
374      global_free(m_zipdata);
375   m_zipdata = NULL;
376   
377   if (m_remove_on_close)
378      osd_rmfile(m_fullpath);
379   m_remove_on_close = false;
376380}
377381
378382
379/*-------------------------------------------------
380    mame_fclose_and_open_next - close an open
381    file, and open the next entry in the original
382    searchpath
383-------------------------------------------------*/
383//-------------------------------------------------
384//  compress - enable/disable streaming file
385//  compression via zlib; level is 0 to disable
386//  compression, or up to 9 for max compression
387//-------------------------------------------------
384388
385file_error mame_fclose_and_open_next(mame_file **file, const char *filename, UINT32 openflags)
389file_error emu_file::compress(int level)
386390{
387   path_iterator iterator = (*file)->iterator;
388   mame_fclose(*file);
389   *file = NULL;
390   return fopen_internal(mame_options(), &iterator, filename, 0, openflags, file);
391   return core_fcompress(m_file, level);
391392}
392393
393394
394/*-------------------------------------------------
395    mame_fcompress - enable/disable streaming file
396    compression via zlib; level is 0 to disable
397    compression, or up to 9 for max compression
398-------------------------------------------------*/
395//-------------------------------------------------
396//  seek - seek within a file
397//-------------------------------------------------
399398
400file_error mame_fcompress(mame_file *file, int level)
399int emu_file::seek(INT64 offset, int whence)
401400{
402   return core_fcompress(file->file, level);
403}
401   // load the ZIP file now if we haven't yet
402   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
403      return 1;
404404
405   // seek if we can
406   if (m_file != NULL)
407      return core_fseek(m_file, offset, whence);
405408
406
407/***************************************************************************
408    FILE POSITIONING
409***************************************************************************/
410
411/*-------------------------------------------------
412    mame_fseek - seek within a file
413-------------------------------------------------*/
414
415int mame_fseek(mame_file *file, INT64 offset, int whence)
416{
417   /* load the ZIP file now if we haven't yet */
418   if (file->zipfile != NULL)
419   {
420      if (load_zipped_file(file) != FILERR_NONE)
421         return 1;
422   }
423
424   /* seek if we can */
425   if (file->file != NULL)
426      return core_fseek(file->file, offset, whence);
427
428409   return 1;
429410}
430411
431412
432/*-------------------------------------------------
433    mame_ftell - return the current file position
434-------------------------------------------------*/
413//-------------------------------------------------
414//  tell - return the current file position
415//-------------------------------------------------
435416
436UINT64 mame_ftell(mame_file *file)
417UINT64 emu_file::tell()
437418{
438   /* load the ZIP file now if we haven't yet */
439   if (file->zipfile != NULL)
440   {
441      if (load_zipped_file(file) != FILERR_NONE)
442         return 0;
443   }
419   // load the ZIP file now if we haven't yet
420   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
421      return 0;
444422
445   /* tell if we can */
446   if (file->file != NULL)
447      return core_ftell(file->file);
423   // tell if we can
424   if (m_file != NULL)
425      return core_ftell(m_file);
448426
449427   return 0;
450428}
451429
452430
453/*-------------------------------------------------
454    mame_feof - return 1 if we're at the end
455    of file
456-------------------------------------------------*/
431//-------------------------------------------------
432//  eof - return true if we're at the end of file
433//-------------------------------------------------
457434
458int mame_feof(mame_file *file)
435bool emu_file::eof()
459436{
460   /* load the ZIP file now if we haven't yet */
461   if (file->zipfile != NULL)
462   {
463      if (load_zipped_file(file) != FILERR_NONE)
464         return 0;
465   }
437   // load the ZIP file now if we haven't yet
438   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
439      return 0;
466440
467   /* return EOF if we can */
468   if (file->file != NULL)
469      return core_feof(file->file);
441   // return EOF if we can
442   if (m_file != NULL)
443      return core_feof(m_file);
470444
471445   return 0;
472446}
473447
474448
475/*-------------------------------------------------
476    mame_fsize - returns the size of a file
477-------------------------------------------------*/
449//-------------------------------------------------
450//  size - returns the size of a file
451//-------------------------------------------------
478452
479UINT64 mame_fsize(mame_file *file)
453UINT64 emu_file::size()
480454{
481   /* use the ZIP length if present */
482   if (file->zipfile != NULL)
483      return file->ziplength;
455   // use the ZIP length if present
456   if (m_zipfile != NULL)
457      return m_ziplength;
484458
485   /* return length if we can */
486   if (file->file != NULL)
487      return core_fsize(file->file);
459   // return length if we can
460   if (m_file != NULL)
461      return core_fsize(m_file);
488462
489463   return 0;
490464}
491465
492466
467//-------------------------------------------------
468//  read - read from a file
469//-------------------------------------------------
493470
494/***************************************************************************
495    FILE READ
496***************************************************************************/
497
498/*-------------------------------------------------
499    mame_fread - read from a file
500-------------------------------------------------*/
501
502UINT32 mame_fread(mame_file *file, void *buffer, UINT32 length)
471UINT32 emu_file::read(void *buffer, UINT32 length)
503472{
504   /* load the ZIP file now if we haven't yet */
505   if (file->zipfile != NULL)
506   {
507      if (load_zipped_file(file) != FILERR_NONE)
508         return 0;
509   }
473   // load the ZIP file now if we haven't yet
474   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
475      return 0;
510476
511   /* read the data if we can */
512   if (file->file != NULL)
513      return core_fread(file->file, buffer, length);
477   // read the data if we can
478   if (m_file != NULL)
479      return core_fread(m_file, buffer, length);
514480
515481   return 0;
516482}
517483
518484
519/*-------------------------------------------------
520    mame_fgetc - read a character from a file
521-------------------------------------------------*/
485//-------------------------------------------------
486//  getc - read a character from a file
487//-------------------------------------------------
522488
523int mame_fgetc(mame_file *file)
489int emu_file::getc()
524490{
525   /* load the ZIP file now if we haven't yet */
526   if (file->zipfile != NULL)
527   {
528      if (load_zipped_file(file) != FILERR_NONE)
529         return EOF;
530   }
491   // load the ZIP file now if we haven't yet
492   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
493      return EOF;
531494
532   /* read the data if we can */
533   if (file->file != NULL)
534      return core_fgetc(file->file);
495   // read the data if we can
496   if (m_file != NULL)
497      return core_fgetc(m_file);
535498
536499   return EOF;
537500}
538501
539502
540/*-------------------------------------------------
541    mame_ungetc - put back a character read from
542    a file
543-------------------------------------------------*/
503//-------------------------------------------------
504//  ungetc - put back a character read from a file
505//-------------------------------------------------
544506
545int mame_ungetc(int c, mame_file *file)
507int emu_file::ungetc(int c)
546508{
547   /* load the ZIP file now if we haven't yet */
548   if (file->zipfile != NULL)
549   {
550      if (load_zipped_file(file) != FILERR_NONE)
551         return 1;
552   }
509   // load the ZIP file now if we haven't yet
510   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
511      return 1;
553512
554   /* read the data if we can */
555   if (file->file != NULL)
556      return core_ungetc(c, file->file);
513   // read the data if we can
514   if (m_file != NULL)
515      return core_ungetc(c, m_file);
557516
558517   return 1;
559518}
560519
561520
562/*-------------------------------------------------
563    mame_fgets - read a line from a text file
564-------------------------------------------------*/
521//-------------------------------------------------
522//  gets - read a line from a text file
523//-------------------------------------------------
565524
566char *mame_fgets(char *s, int n, mame_file *file)
525char *emu_file::gets(char *s, int n)
567526{
568   /* load the ZIP file now if we haven't yet */
569   if (file->zipfile != NULL)
570   {
571      if (load_zipped_file(file) != FILERR_NONE)
572         return NULL;
573   }
527   // load the ZIP file now if we haven't yet
528   if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE)
529      return NULL;
574530
575   /* read the data if we can */
576   if (file->file != NULL)
577      return core_fgets(s, n, file->file);
531   // read the data if we can
532   if (m_file != NULL)
533      return core_fgets(s, n, m_file);
578534
579535   return NULL;
580536}
581537
582538
539//-------------------------------------------------
540//  write - write to a file
541//-------------------------------------------------
583542
584/***************************************************************************
585    FILE WRITE
586***************************************************************************/
587
588/*-------------------------------------------------
589    mame_fwrite - write to a file
590-------------------------------------------------*/
591
592UINT32 mame_fwrite(mame_file *file, const void *buffer, UINT32 length)
543UINT32 emu_file::write(const void *buffer, UINT32 length)
593544{
594   /* write the data if we can */
595   if (file->file != NULL)
596      return core_fwrite(file->file, buffer, length);
545   // write the data if we can
546   if (m_file != NULL)
547      return core_fwrite(m_file, buffer, length);
597548
598549   return 0;
599550}
600551
601552
602/*-------------------------------------------------
603    mame_fputs - write a line to a text file
604-------------------------------------------------*/
553//-------------------------------------------------
554//  puts - write a line to a text file
555//-------------------------------------------------
605556
606int mame_fputs(mame_file *file, const char *s)
557int emu_file::puts(const char *s)
607558{
608   /* write the data if we can */
609   if (file->file != NULL)
610      return core_fputs(file->file, s);
559   // write the data if we can
560   if (m_file != NULL)
561      return core_fputs(m_file, s);
611562
612563   return 0;
613564}
614565
615566
616/*-------------------------------------------------
617    mame_vfprintf - vfprintf to a text file
618-------------------------------------------------*/
567//-------------------------------------------------
568//  printf - vfprintf to a text file
569//-------------------------------------------------
619570
620static int mame_vfprintf(mame_file *file, const char *fmt, va_list va)
571int CLIB_DECL emu_file::printf(const char *fmt, ...)
621572{
622   /* write the data if we can */
623   return (file->file != NULL) ? core_vfprintf(file->file, fmt, va) : 0;
624}
625
626
627/*-------------------------------------------------
628    mame_fprintf - vfprintf to a text file
629-------------------------------------------------*/
630
631int CLIB_DECL mame_fprintf(mame_file *file, const char *fmt, ...)
632{
633573   int rc;
634574   va_list va;
635575   va_start(va, fmt);
636   rc = mame_vfprintf(file, fmt, va);
576   rc = vprintf(fmt, va);
637577   va_end(va);
638578   return rc;
639579}
640580
641581
582//-------------------------------------------------
583//  mame_vfprintf - vfprintf to a text file
584//-------------------------------------------------
642585
643/***************************************************************************
644    FILE ENUMERATION
645***************************************************************************/
646
647/*-------------------------------------------------
648    mame_openpath - open a search path (multiple
649    directories) for iteration
650-------------------------------------------------*/
651
652mame_path *mame_openpath(core_options *opts, const char *searchpath)
586int emu_file::vprintf(const char *fmt, va_list va)
653587{
654   mame_path *path;
655
656   /* allocate a new mame_path */
657   path = global_alloc_clear(mame_path);
658
659   /* initialize the iterator */
660   path_iterator_init(&path->iterator, opts, searchpath);
661
662   return path;
588   // write the data if we can
589   return (m_file != NULL) ? core_vfprintf(m_file, fmt, va) : 0;
663590}
664591
665592
666/*-------------------------------------------------
667    mame_readpath - return information about the
668    next file in the search path
669-------------------------------------------------*/
670593
671const osd_directory_entry *mame_readpath(mame_path *path)
594//-------------------------------------------------
595//  attempt_zipped - attempt to open a ZIPped file
596//-------------------------------------------------
597
598file_error emu_file::attempt_zipped()
672599{
673   const osd_directory_entry *result;
600   astring filename;
674601
675   /* loop over potentially empty directories */
602   // loop over directory parts up to the start of filename
676603   while (1)
677604   {
678      /* if no open directory, get the next path */
679      while (path->curdir == NULL)
680      {
681         /* if we fail to get anything more, we're done */
682         if (!path_iterator_get_next(&path->iterator, path->pathbuffer))
683            return NULL;
605      // find the final path separator
606      int dirsep = m_fullpath.rchr(0, PATH_SEPARATOR[0]);
607      if (dirsep == -1)
608         return FILERR_NOT_FOUND;
684609
685         /* open the path */
686         path->curdir = osd_opendir(path->pathbuffer);
687      }
610      // insert the part from the right of the separator into the head of the filename
611      if (filename.len() > 0)
612         filename.ins(0, "/");
613      filename.inssubstr(0, m_fullpath, dirsep + 1, -1);
688614
689      /* get the next entry from the current directory */
690      result = osd_readdir(path->curdir);
691      if (result != NULL)
692         return result;
615      // remove this part of the filename and append a .zip extension
616      m_fullpath.substr(0, dirsep).cat(".zip");
693617
694      /* we're done; close this directory */
695      osd_closedir(path->curdir);
696      path->curdir = NULL;
697   }
698}
618      // attempt to open the ZIP file
619      zip_file *zip;
620      zip_error ziperr = zip_file_open(m_fullpath, &zip);
699621
622      // chop the .zip back off the filename before continuing
623      m_fullpath.substr(0, dirsep);
700624
701/*-------------------------------------------------
702    mame_closepath - close an open seach path
703-------------------------------------------------*/
625      // if we failed to open this file, continue scanning
626      if (ziperr != ZIPERR_NONE)
627         continue;
704628
705void mame_closepath(mame_path *path)
706{
707   /* close anything open */
708   if (path->curdir != NULL)
709      osd_closedir(path->curdir);
629      // see if we can find a file with the right name and (if available) crc
630      const zip_file_header *header;
631      for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
632         if (zip_filename_match(*header, filename) && (!(m_openflags & OPEN_FLAG_HAS_CRC) || header->crc == m_crc))
633            break;
710634
711   /* free memory */
712   global_free(path);
713}
635      // if that failed, look for a file with the right crc, but the wrong filename
636      if (header == NULL && (m_openflags & OPEN_FLAG_HAS_CRC))
637         for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
638            if (header->crc == m_crc && !zip_header_is_path(*header))
639               break;
714640
641      // if that failed, look for a file with the right name; reporting a bad checksum
642      // is more helpful and less confusing than reporting "rom not found"
643      if (header == NULL)
644         for (header = zip_file_first_file(zip); header != NULL; header = zip_file_next_file(zip))
645            if (zip_filename_match(*header, filename))
646               break;
715647
648      // if we got it, read the data
649      if (header != NULL)
650      {
651         m_zipfile = zip;
652         m_ziplength = header->uncompressed_length;
716653
717/***************************************************************************
718    MISCELLANEOUS
719***************************************************************************/
654         // build a hash with just the CRC
655         hash_data_clear(m_hash);
656         UINT8 crcs[4];
657         crcs[0] = header->crc >> 24;
658         crcs[1] = header->crc >> 16;
659         crcs[2] = header->crc >> 8;
660         crcs[3] = header->crc >> 0;
661         hash_data_insert_binary_checksum(m_hash, HASH_CRC, crcs);
720662
721/*-------------------------------------------------
722    mame_core_file - return the core_file
723    underneath the mame_file
724-------------------------------------------------*/
663         return (m_openflags & OPEN_FLAG_NO_PRELOAD) ? FILERR_NONE : load_zipped_file();
664      }
725665
726core_file *mame_core_file(mame_file *file)
727{
728   /* load the ZIP file now if we haven't yet */
729   if (file->zipfile != NULL)
730   {
731      if (load_zipped_file(file) != FILERR_NONE)
732         return NULL;
666      // close up the ZIP file and try the next level
667      zip_file_close(zip);
733668   }
734
735   /* return the core file */
736   return file->file;
737669}
738670
739671
740/*-------------------------------------------------
741    mame_file_full_name - return the full filename
742    for a given mame_file
743-------------------------------------------------*/
672//-------------------------------------------------
673//  load_zipped_file - load a ZIPped file
674//-------------------------------------------------
744675
745const astring &mame_file_full_name(mame_file *file)
676file_error emu_file::load_zipped_file()
746677{
747   return file->filename;
748}
678   assert(m_file == NULL);
679   assert(m_zipdata == NULL);
680   assert(m_zipfile != NULL);
749681
682   // allocate some memory
683   m_zipdata = global_alloc_array(UINT8, m_ziplength);
750684
751/*-------------------------------------------------
752    mame_fhash - returns the hash for a file
753-------------------------------------------------*/
754
755const char *mame_fhash(mame_file *file, UINT32 functions)
756{
757   const UINT8 *filedata;
758   UINT32 wehave;
759
760   /* if we already have the functions we need, just return */
761   wehave = hash_data_used_functions(file->hash);
762   if ((wehave & functions) == functions)
763      return file->hash;
764
765   /* load the ZIP file now if we haven't yet */
766   if (file->zipfile != NULL)
767   {
768      if (load_zipped_file(file) != FILERR_NONE)
769         return file->hash;
770   }
771   if (file->file == NULL)
772      return file->hash;
773
774   /* read the data if we can */
775   filedata = (const UINT8 *)core_fbuffer(file->file);
776   if (filedata == NULL)
777      return file->hash;
778
779   /* compute the hash */
780   hash_compute(file->hash, filedata, core_fsize(file->file), wehave | functions);
781   return file->hash;
782}
783
784
785
786/***************************************************************************
787    PATH ITERATION
788***************************************************************************/
789
790/*-------------------------------------------------
791    path_iterator_init - prepare to iterate over
792    a given path type
793-------------------------------------------------*/
794
795static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath)
796{
797   /* reset the structure */
798   iterator->base = (searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(opts, searchpath) : "";
799   iterator->cur = iterator->base;
800   iterator->index = 0;
801}
802
803
804/*-------------------------------------------------
805    path_iterator_get_next - get the next entry
806    in a multipath sequence
807-------------------------------------------------*/
808
809static int path_iterator_get_next(path_iterator *iterator, astring &buffer)
810{
811   const char *semi;
812
813   /* if none left, return FALSE to indicate we are done */
814   if (iterator->index != 0 && *iterator->cur == 0)
815      return FALSE;
816
817   /* copy up to the next semicolon */
818   semi = strchr(iterator->cur, ';');
819   if (semi == NULL)
820      semi = iterator->cur + strlen(iterator->cur);
821   buffer.cpy(iterator->cur, semi - iterator->cur);
822   iterator->cur = (*semi == 0) ? semi : semi + 1;
823
824   /* bump the index and return TRUE */
825   iterator->index++;
826   return TRUE;
827}
828
829
830
831/***************************************************************************
832    MISC HELPERS
833***************************************************************************/
834
835/*-------------------------------------------------
836    load_zipped_file - load a ZIPped file
837-------------------------------------------------*/
838
839static file_error load_zipped_file(mame_file *file)
840{
841   file_error filerr;
842   zip_error ziperr;
843
844   assert(file->file == NULL);
845   assert(file->zipdata == NULL);
846   assert(file->zipfile != NULL);
847
848   /* allocate some memory */
849   file->zipdata = global_alloc_array(UINT8, file->ziplength);
850
851   /* read the data into our buffer and return */
852   ziperr = zip_file_decompress(file->zipfile, file->zipdata, file->ziplength);
685   // read the data into our buffer and return
686   zip_error ziperr = zip_file_decompress(m_zipfile, m_zipdata, m_ziplength);
853687   if (ziperr != ZIPERR_NONE)
854688   {
855      global_free(file->zipdata);
856      file->zipdata = NULL;
689      global_free(m_zipdata);
690      m_zipdata = NULL;
857691      return FILERR_FAILURE;
858692   }
859693
860   /* convert to RAM file */
861   filerr = core_fopen_ram(file->zipdata, file->ziplength, file->openflags, &file->file);
694   // convert to RAM file
695   file_error filerr = core_fopen_ram(m_zipdata, m_ziplength, m_openflags, &m_file);
862696   if (filerr != FILERR_NONE)
863697   {
864      global_free(file->zipdata);
865      file->zipdata = NULL;
698      global_free(m_zipdata);
699      m_zipdata = NULL;
866700      return FILERR_FAILURE;
867701   }
868702
869   /* close out the ZIP file */
870   zip_file_close(file->zipfile);
871   file->zipfile = NULL;
703   // close out the ZIP file
704   zip_file_close(m_zipfile);
705   m_zipfile = NULL;
872706   return FILERR_NONE;
873707}
874708
875709
876/*-------------------------------------------------
877    zip_filename_match - compare zip filename
878    to expected filename, ignoring any directory
879-------------------------------------------------*/
710//-------------------------------------------------
711//  zip_filename_match - compare zip filename
712//  to expected filename, ignoring any directory
713//-------------------------------------------------
880714
881static int zip_filename_match(const zip_file_header *header, const astring &filename)
715bool emu_file::zip_filename_match(const zip_file_header &header, const astring &filename)
882716{
883   const char *zipfile = header->filename + header->filename_length - filename.len();
884
885   return (zipfile >= header->filename && filename.icmp(zipfile) == 0 &&
886      (zipfile == header->filename || zipfile[-1] == '/'));
717   const char *zipfile = header.filename + header.filename_length - filename.len();
718   return (zipfile >= header.filename && filename.icmp(zipfile) == 0 && (zipfile == header.filename || zipfile[-1] == '/'));
887719}
888720
889/*-------------------------------------------------
890    zip_header_is_path - check whether filename
891                         in header is a path
892  -------------------------------------------------*/
893721
894static int zip_header_is_path(const zip_file_header *header)
895{
896   const char *zipfile = header->filename + header->filename_length - 1;
722//-------------------------------------------------
723//  zip_header_is_path - check whether filename
724//  in header is a path
725//-------------------------------------------------
897726
898   return (zipfile >= header->filename && zipfile[0] == '/');
727bool emu_file::zip_header_is_path(const zip_file_header &header)
728{
729   const char *zipfile = header.filename + header.filename_length - 1;
730   return (zipfile >= header.filename && zipfile[0] == '/');
899731}
src/emu/fileio.h
r10384r10385
44
55    Core file I/O interface functions and definitions.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1038***************************************************************************/
1139
1240#pragma once
r10384r10385
1543#define __FILEIO_H__
1644
1745#include "corefile.h"
46#include "hash.h"
1847
1948
2049
21/***************************************************************************
22    CONSTANTS
23***************************************************************************/
50//**************************************************************************
51//  CONSTANTS
52//**************************************************************************
2453
25/* search paths */
54// search paths
2655#define SEARCHPATH_RAW             NULL
2756#define SEARCHPATH_LANGUAGE        NULL
2857#define SEARCHPATH_DEBUGLOG        NULL
r10384r10385
5079
5180
5281
53/***************************************************************************
54    TYPE DEFINITIONS
55***************************************************************************/
82//**************************************************************************
83//  TYPE DEFINITIONS
84//**************************************************************************
5685
57typedef struct _mame_file mame_file;
58typedef struct _mame_path mame_path;
59
86// forward declarations
6087typedef struct _core_options core_options;
88typedef struct _zip_file_header zip_file_header;
89typedef struct _zip_file zip_file;
6190
6291
92// ======================> path_iterator
6393
64/***************************************************************************
65    FUNCTION PROTOTYPES
66***************************************************************************/
94// helper class for iterating over configured paths
95class path_iterator
96{
97public:
98   // construction/destruction
99   path_iterator(core_options &options, const char *searchpath = "");
100   
101   // getters
102   bool next(astring &buffer);
103   
104   // reset
105   void reset() { m_current = m_base; m_index = 0; }
67106
107private:
108   // internal state
109   const char *   m_base;
110   const char *   m_current;
111   int            m_index;
112};
68113
69/* ----- core initialization ----- */
70114
71/* initialize the fileio system */
72void fileio_init(running_machine *machine);
73115
116// ======================> file_enumerator
74117
118// iterate over all files in all paths specified in the searchpath
119class file_enumerator
120{
121public:
122   // construction/destruction
123   file_enumerator(core_options &opts, const char *searchpath);
124   ~file_enumerator();
75125
76/* ----- file open/close ----- */
126   // iterator
127   const osd_directory_entry *next();
77128
78/* open a file in the given search path with the specified filename */
79file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file);
129private:
130   // internal state
131   path_iterator   m_iterator;
132   osd_directory *   m_curdir;
133   astring         m_pathbuffer;
134   int            m_buflen;
135};
80136
81/* open a file in the given search path with the specified filename or a matching CRC */
82file_error mame_fopen_crc(const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file);
83137
84/* open a file in the given search path with the specified filename, using the specified options */
85file_error mame_fopen_options(core_options *opts, const char *searchpath, const char *filename, UINT32 openflags, mame_file **file);
86138
87/* open a file in the given search path with the specified filename or a matching CRC, using the specified options */
88file_error mame_fopen_crc_options(core_options *opts, const char *searchpath, const char *filename, UINT32 crc, UINT32 openflags, mame_file **file);
139// ======================> emu_file
89140
90/* open a "file" which is actually data in RAM */
91file_error mame_fopen_ram(const void *data, UINT32 length, UINT32 openflags, mame_file **file);
141class emu_file
142{
143public:
144   // file open/creation
145   emu_file(core_options &options, const char *searchpath, UINT32 openflags);
146   virtual ~emu_file();
92147
93/* close an open file */
94void mame_fclose(mame_file *file);
148   // getters   
149   operator core_file *();
150   bool open() const { return (m_file != NULL); }
151   const char *filename() const { return m_filename; }
152   const char *fullpath() const { return m_fullpath; }
153   UINT32 openflags() const { return m_openflags; }
154   const char *hash_string(UINT32 functions);
95155
96/* close an open file, and open the next entry in the original searchpath*/
97file_error mame_fclose_and_open_next(mame_file **file, const char *filename, UINT32 openflags);
156   // setters
157   void remove_on_close() { m_remove_on_close = true; }
158   void set_openflags(UINT32 openflags) { assert(m_file == NULL); m_openflags = openflags; }
98159
99/* enable/disable streaming file compression via zlib; level is 0 to disable compression, or up to 9 for max compression */
100file_error mame_fcompress(mame_file *file, int compress);
160   // open/close
161   file_error open(const char *name);
162   file_error open(const char *name1, const char *name2);
163   file_error open(const char *name1, const char *name2, const char *name3);
164   file_error open(const char *name1, const char *name2, const char *name3, const char *name4);
165   file_error open(const char *name, UINT32 crc);
166   file_error open(const char *name1, const char *name2, UINT32 crc);
167   file_error open(const char *name1, const char *name2, const char *name3, UINT32 crc);
168   file_error open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc);
169   file_error open_next();
170   file_error open_ram(const void *data, UINT32 length);
171   void close();
172   
173   // control
174   file_error compress(int compress);
175   int seek(INT64 offset, int whence);
176   UINT64 tell();
177   bool eof();
178   UINT64 size();
179   
180   // reading
181   UINT32 read(void *buffer, UINT32 length);
182   int getc();
183   int ungetc(int c);
184   char *gets(char *s, int n);
185   
186   // writing
187   UINT32 write(const void *buffer, UINT32 length);
188   int puts(const char *s);
189   int vprintf(const char *fmt, va_list va);
190   int printf(const char *fmt, ...);
191   
192private:
193   // internal helpers
194   file_error attempt_zipped();
195   file_error load_zipped_file();
196   bool zip_filename_match(const zip_file_header &header, const astring &filename);
197   bool zip_header_is_path(const zip_file_header &header);
198   
199   // internal state
200   astring         m_filename;                  // original filename provided
201   astring         m_fullpath;                  // full filename
202   core_file *      m_file;                     // core file pointer
203   path_iterator   m_iterator;                  // iterator for paths
204   UINT32         m_crc;                     // iterator for paths
205   UINT32         m_openflags;               // flags we used for the open
206   char         m_hash[HASH_BUF_SIZE];         // hash data for the file
207   zip_file *      m_zipfile;                  // ZIP file pointer
208   UINT8 *         m_zipdata;                  // ZIP file data
209   UINT64         m_ziplength;               // ZIP file length
210   bool         m_remove_on_close;            // flag: remove the file when closing
211};
101212
102213
103
104/* ----- file positioning ----- */
105
106/* adjust the file pointer within the file */
107int mame_fseek(mame_file *file, INT64 offset, int whence);
108
109/* return the current file pointer */
110UINT64 mame_ftell(mame_file *file);
111
112/* return true if we are at the EOF */
113int mame_feof(mame_file *file);
114
115/* return the total size of the file */
116UINT64 mame_fsize(mame_file *file);
117
118
119
120/* ----- file read ----- */
121
122/* standard binary read from a file */
123UINT32 mame_fread(mame_file *file, void *buffer, UINT32 length);
124
125/* read one character from the file */
126int mame_fgetc(mame_file *file);
127
128/* put back one character from the file */
129int mame_ungetc(int c, mame_file *file);
130
131/* read a full line of text from the file */
132char *mame_fgets(char *s, int n, mame_file *file);
133
134
135
136/* ----- file write ----- */
137
138/* standard binary write to a file */
139UINT32 mame_fwrite(mame_file *file, const void *buffer, UINT32 length);
140
141/* write a line of text to the file */
142int mame_fputs(mame_file *f, const char *s);
143
144/* printf-style text write to a file */
145int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...) ATTR_PRINTF(2,3);
146
147
148
149/* ----- file enumeration ----- */
150
151/* open a search path (multiple directories) for iteration */
152mame_path *mame_openpath(core_options *opts, const char *searchpath);
153
154/* return information about the next file in the search path */
155const osd_directory_entry *mame_readpath(mame_path *path);
156
157/* close an open seach path */
158void mame_closepath(mame_path *path);
159
160
161
162/* ----- file misc ----- */
163
164/* return the core_file underneath the mame_file */
165core_file *mame_core_file(mame_file *file);
166
167/* return the full filename for a given mame_file */
168const astring &mame_file_full_name(mame_file *file);
169
170/* return a hash string for the file with the given functions */
171const char *mame_fhash(mame_file *file, UINT32 functions);
172
173
174
175214#endif   /* __FILEIO_H__ */
src/emu/timer.c
r10384r10385
200200//  configuration
201201//-------------------------------------------------
202202
203bool timer_device_config::device_validity_check(const game_driver &driver) const
203bool timer_device_config::device_validity_check(core_options &options, const game_driver &driver) const
204204{
205205   bool error = false;
206206
src/emu/dimemory.c
r10384r10385
164164//  checks on the memory configuration
165165//-------------------------------------------------
166166
167bool device_config_memory_interface::interface_validity_check(const game_driver &driver) const
167bool device_config_memory_interface::interface_validity_check(core_options &options, const game_driver &driver) const
168168{
169169   const device_config *devconfig = crosscast<const device_config *>(this);
170170   bool detected_overlap = DETECT_OVERLAPPING_MEMORY ? false : true;
src/emu/timer.h
r10384r10385
128128
129129private:
130130   // device_config overrides
131   virtual bool device_validity_check(const game_driver &driver) const;
131   virtual bool device_validity_check(core_options &options, const game_driver &driver) const;
132132
133133   // timer types
134134   enum timer_type
src/emu/mconfig.h
r10384r10385
8484
8585
8686#define NVRAM_HANDLER_NAME(name)   nvram_handler_##name
87#define NVRAM_HANDLER(name)         void NVRAM_HANDLER_NAME(name)(running_machine *machine, mame_file *file, int read_or_write)
87#define NVRAM_HANDLER(name)         void NVRAM_HANDLER_NAME(name)(running_machine *machine, emu_file *file, int read_or_write)
8888#define NVRAM_HANDLER_CALL(name)   NVRAM_HANDLER_NAME(name)(machine, file, read_or_write)
8989
9090#define MEMCARD_HANDLER_NAME(name)   memcard_handler_##name
91#define MEMCARD_HANDLER(name)      void MEMCARD_HANDLER_NAME(name)(running_machine *machine, mame_file *file, int action)
91#define MEMCARD_HANDLER(name)      void MEMCARD_HANDLER_NAME(name)(running_machine *machine, emu_file &file, int action)
9292#define MEMCARD_HANDLER_CALL(name)   MEMCARD_HANDLER_NAME(name)(machine, file, action)
9393
9494
r10384r10385
110110
111111
112112// various callback functions
113typedef void   (*nvram_handler_func)(running_machine *machine, mame_file *file, int read_or_write);
114typedef void   (*memcard_handler_func)(running_machine *machine, mame_file *file, int action);
113typedef void   (*nvram_handler_func)(running_machine *machine, emu_file *file, int read_or_write);
114typedef void   (*memcard_handler_func)(running_machine *machine, emu_file &file, int action);
115115
116116
117117
src/emu/dimemory.h
r10384r10385
123123   virtual const address_space_config *memory_space_config(int spacenum) const = 0;
124124
125125   // optional operation overrides
126   virtual bool interface_validity_check(const game_driver &driver) const;
126   virtual bool interface_validity_check(core_options &options, const game_driver &driver) const;
127127
128128   address_map_constructor   m_address_map[ADDRESS_SPACES]; // address maps for each address space
129129};
src/mess/devices/sonydriv.c
r10384r10385
7171typedef struct
7272{
7373   device_t *img;
74   mame_file *fd;
74   emu_file *fd;
7575
7676   unsigned int ext_speed_control : 1;   /* is motor rotation controlled by external device ? */
7777
src/mess/devices/aescart.c
r10384r10385
617617   /* This line requires that cartslot_t be included in cartslot.h,
618618    otherwise one cannot make use of multicart handling within such a
619619    custom LOAD function. */
620   me = multicart_open(image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
620   me = multicart_open(image.device().machine->options(), image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
621621
622622   /* Now that we have loaded the image files, let the PCB put them all
623623    together. This means we put the images in a structure which allows
r10384r10385
660660
661661         /* Close the multicart; all RAM resources will be
662662               written to disk */
663         multicart_close(cart->mc);
663         multicart_close(pcbdev->machine->options(), cart->mc);
664664         cart->mc = NULL;
665665      }
666666//      else
src/mess/tools/messdocs/messdocs.c
r10384r10385
4040
4141
4242//============================================================
43//  win_error_to_mame_file_error
43//  win_error_to_emu_file_error
4444//============================================================
4545
46static file_error win_error_to_mame_file_error(DWORD error)
46static file_error win_error_to_emu_file_error(DWORD error)
4747{
4848   file_error filerr;
4949
r10384r10385
104104
105105   if (!CreateDirectory(tempstr, NULL))
106106   {
107      filerr = win_error_to_mame_file_error(GetLastError());
107      filerr = win_error_to_emu_file_error(GetLastError());
108108      goto done;
109109   }
110110
r10384r10385
132132
133133   if (!RemoveDirectory(tempstr))
134134   {
135      filerr = win_error_to_mame_file_error(GetLastError());
135      filerr = win_error_to_emu_file_error(GetLastError());
136136      goto done;
137137   }
138138
r10384r10385
151151{
152152   // wrapper for win_copy_file_utf8()
153153   if (!win_copy_file_utf8(srcfile, destfile, TRUE))
154      return win_error_to_mame_file_error(GetLastError());
154      return win_error_to_emu_file_error(GetLastError());
155155
156156   return FILERR_NONE;
157157}
src/mess/tools/castool/stubs.c
r10384r10385
2424/* ----------------------------------------------------------------------- */
2525/* total hack */
2626
27file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
27file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, emu_file **file)
2828{
2929   char buffer[2048];
3030   snprintf(buffer, sizeof(buffer), "crc/%s", filename);
31   *file = (mame_file *) fopen(buffer, "r");
31   *file = (emu_file *) fopen(buffer, "r");
3232   return FILERR_NONE;
3333}
3434
35char *mame_fgets(char *s, int n, mame_file *file)
35char *mame_fgets(char *s, int n, emu_file *file)
3636{
3737   return fgets(s, n, (FILE *) file);
3838}
3939
40UINT32 mame_fwrite(mame_file *file, const void *buffer, UINT32 length)
40UINT32 mame_fwrite(emu_file *file, const void *buffer, UINT32 length)
4141{
4242   return fwrite(buffer, 1, length, (FILE *) file);
4343}
4444
45void mame_fclose(mame_file *file)
45void mame_fclose(emu_file *file)
4646{
4747   fclose((FILE *) file);
4848}
4949
50int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...)
50int CLIB_DECL mame_fprintf(emu_file *f, const char *fmt, ...)
5151{
5252   int rc;
5353   va_list va;
src/mess/tools/messtest/testmess.c
r10384r10385
210210static void dump_screenshot(running_machine *machine, int write_file)
211211{
212212   file_error filerr;
213   mame_file *fp;
213   emu_file *fp;
214214   char buf[128];
215215   int is_blank = 0;
216216
src/mess/tools/imgtool/stubs.c
r10384r10385
2525/* ----------------------------------------------------------------------- */
2626/* total hack */
2727
28file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, mame_file **file)
28file_error mame_fopen(const char *searchpath, const char *filename, UINT32 openflags, emu_file **file)
2929{
3030   char buffer[2048];
3131   snprintf(buffer, sizeof(buffer), "crc/%s", filename);
32   *file = (mame_file *) fopen(buffer, "r");
32   *file = (emu_file *) fopen(buffer, "r");
3333   return FILERR_NONE;
3434}
3535
36char *mame_fgets(char *s, int n, mame_file *file)
36char *mame_fgets(char *s, int n, emu_file *file)
3737{
3838   return fgets(s, n, (FILE *) file);
3939}
4040
41UINT32 mame_fwrite(mame_file *file, const void *buffer, UINT32 length)
41UINT32 mame_fwrite(emu_file *file, const void *buffer, UINT32 length)
4242{
4343   return fwrite(buffer, 1, length, (FILE *) file);
4444}
4545
46void mame_fclose(mame_file *file)
46void mame_fclose(emu_file *file)
4747{
4848   fclose((FILE *) file);
4949}
5050
51int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...)
51int CLIB_DECL mame_fprintf(emu_file *f, const char *fmt, ...)
5252{
5353   int rc;
5454   va_list va;
src/mess/tools/imgtool/windows/wimgtool.c
r10384r10385
897897}
898898
899899//============================================================
900//  win_error_to_mame_file_error
900//  win_error_to_emu_file_error
901901//============================================================
902902
903static file_error win_error_to_mame_file_error(DWORD error)
903static file_error win_error_to_emu_file_error(DWORD error)
904904{
905905   file_error filerr;
906906
r10384r10385
952952
953953   if (!CreateDirectory(tempstr, NULL))
954954   {
955      filerr = win_error_to_mame_file_error(GetLastError());
955      filerr = win_error_to_emu_file_error(GetLastError());
956956      goto done;
957957   }
958958
src/mess/machine/strata.c
r10384r10385
123123/*
124124    load the FEEPROM contents from file
125125*/
126int strataflash_load(device_t *device, mame_file *file)
126int strataflash_load(device_t *device, emu_file *file)
127127{
128128   strata_t *strata = get_safe_token(device);
129129   UINT8 buf;
130130   int i;
131131
132132   /* version flag */
133   if (mame_fread(file, & buf, 1) != 1)
133   if (file->read(& buf, 1) != 1)
134134      return 1;
135135   if (buf != 0)
136136      return 1;
137137
138138   /* chip state: master lock */
139   if (mame_fread(file, & buf, 1) != 1)
139   if (file->read(& buf, 1) != 1)
140140      return 1;
141141   strata->master_lock = buf & 1;
142142
143143   /* main FEEPROM area */
144   if (mame_fread(file, strata->data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
144   if (file->read(strata->data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
145145      return 1;
146146   for (i = 0; i < FEEPROM_SIZE; i += 2)
147147   {
r10384r10385
150150   }
151151
152152   /* protection registers */
153   if (mame_fread(file, strata->prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
153   if (file->read(strata->prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
154154      return 1;
155155   for (i = 0; i < PROT_REGS_SIZE; i += 2)
156156   {
r10384r10385
159159   }
160160
161161   /* block lock flags */
162   if (mame_fread(file, strata->blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
162   if (file->read(strata->blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
163163      return 1;
164164
165165   return 0;
r10384r10385
168168/*
169169    save the FEEPROM contents to file
170170*/
171int strataflash_save(device_t *device, mame_file *file)
171int strataflash_save(device_t *device, emu_file *file)
172172{
173173   strata_t *strata = get_safe_token(device);
174174   UINT8 buf;
r10384r10385
176176
177177   /* version flag */
178178   buf = 0;
179   if (mame_fwrite(file, & buf, 1) != 1)
179   if (file->write(& buf, 1) != 1)
180180      return 1;
181181
182182   /* chip state: lower boot block lockout, higher boot block lockout,
183183    software data protect */
184184   buf = strata->master_lock;
185   if (mame_fwrite(file, & buf, 1) != 1)
185   if (file->write(& buf, 1) != 1)
186186      return 1;
187187
188188   /* main FEEPROM area */
r10384r10385
191191      UINT16 *ptr = (UINT16 *) (&strata->data_ptr[i]);
192192      *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
193193   }
194   if (mame_fwrite(file, strata->data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
194   if (file->write(strata->data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
195195      return 1;
196196   for (i = 0; i < FEEPROM_SIZE; i += 2)
197197   {
r10384r10385
205205      UINT16 *ptr = (UINT16 *) (&strata->prot_regs[i]);
206206      *ptr = LITTLE_ENDIANIZE_INT16(*ptr);
207207   }
208   if (mame_fwrite(file, strata->prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
208   if (file->write(strata->prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE)
209209      return 1;
210210   for (i = 0; i < PROT_REGS_SIZE; i += 2)
211211   {
r10384r10385
214214   }
215215
216216   /* block lock flags */
217   if (mame_fwrite(file, strata->blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
217   if (file->write(strata->blocklock, BLOCKLOCK_SIZE) != BLOCKLOCK_SIZE)
218218      return 1;
219219
220220   return 0;
src/mess/machine/strata.h
r10384r10385
77#define MCFG_STRATAFLASH_ADD(_tag) \
88   MCFG_DEVICE_ADD(_tag, STRATAFLASH, 0)
99
10int strataflash_load(device_t *device, mame_file *file);
11int strataflash_save(device_t *device, mame_file *file);
10int strataflash_load(device_t *device, emu_file *file);
11int strataflash_save(device_t *device, emu_file *file);
1212UINT8 strataflash_8_r(device_t *device, UINT32 address);
1313void strataflash_8_w(device_t *device, UINT32 address, UINT8 data);
1414UINT16 strataflash_16_r(device_t *device, offs_t offset);
src/mess/machine/at45dbxx.c
r10384r10385
377377   flash->pin.sck = data;
378378}
379379
380void at45dbxx_load(device_t *device, mame_file *file)
380void at45dbxx_load(device_t *device, emu_file *file)
381381{
382382   at45dbxx_t *flash = get_token(device);
383383   _logerror( 0, ("at45dbxx_load (%p)\n", file));
384   mame_fread( file, flash->data, flash->size);
384   file->read(flash->data, flash->size);
385385}
386386
387void at45dbxx_save(device_t *device, mame_file *file)
387void at45dbxx_save(device_t *device, emu_file *file)
388388{
389389   at45dbxx_t *flash = get_token(device);
390390   _logerror( 0, ("at45dbxx_save (%p)\n", file));
391   mame_fwrite( file, flash->data, flash->size);
391   file->write(flash->data, flash->size);
392392}
393393
394394#ifdef UNUSED_FUNCTION
src/mess/machine/at45dbxx.h
r10384r10385
4646int  at45dbxx_pin_so(device_t *device);
4747
4848// load/save
49void at45dbxx_load(device_t *device, mame_file *file);
50void at45dbxx_save(device_t *device, mame_file *file);
49void at45dbxx_load(device_t *device, emu_file *file);
50void at45dbxx_save(device_t *device, emu_file *file);
5151
5252// non-volatile ram handler
5353//NVRAM_HANDLER( at45dbxx );
src/mess/machine/msx_slot.c
r10384r10385
746746
747747MSX_SLOT_LOADSRAM(ascii8_sram)
748748{
749   file_error filerr;
750   mame_file *f;
751
752749   if (!state->sramfile)
753750   {
754751      logerror ("ascii8_sram: error: no sram filename provided\n");
755752      return 1;
756753   }
757
758   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
754   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
755   file_error filerr = f.open(state->sramfile);
759756   if (filerr == FILERR_NONE)
760757   {
761      if (mame_fread (f, state->cart.sram.mem, 0x2000) == 0x2000)
758      if (f.read(state->cart.sram.mem, 0x2000) == 0x2000)
762759      {
763         mame_fclose (f);
764760         logerror ("ascii8_sram: info: sram loaded\n");
765761         return 0;
766762      }
767      mame_fclose (f);
768763      memset (state->cart.sram.mem, 0, 0x2000);
769764      logerror ("ascii8_sram: warning: could not read sram file\n");
770765      return 1;
r10384r10385
777772
778773MSX_SLOT_SAVESRAM(ascii8_sram)
779774{
780   file_error filerr;
781   mame_file *f;
782
783775   if (!state->sramfile)
784776   {
785777      return 0;
786778   }
787779
788   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_WRITE, &f);
780   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE);
781   file_error filerr = f.open(state->sramfile);
789782   if (filerr == FILERR_NONE)
790783   {
791      mame_fwrite (f, state->cart.sram.mem, 0x2000);
792      mame_fclose (f);
784      f.write(state->cart.sram.mem, 0x2000);
793785      logerror ("ascii8_sram: info: sram saved\n");
794786
795787      return 0;
r10384r10385
921913
922914MSX_SLOT_LOADSRAM(ascii16_sram)
923915{
924   file_error filerr;
925   mame_file *f;
926916   UINT8 *p;
927917
928918   if (!state->sramfile)
r10384r10385
931921      return 1;
932922   }
933923
934   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
924   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
925   file_error filerr = f.open(state->sramfile);
935926   if (filerr == FILERR_NONE)
936927   {
937928      p = state->cart.sram.mem;
938929
939      if (mame_fread (f, state->cart.sram.mem, 0x200) == 0x200)
930      if (f.read(state->cart.sram.mem, 0x200) == 0x200)
940931      {
941932         int /*offset,*/ i;
942
943         mame_fclose (f);
944
945933         //offset = 0;
946934         for (i=0; i<7; i++)
947935         {
r10384r10385
952940         logerror ("ascii16_sram: info: sram loaded\n");
953941         return 0;
954942      }
955      mame_fclose (f);
956943      memset (state->cart.sram.mem, 0, 0x4000);
957944      logerror ("ascii16_sram: warning: could not read sram file\n");
958945      return 1;
r10384r10385
965952
966953MSX_SLOT_SAVESRAM(ascii16_sram)
967954{
968   file_error filerr;
969   mame_file *f;
970
971955   if (!state->sramfile)
972956   {
973957      return 0;
974958   }
975
976   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_WRITE, &f);
959   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE);
960   file_error filerr = f.open(state->sramfile);
977961   if (filerr == FILERR_NONE)
978962   {
979      mame_fwrite (f, state->cart.sram.mem, 0x200);
980      mame_fclose (f);
963      f.write(state->cart.sram.mem, 0x200);
981964      logerror ("ascii16_sram: info: sram saved\n");
982965
983966      return 0;
r10384r10385
12071190
12081191MSX_SLOT_LOADSRAM(gmaster2)
12091192{
1210   file_error filerr;
1211   mame_file *f;
12121193   UINT8 *p;
12131194
12141195   p = state->cart.sram.mem;
1215   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
1196   
1197   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
1198   file_error filerr = f.open(state->sramfile);
12161199   if (filerr == FILERR_NONE)
12171200   {
1218      if (mame_fread (f, p + 0x1000, 0x2000) == 0x2000)
1201      if (f.read(p + 0x1000, 0x2000) == 0x2000)
12191202      {
12201203         memcpy (p, p + 0x1000, 0x1000);
12211204         memcpy (p + 0x3000, p + 0x2000, 0x1000);
1222         mame_fclose (f);
12231205         logerror ("gmaster2: info: sram loaded\n");
12241206         return 0;
12251207      }
1226      mame_fclose (f);
12271208      memset (p, 0, 0x4000);
12281209      logerror ("gmaster2: warning: could not read sram file\n");
12291210      return 1;
r10384r10385
12361217
12371218MSX_SLOT_SAVESRAM(gmaster2)
12381219{
1239   file_error filerr;
1240   mame_file *f;
1241
1242   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_WRITE, &f);
1220   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE);
1221   file_error filerr = f.open(state->sramfile);
12431222   if (filerr == FILERR_NONE)
12441223   {
1245      mame_fwrite (f, state->cart.sram.mem + 0x1000, 0x2000);
1246      mame_fclose (f);
1224      f.write(state->cart.sram.mem + 0x1000, 0x2000);
12471225      logerror ("gmaster2: info: sram saved\n");
12481226
12491227      return 0;
r10384r10385
17821760
17831761MSX_SLOT_LOADSRAM(fmpac)
17841762{
1785   file_error filerr;
1786   mame_file *f;
17871763   char buf[PAC_HEADER_LEN];
17881764
17891765   if (!state->cart.fmpac.sram_support)
r10384r10385
17971773      logerror ("No sram filename provided\n");
17981774      return 1;
17991775   }
1800
1801   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_READ, &f);
1776   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_READ);
1777   file_error filerr = f.open(state->sramfile);
18021778   if (filerr == FILERR_NONE)
18031779   {
1804      if ((mame_fread (f, buf, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
1780      if ((f.read(buf, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
18051781         !strncmp (buf, PAC_HEADER, PAC_HEADER_LEN) &&
1806         mame_fread (f, state->cart.fmpac.mem, 0x1ffe))
1782         f.read(state->cart.fmpac.mem, 0x1ffe))
18071783      {
18081784         logerror ("fmpac: info: sram loaded\n");
1809         mame_fclose (f);
18101785         return 0;
18111786      }
18121787      else
18131788      {
18141789         logerror ("fmpac: warning: failed to load sram\n");
1815         mame_fclose (f);
18161790         return 1;
18171791      }
18181792   }
r10384r10385
18231797
18241798MSX_SLOT_SAVESRAM(fmpac)
18251799{
1826   file_error filerr;
1827   mame_file *f;
1828
18291800   if (!state->cart.fmpac.sram_support || !state->sramfile)
18301801   {
18311802      return 0;
18321803   }
18331804
1834   filerr = mame_fopen(SEARCHPATH_MEMCARD, state->sramfile, OPEN_FLAG_WRITE, &f);
1805   emu_file f(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE);
1806   file_error filerr = f.open(state->sramfile);
18351807   if (filerr == FILERR_NONE)
18361808   {
1837      if ((mame_fwrite (f, PAC_HEADER, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
1838         (mame_fwrite (f, state->cart.fmpac.mem, 0x1ffe) == 0x1ffe))
1809      if ((f.write(PAC_HEADER, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
1810         (f.write(state->cart.fmpac.mem, 0x1ffe) == 0x1ffe))
18391811      {
18401812         logerror ("fmpac: info: sram saved\n");
1841         mame_fclose (f);
18421813         return 0;
18431814      }
18441815      else
18451816      {
18461817         logerror ("fmpac: warning: sram save to file failed\n");
1847         mame_fclose (f);
18481818         return 1;
18491819      }
18501820   }
src/mess/machine/pc1350.c
r10384r10385
9999
100100   if (read_or_write)
101101   {
102      mame_fwrite(file, cpu, 96);
103      mame_fwrite(file, ram, 0x5000);
102      file->write(cpu, 96);
103      file->write(ram, 0x5000);
104104   }
105105   else if (file)
106106   {
107      mame_fread(file, cpu, 96);
108      mame_fread(file, ram, 0x5000);
107      file->read(cpu, 96);
108      file->read(ram, 0x5000);
109109   }
110110   else
111111   {
src/mess/machine/ti99/gromport.c
r10384r10385
14821482      // This line requires that cartslot_t be included in cartslot.h,
14831483      // otherwise one cannot make use of multicart handling within such a
14841484      // custom LOAD function.
1485      multicart_open_error me = multicart_open(image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
1485      multicart_open_error me = multicart_open(image.device().machine->options(), image.filename(), image.device().machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
14861486
14871487      // Now that we have loaded the image files, let the PCB put them all
14881488      // together. This means we put the images in a structure which allows
r10384r10385
15301530
15311531         // Close the multicart; all RAM resources will be
15321532         // written to disk
1533         multicart_close(cart->mc);
1533         multicart_close(image.device().machine->options(),cart->mc);
15341534         cart->mc = NULL;
15351535
15361536      }
src/mess/machine/ti99/hsgpl.c
r10384r10385
625625   hsgpl_state *card = get_safe_token(device);
626626   astring *hsname = astring_assemble_3(astring_alloc(), device->machine->gamedrv->name, PATH_SEPARATOR, "hsgpl.nv");
627627   file_error filerr;
628   mame_file *nvfile;
629628
630629   if (read_or_write==0)
631630   {
632631      logerror("hsgpl: device nvram load %s\n", astring_c(hsname));
633632
634      filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(hsname), OPEN_FLAG_READ, &nvfile);
633      emu_file nvfile(device->machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_READ);
634      filerr = nvfile.open(astring_c(hsname));
635635      if (filerr != FILERR_NONE)
636636      {
637637         logerror("hsgpl: Could not restore NVRAM\n");
638638         return;
639639      }
640640
641      if (mame_fread(nvfile, card->flashrom, FLROMSIZE) != FLROMSIZE)
641      if (nvfile.read(card->flashrom, FLROMSIZE) != FLROMSIZE)
642642      {
643643         logerror("hsgpl: Error loading NVRAM; unexpected EOF\n");
644         mame_fclose(nvfile);
645644         return;
646645      }
647646
648647      if (card->flashrom[0] != NVVERSION)
649648      {
650649         logerror("hsgpl: Wrong NVRAM image version: %d\n", card->flashrom[0]);
651         mame_fclose(nvfile);
652650         return;
653651      }
654      mame_fclose(nvfile);
655652   }
656653   else
657654   {
r10384r10385
663660         at29c040a_is_dirty(card->gromb))
664661      {
665662         card->flashrom[0] = NVVERSION;
666         filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(hsname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &nvfile);
667
663         
664         emu_file nvfile(device->machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
665         filerr = nvfile.open(astring_c(hsname));
668666         if (filerr != FILERR_NONE)
669667         {
670668            logerror("hsgpl: Could not save NVRAM\n");
671669         }
672670         else
673671         {
674            if (mame_fwrite(nvfile, card->flashrom, FLROMSIZE) != FLROMSIZE)
672            if (nvfile.write(card->flashrom, FLROMSIZE) != FLROMSIZE)
675673            {
676674               logerror("hsgpl: Error while saving contents of NVRAM.\n");
677675            }
678676         }
679         mame_fclose(nvfile);
680677         return;
681678      }
682679      else
src/mess/machine/ti99/evpc.c
r10384r10385
375375   ti99_evpc_state *card = get_safe_token(device);
376376   astring *hsname = astring_assemble_3(astring_alloc(), device->machine->gamedrv->name, PATH_SEPARATOR, "evpc.nv");
377377   file_error filerr;
378   mame_file *nvfile;
379378
380379   if (read_or_write==0)
381380   {
382381      logerror("evpc: device nvram load %s\n", astring_c(hsname));
383382
384      filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(hsname), OPEN_FLAG_READ, &nvfile);
383      emu_file nvfile(device->machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_READ);
384      filerr = nvfile.open(astring_c(hsname));
385385      if (filerr == FILERR_NONE)
386386      {
387         if (mame_fread(nvfile, card->novram, 256) != 256)
387         if (nvfile.read(card->novram, 256) != 256)
388388            logerror("evpc: NOVRAM load error\n");
389         mame_fclose(nvfile);
390389      }
391390   }
392391   else
393392   {
394393      logerror("evpc: device nvram save %s\n", astring_c(hsname));
395      filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(hsname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &nvfile);
394      emu_file nvfile(device->machine->options(), SEARCHPATH_NVRAM, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
395      filerr = nvfile.open(astring_c(hsname));
396396
397397      if (filerr == FILERR_NONE)
398398      {
399         if (mame_fwrite(nvfile, card->novram, 256) != 256)
399         if (nvfile.write(card->novram, 256) != 256)
400400            logerror("evpc: NOVRAM save error\n");
401         mame_fclose(nvfile);
402401      }
403402   }
404403}
src/mess/machine/tc8521.c
r10384r10385
182182    supplied file
183183-------------------------------------------------*/
184184
185void tc8521_load_stream(device_t *device, mame_file *file)
185void tc8521_load_stream(device_t *device, emu_file *file)
186186{
187187   tc8521_t *rtc = get_token(device);
188188
189189   if (file)
190190   {
191      mame_fread(file, &rtc->registers[0], sizeof(unsigned char)*16*4);
192      mame_fread(file, &rtc->alarm_outputs, sizeof(UINT32));
193      mame_fread(file, &rtc->thirty_two_hz_counter, sizeof(UINT32));
191      file->read(&rtc->registers[0], sizeof(unsigned char)*16*4);
192      file->read(&rtc->alarm_outputs, sizeof(UINT32));
193      file->read(&rtc->thirty_two_hz_counter, sizeof(UINT32));
194194   }
195195}
196196
r10384r10385
201201    supplied file
202202-------------------------------------------------*/
203203
204void tc8521_save_stream(device_t *device, mame_file *file)
204void tc8521_save_stream(device_t *device, emu_file *file)
205205{
206206   tc8521_t *rtc = get_token(device);
207207
208208   if (file)
209209   {
210      mame_fwrite(file, &rtc->registers[0], sizeof(unsigned char)*16*4);
211      mame_fwrite(file, &rtc->alarm_outputs, sizeof(UINT32));
212      mame_fwrite(file, &rtc->thirty_two_hz_counter, sizeof(UINT32));
210      file->write(&rtc->registers[0], sizeof(unsigned char)*16*4);
211      file->write(&rtc->alarm_outputs, sizeof(UINT32));
212      file->write(&rtc->thirty_two_hz_counter, sizeof(UINT32));
213213   }
214214}
215215
src/mess/machine/tc8521.h
r10384r10385
4747READ8_DEVICE_HANDLER(tc8521_r);
4848WRITE8_DEVICE_HANDLER(tc8521_w);
4949
50void tc8521_load_stream(device_t *device, mame_file *file);
51void tc8521_save_stream(device_t *device, mame_file *file);
50void tc8521_load_stream(device_t *device, emu_file *file);
51void tc8521_save_stream(device_t *device, emu_file *file);
5252
5353
5454#endif /* __TC8521_H__ */
src/mess/machine/sst39vfx.c
r10384r10385
137137   }
138138}
139139
140void sst39vfx_load(device_t *device, mame_file *file)
140void sst39vfx_load(device_t *device, emu_file *file)
141141{
142142   sst39vfx_t *flash = get_token(device);
143143
144144   _logerror( 0, ("sst39vfx_load (%p)\n", file));
145   mame_fread( file, flash->data, flash->size);
145   file->read(flash->data, flash->size);
146146   if (flash->swap) sst39vfx_swap(device);
147147}
148148
149void sst39vfx_save(device_t *device, mame_file *file)
149void sst39vfx_save(device_t *device, emu_file *file)
150150{
151151   sst39vfx_t *flash = get_token(device);
152152
153153   _logerror( 0, ("sst39vfx_save (%p)\n", file));
154154   if (flash->swap) sst39vfx_swap(device);
155   mame_fwrite( file, flash->data, flash->size);
155   file->write(flash->data, flash->size);
156156   if (flash->swap) sst39vfx_swap(device);
157157}
158158
src/mess/machine/sst39vfx.h
r10384r10385
6363#endif
6464
6565// load/save
66void sst39vfx_load(device_t *device, mame_file *file);
67void sst39vfx_save(device_t *device, mame_file *file);
66void sst39vfx_load(device_t *device, emu_file *file);
67void sst39vfx_save(device_t *device, emu_file *file);
6868
6969// non-volatile ram handler
7070//NVRAM_HANDLER( sst39vfx );
src/mess/machine/europc.c
r10384r10385
335335   }
336336}
337337
338static void europc_rtc_load_stream(mame_file *file)
338static void europc_rtc_load_stream(emu_file *file)
339339{
340   mame_fread(file, europc_rtc.data, sizeof(europc_rtc.data));
340   file->read(europc_rtc.data, sizeof(europc_rtc.data));
341341}
342342
343static void europc_rtc_save_stream(mame_file *file)
343static void europc_rtc_save_stream(emu_file *file)
344344{
345   mame_fwrite(file, europc_rtc.data, sizeof(europc_rtc.data));
345   file->write(europc_rtc.data, sizeof(europc_rtc.data));
346346}
347347
348348NVRAM_HANDLER( europc_rtc )
src/mess/machine/tandy1t.c
r10384r10385
3636   }
3737   else if (read_or_write)
3838   {
39      mame_fwrite(file, eeprom.ee, sizeof(eeprom.ee));
39      file->write(eeprom.ee, sizeof(eeprom.ee));
4040   }
4141   else
4242   {
43      mame_fread(file, eeprom.ee, sizeof(eeprom.ee));
43      file->read(eeprom.ee, sizeof(eeprom.ee));
4444   }
4545}
4646
src/mess/machine/ti85.c
r10384r10385
804804   ti85_state *state = machine->driver_data<ti85_state>();
805805   if (read_or_write)
806806   {
807      mame_fwrite(file, state->ti8x_ram, sizeof(unsigned char)*32*1024);
807      file->write(state->ti8x_ram, sizeof(unsigned char)*32*1024);
808808   }
809809   else
810810   {
811811         if (file)
812812         {
813            mame_fread(file, state->ti8x_ram, sizeof(unsigned char)*32*1024);
813            file->read(state->ti8x_ram, sizeof(unsigned char)*32*1024);
814814            cpu_set_reg(machine->device("maincpu"), Z80_PC,0x0c59);
815815         }
816816         else
r10384r10385
823823   ti85_state *state = machine->driver_data<ti85_state>();
824824   if (read_or_write)
825825   {
826      mame_fwrite(file, state->ti8x_ram, sizeof(unsigned char)*128*1024);
826      file->write(state->ti8x_ram, sizeof(unsigned char)*128*1024);
827827   }
828828   else
829829   {
830830         if (file)
831831         {
832            mame_fread(file, state->ti8x_ram, sizeof(unsigned char)*128*1024);
832            file->read(state->ti8x_ram, sizeof(unsigned char)*128*1024);
833833            cpu_set_reg(machine->device("maincpu"), Z80_PC,0x0c59);
834834         }
835835         else
src/mess/machine/wswan.c
r10384r10385
271271   if ( read_or_write )
272272   {
273273      /* Save the EEPROM data */
274      mame_fwrite( file, state->internal_eeprom, INTERNAL_EEPROM_SIZE );
274      file->write(state->internal_eeprom, INTERNAL_EEPROM_SIZE );
275275   }
276276   else
277277   {
278278      /* Load the EEPROM data */
279279      if ( file )
280280      {
281         mame_fread( file, state->internal_eeprom, INTERNAL_EEPROM_SIZE );
281         file->read(state->internal_eeprom, INTERNAL_EEPROM_SIZE );
282282      }
283283      else
284284      {
src/mess/machine/pc1401.c
r10384r10385
123123
124124   if (read_or_write)
125125   {
126      mame_fwrite(file, cpu, 96);
127      mame_fwrite(file, ram, 0x2800);
126      file->write(cpu, 96);
127      file->write(ram, 0x2800);
128128   }
129129   else if (file)
130130   {
131      mame_fread(file, cpu, 96);
132      mame_fread(file, ram, 0x2800);
131      file->read(cpu, 96);
132      file->read(ram, 0x2800);
133133   }
134134   else
135135   {
src/mess/machine/apple2gs.c
r10384r10385
242242   apple2gs_state *state = machine->driver_data<apple2gs_state>();
243243   if (read_or_write)
244244   {
245      mame_fwrite(file, state->clock_bram, sizeof(state->clock_bram));
245      file->write(state->clock_bram, sizeof(state->clock_bram));
246246   }
247247   else if (file)
248248   {
249      mame_fread(file, state->clock_bram, sizeof(state->clock_bram));
249      file->read(state->clock_bram, sizeof(state->clock_bram));
250250   }
251251   else
252252   {
src/mess/machine/mac.c
r10384r10385
13921392   {
13931393      if (LOG_RTC)
13941394         logerror("Writing PRAM to file\n");
1395      mame_fwrite(file, mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
1395      file->write(mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
13961396   }
13971397   else
13981398   {
r10384r10385
14001400      {
14011401         if (LOG_RTC)
14021402            logerror("Reading PRAM from file\n");
1403         mame_fread(file, mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
1403         file->read(mac->m_rtc_ram, sizeof(mac->m_rtc_ram));
14041404      }
14051405      else
14061406      {
src/mess/machine/pcf8593.c
r10384r10385
396396    pcf8593_load
397397-------------------------------------------------*/
398398
399void pcf8593_load(device_t *device, mame_file *file)
399void pcf8593_load(device_t *device, emu_file *file)
400400{
401401   pcf8593_t *rtc = get_token(device);
402402   system_time systime;
403403
404404   _logerror( 0, ("pcf8593_load (%p)\n", file));
405   mame_fread( file, rtc->data, sizeof(rtc->data));
405   file->read(rtc->data, sizeof(rtc->data));
406406   device->machine->current_datetime(systime);
407407   pcf8593_set_date(device, systime.local_time.year, systime.local_time.month + 1, systime.local_time.mday);
408408   pcf8593_set_time(device, systime.local_time.hour, systime.local_time.minute, systime.local_time.second);
r10384r10385
414414    pcf8593_save
415415-------------------------------------------------*/
416416
417void pcf8593_save(device_t *device, mame_file *file)
417void pcf8593_save(device_t *device, emu_file *file)
418418{
419419   pcf8593_t *rtc = get_token(device);
420420
421421   _logerror( 0, ("pcf8593_save (%p)\n", file));
422   mame_fwrite( file, rtc->data, sizeof(rtc->data));
422   file->write(rtc->data, sizeof(rtc->data));
423423}
424424
425425#ifdef UNUSED_FUNCTION
src/mess/machine/pcf8593.h
r10384r10385
3535int  pcf8593_pin_sda_r(device_t *device);
3636
3737/* load/save */
38void pcf8593_load(device_t *device, mame_file *file);
39void pcf8593_save(device_t *device, mame_file *file);
38void pcf8593_load(device_t *device, emu_file *file);
39void pcf8593_save(device_t *device, emu_file *file);
4040
4141#endif /* __PCF8593_H__ */
src/mess/machine/at29040.c
r10384r10385
140140/*
141141    load the contents of one FEEPROM file
142142*/
143int at29c040a_file_load(int id, mame_file *file)
143int at29c040a_file_load(int id, emu_file *file)
144144{
145145   UINT8 buf;
146146
147147   /* version flag */
148   if (mame_fread(file, & buf, 1) != 1)
148   if (file->read(& buf, 1) != 1)
149149      return 1;
150150   if (buf != 0)
151151      return 1;
152152
153153   /* chip state: lower boot block lockout, higher boot block lockout,
154154    software data protect */
155   if (mame_fread(file, & buf, 1) != 1)
155   if (file->read(& buf, 1) != 1)
156156      return 1;
157157   at29c040a[id].s_lower_bbl = (buf >> 2) & 1;
158158   at29c040a[id].s_higher_bbl = (buf >> 1) & 1;
159159   at29c040a[id].s_sdp = buf & 1;
160160
161161   /* data */
162   if (mame_fread(file, at29c040a[id].data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
162   if (file->read(at29c040a[id].data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
163163      return 1;
164164
165165   at29c040a[id].s_dirty = FALSE;
r10384r10385
170170/*
171171    save the FEEPROM contents to file
172172*/
173int at29c040a_file_save(int id, mame_file *file)
173int at29c040a_file_save(int id, emu_file *file)
174174{
175175   UINT8 buf;
176176
177177   /* version flag */
178178   buf = 0;
179   if (mame_fwrite(file, & buf, 1) != 1)
179   if (file->write(& buf, 1) != 1)
180180      return 1;
181181
182182   /* chip state: lower boot block lockout, higher boot block lockout,
183183    software data protect */
184184   buf = (at29c040a[id].s_lower_bbl << 2) | (at29c040a[id].s_higher_bbl << 1) | at29c040a[id].s_sdp;
185   if (mame_fwrite(file, & buf, 1) != 1)
185   if (file->write(& buf, 1) != 1)
186186      return 1;
187187
188188   /* data */
189   if (mame_fwrite(file, at29c040a[id].data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
189   if (file->write(at29c040a[id].data_ptr, FEEPROM_SIZE) != FEEPROM_SIZE)
190190      return 1;
191191
192192   return 0;
src/mess/machine/msx.c
r10384r10385
278278      return IMAGE_INIT_FAIL;
279279   }
280280   if (msx_slot_list[type].loadsram) {
281      msx_slot_list[type].loadsram (st);
281      msx_slot_list[type].loadsram (image.device().machine, st);
282282   }
283283
284284   state->cart_state[id] = st;
r10384r10385
306306
307307   if (msx_slot_list[state->cart_state[id]->type].savesram)
308308   {
309      msx_slot_list[state->cart_state[id]->type].savesram (state->cart_state[id]);
309      msx_slot_list[state->cart_state[id]->type].savesram (image.device().machine, state->cart_state[id]);
310310   }
311311}
312312
src/mess/machine/at29040.h
r10384r10385
11void at29c040a_init_data_ptr(int id, UINT8 *data_ptr);
22void at29c040a_init(running_machine *machine,int id);
3int at29c040a_file_load(int id, mame_file *file);
4int at29c040a_file_save(int id, mame_file *file);
3int at29c040a_file_load(int id, emu_file *file);
4int at29c040a_file_save(int id, emu_file *file);
55UINT8 at29c040a_r(int id, offs_t offset);
66void at29c040a_w(int id, offs_t offset, UINT8 data);
77int at29c040a_get_dirty_flag(int id);
src/mess/machine/lisa.c
r10384r10385
938938   lisa_state *state = machine->driver_data<lisa_state>();
939939   if (read_or_write)
940940   {
941      mame_fwrite(file, state->fdc_ram, 1024);
941      file->write(state->fdc_ram, 1024);
942942   }
943943   else
944944   {
945945      if (file)
946         mame_fread(file, state->fdc_ram, 1024);
946         file->read(state->fdc_ram, 1024);
947947      else
948948         memset(state->fdc_ram, 0, 1024);
949949
src/mess/machine/docg3.c
r10384r10385
813813
814814#if 0
815815
816static mame_file *nvram_system_fopen( running_machine *machine, UINT32 openflags, const char *name)
816static emu_file *nvram_system_fopen( running_machine *machine, UINT32 openflags, const char *name)
817817{
818818   astring *fname;
819819   file_error filerr;
820   mame_file *file;
820   emu_file *file;
821821   fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, name, ".nv");
822822   filerr = mame_fopen( SEARCHPATH_NVRAM, astring_c( fname), openflags, &file);
823823   astring_free( fname);
r10384r10385
826826
827827static void diskonchip_load( device_t *device, const char *name)
828828{
829   mame_file *file;
829   emu_file *file;
830830   file = nvram_system_fopen( device->machine, OPEN_FLAG_READ, name);
831831   device_nvram_diskonchip_g3( device, file, 0);
832832   if (file) mame_fclose( file);
r10384r10385
834834
835835static void diskonchip_save( device_t *device, const char *name)
836836{
837   mame_file *file;
837   emu_file *file;
838838   file = nvram_system_fopen( device->machine, OPEN_FLAG_CREATE | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE_PATHS, name);
839839   device_nvram_diskonchip_g3( device, file, 1);
840840   if (file) mame_fclose( file);
r10384r10385
901901   {
902902      if (file)
903903      {
904         mame_fwrite( file, doc->data[0], doc->data_size[0]);
905         mame_fwrite( file, doc->data[1], doc->data_size[1]);
906         mame_fwrite( file, doc->data[2], doc->data_size[2]);
904         file->write(doc->data[0], doc->data_size[0]);
905         file->write(doc->data[1], doc->data_size[1]);
906         file->write(doc->data[2], doc->data_size[2]);
907907      }
908908   }
909909   else
910910   {
911911      if (file)
912912      {
913         mame_fread( file, doc->data[0], doc->data_size[0]);
914         mame_fread( file, doc->data[1], doc->data_size[1]);
915         mame_fread( file, doc->data[2], doc->data_size[2]);
913         file->read(doc->data[0], doc->data_size[0]);
914         file->read(doc->data[1], doc->data_size[1]);
915         file->read(doc->data[2], doc->data_size[2]);
916916      }
917917      else
918918      {
src/mess/machine/pc1403.c
r10384r10385
151151
152152   if (read_or_write)
153153   {
154      mame_fwrite(file, cpu, 96);
155      mame_fwrite(file, ram, 0x8000);
154      file->write(cpu, 96);
155      file->write(ram, 0x8000);
156156   }
157157   else if (file)
158158   {
159      mame_fread(file, cpu, 96);
160      mame_fread(file, ram, 0x8000);
159      file->read(cpu, 96);
160      file->read(ram, 0x8000);
161161   }
162162   else
163163   {
src/mess/machine/cybiko.c
r10384r10385
137137// MACHINE START //
138138///////////////////
139139
140static mame_file *nvram_system_fopen( running_machine *machine, UINT32 openflags, const char *name)
140static emu_file *nvram_system_fopen( running_machine *machine, UINT32 openflags, const char *name)
141141{
142   astring *fname;
143142   file_error filerr;
144   mame_file *file;
145   fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, name, ".nv");
146   filerr = mame_fopen( SEARCHPATH_NVRAM, astring_c( fname), openflags, &file);
143   astring *fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, name, ".nv");   
144   emu_file *file = global_alloc(emu_file(machine->options(), SEARCHPATH_NVRAM, openflags));
145   filerr = file->open(astring_c( fname));   
147146   astring_free( fname);
148147   return (filerr == FILERR_NONE) ? file : NULL;
149148}
150149
151typedef void (nvram_load_func)(running_machine *machine, mame_file *file);
150typedef void (nvram_load_func)(running_machine *machine, emu_file *file);
152151
153152static int nvram_system_load( running_machine *machine, const char *name, nvram_load_func _nvram_load, int required)
154153{
155   mame_file *file;
154   emu_file *file;
156155   file = nvram_system_fopen( machine, OPEN_FLAG_READ, name);
157156   if (!file)
158157   {
r10384r10385
160159      return FALSE;
161160   }
162161   (*_nvram_load)(machine, file);
163   mame_fclose( file);
162   global_free(file);
164163   return TRUE;
165164}
166165
167typedef void (nvram_save_func)(running_machine *machine, mame_file *file);
166typedef void (nvram_save_func)(running_machine *machine, emu_file *file);
168167
169168static int nvram_system_save( running_machine *machine, const char *name, nvram_save_func _nvram_save)
170169{
171   mame_file *file;
170   emu_file *file;
172171   file = nvram_system_fopen( machine, OPEN_FLAG_CREATE | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE_PATHS, name);
173172   if (!file)
174173   {
r10384r10385
176175      return FALSE;
177176   }
178177   (*_nvram_save)(machine, file);
179   mame_fclose( file);
178   global_free(file);
180179   return TRUE;
181180}
182181
183static void cybiko_pcf8593_load(running_machine *machine, mame_file *file)
182static void cybiko_pcf8593_load(running_machine *machine, emu_file *file)
184183{
185184   device_t *device = machine->device("rtc");
186185   pcf8593_load(device, file);
187186}
188187
189static void cybiko_pcf8593_save(running_machine *machine, mame_file *file)
188static void cybiko_pcf8593_save(running_machine *machine, emu_file *file)
190189{
191190   device_t *device = machine->device("rtc");
192191   pcf8593_save(device, file);
193192}
194193
195static void cybiko_at45dbxx_load(running_machine *machine, mame_file *file)
194static void cybiko_at45dbxx_load(running_machine *machine, emu_file *file)
196195{
197196   device_t *device = machine->device("flash1");
198197   at45dbxx_load(device, file);
199198}
200199
201static void cybiko_at45dbxx_save(running_machine *machine, mame_file *file)
200static void cybiko_at45dbxx_save(running_machine *machine, emu_file *file)
202201{
203202   device_t *device = machine->device("flash1");
204203   at45dbxx_save(device, file);
205204}
206205
207static void cybiko_sst39vfx_load(running_machine *machine, mame_file *file)
206static void cybiko_sst39vfx_load(running_machine *machine, emu_file *file)
208207{
209208   device_t *device = machine->device("flash2");
210209   sst39vfx_load(device, file);
211210}
212211
213static void cybiko_sst39vfx_save(running_machine *machine, mame_file *file)
212static void cybiko_sst39vfx_save(running_machine *machine, emu_file *file)
214213{
215214   device_t *device = machine->device("flash2");
216215   sst39vfx_save(device, file);
src/mess/machine/pce.c
r10384r10385
464464{
465465   if (read_or_write)
466466   {
467      mame_fwrite(file, pce_cd.bram, PCE_BRAM_SIZE);
467      file->write(pce_cd.bram, PCE_BRAM_SIZE);
468468   }
469469   else
470470   {
471471      /* load battery backed memory from disk */
472472      if (file)
473         mame_fread(file, pce_cd.bram, PCE_BRAM_SIZE);
473         file->read(pce_cd.bram, PCE_BRAM_SIZE);
474474   }
475475}
476476
src/mess/machine/pc1251.c
r10384r10385
9999
100100   if (read_or_write)
101101   {
102      mame_fwrite(file, cpu, 96);
103      mame_fwrite(file, ram, 0x4800);
102      file->write(cpu, 96);
103      file->write(ram, 0x4800);
104104   }
105105   else if (file)
106106   {
107      mame_fread(file, cpu, 96);
108      mame_fread(file, ram, 0x4800);
107      file->read(cpu, 96);
108      file->read(ram, 0x4800);
109109   }
110110   else
111111   {
src/mess/includes/nc.h
r10384r10385
4444   int irq_latch;
4545   int irq_latch_mask;
4646   int sound_channel_periods[2];
47   mame_file *file;
47   emu_file *file;
4848   int previous_inputport_10_state;
4949   int previous_alarm_state;
5050   UINT8 nc200_uart_interrupt_irq;
src/mess/includes/msx_slot.h
r10384r10385
153153   void (*reset)(running_machine *machine, slot_state*);
154154   void (*map)(running_machine *machine, slot_state*, int page);
155155   void (*write)(running_machine *machine, slot_state*, UINT16, UINT8);
156   int (*loadsram)(slot_state*);
157   int (*savesram)(slot_state*);
156   int (*loadsram)(running_machine *machine, slot_state*);
157   int (*savesram)(running_machine *machine, slot_state*);
158158} msx_slot;
159159
160160extern const msx_slot msx_slot_list[];
r10384r10385
235235#define MSX_SLOT_RESET(nm)         \
236236   static void slot_##nm##_reset (running_machine *machine, slot_state *state)
237237#define MSX_SLOT_LOADSRAM(nm)      \
238   static int slot_##nm##_loadsram (slot_state *state)
238   static int slot_##nm##_loadsram (running_machine *machine, slot_state *state)
239239#define MSX_SLOT_SAVESRAM(nm)      \
240   static int slot_##nm##_savesram (slot_state *state)
240   static int slot_##nm##_savesram (running_machine *machine, slot_state *state)
241241
242242typedef struct {
243243   char name[9];
src/mess/formats/ti85_ser.c
r10384r10385
718718{
719719   ti85serial_state *ti85serial = get_token( device );
720720   char var_file_name[16];
721   mame_file * var_file;
722721   UINT8* temp;
723722   file_error filerr;
724723
r10384r10385
889888            ti85serial->variable_number = 0;
890889            ti85serial->status =  TI85_SEND_STOP;
891890            sprintf (var_file_name, "%08d.85g", ti85serial->var_file_number);
892            filerr = mame_fopen(NULL, var_file_name, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &var_file);
891            emu_file var_file(device->machine->options(), NULL, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
892            filerr = var_file.open(var_file_name);
893
893894            if (filerr == FILERR_NONE)
894895            {
895               mame_fwrite(var_file, ti85serial->var_file_data, ti85serial->var_file_size);
896               mame_fclose(var_file);
896               var_file.write(ti85serial->var_file_data, ti85serial->var_file_size);               
897897               free (ti85serial->var_file_data);
898898               ti85serial->var_file_data = NULL;
899899               ti85serial->var_file_size = 0;
r10384r10385
911911
912912   file_error filerr;
913913   char backup_file_name[] = "00000000.85b";
914   mame_file * backup_file;
915914
916915   switch (ti85serial->status)
917916   {
r10384r10385
10311030               ti85serial->backup_file_data[0x42+0x06+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]] = ti85_calculate_checksum(ti85serial->backup_file_data+0x37, 0x42+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]+0x06-0x37)&0x00ff;
10321031               ti85serial->backup_file_data[0x42+0x06+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]+0x01] = (ti85_calculate_checksum(ti85serial->backup_file_data+0x37, 0x42+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]+0x06-0x37)&0xff00)>>8;
10331032               sprintf (backup_file_name, "%08d.85b", ti85serial->backup_file_number);
1034               filerr = mame_fopen(NULL, backup_file_name, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &backup_file);
1033               
1034               emu_file backup_file(device->machine->options(), NULL, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
1035               filerr = backup_file.open(backup_file_name);
1036               
10351037               if (filerr == FILERR_NONE)
10361038               {
1037                  mame_fwrite(backup_file, ti85serial->backup_file_data, 0x42+0x06+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]+0x02);
1038                  mame_fclose(backup_file);
1039                  backup_file.write(ti85serial->backup_file_data, 0x42+0x06+ti85serial->backup_data_size[0]+ti85serial->backup_data_size[1]+ti85serial->backup_data_size[2]+0x02);
10391040                  ti85serial->backup_file_number++;
10401041               }
10411042               free(ti85serial->backup_file_data); ti85serial->backup_file_data = NULL;
r10384r10385
10511052   ti85serial_state *ti85serial = get_token( device );
10521053   char image_file_name[] = "00000000.85i";
10531054   file_error filerr;
1054   mame_file * image_file;
10551055   UINT8 * image_file_data;
10561056
10571057   switch (ti85serial->status)
r10384r10385
10951095         {
10961096            ti85_convert_stream_to_data (ti85serial->receive_buffer, 1030*8, ti85serial->receive_data);
10971097            sprintf (image_file_name, "%08d.85i", ti85serial->image_file_number);
1098            filerr = mame_fopen(NULL, image_file_name, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &image_file);
1098           
1099            emu_file image_file(device->machine->options(), NULL, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
1100            filerr = image_file.open(image_file_name);
1101           
10991102            if (filerr == FILERR_NONE)
11001103            {
11011104               image_file_data = (UINT8*)malloc (0x49+1008);
r10384r10385
11241127               memcpy(image_file_data+0x47, ti85serial->receive_data+4, 1008);
11251128               image_file_data[1008+0x49-2] = ti85_calculate_checksum(image_file_data+0x37, 1008+0x10)&0x00ff;
11261129               image_file_data[1008+0x49-1] = (ti85_calculate_checksum(image_file_data+0x37, 1008+0x10)&0xff00)>>8;
1127               mame_fwrite(image_file, image_file_data, 1008+0x49);
1128               mame_fclose(image_file);
1130               image_file.write(image_file_data, 1008+0x49);               
11291131               free(image_file_data);
11301132               ti85serial->image_file_number++;
11311133            }
src/mess/drivers/jaguar.c
r10384r10385
193193*
194194********************************************************************/
195195/*
196static mame_file *jaguar_nvram_fopen( running_machine *machine, UINT32 openflags)
196static emu_file *jaguar_nvram_fopen( running_machine *machine, UINT32 openflags)
197197{
198198    device_image_interface *image = dynamic_cast<device_image_interface *>(machine->device("cart"));
199199    astring *fname;
200200    file_error filerr;
201    mame_file *file;
201    emu_file *file;
202202    if (image->exists())
203203    {
204204        fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, image->basename_noext(), ".nv");
r10384r10385
212212
213213static void jaguar_nvram_load(running_machine *machine)
214214{
215    mame_file *nvram_file = NULL;
215    emu_file *nvram_file = NULL;
216216    device_t *device;
217217
218218    for (device = machine->m_devicelist.first(); device != NULL; device = device->next())
r10384r10385
232232
233233static void jaguar_nvram_save(running_machine *machine)
234234{
235    mame_file *nvram_file = NULL;
235    emu_file *nvram_file = NULL;
236236    device_t *device;
237237
238238    for (device = machine->m_devicelist.first(); device != NULL; device = device->next())
src/mess/drivers/pocketc.c
r10384r10385
802802
803803   if (read_or_write)
804804   {
805      mame_fwrite(file, cpu, 96);
806      mame_fwrite(file, ram, 0x2800);
805      file->write(cpu, 96);
806      file->write(ram, 0x2800);
807807   }
808808   else if (file)
809809   {
810      mame_fread(file, cpu, 96);
811      mame_fread(file, ram, 0x2800);
810      file->read(cpu, 96);
811      file->read(ram, 0x2800);
812812   }
813813   else
814814   {
src/mess/drivers/cat.c
r10384r10385
392392
393393   if (read_or_write)
394394   {
395      mame_fwrite(file, state->sram, 0x4000);
395      file->write(state->sram, 0x4000);
396396   }
397397   else
398398   {
399399      if (file)
400400      {
401         mame_fread(file, state->sram, 0x4000);
401         file->read(state->sram, 0x4000);
402402      }
403403   }
404404}
src/mess/drivers/ip22.c
r10384r10385
131131   ip22_state *state = machine->driver_data<ip22_state>();
132132   if (read_or_write)
133133   {
134      mame_fwrite(file, state->nRTC_UserRAM, 0x200);
135      mame_fwrite(file, state->nRTC_RAM, 0x200);
134      file->write(state->nRTC_UserRAM, 0x200);
135      file->write(state->nRTC_RAM, 0x200);
136136   }
137137   else
138138   {
139139      if (file)
140140      {
141         mame_fread(file, state->nRTC_UserRAM, 0x200);
142         mame_fread(file, state->nRTC_RAM, 0x200);
141         file->read(state->nRTC_UserRAM, 0x200);
142         file->read(state->nRTC_RAM, 0x200);
143143      }
144144   }
145145}
src/mess/drivers/ng_aes.c
r10384r10385
541541   {
542542   case MEMCARD_CREATE:
543543      memset(state->memcard_data, 0, MEMCARD_SIZE);
544      mame_fwrite(file, state->memcard_data, MEMCARD_SIZE);
544      file.write(state->memcard_data, MEMCARD_SIZE);
545545      break;
546546
547547   case MEMCARD_INSERT:
548      mame_fread(file, state->memcard_data, MEMCARD_SIZE);
548      file.read(state->memcard_data, MEMCARD_SIZE);
549549      break;
550550
551551   case MEMCARD_EJECT:
552      mame_fwrite(file, state->memcard_data, MEMCARD_SIZE);
552      file.write(state->memcard_data, MEMCARD_SIZE);
553553      break;
554554   }
555555}
src/mess/drivers/x07.c
r10384r10385
12571257
12581258   if (read_or_write)
12591259   {
1260      mame_fwrite(file, state->m_t6834_ram, sizeof(state->m_t6834_ram));
1261      mame_fwrite(file, ram_get_ptr(state->m_ram), ram_get_size(state->m_ram));
1260      file->write(state->m_t6834_ram, sizeof(state->m_t6834_ram));
1261      file->write(ram_get_ptr(state->m_ram), ram_get_size(state->m_ram));
12621262   }
12631263   else
12641264   {
12651265      if (file)
12661266      {
1267         mame_fread(file, state->m_t6834_ram, sizeof(state->m_t6834_ram));
1268         mame_fread(file, ram_get_ptr(state->m_ram), ram_get_size(state->m_ram));
1267         file->read(state->m_t6834_ram, sizeof(state->m_t6834_ram));
1268         file->read(ram_get_ptr(state->m_ram), ram_get_size(state->m_ram));
12691269         state->m_warm_start = 1;
12701270      }
12711271      else
src/mess/drivers/nc.c
r10384r10385
432432
433433   LOG(("restoring nc memory\n"));
434434   /* get size of memory data stored */
435   mame_fread(state->file, &stored_size, sizeof(unsigned long));
435   state->file->read(&stored_size, sizeof(unsigned long));
436436
437437   if (stored_size > ram_get_size(machine->device(RAM_TAG)))
438438      restore_size = ram_get_size(machine->device(RAM_TAG));
r10384r10385
440440      restore_size = stored_size;
441441
442442   /* read as much as will fit into memory */
443   mame_fread(state->file, ram_get_ptr(machine->device(RAM_TAG)), restore_size);
443   state->file->read(ram_get_ptr(machine->device(RAM_TAG)), restore_size);
444444   /* seek over remaining data */
445   mame_fseek(state->file, SEEK_CUR,stored_size - restore_size);
445   state->file->seek(SEEK_CUR,stored_size - restore_size);
446446}
447447
448448/* store a block of memory to the nvram file */
r10384r10385
455455
456456   LOG(("storing nc memory\n"));
457457   /* write size of memory data */
458   mame_fwrite(state->file, &size, sizeof(UINT32));
458   state->file->write(&size, sizeof(UINT32));
459459
460460   /* write data block */
461   mame_fwrite(state->file, ram_get_ptr(machine->device(RAM_TAG)), size);
461   state->file->write(ram_get_ptr(machine->device(RAM_TAG)), size);
462462}
463463
464464static void nc_common_open_stream_for_reading(running_machine *machine)
r10384r10385
468468
469469   sprintf(filename,"%s.nv", machine->gamedrv->name);
470470
471   mame_fopen(SEARCHPATH_MEMCARD, filename, OPEN_FLAG_READ, &state->file);
471   state->file = global_alloc(emu_file(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE));
472   state->file->open(filename);
472473}
473474
474475static void nc_common_open_stream_for_writing(running_machine *machine)
r10384r10385
477478   char filename[MAX_DRIVER_NAME_CHARS + 5];
478479
479480   sprintf(filename,"%s.nv", machine->gamedrv->name);
480
481   mame_fopen(SEARCHPATH_MEMCARD, filename, OPEN_FLAG_WRITE, &state->file);
481   
482   state->file = global_alloc(emu_file(machine->options(), SEARCHPATH_MEMCARD, OPEN_FLAG_WRITE));
483   state->file->open(filename);
482484}
483485
484486
r10384r10385
486488{
487489   nc_state *state = machine->driver_data<nc_state>();
488490   if (state->file)
489      mame_fclose(state->file);
491      global_free(state->file);
490492}
491493
492494
src/mess/drivers/px4.c
r10384r10385
10151015   px4_state *px4 = machine->driver_data<px4_state>();
10161016
10171017   if (read_or_write)
1018      mame_fwrite(file, px4->ramdisk, 0x20000);
1018      file->write(px4->ramdisk, 0x20000);
10191019   else
10201020      if (file)
1021         mame_fread(file, px4->ramdisk, 0x20000);
1021         file->read(px4->ramdisk, 0x20000);
10221022}
10231023
10241024
src/mess/drivers/gp32.c
r10384r10385
17701770   {
17711771      if (file)
17721772      {
1773         mame_fwrite( file, state->eeprom_data, 0x2000);
1773         file->write(state->eeprom_data, 0x2000);
17741774      }
17751775   }
17761776   else
17771777   {
17781778      if (file)
17791779      {
1780         mame_fread( file, state->eeprom_data, 0x2000);
1780         file->read(state->eeprom_data, 0x2000);
17811781      }
17821782      else
17831783      {
src/mess/drivers/saturn.c
r10384r10385
18861886   int i;
18871887
18881888   if (read_or_write)
1889      mame_fwrite(file, backup, 64*1024/4);
1889      file->write(backup, 64*1024/4);
18901890   else
18911891   {
18921892      if (file)
18931893      {
1894         mame_fread(file, backup, 64*1024/4);
1894         file->read(backup, 64*1024/4);
18951895      }
18961896      else
18971897      {
src/mess/drivers/micronic.c
r10384r10385
403403
404404   if (read_or_write)
405405   {
406      mame_fwrite(file, state->ram, 0x8000);
407      mame_fwrite(file, ram_get_ptr(machine->device(RAM_TAG)), 224*1024);
406      file->write(state->ram, 0x8000);
407      file->write(ram_get_ptr(machine->device(RAM_TAG)), 224*1024);
408408   }
409409   else
410410   {
411411      if (file)
412412      {
413         mame_fread(file, state->ram, 0x8000);
414         mame_fread(file, ram_get_ptr(machine->device(RAM_TAG)), 224*1024);
413         file->read(state->ram, 0x8000);
414         file->read(ram_get_ptr(machine->device(RAM_TAG)), 224*1024);
415415
416416         /* reload register A and B for restore the periodic irq state */
417         mame_fseek(file, 0x4000a, SEEK_SET);
418         mame_fread(file, &reg_a, 0x01);
419         mame_fread(file, &reg_b, 0x01);
417         file->seek(0x4000a, SEEK_SET);
418         file->read(&reg_a, 0x01);
419         file->read(&reg_b, 0x01);
420420
421421         set_146818_periodic_irq(machine, reg_a);
422422         state->periodic_irq = (reg_b & 0x40) ? 1 : 0;
src/mess/drivers/psion.c
r10384r10385
611611
612612   if (read_or_write)
613613   {
614      mame_fwrite(file, state->m_sys_register, 0xc0);
615      mame_fwrite(file, state->m_ram, state->m_ram_size);
614      file->write(state->m_sys_register, 0xc0);
615      file->write(state->m_ram, state->m_ram_size);
616616      if (state->m_ram_bank_count)
617         mame_fwrite(file, state->m_paged_ram, state->m_ram_bank_count * 0x4000);
617         file->write(state->m_paged_ram, state->m_ram_bank_count * 0x4000);
618618   }
619619   else
620620   {
621621      if (file)
622622      {
623         mame_fread(file, state->m_sys_register, 0xc0);
624         mame_fread(file, state->m_ram, state->m_ram_size);
623         file->read(state->m_sys_register, 0xc0);
624         file->read(state->m_ram, state->m_ram_size);
625625         if (state->m_ram_bank_count)
626            mame_fread(file, state->m_paged_ram, state->m_ram_bank_count * 0x4000);
626            file->read(state->m_paged_ram, state->m_ram_bank_count * 0x4000);
627627
628628         //warm start
629629         state->m_stby_pwr = 1;
src/ldplayer/ldplayer.c
r10384r10385
8989
9090static chd_file *get_disc(device_t *device)
9191{
92   mame_file *image_file = NULL;
92   emu_file *image_file = NULL;
9393   chd_file *image_chd = NULL;
94   mame_path *path;
9594
9695   /* open a path to the ROMs and find the first CHD file */
97   path = mame_openpath(device->machine->options(), OPTION_ROMPATH);
98   if (path != NULL)
96   file_enumerator path(device->machine->options(), OPTION_ROMPATH);
97   const osd_directory_entry *dir;
98
99   /* iterate while we get new objects */
100   while ((dir = path.next()) != NULL)
99101   {
100      const osd_directory_entry *dir;
102      int length = strlen(dir->name);
101103
102      /* iterate while we get new objects */
103      while ((dir = mame_readpath(path)) != NULL)
104      /* look for files ending in .chd */
105      if (length > 4 &&
106         dir->name[length - 4] == '.' &&
107         tolower(dir->name[length - 3]) == 'c' &&
108         tolower(dir->name[length - 2]) == 'h' &&
109         tolower(dir->name[length - 1]) == 'd')
104110      {
105         int length = strlen(dir->name);
111         file_error filerr;
112         chd_error chderr;
106113
107         /* look for files ending in .chd */
108         if (length > 4 &&
109            dir->name[length - 4] == '.' &&
110            tolower(dir->name[length - 3]) == 'c' &&
111            tolower(dir->name[length - 2]) == 'h' &&
112            tolower(dir->name[length - 1]) == 'd')
114         /* open the file itself via our search path */
115         image_file = auto_alloc(device->machine, emu_file(device->machine->options(), SEARCHPATH_IMAGE, OPEN_FLAG_READ));
116         filerr = image_file->open(dir->name);
117         if (filerr == FILERR_NONE)
113118         {
114            file_error filerr;
115            chd_error chderr;
116
117            /* open the file itself via our search path */
118            filerr = mame_fopen(SEARCHPATH_IMAGE, dir->name, OPEN_FLAG_READ, &image_file);
119            if (filerr == FILERR_NONE)
119            /* try to open the CHD */
120            chderr = chd_open_file(image_file, CHD_OPEN_READ, NULL, &image_chd);
121            if (chderr == CHDERR_NONE)
120122            {
121               /* try to open the CHD */
122               chderr = chd_open_file(mame_core_file(image_file), CHD_OPEN_READ, NULL, &image_chd);
123               if (chderr == CHDERR_NONE)
124               {
125                  set_disk_handle(device->machine, "laserdisc", image_file, image_chd);
126                  filename.cpy(dir->name);
127                  device->machine->add_notifier(MACHINE_NOTIFY_EXIT, free_string);
128                  break;
129               }
130
131               /* close the file on failure */
132               mame_fclose(image_file);
133               image_file = NULL;
123               set_disk_handle(*device->machine, "laserdisc", *image_file, *image_chd);
124               filename.cpy(dir->name);
125               device->machine->add_notifier(MACHINE_NOTIFY_EXIT, free_string);
126               break;
134127            }
135128         }
129
130         /* close the file on failure */
131         auto_free(device->machine, image_file);
132         image_file = NULL;
136133      }
137      mame_closepath(path);
138134   }
139135
140136   /* if we failed, pop a message and exit */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team