Previous 199869 Revisions Next

r32513 Friday 3rd October, 2014 at 18:59:59 UTC by Fabio Priuli
(MESS) fds/famitwin: attach the disk controller device directly
to the machines, without the intermediate cartslot. This is more
accurate for famitwin and it also avoids the possible
misunderstanding about the -cart switches in these systems
(+ avoids possible misconfigurations). nw.
[src/emu/bus/nes]nes_slot.c
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/video]nes.c

trunk/src/emu/bus/nes/nes_slot.c
r32512r32513
690690            m_prg_bank[i] = i;
691691         }
692692      }
693     
694      // Setup CHR
695      m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
696      chr8(0, m_chr_source);
697693   }
698
694   
695   // Setup CHR (VRAM can be present also without PRG rom)
696   m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
697   chr8(0, m_chr_source);
698   
699699   // Setup NT
700700   m_ciram = ciram_ptr;
701701
trunk/src/mess/drivers/nes.c
r32512r32513
737737   MCFG_SOFTWARE_LIST_ADD("cass_list", "famicom_cass")
738738MACHINE_CONFIG_END
739739
740void nes_state::setup_disk(nes_cart_slot_device *slot)
740void nes_state::setup_disk(nes_disksys_device *slot)
741741{
742   address_space &space = m_maincpu->space(AS_PROGRAM);
743
744742   if (slot)
745743   {
744      address_space &space = m_maincpu->space(AS_PROGRAM);
745
746746      // 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));
755755     
756      slot->m_cart->vram_alloc(0x2000);
757      slot->m_cart->prgram_alloc(0x8000);
756      slot->vram_alloc(0x2000);
757      slot->prgram_alloc(0x8000);
758758     
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));
766766   }
767767}
768768
r32512r32513
771771{   
772772   m_ciram = auto_alloc_array(machine(), UINT8, 0x800);
773773   setup_ioports();
774   // setup the disk expansion instead
775   setup_disk(m_cartslot);
774   setup_disk(m_disk);
776775}
777776
777MACHINE_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
778791static MACHINE_CONFIG_DERIVED( fds, famicom )
779792   MCFG_MACHINE_START_OVERRIDE( nes_state, fds )
793   MCFG_MACHINE_RESET_OVERRIDE( nes_state, fds )
780794   MCFG_DEVICE_REMOVE("tape")
781795
782796   MCFG_DEVICE_REMOVE("nes_slot")
783   MCFG_DISKSYS_ADD("nes_slot", disksys_only, "disksys")
797   MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0)
784798
785799   MCFG_DEVICE_REMOVE("cart_list")
786800   MCFG_DEVICE_REMOVE("cass_list")
r32512r32513
793807   machine_start();
794808
795809   // if there is no cart inserted, setup the disk expansion instead
796   if (!m_cartslot->m_cart)
810   if (!m_cartslot->exists())
797811   {
798      setup_disk(m_cartslot2);
812      setup_disk(m_disk);
799813     
800814      // replace the famicom disk ROM with the famicom twin one (until we modernize the floppy drive)
801815      m_maincpu->space(AS_PROGRAM).install_read_bank(0xe000, 0xffff, "ftbios");
r32512r32513
808822   // Reset the mapper variables. Will also mark the char-gen ram as dirty
809823   m_cartslot->pcb_reset();
810824   // 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();
813827   
814828   // the rest is the same as for nes/famicom/dendy
815829   m_maincpu->reset();
r32512r32513
825839   MCFG_MACHINE_START_OVERRIDE( nes_state, famitwin )
826840   MCFG_MACHINE_RESET_OVERRIDE( nes_state, famitwin )
827841
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")
833843   MCFG_NES_CARTRIDGE_NOT_MANDATORY
834844
835   MCFG_DISKSYS_ADD("disk_slot", disksys_only, "disksys")
845   MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0)
836846MACHINE_CONFIG_END
837847
838848
trunk/src/mess/includes/nes.h
r32512r32513
6969         m_ppu(*this, "ppu"),
7070         m_sound(*this, "nessound"),
7171         m_cartslot(*this, "nes_slot"),
72         m_cartslot2(*this, "disk_slot"),   // temp hack for famitwin
72         m_disk(*this, "disk"),
7373         m_cassette(*this, "tape")
7474      { }
7575
r32512r32513
104104   required_device<ppu2c0x_device> m_ppu;
105105   required_device<nesapu_device> m_sound;
106106   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;
108108   optional_device<cassette_image_device> m_cassette;
109109
110110   int nes_ppu_vidaccess(int address, int data);
r32512r32513
124124   virtual void video_reset();
125125   DECLARE_PALETTE_INIT(nes);
126126   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);
128127   DECLARE_READ8_MEMBER(psg_4015_r);
129128   DECLARE_WRITE8_MEMBER(psg_4015_w);
130129   DECLARE_WRITE8_MEMBER(psg_4017_w);
r32512r32513
136135   // these are needed until we modernize the FDS controller
137136   DECLARE_MACHINE_START(fds);
138137   DECLARE_MACHINE_START(famitwin);
138   DECLARE_MACHINE_RESET(fds);
139139   DECLARE_MACHINE_RESET(famitwin);
140   void setup_disk(nes_cart_slot_device *slot);
140   void setup_disk(nes_disksys_device *slot);
141141
142142   // input related
143143   UINT32 m_pad_latch[4];
trunk/src/mess/video/nes.c
r32512r32513
3737   m_ppu->render(bitmap, 0, 0, 0, 0);
3838
3939   // if this is a disk system game, check for the flip-disk key
40   if (m_cartslot &&
41       (m_cartslot->get_pcb_id() == STD_DISKSYS   // first scenario = disksys in m_cartslot (= famicom)
42         || !m_cartslot->exists()))   // second scenario = disk via fixed internal option (= fds)
40   if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS))   // first scenario = disksys in m_cartslot (= famicom)
41         || m_disk)   // second scenario = disk via fixed internal disk option (fds & famitwin)
4342   {
4443      // latch this input so it doesn't go at warp speed
4544      if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
4645      {
47         m_cartslot->disk_flip_side();
46         if (m_disk)
47            m_disk->disk_flip_side();
48         else
49            m_cartslot->disk_flip_side();
4850         m_last_frame_flip = 1;
4951      }
5052
r32512r32513
5355   }
5456   return 0;
5557}
56
57// Alternative version to support "Disk flip hack" also in the Famicom Twin System (to be removed soonish!)
58UINT32 nes_state::screen_update_famitwin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
59{
60   // render the ppu
61   m_ppu->render(bitmap, 0, 0, 0, 0);
62
63   if (m_cartslot2 && !m_cartslot2->exists())
64   {
65      // latch this input so it doesn't go at warp speed
66      if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
67      {
68         m_cartslot2->disk_flip_side();
69         m_last_frame_flip = 1;
70      }
71     
72      if (!m_io_disksel->read_safe(1) & 0x01)
73         m_last_frame_flip = 0;
74   }
75   return 0;
76}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team