Previous 15994 Revisions Next

r7950 Saturday 1st May, 2010 at 05:56:40 UTC by Fabio Priuli
Added software list handling to gx4000 (and cpc+), fixed possible memory leaks with svision and added back some comments to crvision.xml
[hash]crvision.xml gx4000.xml
[src/mess/drivers]amstrad.c svision.c
[src/mess/machine]amstrad.c

hash/gx4000.xml
r7949r7950
117117   </software>
118118
119119   <!-- doesn't boot -->
120   <software name="noexit">
120   <software name="noexit" supported="no">
121121      <description>No Exit</description>
122122      <year>1990</year>
123123      <publisher>CVS</publisher>
r7949r7950
129129   </software>
130130
131131   <!-- doesn't boot -->
132   <software name="othunder">
132   <software name="othunder" supported="no">
133133      <description>Operation Thunderbolt</description>
134134      <year>1990</year>
135135      <publisher>Ocean Software</publisher>
r7949r7950
198198   </software>
199199
200200   <!-- doesn't boot -->
201   <software name="robocop2">
201   <software name="robocop2" supported="no">>
202202      <description>Robocop 2</description>
203203      <year>1990</year>
204204      <publisher>Ocean Software</publisher>
hash/crvision.xml
r7949r7950
22<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
33
44<!-- Many thanks to Luca Antignano for the help with this software list -->
5<!--
6A couple of comments about the 6k/8k images:
7- game code occupies 6k, but there can be different chips inside the actual carts:
8  1x8k eprom, 2x4k eproms or 1x2k + 1x4k eproms. In the 1x8k case, the console
9  actually accesses only the first 2k and the final 4k.
10There have been found carts where the remaining part is empty, and carts where the lower
112k are repeated (see the Alt dumps below), but the dumps are basically the same and
12a Creativision would not see the difference between them.
13
14TODO: split the content of the various chips
15-->
16
17<!-- Creativision carts were universal (Japanese NTSC dumps turned out to be the same as worldwide PAL ones). -->
518<softwarelist name="crvision" description="V-Tech Creativision cartridges">
619   <!-- Id: 8008 -->
720   <software name="airsea">
r7949r7950
2740      </part>
2841   </software>
2942
43    <!-- astrop1 differs from astropin only in the 1st byte.
44        This image came from FunnyMu < 0.43, and it might be
45        a bad dump (astropin has been confirmed good) -->
3046   <software name="astropin1" cloneof="astropin">
3147      <description>Astro Pinball (Bad?)</description>
3248      <year>1982</year>
r7949r7950
373389      </part>
374390   </software>
375391
376    <!-- This was an hombrew cart sold back in the 80s -->
392    <!-- hapmon is a homebrew hex editor created in the 80s and perfectly working
393        on the real machine. It was dumped and released to the public in ~2002,
394        when FunnyMu emulator (written by Paul Hayter) was released -->
377395   <software name="hapmon">
378396      <description>Hapmon</description>
379      <year>19??</year>
397      <year>198?</year>
380398      <publisher>Richard Hayter</publisher>
381399      <part name="cart" interface="crvision_cart">
382400         <dataarea name="rom" size="4096">
src/mess/machine/amstrad.c
r7949r7950
34893489   //                'cb01' represent Cartridge block 1, and is loaded to &4000-&7fff
34903490   //                ... and so on.
34913491
3492   unsigned char header[12];  // RIFF chunk
3493   char chunkid[4];  // chunk ID (4 character code - cb00, cb01, cb02... upto cb31 (max 512kB), other chunks are ignored)
3494   char chunklen[4];  // chunk length (always little-endian)
3495   int chunksize;  // chunk length, calcaulated from the above
3496   int ramblock;  // 16k RAM block chunk is to be loaded in to
3497   int result;
3498   unsigned int bytes_to_read;  // total bytes to read, as mame_feof doesn't react to EOF without trying to go past it.
3492   UINT32 size, offset = 0;
3493   UINT8 *temp_copy;
3494   unsigned char header[12];     // RIFF chunk
3495   char chunkid[4];              // chunk ID (4 character code - cb00, cb01, cb02... upto cb31 (max 512kB), other chunks are ignored)
3496   char chunklen[4];             // chunk length (always little-endian)
3497   int chunksize;                // chunk length, calcaulated from the above
3498   int ramblock;                 // 16k RAM block chunk is to be loaded in to
3499   unsigned int bytes_to_read;   // total bytes to read, as mame_feof doesn't react to EOF without trying to go past it.
34993500   unsigned char* mem = memory_region(image->machine, "maincpu");
35003501
3502   if (image_software_entry(image) == NULL)
3503   {
3504      size = image_length(image);
3505      temp_copy = auto_alloc_array(image->machine, UINT8, size);
3506      if (image_fread(image, temp_copy, size) != size)
3507      {
3508         logerror("IMG: failed to read from cart image\n");
3509         auto_free(image->machine, temp_copy);
3510         return INIT_FAIL;
3511      }
3512   }
3513   else
3514   {
3515      size= image_get_software_region_length(image, "rom");
3516      temp_copy = auto_alloc_array(image->machine, UINT8, size);
3517      memcpy(temp_copy, image_get_software_region(image, "rom"), size);
3518   }
3519
35013520   logerror("IMG: loading CPC+ cartridge file\n");
35023521   // load RIFF chunk
3503   result = image_fread(image,header,12);
3504   if(result != 12)
3522   memcpy(header, temp_copy, 12);
3523   offset += 12;
3524
3525   if (strncmp((char *)header, "RIFF", 4) != 0)
35053526   {
3506      logerror("IMG: failed to read from cart image\n");
3507      return INIT_FAIL;
3508   }
3509   if(strncmp((char *)header,"RIFF",4) != 0)
3510   {
3527      logerror("IMG: raw CPC+ cartridge file\n");
3528      offset -= 12;   // no header, so we go back to the start of the file
3529
35113530      // not an RIFF format file, assume raw binary (*.bin)
3512      image_fseek(image,0,SEEK_SET);
3513      ramblock = 0;
3514      while(!image_feof(image))
3531      while (offset < size)
35153532      {
3516         result = image_fread(image,mem+(0x4000*ramblock),0x4000);
3517         if(result < 0x4000)
3533         memcpy(mem + offset, temp_copy + offset, 0x4000);
3534
3535         if ((size - offset) < 0x4000)
35183536         {
3519            logerror("BIN: block %i loaded is smaller than 16kB in size\n",ramblock);
3537            logerror("BIN: block %i loaded is smaller than 16kB in size\n", offset / 0x4000);
3538            auto_free(image->machine, temp_copy);
35203539            return INIT_FAIL;
35213540         }
3522         ramblock++;
3541         offset += 0x4000;
35233542      }
35243543   }
3525   else
3544   else if (image_software_entry(image) == NULL)   // we have no CPR carts in our gx4000 softlist
35263545   {
35273546      // Is RIFF format (*.cpr)
3528      if(strncmp((char*)(header+8),"AMS!",4) != 0)
3547      if (strncmp((char*)(header + 8), "AMS!", 4) != 0)
35293548      {
35303549         logerror("CPR: not an Amstrad CPC cartridge image\n");
3550         auto_free(image->machine, temp_copy);
35313551         return INIT_FAIL;
35323552      }
35333553
35343554      bytes_to_read = header[4] + (header[5] << 8) + (header[6] << 16)+ (header[7] << 24);
35353555      bytes_to_read -= 4;  // account for AMS! header
3536      logerror("CPR: Data to read: %i bytes\n",bytes_to_read);
3556      logerror("CPR: Data to read: %i bytes\n", bytes_to_read);
35373557      // read some chunks
3538      while(bytes_to_read > 0)
3558      while (bytes_to_read > 0)
35393559      {
3540         result = image_fread(image,chunkid,4);
3541         if(result != 4)
3542         {
3543            logerror("CPR: failed to read from cart image\n");
3544            return INIT_FAIL;
3545         }
3546         bytes_to_read -= result;
3547         result = image_fread(image,chunklen,4);
3548         if(result != 4)
3549         {
3550            logerror("CPR: failed to read from cart image\n");
3551            return INIT_FAIL;
3552         }
3553         bytes_to_read -= result;
3560         memcpy(chunkid, temp_copy + offset, 4);
3561         bytes_to_read -= 4;
3562         offset += 4;
3563
3564         memcpy(chunklen, temp_copy + offset, 4);
3565         bytes_to_read -= 4;
3566         offset += 4;
3567         
35543568         // calculate little-endian value, just to be sure
35553569         chunksize = chunklen[0] + (chunklen[1] << 8) + (chunklen[2] << 16) + (chunklen[3] << 24);
3556
3557         if(strncmp(chunkid,"cb",2) == 0)
3570         
3571         if (strncmp(chunkid, "cb", 2) == 0)
35583572         {
35593573            // load chunk into RAM
35603574            // find out what block this is
35613575            ramblock = (chunkid[2] - 0x30) * 10;
35623576            ramblock += chunkid[3] - 0x30;
3563            logerror("CPR: Loading chunk into RAM block %i ['%4s']\n",ramblock,chunkid);
3577            logerror("CPR: Loading chunk into RAM block %i ['%4s']\n", ramblock, chunkid);
3578
35643579            if(ramblock >= 0 && ramblock < 32)
35653580            {
35663581               // clear RAM block
3567               memset(mem+(0x4000*ramblock),0,0x4000);
3568
3582               memset(mem + 0x4000 * ramblock, 0, 0x4000);
3583               
35693584               // load block into ROM area
3570               if(chunksize > 16384)
3585               if (chunksize > 16384)
35713586                  chunksize = 16384;
3572               result = image_fread(image,mem+(0x4000*ramblock),chunksize);
3573               if(result != chunksize)
3574               {
3575                  logerror("CPR: Read %i-byte chunk, expected %i bytes\n",result,chunksize);
3576                  return INIT_FAIL;
3577               }
3587
3588               memcpy(mem + 0x4000 * ramblock, temp_copy + offset, chunksize);
35783589               bytes_to_read -= chunksize;
3579               logerror("CPR: Loaded %i-byte chunk into RAM block %i\n",result,ramblock);
3590               offset += chunksize;
3591               logerror("CPR: Loaded %i-byte chunk into RAM block %i\n", chunksize, ramblock);
35803592            }
35813593         }
35823594         else
35833595         {
3584            logerror("CPR: Unknown chunk '%4s', skipping %i bytes\n",chunkid,chunksize);
3585            if(chunksize != 0)
3596            logerror("CPR: Unknown chunk '%4s', skipping %i bytes\n", chunkid, chunksize);
3597            if (chunksize != 0)
35863598            {
3587               image_fseek(image,chunksize,SEEK_CUR);
35883599               bytes_to_read -= chunksize;
3600               offset += chunksize;
35893601            }
35903602         }
35913603      }
35923604   }
3605   else   // CPR carts in our softlist
3606   {
3607      logerror("Gamelist cart in RIFF format\n");
3608      auto_free(image->machine, temp_copy);
3609      return INIT_FAIL;
3610   }
35933611
3594
3612   auto_free(image->machine, temp_copy);
35953613   return INIT_PASS;
35963614}
35973615
src/mess/drivers/amstrad.c
r7949r7950
865865   MDRV_CARTSLOT_ADD("cart")
866866   MDRV_CARTSLOT_EXTENSION_LIST("cpr,bin")
867867   MDRV_CARTSLOT_MANDATORY
868   MDRV_CARTSLOT_INTERFACE("gx4000_cart")
868869   MDRV_CARTSLOT_LOAD(amstrad_plus_cartridge)
870   MDRV_SOFTWARE_LIST_ADD("gx4000")
869871MACHINE_DRIVER_END
870872
871873static MACHINE_DRIVER_START( amstrad )
src/mess/drivers/svision.c
r7949r7950
470470      if (size > memory_region_length(image->machine, "user1"))
471471      {
472472         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
473         auto_free(image->machine, temp_copy);
473474         return INIT_FAIL;
474475      }
475476     
476477      if (image_fread(image, temp_copy, size) != size)
477478      {
478479         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
480         auto_free(image->machine, temp_copy);
479481         return INIT_FAIL;
480482      }
481483   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team