Previous 15994 Revisions Next

r15292 Thursday 24th May, 2012 at 01:14:21 UTC by Robbbert
ELEKTOR added support for pgm quickloads. Added notes on how to use quickloads on vc4000 etc. [Robbbert]
[src/mess/drivers]vc4000.c

src/mess/drivers/vc4000.c
r15291r15292
8686The Select key (Z) and the joystick don't actually exist, but I've left them
8787in the keyboard matrix for now.
8888
89
90Quickloads
91----------
92You can load pgm and tvc files with the quickload facility. The quickloads
93are meant for the ElektorTVGC, however with a bit a trickery they can be made
94to work on the vc4000 as well. Procedure:
95
96- Get a copy of the Elektor bios and rename it to ELEKTOR.BIN then save it
97  with the rest of your vc4000 carts.
98
99- Start vc4000, and load ELEKTOR.BIN into the cartslot. Now your vc4000
100  thinks it is an Elektor.
101
102- Load a quickload file. Some of them will work, and in some cases, better
103  than on the Elektor system.
104
89105******************************************************************************/
90106
91107#include "includes/vc4000.h"
r15291r15292
396412   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
397413
398414   /* quickload */
399   MCFG_QUICKLOAD_ADD("quickload", vc4000, "tvc", 0)
415   MCFG_QUICKLOAD_ADD("quickload", vc4000, "pgm,tvc", 0)
400416
401417   /* cartridge */
402418   MCFG_CARTSLOT_ADD("cart")
r15291r15292
527543   quick_length = image.length();
528544   quick_data = (UINT8*)malloc(quick_length);
529545   if (!quick_data)
546   {
547      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
548      image.message(" Cannot open file");
530549      return IMAGE_INIT_FAIL;
550   }
531551
532552   read_ = image.fread( quick_data, quick_length);
533553   if (read_ != quick_length)
554   {
555      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
556      image.message(" Cannot read the file");
534557      return IMAGE_INIT_FAIL;
558   }
535559
536   if (quick_data[0] != 2)
537      return IMAGE_INIT_FAIL;
560   if (mame_stricmp(image.filetype(), "tvc")==0)
561   {
562      if (quick_data[0] != 2)
563      {
564         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
565         image.message(" Invalid header");
566         return IMAGE_INIT_FAIL;
567      }
538568
539   quick_addr = quick_data[1] * 256 + quick_data[2];
540   exec_addr = quick_data[3] * 256 + quick_data[4];
569      quick_addr = quick_data[1] * 256 + quick_data[2];
570      exec_addr = quick_data[3] * 256 + quick_data[4];
541571
542   //if ((quick_addr + quick_length - 5) > 0x1000)
543   //  return IMAGE_INIT_FAIL;
572      space->write_byte(0x08be, quick_data[3]);
573      space->write_byte(0x08bf, quick_data[4]);
544574
545   space->write_byte(0x08be, quick_data[3]);
546   space->write_byte(0x08bf, quick_data[4]);
575      for (i = 0; i < quick_length - 5; i++)
576         if ((quick_addr + i) < 0x1600)
577            space->write_byte(i + quick_addr, quick_data[i+5]);
547578
548   for (i = 0; i < quick_length - 5; i++)
549   {   if ((quick_addr + i) < 0x1000)
550         space->write_byte(i + quick_addr, quick_data[i+5]);
579      /* display a message about the loaded quickload */
580      image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr);
581
582      // Start the quickload
583      cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr);
584      return IMAGE_INIT_PASS;
551585   }
586   else
587   if (mame_stricmp(image.filetype(), "pgm")==0)
588   {
589      if (quick_data[0] != 0)
590      {
591         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
592         image.message(" Invalid header");
593         return IMAGE_INIT_FAIL;
594      }
552595
553   /* display a message about the loaded quickload */
554   image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr);
596      exec_addr = quick_data[1] * 256 + quick_data[2];
555597
556   // Start the quickload (only does something on Elektor)
557   cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr);
558   return IMAGE_INIT_PASS;
598      if (exec_addr >= quick_length)
599      {
600         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file");
601         image.message(" Exec address beyond end of file");
602         return IMAGE_INIT_FAIL;
603      }
604
605      if (quick_length < 0x904)
606      {
607         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
608         image.message(" File too short");
609         return IMAGE_INIT_FAIL;
610      }
611
612      // some programs store data in PVI memory and other random places. This is not supported.
613      if (quick_length > 0x1600)
614      {
615         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long");
616         image.message(" File too long");
617         return IMAGE_INIT_FAIL;
618      }
619
620      for (i = quick_addr; i < quick_length; i++)
621         if (i < 0x1600)
622            space->write_byte(i, quick_data[i]);
623
624      /* display a message about the loaded quickload */
625      image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr);
626
627      // Start the quickload
628      cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr);
629      return IMAGE_INIT_PASS;
630   }
631   else
632      return IMAGE_INIT_FAIL;
559633}
560634
561635

Previous 15994 Revisions Next


© 1998-2018 The MESS Team