Previous 199869 Revisions Next

r22578 Saturday 27th April, 2013 at 14:44:06 UTC by Robbbert
(MESS) Ravens: add new bios; fix memory leak
[src/mess/drivers]ravens.c

trunk/src/mess/drivers/ravens.c
r22577r22578
266266   int quick_length;
267267   UINT8 *quick_data;
268268   int read_;
269   int result = IMAGE_INIT_FAIL;
269270
270271   quick_length = image.length();
271   quick_data = (UINT8*)malloc(quick_length);
272   if (!quick_data)
273   {
274      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
275      image.message(" Cannot open file");
276      return IMAGE_INIT_FAIL;
277   }
278
279   read_ = image.fread( quick_data, quick_length);
280   if (read_ != quick_length)
281   {
282      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
283      image.message(" Cannot read the file");
284      return IMAGE_INIT_FAIL;
285   }
286
287   if (quick_data[0] != 0xc6)
288   {
289      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
290      image.message(" Invalid header");
291      return IMAGE_INIT_FAIL;
292   }
293
294   exec_addr = quick_data[1] * 256 + quick_data[2];
295
296   if (exec_addr >= quick_length)
297   {
298      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
299      image.message(" Exec address beyond end of file");
300      return IMAGE_INIT_FAIL;
301   }
302
303272   if (quick_length < 0x0900)
304273   {
305274      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
306275      image.message(" File too short");
307      return IMAGE_INIT_FAIL;
308276   }
309
310   if (quick_length > 0x8000)
277   else if (quick_length > 0x8000)
311278   {
312279      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long");
313280      image.message(" File too long");
314      return IMAGE_INIT_FAIL;
315281   }
282   else
283   {
284      quick_data = (UINT8*)malloc(quick_length);
285      if (!quick_data)
286      {
287         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
288         image.message(" Cannot open file");
289      }
290      else
291      {
292         read_ = image.fread( quick_data, quick_length);
293         if (read_ != quick_length)
294         {
295            image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
296            image.message(" Cannot read the file");
297         }
298         else if (quick_data[0] != 0xc6)
299         {
300            image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
301            image.message(" Invalid header");
302         }
303         else
304         {
305            exec_addr = quick_data[1] * 256 + quick_data[2];
316306
317//   read_ = 0x1000;
318//   if (quick_length < 0x1000)
319//      read_ = quick_length;
307            if (exec_addr >= quick_length)
308            {
309               image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
310               image.message(" Exec address beyond end of file");
311            }
312            else
313            {
314               for (i = quick_addr; i < read_; i++)
315                  space.write_byte(i, quick_data[i]);
320316
321   for (i = quick_addr; i < read_; i++)
322      space.write_byte(i, quick_data[i]);
317               /* display a message about the loaded quickload */
318               image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
323319
324//   read_ = 0x1780;
325//   if (quick_length < 0x1780)
326//      read_ = quick_length;
320               // Start the quickload
321               m_maincpu->set_pc(exec_addr);
327322
328//   if (quick_length > 0x157f)
329//      for (i = 0x1580; i < read_; i++)
330//         space.write_byte(i, quick_data[i]);
323               result = IMAGE_INIT_PASS;
324            }
325         }
326      }
331327
332//   if (quick_length > 0x17ff)
333//      for (i = 0x1800; i < quick_length; i++)
334//         space.write_byte(i, quick_data[i]);
328      free( quick_data );
329   }
335330
336   /* display a message about the loaded quickload */
337   image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
338
339   // Start the quickload
340   m_maincpu->set_pc(exec_addr);
341   return IMAGE_INIT_PASS;
331   return result;
342332}
343333
344334static MACHINE_CONFIG_START( ravens, ravens_state )
r22577r22578
380370/* ROM definition */
381371ROM_START( ravens )
382372   ROM_REGION( 0x8000, "maincpu", 0 )
383   ROM_LOAD( "mon_v0.9.bin", 0x0000, 0x0800, CRC(785eb1ad) SHA1(c316b8ac32ab6aa37746af37b9f81a23367fedd8))
373   ROM_SYSTEM_BIOS( 0, "v1.0", "V1.0" )
374   ROMX_LOAD( "mon_v1.0.bin", 0x0000, 0x0800, CRC(785eb1ad) SHA1(c316b8ac32ab6aa37746af37b9f81a23367fedd8), ROM_BIOS(1))
375   ROM_SYSTEM_BIOS( 1, "v0.9", "V0.9" )
376   ROMX_LOAD( "mon_v0_9.bin", 0x0000, 0x07b5, CRC(2f9b9178) SHA1(ec2ebbc80ee9ff2502c1409ab4f99127032ed724), ROM_BIOS(2))
384377ROM_END
385378
386379ROM_START( ravens2 )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team