Previous 15994 Revisions Next

r12477 Thursday 4th August, 2011 at 20:11:23 UTC by Wilbert Pol
msx.c: Added support for software lists. [Wilbert Pol]
[src/mess/drivers]msx.c
[src/mess/machine]msx.c

src/mess/machine/msx.c
r12476r12477
111111      return IMAGE_INIT_FAIL;
112112   }
113113
114   size = image.length ();
115   if (size < 0x2000) {
116      logerror ("cart #%d: error: file is smaller than 2kb, too small "
117              "to be true!\n", id);
118      return IMAGE_INIT_FAIL;
119   }
114   if ( image.software_entry() != NULL )
115   {
116      /* Load software from software list */
117      /* TODO: Add proper SRAM (size) handling */
120118
121   /* allocate memory and load */
122   size_aligned = 0x2000;
123   while (size_aligned < size) {
124      size_aligned *= 2;
125   }
126   mem = auto_alloc_array(image.device().machine(),UINT8,size_aligned);
127   if (!mem) {
128      logerror ("cart #%d: error: failed to allocate memory for cartridge\n",
129                  id);
130      return IMAGE_INIT_FAIL;
131   }
132   if (size < size_aligned) {
133      memset (mem, 0xff, size_aligned);
134   }
135   if (image.fread(mem, size) != size) {
136      logerror ("cart #%d: %s: can't read full %d bytes\n",
137                  id, image.filename (), size);
138      return IMAGE_INIT_FAIL;
139   }
119      const char *mapper = software_part_get_feature( (software_part*)image.part_entry(), "mapper" );
140120
141   /* see if msx.crc will tell us more */
142   extra = hashfile_extrainfo(image);
121      if ( mapper != NULL )
122      {
123         static const struct { const char *mapper_name; int mapper_type; } mapper_types[] =
124         {
125            { "M60002-0125SP", SLOT_ASCII8 },
126            { "LZ93A13", SLOT_ASCII8 }
127         };
143128
144   if (!extra)
145   {
146      logerror("cart #%d: warning: no information in crc file\n", id);
147      type = -1;
129         type = -1;
130         for ( int i = 0; i < ARRAY_LENGTH(mapper_types) && type < 0; i++ )
131         {
132            if ( !mame_stricmp( mapper, mapper_types[i].mapper_name ) )
133            {
134               type = mapper_types[i].mapper_type;
135            }
136         }
137
138         if ( -1 == type )
139         {
140            logerror( "Mapper '%s' not recognized!\n", mapper );
141         }
142      }
143
144      UINT8 *rom_region = image.get_software_region( "rom" );
145      size = size_aligned = image.get_software_region_length( "rom" );
146
147      mem = auto_alloc_array( image.device().machine(), UINT8, size_aligned );
148      memcpy( mem, rom_region, size_aligned );
148149   }
149   else if ((1 != sscanf(extra, "%d", &type) ) ||
150         type < 0 || type > SLOT_LAST_CARTRIDGE_TYPE)
151   {
152      logerror("cart #%d: warning: information in crc file not valid\n", id);
153      type = -1;
154   }
155150   else
156151   {
157      logerror ("cart #%d: info: cart extra info: '%s' = %s\n", id, extra,
158                  msx_slot_list[type].name);
159   }
152      /* Old style image loading */
160153
161   /* if not, attempt autodetection */
162   if (type < 0)
163   {
164      type = msx_probe_type (mem, size);
154      size = image.length ();
155      if (size < 0x2000) {
156         logerror ("cart #%d: error: file is smaller than 2kb, too small "
157                 "to be true!\n", id);
158         return IMAGE_INIT_FAIL;
159      }
165160
166      if (mem[0] != 'A' || mem[1] != 'B') {
167         logerror("cart #%d: %s: May not be a valid ROM file\n",
168                     id, image.filename ());
161      /* allocate memory and load */
162      size_aligned = 0x2000;
163      while (size_aligned < size) {
164         size_aligned *= 2;
169165      }
166      mem = auto_alloc_array(image.device().machine(),UINT8,size_aligned);
167      if (!mem) {
168         logerror ("cart #%d: error: failed to allocate memory for cartridge\n",
169                     id);
170         return IMAGE_INIT_FAIL;
171      }
172      if (size < size_aligned) {
173         memset (mem, 0xff, size_aligned);
174      }
175      if (image.fread(mem, size) != size) {
176         logerror ("cart #%d: %s: can't read full %d bytes\n",
177                     id, image.filename (), size);
178         return IMAGE_INIT_FAIL;
179      }
170180
171      logerror("cart #%d: Probed cartridge mapper %d/%s\n", id,
172                  type, msx_slot_list[type].name);
181      /* see if msx.crc will tell us more */
182      extra = hashfile_extrainfo(image);
183
184      if (!extra)
185      {
186         logerror("cart #%d: warning: no information in crc file\n", id);
187         type = -1;
188      }
189      else if ((1 != sscanf(extra, "%d", &type) ) ||
190            type < 0 || type > SLOT_LAST_CARTRIDGE_TYPE)
191      {
192         logerror("cart #%d: warning: information in crc file not valid\n", id);
193         type = -1;
194      }
195      else
196      {
197         logerror ("cart #%d: info: cart extra info: '%s' = %s\n", id, extra,
198                     msx_slot_list[type].name);
199      }
200
201      /* if not, attempt autodetection */
202      if (type < 0)
203      {
204         type = msx_probe_type (mem, size);
205
206         if (mem[0] != 'A' || mem[1] != 'B') {
207            logerror("cart #%d: %s: May not be a valid ROM file\n",
208                        id, image.filename ());
209         }
210
211         logerror("cart #%d: Probed cartridge mapper %d/%s\n", id,
212                     type, msx_slot_list[type].name);
213      }
173214   }
174215
175216   /* mapper type 0 always needs 64kB */
src/mess/drivers/msx.c
r12476r12477
10331033   MCFG_CARTSLOT_ADD("cart1")
10341034   MCFG_CARTSLOT_EXTENSION_LIST("mx1,rom")
10351035   MCFG_CARTSLOT_NOT_MANDATORY
1036   MCFG_CARTSLOT_INTERFACE("msx_cart")
10361037   MCFG_CARTSLOT_LOAD(msx_cart)
10371038   MCFG_CARTSLOT_UNLOAD(msx_cart)
10381039
10391040   MCFG_CARTSLOT_ADD("cart2")
10401041   MCFG_CARTSLOT_EXTENSION_LIST("mx1,rom")
10411042   MCFG_CARTSLOT_NOT_MANDATORY
1043   MCFG_CARTSLOT_INTERFACE("msx_cart")
10421044   MCFG_CARTSLOT_LOAD(msx_cart)
10431045   MCFG_CARTSLOT_UNLOAD(msx_cart)
10441046MACHINE_CONFIG_END
r12476r12477
10801082   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(msx_floppy_interface)
10811083
10821084   MCFG_FRAGMENT_ADD(msx_cartslot)
1085
1086   /* Software lists */
1087   MCFG_SOFTWARE_LIST_ADD("cart_list","msx1_cart")
10831088MACHINE_CONFIG_END
10841089
10851090
r12476r12477
11901195   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(msx_floppy_interface)
11911196
11921197   MCFG_FRAGMENT_ADD(msx_cartslot)
1198
1199   /* Software lists */
1200   MCFG_SOFTWARE_LIST_ADD("cart_list","msx2_cart")
11931201MACHINE_CONFIG_END
11941202
11951203

Previous 15994 Revisions Next


© 1998-2018 The MESS Team