(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.
This commit is contained in:
Fabio Priuli 2014-10-03 18:59:59 +00:00
parent 0e19a1d31f
commit d69ad9d29f
4 changed files with 58 additions and 67 deletions

View File

@ -690,12 +690,12 @@ void device_nes_cart_interface::pcb_start(running_machine &machine, UINT8 *ciram
m_prg_bank[i] = i;
}
}
// Setup CHR
m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
chr8(0, m_chr_source);
}
// Setup CHR (VRAM can be present also without PRG rom)
m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
chr8(0, m_chr_source);
// Setup NT
m_ciram = ciram_ptr;

View File

@ -737,32 +737,32 @@ static MACHINE_CONFIG_DERIVED( famicom, nes )
MCFG_SOFTWARE_LIST_ADD("cass_list", "famicom_cass")
MACHINE_CONFIG_END
void nes_state::setup_disk(nes_cart_slot_device *slot)
void nes_state::setup_disk(nes_disksys_device *slot)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
if (slot)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
// Set up memory handlers
space.install_read_handler(0x4020, 0x40ff, read8_delegate(FUNC(nes_cart_slot_device::read_ex), (nes_cart_slot_device *)slot));
space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_cart_slot_device::write_ex), (nes_cart_slot_device *)slot));
space.install_read_handler(0x4100, 0x5fff, read8_delegate(FUNC(nes_cart_slot_device::read_l), (nes_cart_slot_device *)slot));
space.install_write_handler(0x4100, 0x5fff, write8_delegate(FUNC(nes_cart_slot_device::write_l), (nes_cart_slot_device *)slot));
space.install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(nes_cart_slot_device::read_m), (nes_cart_slot_device *)slot));
space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(nes_cart_slot_device::write_m), (nes_cart_slot_device *)slot));
space.install_read_handler(0x8000, 0xffff, read8_delegate(FUNC(nes_cart_slot_device::read_h), (nes_cart_slot_device *)slot));
space.install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(nes_cart_slot_device::write_h), (nes_cart_slot_device *)slot));
space.install_read_handler(0x4020, 0x40ff, read8_delegate(FUNC(nes_disksys_device::read_ex), (nes_disksys_device *)slot));
space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_disksys_device::write_ex), (nes_disksys_device *)slot));
space.install_read_handler(0x4100, 0x5fff, read8_delegate(FUNC(device_nes_cart_interface::read_l), (device_nes_cart_interface *)slot));
space.install_write_handler(0x4100, 0x5fff, write8_delegate(FUNC(device_nes_cart_interface::write_l), (device_nes_cart_interface *)slot));
space.install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(nes_disksys_device::read_m), (nes_disksys_device *)slot));
space.install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(nes_disksys_device::write_m), (nes_disksys_device *)slot));
space.install_read_handler(0x8000, 0xffff, read8_delegate(FUNC(nes_disksys_device::read_h), (nes_disksys_device *)slot));
space.install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(nes_disksys_device::write_h), (nes_disksys_device *)slot));
slot->m_cart->vram_alloc(0x2000);
slot->m_cart->prgram_alloc(0x8000);
slot->vram_alloc(0x2000);
slot->prgram_alloc(0x8000);
slot->pcb_start(m_ciram);
slot->m_cart->pcb_reg_postload(machine());
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));
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));
m_ppu->set_scanline_callback(ppu2c0x_scanline_delegate(FUNC(device_nes_cart_interface::scanline_irq),slot->m_cart));
m_ppu->set_hblank_callback(ppu2c0x_hblank_delegate(FUNC(device_nes_cart_interface::hblank_irq),slot->m_cart));
m_ppu->set_latch(ppu2c0x_latch_delegate(FUNC(device_nes_cart_interface::ppu_latch),slot->m_cart));
slot->pcb_start(machine(), m_ciram, FALSE);
slot->pcb_reg_postload(machine());
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));
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));
m_ppu->set_scanline_callback(ppu2c0x_scanline_delegate(FUNC(device_nes_cart_interface::scanline_irq),(device_nes_cart_interface *)slot));
m_ppu->set_hblank_callback(ppu2c0x_hblank_delegate(FUNC(nes_disksys_device::hblank_irq),(nes_disksys_device *)slot));
m_ppu->set_latch(ppu2c0x_latch_delegate(FUNC(device_nes_cart_interface::ppu_latch),(device_nes_cart_interface *)slot));
}
}
@ -771,16 +771,30 @@ MACHINE_START_MEMBER( nes_state, fds )
{
m_ciram = auto_alloc_array(machine(), UINT8, 0x800);
setup_ioports();
// setup the disk expansion instead
setup_disk(m_cartslot);
setup_disk(m_disk);
}
MACHINE_RESET_MEMBER( nes_state, fds )
{
// Reset the mapper variables
m_disk->pcb_reset();
// the rest is the same as for nes/famicom/dendy
m_maincpu->reset();
memset(m_pad_latch, 0, sizeof(m_pad_latch));
memset(m_zapper_latch, 0, sizeof(m_zapper_latch));
m_paddle_latch = 0;
m_paddle_btn_latch = 0;
}
static MACHINE_CONFIG_DERIVED( fds, famicom )
MCFG_MACHINE_START_OVERRIDE( nes_state, fds )
MCFG_MACHINE_RESET_OVERRIDE( nes_state, fds )
MCFG_DEVICE_REMOVE("tape")
MCFG_DEVICE_REMOVE("nes_slot")
MCFG_DISKSYS_ADD("nes_slot", disksys_only, "disksys")
MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0)
MCFG_DEVICE_REMOVE("cart_list")
MCFG_DEVICE_REMOVE("cass_list")
@ -793,9 +807,9 @@ MACHINE_START_MEMBER( nes_state, famitwin )
machine_start();
// if there is no cart inserted, setup the disk expansion instead
if (!m_cartslot->m_cart)
if (!m_cartslot->exists())
{
setup_disk(m_cartslot2);
setup_disk(m_disk);
// replace the famicom disk ROM with the famicom twin one (until we modernize the floppy drive)
m_maincpu->space(AS_PROGRAM).install_read_bank(0xe000, 0xffff, "ftbios");
@ -808,8 +822,8 @@ MACHINE_RESET_MEMBER( nes_state, famitwin )
// Reset the mapper variables. Will also mark the char-gen ram as dirty
m_cartslot->pcb_reset();
// if there is no cart inserted, initialize the disk expansion instead
if (!m_cartslot->m_cart)
m_cartslot2->pcb_reset();
if (!m_cartslot->exists())
m_disk->pcb_reset();
// the rest is the same as for nes/famicom/dendy
m_maincpu->reset();
@ -825,14 +839,10 @@ static MACHINE_CONFIG_DERIVED( famitwin, famicom )
MCFG_MACHINE_START_OVERRIDE( nes_state, famitwin )
MCFG_MACHINE_RESET_OVERRIDE( nes_state, famitwin )
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_UPDATE_DRIVER(nes_state, screen_update_famitwin)
MCFG_DEVICE_REMOVE("nes_slot")
MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_cart, NULL)
MCFG_DEVICE_MODIFY("nes_slot")
MCFG_NES_CARTRIDGE_NOT_MANDATORY
MCFG_DISKSYS_ADD("disk_slot", disksys_only, "disksys")
MCFG_DEVICE_ADD("disk", NES_DISKSYS, 0)
MACHINE_CONFIG_END

