Previous 15994 Revisions Next

r7917 Tuesday 27th April, 2010 at 22:06:14 UTC by Fabio Priuli
Added softlist support to advision, gamecom, gmaster and pokemini
[src/mess/drivers]advision.c gamecom.c gmaster.c pokemini.c
[src/mess/includes]pokemini.h
[src/mess/machine]advision.c gamecom.c pokemini.c

src/mess/includes/pokemini.h
r7916r7917
1515WRITE8_HANDLER( pokemini_hwreg_w );
1616READ8_HANDLER( pokemini_hwreg_r );
1717
18DEVICE_START( pokemini_cart );
1918DEVICE_IMAGE_LOAD( pokemini_cart );
2019
2120#endif /* POKEMINI_H */
src/mess/machine/pokemini.c
r7916r7917
13991399   return data;
14001400}
14011401
1402DEVICE_START( pokemini_cart )
1403{
1404}
1405
14061402DEVICE_IMAGE_LOAD( pokemini_cart )
14071403{
1408   int   size = image_length( image );
1409
1410   /* Verify that the image is big enough */
1411   if ( size <= 0x2100 )
1404   if (image_software_entry(image) == NULL)
14121405   {
1413      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too small" );
1414      return INIT_FAIL;
1415   }
1406      int   size = image_length(image);
14161407
1417   /* Verify that the image is not too big */
1418   if ( size > 0x1FFFFF )
1419   {
1420      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too big" );
1421      return INIT_FAIL;
1422   }
1408      /* Verify that the image is big enough */
1409      if (size <= 0x2100)
1410      {
1411         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too small");
1412         return INIT_FAIL;
1413      }
14231414
1424   /* Skip the first 0x2100 bytes */
1425   image_fseek( image, 0x2100, SEEK_SET );
1426   size -= 0x2100;
1415      /* Verify that the image is not too big */
1416      if (size > 0x1FFFFF)
1417      {
1418         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too big");
1419         return INIT_FAIL;
1420      }
14271421
1428   if ( size != image_fread( image, memory_region(image->machine, "maincpu") + 0x2100, size ) )
1422      /* Skip the first 0x2100 bytes */
1423      image_fseek(image, 0x2100, SEEK_SET);
1424      size -= 0x2100;
1425
1426      if (size != image_fread(image, memory_region(image->machine, "maincpu") + 0x2100, size))
1427      {
1428         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Error occured while reading ROM image");
1429         return INIT_FAIL;
1430      }
1431   }
1432   else
14291433   {
1430      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Error occured while reading ROM image" );
1431      return INIT_FAIL;
1434      UINT8 *cart_rom = image_get_software_region(image, "rom");
1435      UINT32 cart_rom_size = image_get_software_region_length(image, "rom");
1436      memcpy(memory_region(image->machine, "maincpu") + 0x2100, cart_rom + 0x2100, cart_rom_size - 0x2100);
14321437   }
14331438
14341439   return INIT_PASS;
src/mess/machine/gamecom.c
r7916r7917
702702{
703703   UINT32 filesize;
704704   UINT32 load_offset = 0;
705   UINT32 bytes_read;
706705
707706   cartridge1 = memory_region(image->machine, "user2");
708707
709   filesize = image_length( image );
710   switch( filesize )
708   if (image_software_entry(image) == NULL)
709      filesize = image_length(image);
710   else
711      filesize = image_get_software_region_length(image, "rom");
712
713   switch(filesize)
711714   {
712   case 0x008000: load_offset = 0;        break;  /* 32 KB */
713   case 0x040000: load_offset = 0;        break;  /* 256KB */
714   case 0x080000: load_offset = 0;        break;  /* 512KB */
715   case 0x100000: load_offset = 0;        break;  /* 1  MB */
716   case 0x1c0000: load_offset = 0x040000; break;  /* 1.8MB */
717   case 0x200000: load_offset = 0;        break;  /* 2  MB */
718   default:                                       /* otherwise */
719      logerror( "Error loading cartridge: Invalid file size 0x%X\n",filesize );
720      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unhandled cart size" );
721      return INIT_FAIL;
715      case 0x008000: load_offset = 0;        break;  /* 32 KB */
716      case 0x040000: load_offset = 0;        break;  /* 256KB */
717      case 0x080000: load_offset = 0;        break;  /* 512KB */
718      case 0x100000: load_offset = 0;        break;  /* 1  MB */
719      case 0x1c0000: load_offset = 0x040000; break;  /* 1.8MB */
720      case 0x200000: load_offset = 0;        break;  /* 2  MB */
721      default:                                       /* otherwise */
722         logerror("Error loading cartridge: Invalid file size 0x%X\n", filesize);
723         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unhandled cart size");
724         return INIT_FAIL;
722725   }
723   bytes_read = image_fread( image, cartridge1 + load_offset, filesize );
724   if (bytes_read  != filesize )
726
727   if (image_software_entry(image) == NULL)
725728   {
726      logerror( "Error loading cartridge: Read 0x%X, should have been 0x%X\n",bytes_read,filesize );
727      image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to load all of the cart" );
728      return INIT_FAIL;
729      if (image_fread(image, cartridge1 + load_offset, filesize) != filesize)
730      {
731         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to load all of the cart");
732         return INIT_FAIL;
733      }
729734   }
730   if ( filesize < 0x010000 ) { memcpy( cartridge1 + 0x008000, cartridge1, 0x008000 ); } /* ->64KB */
731   if ( filesize < 0x020000 ) { memcpy( cartridge1 + 0x010000, cartridge1, 0x010000 ); } /* ->128KB */
732   if ( filesize < 0x040000 ) { memcpy( cartridge1 + 0x020000, cartridge1, 0x020000 ); } /* ->256KB */
733   if ( filesize < 0x080000 ) { memcpy( cartridge1 + 0x040000, cartridge1, 0x040000 ); } /* ->512KB */
734   if ( filesize < 0x100000 ) { memcpy( cartridge1 + 0x080000, cartridge1, 0x080000 ); } /* ->1MB */
735   if ( filesize < 0x1c0000 ) { memcpy( cartridge1 + 0x100000, cartridge1, 0x100000 ); } /* -> >=1.8MB */
735   else
736      memcpy(cartridge1 + load_offset, image_get_software_region(image, "rom"), filesize);
737   
738   if (filesize < 0x010000) { memcpy(cartridge1 + 0x008000, cartridge1, 0x008000); } /* ->64KB */
739   if (filesize < 0x020000) { memcpy(cartridge1 + 0x010000, cartridge1, 0x010000); } /* ->128KB */
740   if (filesize < 0x040000) { memcpy(cartridge1 + 0x020000, cartridge1, 0x020000); } /* ->256KB */
741   if (filesize < 0x080000) { memcpy(cartridge1 + 0x040000, cartridge1, 0x040000); } /* ->512KB */
742   if (filesize < 0x100000) { memcpy(cartridge1 + 0x080000, cartridge1, 0x080000); } /* ->1MB */
743   if (filesize < 0x1c0000) { memcpy(cartridge1 + 0x100000, cartridge1, 0x100000); } /* -> >=1.8MB */
736744   return INIT_PASS;
737745}
738746
src/mess/machine/advision.c
r7916r7917
99#include "emu.h"
1010#include "includes/advision.h"
1111#include "cpu/mcs48/mcs48.h"
12#include "devices/cartslot.h"
1312#include "sound/dac.h"
1413
1514/*
src/mess/drivers/pokemini.c
r7916r7917
8787   MDRV_CARTSLOT_ADD("cart")
8888   MDRV_CARTSLOT_EXTENSION_LIST("min,bin")
8989   MDRV_CARTSLOT_NOT_MANDATORY
90   MDRV_CARTSLOT_START(pokemini_cart)
90   MDRV_CARTSLOT_INTERFACE("pokemini_cart")
9191   MDRV_CARTSLOT_LOAD(pokemini_cart)
92
93   /* Software lists */
94   MDRV_SOFTWARE_LIST_ADD("pokemini")
9295MACHINE_DRIVER_END
9396
9497
src/mess/drivers/gamecom.c
r7916r7917
125125   MDRV_CARTSLOT_ADD("cart")
126126   MDRV_CARTSLOT_EXTENSION_LIST("bin,tgc")
127127   MDRV_CARTSLOT_NOT_MANDATORY
128   MDRV_CARTSLOT_INTERFACE("gamecom_cart")
128129   MDRV_CARTSLOT_LOAD(gamecom_cart)
130   MDRV_SOFTWARE_LIST_ADD("gamecom")
129131MACHINE_DRIVER_END
130132
131133ROM_START( gamecom )
src/mess/drivers/advision.c
r7916r7917
5959    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_PLAYER(1) PORT_8WAY
6060INPUT_PORTS_END
6161
62/* Cartridge (+ Software List) */
63
64static DEVICE_IMAGE_LOAD( advision_cart )
65{
66   UINT8   *cart_rom;
67   UINT32   cart_rom_size;
68   
69   if (image_software_entry(image) == NULL)
70   {
71      cart_rom = memory_region(image->machine, "cart");
72      cart_rom_size = image_length(image);
73
74      if (cart_rom_size > memory_region_length(image->machine, "cart"))
75      {
76         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
77         return INIT_FAIL;
78      }
79     
80      if (image_fread(image, cart_rom, cart_rom_size) != cart_rom_size)
81      {
82         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
83         return INIT_FAIL;
84      }
85     
86   }
87   else
88   {
89      cart_rom = image_get_software_region(image, "rom");
90      cart_rom_size = image_get_software_region_length(image, "rom");
91   }
92   
93   memcpy(memory_region(image->machine, I8048_TAG), cart_rom, cart_rom_size);
94
95   return INIT_PASS;
96}
97
6298/* Machine Driver */
6399
64100static COP400_INTERFACE( advision_cop411_interface )
r7916r7917
106142   MDRV_CARTSLOT_ADD("cart")
107143   MDRV_CARTSLOT_EXTENSION_LIST("bin")
108144   MDRV_CARTSLOT_MANDATORY
145   MDRV_CARTSLOT_INTERFACE("advision_cart")
146   MDRV_CARTSLOT_LOAD(advision_cart)
147
148   /* Software lists */
149   MDRV_SOFTWARE_LIST_ADD("advision")
109150MACHINE_DRIVER_END
110151
111152/* ROMs */
112153
113154ROM_START( advision )
114   ROM_REGION( 0x1000, I8048_TAG, 0 )
115   ROM_CART_LOAD( "cart", 0x0000, 0x1000, ROM_NOMIRROR | ROM_FULLSIZE )
155   ROM_REGION( 0x1000, I8048_TAG, ROMREGION_ERASE00 )
116156
117157   ROM_REGION( 0x400, "bios", 0 )
118158    ROM_LOAD( "avbios.u5", 0x000, 0x400, CRC(279e33d1) SHA1(bf7b0663e9125c9bfb950232eab627d9dbda8460) )
119159
120160   ROM_REGION( 0x200, COP411_TAG, 0 )
121161   ROM_LOAD( "avsound.u8", 0x000, 0x200, CRC(81e95975) SHA1(8b6f8c30dd3e9d8e43f1ea20fba2361b383790eb) )
162
163   ROM_REGION( 0x1000, "cart", ROMREGION_ERASE00 )
122164ROM_END
123165
124166/* Game Driver */
src/mess/drivers/gmaster.c
r7916r7917
33******************************************************************************/
44
55#include "emu.h"
6//#include "vidhrdw/generic.h"
76#include "cpu/upd7810/upd7810.h"
87#include "devices/cartslot.h"
98
r7916r7917
180179{
181180   int i;
182181
183   for ( i = 0; i < 2; i++ )
182   for (i = 0; i < 2; i++)
184183   {
185184      palette_set_color_rgb(machine, i, gmaster_palette[i][0], gmaster_palette[i][1], gmaster_palette[i][2]);
186185   }
r7916r7917
198197         UINT16 *line;
199198
200199         line = BITMAP_ADDR16(bitmap, (y * 8), x);
201         line[0] = (d >> 0) & 1;
200         line[0] = BIT(d, 0);
202201         line = BITMAP_ADDR16(bitmap, (y * 8 + 1), x);
203         line[0] = (d >> 1) & 1;
202         line[0] = BIT(d, 1);
204203         line = BITMAP_ADDR16(bitmap, (y * 8 + 2), x);
205         line[0] = (d >> 2) & 1;
204         line[0] = BIT(d, 2);
206205         line = BITMAP_ADDR16(bitmap, (y * 8 + 3), x);
207         line[0] = (d >> 3) & 1;
206         line[0] = BIT(d, 3);
208207         line = BITMAP_ADDR16(bitmap, (y * 8 + 4), x);
209         line[0] = (d >> 4) & 1;
208         line[0] = BIT(d, 4);
210209         line = BITMAP_ADDR16(bitmap, (y * 8 + 5), x);
211         line[0] = (d >> 5) & 1;
210         line[0] = BIT(d, 5);
212211         line = BITMAP_ADDR16(bitmap, (y * 8 + 6), x);
213         line[0] = (d >> 6) & 1;
212         line[0] = BIT(d, 6);
214213         line = BITMAP_ADDR16(bitmap, (y * 8 + 7), x);
215         line[0] = (d >> 7) & 1;
214         line[0] = BIT(d, 7);
216215      }
217216    }
218217    return 0;
219218}
220219
220static DEVICE_IMAGE_LOAD( gmaster_cart )
221{
222   UINT8 *cart_rom;
223   UINT32 cart_rom_size;
224   
225   if (image_software_entry(image) == NULL)
226   {
227      cart_rom = memory_region(image->machine, "cart");
228      cart_rom_size = image_length(image);
229     
230      if (cart_rom_size > memory_region_length(image->machine, "cart"))
231      {
232         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
233         return INIT_FAIL;
234      }
235     
236      if (image_fread(image, cart_rom, cart_rom_size) != cart_rom_size)
237      {
238         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
239         return INIT_FAIL;
240      }
241     
242   }
243   else
244   {
245      cart_rom = image_get_software_region(image, "rom");
246      cart_rom_size = image_get_software_region_length(image, "rom");
247   }
248   
249   memcpy(memory_region(image->machine, "maincpu") + 0x8000, cart_rom, cart_rom_size);
250   
251   return INIT_PASS;
252}
253
221254static INTERRUPT_GEN( gmaster_interrupt )
222255{
223256   cputag_set_input_line(device->machine, "maincpu", UPD7810_INTFE1, ASSERT_LINE);
r7916r7917
251284   MDRV_SOUND_ROUTE(0, "speaker", 0.50)
252285
253286   MDRV_CARTSLOT_ADD("cart")
287   MDRV_CARTSLOT_EXTENSION_LIST("bin")
288   MDRV_CARTSLOT_MANDATORY
289   MDRV_CARTSLOT_INTERFACE("gmaster_cart")
290   MDRV_CARTSLOT_LOAD(gmaster_cart)
291   MDRV_SOFTWARE_LIST_ADD("gmaster")
254292MACHINE_DRIVER_END
255293
256294
r7916r7917
258296   ROM_REGION(0x10000,"maincpu", 0)
259297   ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) )
260298//  ROM_CART_LOAD(0, "bin", 0x8000, 0x7f00, 0)
261   ROM_CART_LOAD("cart", 0x8000, 0x8000, 0)
299
300   ROM_REGION( 0x8000, "cart", ROMREGION_ERASE00 )
262301ROM_END
263302
264303static DRIVER_INIT( gmaster )
r7916r7917
266305   memset(&gmaster_video, 0, sizeof(gmaster_video));
267306}
268307
269#if 0
270static int gmaster_load_rom(running_machine *machine, int id)
271{
272   FILE *cartfile;
273   UINT8 *rom = memory_region(machine, "maincpu");
274   int size;
275
276   if (device_filename(IO_CARTSLOT, id) == NULL)
277   {
278      printf("%s requires Cartridge!\n", machine->gamedrv->name);
279      return 0;
280   }
281
282   if (!(cartfile = (FILE*)image_fopen(IO_CARTSLOT, id, OSD_FILETYPE_IMAGE_R, 0)))
283   {
284      logerror("%s not found\n",device_filename(IO_CARTSLOT,id));
285      return 1;
286   }
287   size=osd_fsize(cartfile);
288   if (size>0x8000)
289   {
290       logerror("%s: size %d not yet supported\n",device_filename(IO_CARTSLOT,id), size);
291       return 1;
292   }
293
294   if (osd_fread(cartfile, rom+0x8000, size)!=size)
295   {
296      logerror("%s load error\n",device_filename(IO_CARTSLOT,id));
297      osd_fclose(cartfile);
298      return 1;
299   }
300//  memcpy(rom+0x0000, rom+0x8000, 0x4000);
301   osd_fclose(cartfile);
302   return 0;
303}
304#endif
305
306308/*    YEAR      NAME            PARENT  MACHINE   INPUT     INIT  COMPANY                 FULLNAME */
307309CONS( 1990, gmaster,       0,          0, gmaster,  gmaster,    gmaster,    "Hartung", "Game Master", GAME_IMPERFECT_SOUND)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team