src/mess/machine/nes.c
| r1668 | r1669 | |
| 188 | 188 | { |
| 189 | 189 | init_nes_core(); |
| 190 | 190 | 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 | | } |
| 200 | 191 | } |
| 201 | 192 | |
| 202 | 193 | static void nes_machine_stop(running_machine *machine) |
| r1668 | r1669 | |
| 562 | 553 | } |
| 563 | 554 | |
| 564 | 555 | |
| 556 | DEVICE_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; |
| 565 | 562 | |
| 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 | |
| 566 | 574 | DEVICE_LOAD(nes_disk) |
| 567 | 575 | { |
| 568 | 576 | unsigned char magic[4]; |
| 569 | 577 | |
| 570 | | /* See if it has a fucking redundant header on it */ |
| 578 | /* See if it has a redundant header on it */ |
| 571 | 579 | image_fread(image, magic, 4); |
| 572 | 580 | if ((magic[0] == 'F') && |
| 573 | 581 | (magic[1] == 'D') && |
| 574 | 582 | (magic[2] == 'S')) |
| 575 | 583 | { |
| 576 | | /* Skip past the fucking redundant header */ |
| 584 | /* Skip past the redundant header */ |
| 577 | 585 | image_fseek (image, 0x10, SEEK_SET); |
| 578 | 586 | } |
| 579 | 587 | else |
| 580 | 588 | /* otherwise, point to the start of the image */ |
| 581 | 589 | image_fseek (image, 0, SEEK_SET); |
| 582 | 590 | |
| 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 | | |
| 595 | 591 | /* read in all the sides */ |
| 596 | 592 | while (!image_feof (image)) |
| 597 | 593 | { |