src/mame/machine/atari.c
| r4474 | r4475 | |
| 20 | 20 | #define VERBOSE_SERIAL 0 |
| 21 | 21 | #define VERBOSE_TIMERS 0 |
| 22 | 22 | |
| 23 | | //#define LOG(x) if (errorlog) fprintf x |
| 24 | | |
| 25 | | static int atari = 0; |
| 26 | | #define ATARI_5200 0 |
| 27 | | #define ATARI_400 1 |
| 28 | | #define ATARI_800 2 |
| 29 | | #define ATARI_600XL 3 |
| 30 | | #define ATARI_800XL 4 |
| 31 | | |
| 32 | | #ifdef MESS |
| 33 | | static int a800_cart_loaded = 0; |
| 34 | | static int a800_cart_is_16k = 0; |
| 35 | | #endif |
| 36 | | |
| 37 | 23 | static void a800xl_mmu(running_machine *machine, UINT8 new_mmu); |
| 38 | 24 | static void a600xl_mmu(running_machine *machine, UINT8 new_mmu); |
| 39 | 25 | |
| r4474 | r4475 | |
| 90 | 76 | static WRITE8_DEVICE_HANDLER(a600xl_pia_pb_w) { a600xl_mmu(device->machine, data); } |
| 91 | 77 | static WRITE8_DEVICE_HANDLER(a800xl_pia_pb_w) { a800xl_mmu(device->machine, data); } |
| 92 | 78 | |
| 93 | | #ifndef MESS |
| 94 | 79 | WRITE_LINE_DEVICE_HANDLER(atari_pia_cb2_w) { } |
| 95 | | #endif |
| 96 | 80 | |
| 97 | 81 | const pia6821_interface atari_pia_interface = |
| 98 | 82 | { |
| r4474 | r4475 | |
| 423 | 407 | atari_last = 0xff; |
| 424 | 408 | } |
| 425 | 409 | |
| 426 | | #ifdef MESS |
| 427 | | DRIVER_INIT( atari ) |
| 428 | | { |
| 429 | | offs_t ram_top; |
| 430 | | offs_t ram_size; |
| 431 | 410 | |
| 432 | | if (!strcmp(machine->gamedrv->name, "a400") |
| 433 | | || !strcmp(machine->gamedrv->name, "a400pal") |
| 434 | | || !strcmp(machine->gamedrv->name, "a800") |
| 435 | | || !strcmp(machine->gamedrv->name, "a800pal") |
| 436 | | || !strcmp(machine->gamedrv->name, "a800xl")) |
| 437 | | { |
| 438 | | ram_size = 0xA000; |
| 439 | | } |
| 440 | | else |
| 441 | | { |
| 442 | | ram_size = 0x8000; |
| 443 | | } |
| 444 | | |
| 445 | | /* install RAM */ |
| 446 | | ram_top = MIN(mess_ram_size, ram_size) - 1; |
| 447 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 448 | | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 449 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 450 | | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 451 | | memory_set_bankptr(machine, 2, mess_ram); |
| 452 | | } |
| 453 | | #endif |
| 454 | | |
| 455 | | |
| 456 | | |
| 457 | 411 | /************************************* |
| 458 | 412 | * |
| 459 | 413 | * Generic Atari Code |
| 460 | 414 | * |
| 461 | 415 | *************************************/ |
| 462 | 416 | |
| 463 | | #ifdef MESS |
| 464 | | static void a800_setbank(running_machine *machine, int n) |
| 465 | | { |
| 466 | | void *read_addr; |
| 467 | | void *write_addr; |
| 468 | | UINT8 *mem = memory_region(machine, "maincpu"); |
| 469 | 417 | |
| 470 | | switch (n) |
| 471 | | { |
| 472 | | case 1: |
| 473 | | read_addr = &mem[0x10000]; |
| 474 | | write_addr = NULL; |
| 475 | | break; |
| 476 | | default: |
| 477 | | if( atari <= ATARI_400 ) |
| 478 | | { |
| 479 | | /* Atari 400 has no RAM here, so install the NOP handler */ |
| 480 | | read_addr = NULL; |
| 481 | | write_addr = NULL; |
| 482 | | } |
| 483 | | else |
| 484 | | { |
| 485 | | read_addr = &mess_ram[0x08000]; |
| 486 | | write_addr = &mess_ram[0x08000]; |
| 487 | | } |
| 488 | | break; |
| 489 | | } |
| 490 | | |
| 491 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, |
| 492 | | read_addr ? SMH_BANK1 : SMH_NOP); |
| 493 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, |
| 494 | | write_addr ? SMH_BANK1 : SMH_NOP); |
| 495 | | if (read_addr) |
| 496 | | memory_set_bankptr(machine, 1, read_addr); |
| 497 | | if (write_addr) |
| 498 | | memory_set_bankptr(machine, 1, write_addr); |
| 499 | | } |
| 500 | | #endif |
| 501 | | |
| 502 | | |
| 503 | | |
| 504 | 418 | static void pokey_reset(running_machine *machine) |
| 505 | 419 | { |
| 506 | 420 | const device_config *pokey = devtag_get_device(machine, "pokey"); |
| r4474 | r4475 | |
| 508 | 422 | } |
| 509 | 423 | |
| 510 | 424 | |
| 511 | | |
| 512 | | static void cart_reset(running_machine *machine) |
| 513 | | { |
| 514 | | #ifdef MESS |
| 515 | | if (a800_cart_loaded) |
| 516 | | a800_setbank(machine, 1); |
| 517 | | #endif /* MESS */ |
| 518 | | } |
| 519 | | |
| 520 | | |
| 521 | | |
| 522 | 425 | static UINT8 console_read(const address_space *space) |
| 523 | 426 | { |
| 524 | 427 | return input_port_read(space->machine, "console"); |
| 525 | 428 | } |
| 526 | 429 | |
| 527 | 430 | |
| 528 | | |
| 529 | 431 | static void console_write(const address_space *space, UINT8 data) |
| 530 | 432 | { |
| 531 | 433 | const device_config *dac = devtag_get_device(space->machine, "dac"); |
| r4474 | r4475 | |
| 542 | 444 | } |
| 543 | 445 | |
| 544 | 446 | |
| 545 | | static void atari_machine_start(running_machine *machine, int type, int has_cart) |
| 447 | void atari_machine_start(running_machine *machine) |
| 546 | 448 | { |
| 547 | 449 | gtia_interface gtia_intf; |
| 548 | 450 | |
| 549 | | atari = type; |
| 550 | | |
| 551 | 451 | /* GTIA */ |
| 552 | 452 | memset(>ia_intf, 0, sizeof(gtia_intf)); |
| 553 | 453 | if (input_port_by_tag(machine->portconfig, "console") != NULL) |
| r4474 | r4475 | |
| 562 | 462 | /* ANTIC */ |
| 563 | 463 | add_reset_callback(machine, _antic_reset); |
| 564 | 464 | |
| 565 | | /* cartridge */ |
| 566 | | if (has_cart) |
| 567 | | add_reset_callback(machine, cart_reset); |
| 568 | | |
| 569 | | #ifdef MESS |
| 570 | | { |
| 571 | | offs_t ram_top; |
| 572 | | offs_t ram_size; |
| 573 | | |
| 574 | | if (!strcmp(machine->gamedrv->name, "a400") |
| 575 | | || !strcmp(machine->gamedrv->name, "a400pal") |
| 576 | | || !strcmp(machine->gamedrv->name, "a800") |
| 577 | | || !strcmp(machine->gamedrv->name, "a800pal") |
| 578 | | || !strcmp(machine->gamedrv->name, "a800xl")) |
| 579 | | { |
| 580 | | ram_size = 0xA000; |
| 581 | | } |
| 582 | | else |
| 583 | | { |
| 584 | | ram_size = 0x8000; |
| 585 | | } |
| 586 | | |
| 587 | | /* install RAM */ |
| 588 | | ram_top = MIN(mess_ram_size, ram_size) - 1; |
| 589 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 590 | | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 591 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 592 | | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 593 | | memory_set_bankptr(machine, 2, mess_ram); |
| 594 | | } |
| 595 | | #endif /* MESS */ |
| 596 | | |
| 597 | 465 | /* save states */ |
| 598 | 466 | state_save_register_global_pointer(machine, ((UINT8 *) &antic.r), sizeof(antic.r)); |
| 599 | 467 | state_save_register_global_pointer(machine, ((UINT8 *) &antic.w), sizeof(antic.w)); |
| 600 | 468 | } |
| 601 | 469 | |
| 602 | 470 | |
| 603 | | |
| 604 | 471 | /************************************* |
| 605 | 472 | * |
| 606 | | * Atari 400 |
| 607 | 473 | * Atari 600XL |
| 608 | 474 | * |
| 609 | 475 | *************************************/ |
| 610 | 476 | |
| 611 | | MACHINE_START( a400 ) |
| 612 | | { |
| 613 | | atari_machine_start(machine, ATARI_400, TRUE); |
| 614 | | } |
| 615 | | |
| 616 | 477 | MACHINE_START( a600xl ) |
| 617 | 478 | { |
| 618 | | atari_machine_start(machine, ATARI_600XL, TRUE); |
| 479 | atari_machine_start(machine); |
| 619 | 480 | } |
| 620 | | |
| 621 | | |
| 622 | | |
| 623 | | /************************************* |
| 624 | | * |
| 625 | | * Atari 800 |
| 626 | | * |
| 627 | | *************************************/ |
| 628 | | |
| 629 | | MACHINE_START( a800 ) |
| 630 | | { |
| 631 | | atari_machine_start(machine, ATARI_800, TRUE); |
| 632 | | } |
| 633 | | |
| 634 | | |
| 635 | | |
| 636 | | #ifdef MESS |
| 637 | | DEVICE_IMAGE_LOAD( a800_cart ) |
| 638 | | { |
| 639 | | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 640 | | int size; |
| 641 | | |
| 642 | | /* load an optional (dual) cartridge (e.g. basic.rom) */ |
| 643 | | if( strcmp(image->tag,"cart2") == 0 ) |
| 644 | | { |
| 645 | | size = image_fread(image, &mem[0x12000], 0x2000); |
| 646 | | a800_cart_is_16k = (size == 0x2000); |
| 647 | | logerror("%s loaded right cartridge '%s' size 16K\n", image->machine->gamedrv->name, image_filename(image) ); |
| 648 | | } |
| 649 | | else |
| 650 | | { |
| 651 | | size = image_fread(image, &mem[0x10000], 0x2000); |
| 652 | | a800_cart_loaded = size > 0x0000; |
| 653 | | size = image_fread(image, &mem[0x12000], 0x2000); |
| 654 | | a800_cart_is_16k = size > 0x2000; |
| 655 | | logerror("%s loaded left cartridge '%s' size %s\n", image->machine->gamedrv->name, image_filename(image) , (a800_cart_is_16k) ? "16K":"8K"); |
| 656 | | } |
| 657 | | return INIT_PASS; |
| 658 | | } |
| 659 | | |
| 660 | | DEVICE_IMAGE_UNLOAD( a800_cart ) |
| 661 | | { |
| 662 | | if( strcmp(image->tag,"cart2") == 0 ) |
| 663 | | { |
| 664 | | a800_cart_is_16k = 0; |
| 665 | | a800_setbank(image->machine, 1); |
| 666 | | } |
| 667 | | else |
| 668 | | { |
| 669 | | a800_cart_loaded = 0; |
| 670 | | a800_setbank(image->machine, 0); |
| 671 | | } |
| 672 | | } |
| 673 | | #endif |
| 674 | | |
| 675 | | |
| 676 | | |
| 677 | | /************************************* |
| 678 | | * |
| 679 | | * Atari 800XL |
| 680 | | * |
| 681 | | *************************************/ |
| 682 | | |
| 683 | | MACHINE_START( a800xl ) |
| 684 | | { |
| 685 | | atari_machine_start(machine, ATARI_800XL, TRUE); |
| 686 | | } |
| 687 | | |
| 688 | | |
| 689 | | |
| 690 | | #ifdef MESS |
| 691 | | DEVICE_IMAGE_LOAD( a800xl_cart ) |
| 692 | | { |
| 693 | | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 694 | | astring *fname; |
| 695 | | mame_file *basic_fp; |
| 696 | | file_error filerr; |
| 697 | | unsigned size; |
| 698 | | |
| 699 | | fname = astring_assemble_3(astring_alloc(), image->machine->gamedrv->name, PATH_SEPARATOR, "basic.rom"); |
| 700 | | filerr = mame_fopen(SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ, &basic_fp); |
| 701 | | astring_free(fname); |
| 702 | | |
| 703 | | if (filerr != FILERR_NONE) |
| 704 | | { |
| 705 | | size = mame_fread(basic_fp, &mem[0x14000], 0x2000); |
| 706 | | if( size < 0x2000 ) |
| 707 | | { |
| 708 | | logerror("%s image '%s' load failed (less than 8K)\n", image->machine->gamedrv->name, astring_c(fname)); |
| 709 | | mame_fclose(basic_fp); |
| 710 | | return 2; |
| 711 | | } |
| 712 | | } |
| 713 | | |
| 714 | | /* load an optional (dual) cartidge (e.g. basic.rom) */ |
| 715 | | if (filerr != FILERR_NONE) |
| 716 | | { |
| 717 | | { |
| 718 | | size = image_fread(image, &mem[0x14000], 0x2000); |
| 719 | | a800_cart_loaded = size / 0x2000; |
| 720 | | size = image_fread(image, &mem[0x16000], 0x2000); |
| 721 | | a800_cart_is_16k = size / 0x2000; |
| 722 | | logerror("%s loaded cartridge '%s' size %s\n", |
| 723 | | image->machine->gamedrv->name, image_filename(image), (a800_cart_is_16k) ? "16K":"8K"); |
| 724 | | } |
| 725 | | mame_fclose(basic_fp); |
| 726 | | } |
| 727 | | |
| 728 | | return INIT_PASS; |
| 729 | | } |
| 730 | | #endif |
| 731 | | |
| 732 | | |
| 733 | | |
| 734 | | /************************************* |
| 735 | | * |
| 736 | | * Atari 5200 console |
| 737 | | * |
| 738 | | *************************************/ |
| 739 | | |
| 740 | | MACHINE_START( a5200 ) |
| 741 | | { |
| 742 | | atari_machine_start(machine, ATARI_800XL, FALSE); |
| 743 | | } |
| 744 | | |
| 745 | | |
| 746 | | |
| 747 | | #ifdef MESS |
| 748 | | DEVICE_IMAGE_LOAD( a5200_cart ) |
| 749 | | { |
| 750 | | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 751 | | int size; |
| 752 | | |
| 753 | | /* load an optional (dual) cartidge */ |
| 754 | | size = image_fread(image, &mem[0x4000], 0x8000); |
| 755 | | if (size<0x8000) memmove(mem+0x4000+0x8000-size, mem+0x4000, size); |
| 756 | | // mirroring of smaller cartridges |
| 757 | | if (size <= 0x1000) memcpy(mem+0xa000, mem+0xb000, 0x1000); |
| 758 | | if (size <= 0x2000) memcpy(mem+0x8000, mem+0xa000, 0x2000); |
| 759 | | if (size <= 0x4000) |
| 760 | | { |
| 761 | | const char *info; |
| 762 | | memcpy(&mem[0x4000], &mem[0x8000], 0x4000); |
| 763 | | info = image_extrainfo(image); |
| 764 | | if (info!=NULL && strcmp(info, "A13MIRRORING")==0) |
| 765 | | { |
| 766 | | memcpy(&mem[0x8000], &mem[0xa000], 0x2000); |
| 767 | | memcpy(&mem[0x6000], &mem[0x4000], 0x2000); |
| 768 | | } |
| 769 | | } |
| 770 | | logerror("%s loaded cartridge '%s' size %dK\n", |
| 771 | | image->machine->gamedrv->name, image_filename(image) , size/1024); |
| 772 | | return INIT_PASS; |
| 773 | | } |
| 774 | | |
| 775 | | DEVICE_IMAGE_UNLOAD( a5200_cart ) |
| 776 | | { |
| 777 | | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 778 | | /* zap the cartridge memory (again) */ |
| 779 | | memset(&mem[0x4000], 0x00, 0x8000); |
| 780 | | } |
| 781 | | #endif |
| 782 | | |
src/mess/machine/ataricrt.c
| r0 | r4475 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | MESS specific Atari init and Cartridge code for Atari 8 bit systems |
| 4 | |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #include "driver.h" |
| 8 | #include "includes/atari.h" |
| 9 | #include "ataridev.h" |
| 10 | |
| 11 | static int a800_cart_loaded = 0; |
| 12 | static int a800_cart_is_16k = 0; |
| 13 | static int atari = 0; |
| 14 | |
| 15 | /************************************* |
| 16 | * |
| 17 | * Generic code |
| 18 | * |
| 19 | *************************************/ |
| 20 | |
| 21 | DRIVER_INIT( atari ) |
| 22 | { |
| 23 | offs_t ram_top; |
| 24 | offs_t ram_size; |
| 25 | |
| 26 | if (!strcmp(machine->gamedrv->name, "a400") |
| 27 | || !strcmp(machine->gamedrv->name, "a400pal") |
| 28 | || !strcmp(machine->gamedrv->name, "a800") |
| 29 | || !strcmp(machine->gamedrv->name, "a800pal") |
| 30 | || !strcmp(machine->gamedrv->name, "a800xl")) |
| 31 | { |
| 32 | ram_size = 0xA000; |
| 33 | } |
| 34 | else |
| 35 | { |
| 36 | ram_size = 0x8000; |
| 37 | } |
| 38 | |
| 39 | /* install RAM */ |
| 40 | ram_top = MIN(mess_ram_size, ram_size) - 1; |
| 41 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 42 | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 43 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 44 | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 45 | memory_set_bankptr(machine, 2, mess_ram); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | static void a800_setbank(running_machine *machine, int n) |
| 50 | { |
| 51 | void *read_addr; |
| 52 | void *write_addr; |
| 53 | UINT8 *mem = memory_region(machine, "maincpu"); |
| 54 | |
| 55 | switch (n) |
| 56 | { |
| 57 | case 1: |
| 58 | read_addr = &mem[0x10000]; |
| 59 | write_addr = NULL; |
| 60 | break; |
| 61 | default: |
| 62 | if( atari <= ATARI_400 ) |
| 63 | { |
| 64 | /* Atari 400 has no RAM here, so install the NOP handler */ |
| 65 | read_addr = NULL; |
| 66 | write_addr = NULL; |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | read_addr = &mess_ram[0x08000]; |
| 71 | write_addr = &mess_ram[0x08000]; |
| 72 | } |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, |
| 77 | read_addr ? SMH_BANK1 : SMH_NOP); |
| 78 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, |
| 79 | write_addr ? SMH_BANK1 : SMH_NOP); |
| 80 | if (read_addr) |
| 81 | memory_set_bankptr(machine, 1, read_addr); |
| 82 | if (write_addr) |
| 83 | memory_set_bankptr(machine, 1, write_addr); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | static void cart_reset(running_machine *machine) |
| 88 | { |
| 89 | if (a800_cart_loaded) |
| 90 | a800_setbank(machine, 1); |
| 91 | } |
| 92 | |
| 93 | /* MESS specific parts that have to be started */ |
| 94 | static void ms_atari_machine_start(running_machine *machine, int type, int has_cart) |
| 95 | { |
| 96 | offs_t ram_top; |
| 97 | offs_t ram_size; |
| 98 | |
| 99 | /* set atari type (needed for banks above) */ |
| 100 | atari = type; |
| 101 | |
| 102 | /* determine RAM */ |
| 103 | if (!strcmp(machine->gamedrv->name, "a400") |
| 104 | || !strcmp(machine->gamedrv->name, "a400pal") |
| 105 | || !strcmp(machine->gamedrv->name, "a800") |
| 106 | || !strcmp(machine->gamedrv->name, "a800pal") |
| 107 | || !strcmp(machine->gamedrv->name, "a800xl")) |
| 108 | { |
| 109 | ram_size = 0xA000; |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | ram_size = 0x8000; |
| 114 | } |
| 115 | |
| 116 | /* install RAM */ |
| 117 | ram_top = MIN(mess_ram_size, ram_size) - 1; |
| 118 | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 119 | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 120 | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), |
| 121 | 0x0000, ram_top, 0, 0, SMH_BANK2); |
| 122 | memory_set_bankptr(machine, 2, mess_ram); |
| 123 | |
| 124 | /* cartridge */ |
| 125 | if (has_cart) |
| 126 | add_reset_callback(machine, cart_reset); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | /************************************* |
| 131 | * |
| 132 | * Atari 400 |
| 133 | * |
| 134 | *************************************/ |
| 135 | |
| 136 | MACHINE_START( a400 ) |
| 137 | { |
| 138 | atari_machine_start(machine); |
| 139 | ms_atari_machine_start(machine, ATARI_400, TRUE); |
| 140 | } |
| 141 | |
| 142 | |
| 143 | /************************************* |
| 144 | * |
| 145 | * Atari 800 |
| 146 | * |
| 147 | *************************************/ |
| 148 | |
| 149 | MACHINE_START( a800 ) |
| 150 | { |
| 151 | atari_machine_start(machine); |
| 152 | ms_atari_machine_start(machine, ATARI_800, TRUE); |
| 153 | } |
| 154 | |
| 155 | |
| 156 | DEVICE_IMAGE_LOAD( a800_cart ) |
| 157 | { |
| 158 | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 159 | int size; |
| 160 | |
| 161 | /* load an optional (dual) cartridge (e.g. basic.rom) */ |
| 162 | if( strcmp(image->tag,"cart2") == 0 ) |
| 163 | { |
| 164 | size = image_fread(image, &mem[0x12000], 0x2000); |
| 165 | a800_cart_is_16k = (size == 0x2000); |
| 166 | logerror("%s loaded right cartridge '%s' size 16K\n", image->machine->gamedrv->name, image_filename(image) ); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | size = image_fread(image, &mem[0x10000], 0x2000); |
| 171 | a800_cart_loaded = size > 0x0000; |
| 172 | size = image_fread(image, &mem[0x12000], 0x2000); |
| 173 | a800_cart_is_16k = size > 0x2000; |
| 174 | logerror("%s loaded left cartridge '%s' size %s\n", image->machine->gamedrv->name, image_filename(image) , (a800_cart_is_16k) ? "16K":"8K"); |
| 175 | } |
| 176 | return INIT_PASS; |
| 177 | } |
| 178 | |
| 179 | DEVICE_IMAGE_UNLOAD( a800_cart ) |
| 180 | { |
| 181 | if( strcmp(image->tag,"cart2") == 0 ) |
| 182 | { |
| 183 | a800_cart_is_16k = 0; |
| 184 | a800_setbank(image->machine, 1); |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | a800_cart_loaded = 0; |
| 189 | a800_setbank(image->machine, 0); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | |
| 194 | /************************************* |
| 195 | * |
| 196 | * Atari 800XL |
| 197 | * |
| 198 | *************************************/ |
| 199 | |
| 200 | MACHINE_START( a800xl ) |
| 201 | { |
| 202 | atari_machine_start(machine); |
| 203 | ms_atari_machine_start(machine, ATARI_800XL, TRUE); |
| 204 | } |
| 205 | |
| 206 | DEVICE_IMAGE_LOAD( a800xl_cart ) |
| 207 | { |
| 208 | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 209 | astring *fname; |
| 210 | mame_file *basic_fp; |
| 211 | file_error filerr; |
| 212 | unsigned size; |
| 213 | |
| 214 | fname = astring_assemble_3(astring_alloc(), image->machine->gamedrv->name, PATH_SEPARATOR, "basic.rom"); |
| 215 | filerr = mame_fopen(SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ, &basic_fp); |
| 216 | astring_free(fname); |
| 217 | |
| 218 | if (filerr != FILERR_NONE) |
| 219 | { |
| 220 | size = mame_fread(basic_fp, &mem[0x14000], 0x2000); |
| 221 | if( size < 0x2000 ) |
| 222 | { |
| 223 | logerror("%s image '%s' load failed (less than 8K)\n", image->machine->gamedrv->name, astring_c(fname)); |
| 224 | mame_fclose(basic_fp); |
| 225 | return 2; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /* load an optional (dual) cartidge (e.g. basic.rom) */ |
| 230 | if (filerr != FILERR_NONE) |
| 231 | { |
| 232 | { |
| 233 | size = image_fread(image, &mem[0x14000], 0x2000); |
| 234 | a800_cart_loaded = size / 0x2000; |
| 235 | size = image_fread(image, &mem[0x16000], 0x2000); |
| 236 | a800_cart_is_16k = size / 0x2000; |
| 237 | logerror("%s loaded cartridge '%s' size %s\n", |
| 238 | image->machine->gamedrv->name, image_filename(image), (a800_cart_is_16k) ? "16K":"8K"); |
| 239 | } |
| 240 | mame_fclose(basic_fp); |
| 241 | } |
| 242 | |
| 243 | return INIT_PASS; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /************************************* |
| 248 | * |
| 249 | * Atari 5200 console |
| 250 | * |
| 251 | *************************************/ |
| 252 | |
| 253 | MACHINE_START( a5200 ) |
| 254 | { |
| 255 | atari_machine_start(machine); |
| 256 | ms_atari_machine_start(machine, ATARI_800XL, TRUE); |
| 257 | } |
| 258 | |
| 259 | |
| 260 | DEVICE_IMAGE_LOAD( a5200_cart ) |
| 261 | { |
| 262 | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 263 | int size; |
| 264 | |
| 265 | /* load an optional (dual) cartidge */ |
| 266 | size = image_fread(image, &mem[0x4000], 0x8000); |
| 267 | if (size<0x8000) memmove(mem+0x4000+0x8000-size, mem+0x4000, size); |
| 268 | // mirroring of smaller cartridges |
| 269 | if (size <= 0x1000) memcpy(mem+0xa000, mem+0xb000, 0x1000); |
| 270 | if (size <= 0x2000) memcpy(mem+0x8000, mem+0xa000, 0x2000); |
| 271 | if (size <= 0x4000) |
| 272 | { |
| 273 | const char *info; |
| 274 | memcpy(&mem[0x4000], &mem[0x8000], 0x4000); |
| 275 | info = image_extrainfo(image); |
| 276 | if (info!=NULL && strcmp(info, "A13MIRRORING")==0) |
| 277 | { |
| 278 | memcpy(&mem[0x8000], &mem[0xa000], 0x2000); |
| 279 | memcpy(&mem[0x6000], &mem[0x4000], 0x2000); |
| 280 | } |
| 281 | } |
| 282 | logerror("%s loaded cartridge '%s' size %dK\n", |
| 283 | image->machine->gamedrv->name, image_filename(image) , size/1024); |
| 284 | return INIT_PASS; |
| 285 | } |
| 286 | |
| 287 | DEVICE_IMAGE_UNLOAD( a5200_cart ) |
| 288 | { |
| 289 | UINT8 *mem = memory_region(image->machine, "maincpu"); |
| 290 | /* zap the cartridge memory (again) */ |
| 291 | memset(&mem[0x4000], 0x00, 0x8000); |
| 292 | } |