Previous 15994 Revisions Next

r15495 Sunday 24th June, 2012 at 12:41:33 UTC by Robbbert
homelab WIP
[src/mess/drivers]homelab.c

src/mess/drivers/homelab.c
r15494r15495
66    15/06/2012 Various updates [Robbbert]
77
88    ToDO:
9    - Quickload loads the files ok, but the machine crashes.
910    - homelab2 - cassette
1011                 Note that rom code 0x40-48 is meaningless garbage,
1112                 had to patch to stop it crashing. Need a new dump.
r15494r15495
3637#include "imagedev/cassette.h"
3738#include "audio/mea8000.h"
3839#include "sound/dac.h"
40#include "imagedev/snapquik.h"
3941
4042
4143#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
r15494r15495
500502
501503static const mea8000_interface brailab4_speech_intf = { "speech", NULL };
502504
505static QUICKLOAD_LOAD(homelab)
506{
507   address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM);
508   int i=0;
509   UINT8 ch;
510   UINT16 quick_addr;
511   UINT16 quick_length;
512   UINT8 *quick_data;
513   char pgmname[256];
514   UINT16 args[3];
515   int read_;
516
517   quick_length = image.length();
518   quick_data = (UINT8*)malloc(quick_length);
519   if (!quick_data)
520   {
521      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file");
522      image.message(" Cannot open file");
523      return IMAGE_INIT_FAIL;
524   }
525
526   read_ = image.fread( quick_data, quick_length);
527   if (read_ != quick_length)
528   {
529      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file");
530      image.message(" Cannot read the file");
531      return IMAGE_INIT_FAIL;
532   }
533
534   image.fseek(0x100, SEEK_SET);
535   ch = image.fgetc();
536   if (ch != 0xA5)
537   {
538      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header");
539      image.message(" Invalid header");
540      return IMAGE_INIT_FAIL;
541   }
542
543   while((ch = image.fgetc()))
544   {
545      if (ch == EOF)
546      {
547         image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file name");
548         image.message(" Unexpected EOF while getting file name");
549         return IMAGE_INIT_FAIL;
550      }
551
552      if (ch != '\0')
553      {
554         if (i >= (ARRAY_LENGTH(pgmname) - 1))
555         {
556            image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long");
557            image.message(" File name too long");
558            return IMAGE_INIT_FAIL;
559         }
560
561         pgmname[i] = ch;   /* build program name */
562         i++;
563      }
564   }
565
566   pgmname[i] = '\0';   /* terminate string with a null */
567
568   if (image.fread(args, sizeof(args)) != sizeof(args))
569   {
570      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size");
571      image.message(" Unexpected EOF while getting file size");
572      return IMAGE_INIT_FAIL;
573   }
574
575   quick_addr = LITTLE_ENDIANIZE_INT16(args[0]);
576   quick_length = LITTLE_ENDIANIZE_INT16(args[1]);
577   int quick_end = quick_addr+quick_length-1;
578
579   if (quick_end > 0x7fff)
580   {
581      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too large");
582      image.message(" File too large");
583      return IMAGE_INIT_FAIL;
584   }
585
586   /* display a message about the loaded quickload */
587   image.message(" %s\nsize=%04X : start=%04X : end=%04X",pgmname,quick_length,quick_addr,quick_end);
588
589   for (i = 0; i < quick_length; i++)
590   {
591      int j = (quick_addr + i);
592      if (image.fread(&ch, 1) != 1)
593      {
594         char message[256];
595         snprintf(message, ARRAY_LENGTH(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
596         image.seterror(IMAGE_ERROR_INVALIDIMAGE, message);
597         image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
598         return IMAGE_INIT_FAIL;
599      }
600      space->write_byte(j, ch);
601   }
602
603   return IMAGE_INIT_PASS;
604}
605
503606/* Machine driver */
504607static MACHINE_CONFIG_START( homelab, homelab_state )
505608   /* basic machine hardware */
r15494r15495
526629   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
527630
528631   MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface )
632   MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 2)
529633MACHINE_CONFIG_END
530634
531635static MACHINE_CONFIG_START( homelab3, homelab_state )
r15494r15495
553657   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
554658
555659   MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface )
660   MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 2)
556661MACHINE_CONFIG_END
557662
558663static MACHINE_CONFIG_START( brailab4, homelab_state )
r15494r15495
583688
584689   MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface )
585690   MCFG_MEA8000_ADD("mea8000", brailab4_speech_intf)
691   MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 8)
586692MACHINE_CONFIG_END
587693
588694

Previous 15994 Revisions Next


© 1998-2018 The MESS Team