trunk/src/mess/machine/snescart.c
| r21700 | r21701 | |
| 643 | 643 | DEVICE_IMAGE_LOAD_MEMBER( snes_state,snes_cart ) |
| 644 | 644 | { |
| 645 | 645 | int supported_type = 1; |
| 646 | | running_machine &machine = image.device().machine(); |
| 647 | 646 | int has_bsx_slot = 0, st_bios = 0; |
| 648 | 647 | UINT32 offset, int_header_offs; |
| 649 | 648 | UINT8 *ROM = memregion("cart")->base(); |
| r21700 | r21701 | |
| 667 | 666 | if (SNES_CART_DEBUG) mame_printf_error("size %08X\n", m_cart_size - offset); |
| 668 | 667 | |
| 669 | 668 | m_cart[0].m_rom_size = m_cart_size; |
| 670 | | m_cart[0].m_rom = auto_alloc_array_clear(machine, UINT8, m_cart[0].m_rom_size); |
| 669 | m_cart[0].m_rom = auto_alloc_array_clear(machine(), UINT8, m_cart[0].m_rom_size); |
| 671 | 670 | memcpy(m_cart[0].m_rom, ROM, m_cart[0].m_rom_size - offset); |
| 672 | 671 | rom_map_setup(m_cart[0].m_rom_size); |
| 673 | 672 | |
| r21700 | r21701 | |
| 731 | 730 | if (SNES_CART_DEBUG) mame_printf_error("mode %d\n", m_cart[0].mode); |
| 732 | 731 | |
| 733 | 732 | /* Detect special chips */ |
| 734 | | supported_type = snes_find_addon_chip(machine, ROM, int_header_offs); |
| 733 | supported_type = snes_find_addon_chip(machine(), ROM, int_header_offs); |
| 735 | 734 | |
| 736 | 735 | /* Find the amount of cart ram */ |
| 737 | 736 | m_cart[0].m_nvram_size = 0; |
| r21700 | r21701 | |
| 769 | 768 | } |
| 770 | 769 | |
| 771 | 770 | if (m_cart[0].m_nvram_size > 0) |
| 772 | | m_cart[0].m_nvram = auto_alloc_array_clear(machine, UINT8, m_cart[0].m_nvram_size); |
| 771 | m_cart[0].m_nvram = auto_alloc_array_clear(machine(), UINT8, m_cart[0].m_nvram_size); |
| 773 | 772 | |
| 774 | 773 | /* Log snes_cart information */ |
| 775 | | snes_cart_log_info(machine, ROM, supported_type); |
| 774 | snes_cart_log_info(machine(), ROM, supported_type); |
| 776 | 775 | |
| 777 | 776 | /* Load SRAM */ |
| 778 | 777 | if (m_cart[0].m_nvram_size > 0) |
| 779 | | snes_load_sram(machine); |
| 778 | snes_load_sram(machine()); |
| 780 | 779 | |
| 781 | 780 | /* All done */ |
| 782 | 781 | return IMAGE_INIT_PASS; |
| r21700 | r21701 | |
| 784 | 783 | |
| 785 | 784 | DEVICE_IMAGE_LOAD_MEMBER( snes_state,sufami_cart ) |
| 786 | 785 | { |
| 787 | | running_machine &machine = image.device().machine(); |
| 788 | 786 | int st_bios = 0, slot_id = 0; |
| 789 | 787 | UINT32 offset; |
| 790 | | UINT8 *ROM = image.device().machine().root_device().memregion(image.device().tag())->base(); |
| 788 | UINT8 *ROM = machine().root_device().memregion(image.device().tag())->base(); |
| 791 | 789 | |
| 792 | 790 | if (strcmp(image.device().tag(), ":slot_a") == 0) |
| 793 | 791 | slot_id = 0; |
| r21700 | r21701 | |
| 836 | 834 | |
| 837 | 835 | |
| 838 | 836 | m_cart[slot_id].m_rom_size = m_cart_size; |
| 839 | | m_cart[slot_id].m_rom = auto_alloc_array_clear(machine, UINT8, m_cart[0].m_rom_size); |
| 837 | m_cart[slot_id].m_rom = auto_alloc_array_clear(machine(), UINT8, m_cart[0].m_rom_size); |
| 840 | 838 | memcpy(m_cart[slot_id].m_rom, ROM, m_cart[slot_id].m_rom_size - offset); |
| 841 | 839 | rom_map_setup(m_cart[slot_id].m_rom_size); |
| 842 | 840 | |
| 843 | 841 | m_cart[slot_id].m_nvram_size = 0x20000; |
| 844 | | m_cart[slot_id].m_nvram = auto_alloc_array_clear(machine, UINT8, m_cart[slot_id].m_nvram_size); |
| 842 | m_cart[slot_id].m_nvram = auto_alloc_array_clear(machine(), UINT8, m_cart[slot_id].m_nvram_size); |
| 845 | 843 | |
| 846 | | sufami_load_sram(machine, image.device().tag()); |
| 844 | sufami_load_sram(machine(), image.device().tag()); |
| 847 | 845 | |
| 848 | 846 | m_cart[slot_id].slot_in_use = 1; // aknowledge the cart in this slot, for saving sram at exit |
| 849 | 847 | |