Previous 15994 Revisions Next

r1669 Friday 8th February, 2008 at 16:16:25 UTC by Wilbert Pol
[FAMICOM] Allow system to boot with no disk inserted. Cleaned up a few comments.
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c

src/mess/includes/nes.h
r1668r1669
8585/* protos */
8686
8787DEVICE_LOAD(nes_cart);
88DEVICE_INIT(nes_disk);
8889DEVICE_LOAD(nes_disk);
8990DEVICE_UNLOAD(nes_disk);
9091
src/mess/machine/nes.c
r1668r1669
188188{
189189   init_nes_core();
190190   add_exit_callback(machine, nes_machine_stop);
191
192   if ((!image_exists(image_from_devtype_and_index(IO_CARTSLOT, 0))) && (!image_exists(image_from_devtype_and_index(IO_FLOPPY, 0))))
193   {
194      /* NPW 05-Mar-2006 - Hack to keep the Famicom from crashing */
195      static const UINT8 infinite_loop[] = { 0x4C, 0xF9, 0xFF, 0xF9, 0xFF }; /* JMP $FFF9, DC.W $FFF9 */
196      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xFFF9, 0xFFFD, 0, 0, MRA8_BANK11);
197      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xFFF9, 0xFFFD, 0, 0, MWA8_BANK11);
198      memory_set_bankptr(11, (void *) infinite_loop);
199   }
200191}
201192
202193static void nes_machine_stop(running_machine *machine)
r1668r1669
562553}
563554
564555
556DEVICE_INIT(nes_disk)
557{
558   /* clear some of the cart variables we don't use */
559   nes.trainer = 0;
560   nes.battery = 0;
561   nes.prg_chunks = nes.chr_chunks = 0;
565562
563   nes.mapper = 20;
564   nes.four_screen_vram = 0;
565   nes.hard_mirroring = 0;
566
567   nes_fds.sides = 0;
568   nes_fds.data = NULL;
569
570   return INIT_PASS;
571}
572
573
566574DEVICE_LOAD(nes_disk)
567575{
568576   unsigned char magic[4];
569577
570   /* See if it has a fucking redundant header on it */
578   /* See if it has a redundant header on it */
571579   image_fread(image, magic, 4);
572580   if ((magic[0] == 'F') &&
573581      (magic[1] == 'D') &&
574582      (magic[2] == 'S'))
575583   {
576      /* Skip past the fucking redundant header */
584      /* Skip past the redundant header */
577585      image_fseek (image, 0x10, SEEK_SET);
578586   }
579587   else
580588      /* otherwise, point to the start of the image */
581589      image_fseek (image, 0, SEEK_SET);
582590
583   /* clear some of the cart variables we don't use */
584   nes.trainer = 0;
585   nes.battery = 0;
586   nes.prg_chunks = nes.chr_chunks = 0;
587
588   nes.mapper = 20;
589   nes.four_screen_vram = 0;
590   nes.hard_mirroring = 0;
591
592   nes_fds.sides = 0;
593   nes_fds.data = NULL;
594
595591   /* read in all the sides */
596592   while (!image_feof (image))
597593   {
src/mess/drivers/nes.c
r1668r1669
394394      case DEVINFO_INT_COUNT:                     info->i = 1; break;
395395
396396      /* --- the following bits of info are returned as pointers to data or functions --- */
397      case DEVINFO_PTR_INIT:                     info->init = device_init_nes_disk; break;
397398      case DEVINFO_PTR_LOAD:                     info->load = device_load_nes_disk; break;
398399      case DEVINFO_PTR_UNLOAD:                  info->unload = device_unload_nes_disk; break;
399400

Previous 15994 Revisions Next


© 1998-2018 The MESS Team