View File

@ -69,7 +69,7 @@ public:
m_ppu(*this, "ppu"),
m_sound(*this, "nessound"),
m_cartslot(*this, "nes_slot"),
m_cartslot2(*this, "disk_slot"), // temp hack for famitwin
m_disk(*this, "disk"),
m_cassette(*this, "tape")
{ }
@ -104,7 +104,7 @@ public:
required_device<ppu2c0x_device> m_ppu;
required_device<nesapu_device> m_sound;
optional_device<nes_cart_slot_device> m_cartslot;
optional_device<nes_cart_slot_device> m_cartslot2;
optional_device<nes_disksys_device> m_disk;
optional_device<cassette_image_device> m_cassette;
int nes_ppu_vidaccess(int address, int data);
@ -124,7 +124,6 @@ public:
virtual void video_reset();
DECLARE_PALETTE_INIT(nes);
UINT32 screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update_famitwin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_READ8_MEMBER(psg_4015_r);
DECLARE_WRITE8_MEMBER(psg_4015_w);
DECLARE_WRITE8_MEMBER(psg_4017_w);
@ -136,8 +135,9 @@ public:
// these are needed until we modernize the FDS controller
DECLARE_MACHINE_START(fds);
DECLARE_MACHINE_START(famitwin);
DECLARE_MACHINE_RESET(fds);
DECLARE_MACHINE_RESET(famitwin);
void setup_disk(nes_cart_slot_device *slot);
void setup_disk(nes_disksys_device *slot);
// input related
UINT32 m_pad_latch[4];

View File

@ -37,14 +37,16 @@ UINT32 nes_state::screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap,
m_ppu->render(bitmap, 0, 0, 0, 0);
// if this is a disk system game, check for the flip-disk key
if (m_cartslot &&
(m_cartslot->get_pcb_id() == STD_DISKSYS // first scenario = disksys in m_cartslot (= famicom)
|| !m_cartslot->exists())) // second scenario = disk via fixed internal option (= fds)
if ((m_cartslot && m_cartslot->exists() && (m_cartslot->get_pcb_id() == STD_DISKSYS)) // first scenario = disksys in m_cartslot (= famicom)
|| m_disk) // second scenario = disk via fixed internal disk option (fds & famitwin)
{
// latch this input so it doesn't go at warp speed
if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
{
m_cartslot->disk_flip_side();
if (m_disk)
m_disk->disk_flip_side();
else
m_cartslot->disk_flip_side();
m_last_frame_flip = 1;
}
@ -53,24 +55,3 @@ UINT32 nes_state::screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap,
}
return 0;
}
// Alternative version to support "Disk flip hack" also in the Famicom Twin System (to be removed soonish!)
UINT32 nes_state::screen_update_famitwin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// render the ppu
m_ppu->render(bitmap, 0, 0, 0, 0);
if (m_cartslot2 && !m_cartslot2->exists())
{
// latch this input so it doesn't go at warp speed
if ((m_io_disksel->read_safe(0) & 0x01) && (!m_last_frame_flip))
{
m_cartslot2->disk_flip_side();
m_last_frame_flip = 1;
}
if (!m_io_disksel->read_safe(1) & 0x01)
m_last_frame_flip = 0;
}
return 0;
}