trunk/src/mess/drivers/nes.c
| r32512 | r32513 | |
| 737 | 737 | MCFG_SOFTWARE_LIST_ADD("cass_list", "famicom_cass") |
| 738 | 738 | MACHINE_CONFIG_END |
| 739 | 739 | |
| 740 | | void nes_state::setup_disk(nes_cart_slot_device *slot) |
| 740 | void nes_state::setup_disk(nes_disksys_device *slot) |
| 741 | 741 | { |
| 742 | | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 743 | | |
| 744 | 742 | if (slot) |
| 745 | 743 | { |
| 744 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 745 | |
| 746 | 746 | // Set up memory handlers |
| 747 | | space.install_read_handler(0x4020, 0x40ff, read8_delegate(FUNC(nes_cart_slot_device::read_ex), (nes_cart_slot_device *)slot)); |
| 748 | | space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_cart_slot_device::write_ex), (nes_cart_slot_device *)slot)); |
| 749 | | space.install_read_handler(0x4100, 0x5fff, read8_delegate(FUNC(nes_cart_slot_device::read_l), (nes_cart_slot_device *)slot)); |
| 750 | | space.install_write_handler(0x4100, 0x5fff, write8_delegate(FUNC(nes_cart_slot_device::write_l), (nes_cart_slot_device *)slot)); |
| 751 | | space.install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(nes_cart_slot_device::read_m), (nes_cart_slot_device *)slot)); |
| 752 | | space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(nes_cart_slot_device::write_m), (nes_cart_slot_device *)slot)); |
| 753 | | space.install_read_handler(0x8000, 0xffff, read8_delegate(FUNC(nes_cart_slot_device::read_h), (nes_cart_slot_device *)slot)); |
| 754 | | space.install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(nes_cart_slot_device::write_h), (nes_cart_slot_device *)slot)); |
| 747 | space.install_read_handler(0x4020, 0x40ff, read8_delegate(FUNC(nes_disksys_device::read_ex), (nes_disksys_device *)slot)); |
| 748 | space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_disksys_device::write_ex), (nes_disksys_device *)slot)); |
| 749 | space.install_read_handler(0x4100, 0x5fff, read8_delegate(FUNC(device_nes_cart_interface::read_l), (device_nes_cart_interface *)slot)); |
| 750 | space.install_write_handler(0x4100, 0x5fff, write8_delegate(FUNC(device_nes_cart_interface::write_l), (device_nes_cart_interface *)slot)); |
| 751 | space.install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(nes_disksys_device::read_m), (nes_disksys_device *)slot)); |
| 752 | space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(nes_disksys_device::write_m), (nes_disksys_device *)slot)); |
| 753 | space.install_read_handler(0x8000, 0xffff, read8_delegate(FUNC(nes_disksys_device::read_h), (nes_disksys_device *)slot)); |
| 754 | space.install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(nes_disksys_device::write_h), (nes_disksys_device *)slot)); |
| 755 | 755 | |
| 756 | | slot->m_cart->vram_alloc(0x2000); |
| 757 | | slot->m_cart->prgram_alloc(0x8000); |
| 756 | slot->vram_alloc(0x2000); |
| 757 | slot->prgram_alloc(0x8000); |
| 758 | 758 | |
| 759 | | slot->pcb_start(m_ciram); |
| 760 | | slot->m_cart->pcb_reg_postload(machine()); |
| 761 | | m_ppu->space(AS_PROGRAM).install_readwrite_handler(0, 0x1fff, read8_delegate(FUNC(device_nes_cart_interface::chr_r),slot->m_cart), write8_delegate(FUNC(device_nes_cart_interface::chr_w),slot->m_cart)); |
| 762 | | m_ppu->space(AS_PROGRAM).install_readwrite_handler(0x2000, 0x3eff, read8_delegate(FUNC(device_nes_cart_interface::nt_r),slot->m_cart), write8_delegate(FUNC(device_nes_cart_interface::nt_w),slot->m_cart)); |
| 763 | | m_ppu->set_scanline_callback(ppu2c0x_scanline_delegate(FUNC(device_nes_cart_interface::scanline_irq),slot->m_cart)); |
| 764 | | m_ppu->set_hblank_callback(ppu2c0x_hblank_delegate(FUNC(device_nes_cart_interface::hblank_irq),slot->m_cart)); |
| 765 | | m_ppu->set_latch(ppu2c0x_latch_delegate(FUNC(device_nes_cart_interface::ppu_latch),slot->m_cart)); |
| 759 | slot->pcb_start(machine(), m_ciram, FALSE); |
| 760 | slot->pcb_reg_postload(machine()); |
| 761 | m_ppu->space(AS_PROGRAM).install_readwrite_handler(0, 0x1fff, read8_delegate(FUNC(device_nes_cart_interface::chr_r),(device_nes_cart_interface *)slot), write8_delegate(FUNC(device_nes_cart_interface::chr_w),(device_nes_cart_interface *)slot)); |
| 762 | m_ppu->space(AS_PROGRAM).install_readwrite_handler(0x2000, 0x3eff, read8_delegate(FUNC(device_nes_cart_interface::nt_r),(device_nes_cart_interface *)slot), write8_delegate(FUNC(device_nes_cart_interface::nt_w),(device_nes_cart_interface *)slot)); |
| 763 | m_ppu->set_scanline_callback(ppu2c0x_scanline_delegate(FUNC(device_nes_cart_interface::scanline_irq),(device_nes_cart_interface *)slot)); |
| 764 | m_ppu->set_hblank_callback(ppu2c0x_hblank_delegate(FUNC(nes_disksys_device::hblank_irq),(nes_disksys_device *)slot)); |
| 765 | m_ppu->set_latch(ppu2c0x_latch_delegate(FUNC(device_nes_cart_interface::ppu_latch),(device_nes_cart_interface *)slot)); |
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | |
| r32512 | r32513 | |
| 771 | 771 | { |
| 772 | 772 | m_ciram = auto_alloc_array(machine(), UINT8, 0x800); |
| 773 | 773 | setup_ioports(); |
| 774 | | // setup the disk expansion instead |
| 775 | | setup_disk(m_cartslot); |
| 774 | setup_disk(m_disk); |
| 776 | 775 | } |
| 777 | 776 | |
| 777 | MACHINE_RESET_MEMBER( nes_state, fds ) |
| 778 | { |
| 779 | // Reset the mapper variables |
| 780 | m_disk->pcb_reset(); |
| 781 | |
| 782 | // the rest is the same as for nes/famicom/dendy |
| 783 | m_maincpu->reset(); |
| 784 | |
| 785 | memset(m_pad_latch, 0, sizeof(m_pad_latch)); |
| 786 | memset(m_zapper_latch, 0, sizeof(m_zapper_latch)); |
| 787 | m_paddle_latch = 0; |
| 788 | m_paddle_btn_latch = 0; |
| 789 | } |
| 790 | |
| 778 | 791 | static MACHINE_CONFIG_DERIVED( fds, famicom ) |
| 779 | 792 | MCFG_MACHINE_START_OVERRIDE( nes_state, fds ) |
| 793 | MCFG_MACHINE_RESET_OVERRIDE( nes_state, fds ) |
| 780 | 794 | MCFG_DEVICE_REMOVE("tape") |
| 781 | 795 | |
| 782 | 796 | MCFG_DEVICE_REMOVE("nes_slot") |
| 783 | | MCFG_DISKSYS_ADD("nes_slot", disksys_only, "disksys") |
| 797 | MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0) |
| 784 | 798 | |
| 785 | 799 | MCFG_DEVICE_REMOVE("cart_list") |
| 786 | 800 | MCFG_DEVICE_REMOVE("cass_list") |
| r32512 | r32513 | |
| 793 | 807 | machine_start(); |
| 794 | 808 | |
| 795 | 809 | // if there is no cart inserted, setup the disk expansion instead |
| 796 | | if (!m_cartslot->m_cart) |
| 810 | if (!m_cartslot->exists()) |
| 797 | 811 | { |
| 798 | | setup_disk(m_cartslot2); |
| 812 | setup_disk(m_disk); |
| 799 | 813 | |
| 800 | 814 | // replace the famicom disk ROM with the famicom twin one (until we modernize the floppy drive) |
| 801 | 815 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xe000, 0xffff, "ftbios"); |
| r32512 | r32513 | |
| 808 | 822 | // Reset the mapper variables. Will also mark the char-gen ram as dirty |
| 809 | 823 | m_cartslot->pcb_reset(); |
| 810 | 824 | // if there is no cart inserted, initialize the disk expansion instead |
| 811 | | if (!m_cartslot->m_cart) |
| 812 | | m_cartslot2->pcb_reset(); |
| 825 | if (!m_cartslot->exists()) |
| 826 | m_disk->pcb_reset(); |
| 813 | 827 | |
| 814 | 828 | // the rest is the same as for nes/famicom/dendy |
| 815 | 829 | m_maincpu->reset(); |
| r32512 | r32513 | |
| 825 | 839 | MCFG_MACHINE_START_OVERRIDE( nes_state, famitwin ) |
| 826 | 840 | MCFG_MACHINE_RESET_OVERRIDE( nes_state, famitwin ) |
| 827 | 841 | |
| 828 | | MCFG_SCREEN_MODIFY("screen") |
| 829 | | MCFG_SCREEN_UPDATE_DRIVER(nes_state, screen_update_famitwin) |
| 830 | | |
| 831 | | MCFG_DEVICE_REMOVE("nes_slot") |
| 832 | | MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_cart, NULL) |
| 842 | MCFG_DEVICE_MODIFY("nes_slot") |
| 833 | 843 | MCFG_NES_CARTRIDGE_NOT_MANDATORY |
| 834 | 844 | |
| 835 | | MCFG_DISKSYS_ADD("disk_slot", disksys_only, "disksys") |
| 845 | MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0) |
| 836 | 846 | MACHINE_CONFIG_END |
| 837 | 847 | |
| 838 | 848 | |
trunk/src/mess/includes/nes.h
| r32512 | r32513 | |
| 69 | 69 | m_ppu(*this, "ppu"), |
| 70 | 70 | m_sound(*this, "nessound"), |
| 71 | 71 | m_cartslot(*this, "nes_slot"), |
| 72 | | m_cartslot2(*this, "disk_slot"), // temp hack for famitwin |
| 72 | m_disk(*this, "disk"), |
| 73 | 73 | m_cassette(*this, "tape") |
| 74 | 74 | { } |
| 75 | 75 | |
| r32512 | r32513 | |
| 104 | 104 | required_device<ppu2c0x_device> m_ppu; |
| 105 | 105 | required_device<nesapu_device> m_sound; |
| 106 | 106 | optional_device<nes_cart_slot_device> m_cartslot; |
| 107 | | optional_device<nes_cart_slot_device> m_cartslot2; |
| 107 | optional_device<nes_disksys_device> m_disk; |
| 108 | 108 | optional_device<cassette_image_device> m_cassette; |
| 109 | 109 | |
| 110 | 110 | int nes_ppu_vidaccess(int address, int data); |
| r32512 | r32513 | |
| 124 | 124 | virtual void video_reset(); |
| 125 | 125 | DECLARE_PALETTE_INIT(nes); |
| 126 | 126 | UINT32 screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 127 | | UINT32 screen_update_famitwin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 128 | 127 | DECLARE_READ8_MEMBER(psg_4015_r); |
| 129 | 128 | DECLARE_WRITE8_MEMBER(psg_4015_w); |
| 130 | 129 | DECLARE_WRITE8_MEMBER(psg_4017_w); |
| r32512 | r32513 | |
| 136 | 135 | // these are needed until we modernize the FDS controller |
| 137 | 136 | DECLARE_MACHINE_START(fds); |
| 138 | 137 | DECLARE_MACHINE_START(famitwin); |
| 138 | DECLARE_MACHINE_RESET(fds); |
| 139 | 139 | DECLARE_MACHINE_RESET(famitwin); |
| 140 | | void setup_disk(nes_cart_slot_device *slot); |
| 140 | void setup_disk(nes_disksys_device *slot); |
| 141 | 141 | |
| 142 | 142 | // input related |
| 143 | 143 | UINT32 m_pad_latch[4]; |