2008-08-07 14:26:07 +02:00
|
|
|
/***************************************************************************************
|
2009-05-13 16:26:55 +02:00
|
|
|
* Genesis Plus
|
2011-04-01 00:11:05 +02:00
|
|
|
* Internal Hardware & Bus controllers
|
2008-08-07 14:26:07 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
|
2011-04-01 00:11:05 +02:00
|
|
|
* Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port
|
2008-08-07 14:26:07 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
****************************************************************************************/
|
2007-08-10 22:34:06 +02:00
|
|
|
|
|
|
|
#include "shared.h"
|
|
|
|
|
2010-06-14 10:05:45 +02:00
|
|
|
uint8 tmss[4]; /* TMSS security register */
|
|
|
|
uint8 bios_rom[0x800]; /* OS ROM */
|
2010-01-24 12:41:53 +01:00
|
|
|
uint8 work_ram[0x10000]; /* 68K RAM */
|
|
|
|
uint8 zram[0x2000]; /* Z80 RAM */
|
|
|
|
uint32 zbank; /* Z80 bank window address */
|
2010-06-14 10:05:45 +02:00
|
|
|
uint8 zstate; /* Z80 bus state (d0 = BUSACK, d1 = /RESET) */
|
|
|
|
|
|
|
|
/* PICO data */
|
|
|
|
uint8 pico_current;
|
|
|
|
uint8 pico_page[7];
|
2008-12-04 20:32:22 +01:00
|
|
|
|
2007-08-10 22:34:06 +02:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/* Init, reset, shutdown functions */
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
2009-08-14 18:46:19 +02:00
|
|
|
void gen_init(void)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2008-12-10 19:16:30 +01:00
|
|
|
int i;
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* initialize 68k */
|
2009-08-14 18:46:19 +02:00
|
|
|
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
|
2008-12-10 19:16:30 +01:00
|
|
|
m68k_init();
|
2011-04-01 00:11:05 +02:00
|
|
|
|
|
|
|
/* initialize Z80 */
|
2010-07-03 01:03:05 +02:00
|
|
|
z80_init(0,z80_irq_callback);
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* initialize 68k memory map */
|
|
|
|
/* $000000-$7FFFFF is affected to cartridge area (see md_cart.c) */
|
2009-06-16 19:00:40 +02:00
|
|
|
for (i=0x80; i<0x100; i++)
|
2008-12-10 19:16:30 +01:00
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* $800000-$FFFFFF is affected to WRAM (see VDP DMA) */
|
2008-12-04 20:32:22 +01:00
|
|
|
m68k_memory_map[i].base = work_ram;
|
|
|
|
m68k_memory_map[i].read8 = NULL;
|
|
|
|
m68k_memory_map[i].read16 = NULL;
|
|
|
|
m68k_memory_map[i].write8 = NULL;
|
2008-12-10 19:16:30 +01:00
|
|
|
m68k_memory_map[i].write16 = NULL;
|
2008-12-04 20:32:22 +01:00
|
|
|
zbank_memory_map[i].read = NULL;
|
|
|
|
zbank_memory_map[i].write = NULL;
|
|
|
|
}
|
|
|
|
|
2009-06-16 19:00:40 +02:00
|
|
|
/* initialize 68k memory handlers */
|
2008-12-10 19:16:30 +01:00
|
|
|
for (i=0x80; i<0xe0; i++)
|
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* $800000-$DFFFFF : illegal area by default */
|
2008-12-04 20:32:22 +01:00
|
|
|
m68k_memory_map[i].read8 = m68k_lockup_r_8;
|
|
|
|
m68k_memory_map[i].read16 = m68k_lockup_r_16;
|
|
|
|
m68k_memory_map[i].write8 = m68k_lockup_w_8;
|
2008-12-10 19:16:30 +01:00
|
|
|
m68k_memory_map[i].write16 = m68k_lockup_w_16;
|
2008-12-04 20:32:22 +01:00
|
|
|
zbank_memory_map[i].read = zbank_lockup_r;
|
|
|
|
zbank_memory_map[i].write = zbank_lockup_w;
|
2008-12-10 19:16:30 +01:00
|
|
|
}
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* $A10000-$A1FFFF : I/O & Control registers */
|
2008-12-04 20:32:22 +01:00
|
|
|
m68k_memory_map[0xa1].read8 = ctrl_io_read_byte;
|
|
|
|
m68k_memory_map[0xa1].read16 = ctrl_io_read_word;
|
|
|
|
m68k_memory_map[0xa1].write8 = ctrl_io_write_byte;
|
|
|
|
m68k_memory_map[0xa1].write16 = ctrl_io_write_word;
|
|
|
|
zbank_memory_map[0xa1].read = zbank_read_ctrl_io;
|
|
|
|
zbank_memory_map[0xa1].write = zbank_write_ctrl_io;
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* $C0xxxx, $C8xxxx, $D0xxxx, $D8xxxx : VDP ports */
|
|
|
|
for (i=0xc0; i<0xe0; i+=8)
|
2010-06-14 10:05:45 +02:00
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
m68k_memory_map[i].read8 = vdp_read_byte;
|
|
|
|
m68k_memory_map[i].read16 = vdp_read_word;
|
|
|
|
m68k_memory_map[i].write8 = vdp_write_byte;
|
|
|
|
m68k_memory_map[i].write16 = vdp_write_word;
|
|
|
|
zbank_memory_map[i].read = zbank_read_vdp;
|
|
|
|
zbank_memory_map[i].write = zbank_write_vdp;
|
2010-06-14 10:05:45 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* MS COMPATIBILITY mode */
|
|
|
|
if (system_hw == SYSTEM_PBC)
|
2008-08-07 14:26:07 +02:00
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* initialize Z80 read handler */
|
|
|
|
/* NB: memory map & write handler are defined by cartridge hardware */
|
|
|
|
z80_readmem = z80_sms_memory_r;
|
|
|
|
|
|
|
|
/* initialize Z80 ports handlers */
|
|
|
|
z80_writeport = z80_sms_port_w;
|
|
|
|
z80_readport = z80_sms_port_r;
|
|
|
|
|
|
|
|
/* initialize MS cartridge hardware */
|
|
|
|
sms_cart_init();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* PICO hardware */
|
|
|
|
if (system_hw == SYSTEM_PICO)
|
|
|
|
{
|
|
|
|
/* additional registers mapped to $800000-$80FFFF */
|
|
|
|
m68k_memory_map[0x80].read8 = pico_read_byte;
|
|
|
|
m68k_memory_map[0x80].read16 = pico_read_word;
|
|
|
|
m68k_memory_map[0x80].write8 = m68k_unused_8_w;
|
|
|
|
m68k_memory_map[0x80].write16 = m68k_unused_16_w;
|
|
|
|
|
|
|
|
/* there is no I/O area (Notaz) */
|
|
|
|
m68k_memory_map[0xa1].read8 = m68k_read_bus_8;
|
|
|
|
m68k_memory_map[0xa1].read16 = m68k_read_bus_16;
|
|
|
|
m68k_memory_map[0xa1].write8 = m68k_unused_8_w;
|
|
|
|
m68k_memory_map[0xa1].write16 = m68k_unused_16_w;
|
|
|
|
|
|
|
|
/* page registers */
|
|
|
|
pico_current = 0x00;
|
|
|
|
pico_page[0] = 0x00;
|
|
|
|
pico_page[1] = 0x01;
|
|
|
|
pico_page[2] = 0x03;
|
|
|
|
pico_page[3] = 0x07;
|
|
|
|
pico_page[4] = 0x0F;
|
|
|
|
pico_page[5] = 0x1F;
|
|
|
|
pico_page[6] = 0x3F;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize Z80 memory map */
|
|
|
|
/* $0000-$3FFF is mapped to Z80 RAM (8K mirrored) */
|
|
|
|
/* $4000-$FFFF is mapped to hardware but Z80.PC should never point there */
|
|
|
|
for (i=0; i<64; i++)
|
|
|
|
{
|
|
|
|
z80_readmap[i] = &zram[(i & 7) << 10];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize Z80 memory handlers */
|
|
|
|
z80_writemem = z80_md_memory_w;
|
|
|
|
z80_readmem = z80_md_memory_r;
|
|
|
|
|
|
|
|
/* initialize Z80 port handlers */
|
|
|
|
z80_writeport = z80_unused_port_w;
|
|
|
|
z80_readport = z80_unused_port_r;
|
|
|
|
|
|
|
|
/* initialize MD cartridge hardware */
|
|
|
|
md_cart_init();
|
2009-08-14 18:46:19 +02:00
|
|
|
}
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
void gen_reset(int hard_reset)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* System Reset */
|
|
|
|
if (hard_reset)
|
|
|
|
{
|
|
|
|
/* clear RAM */
|
|
|
|
memset (work_ram, 0x00, sizeof (work_ram));
|
|
|
|
memset (zram, 0x00, sizeof (zram));
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* TMSS & OS ROM support */
|
|
|
|
if (config.tmss & 1)
|
|
|
|
{
|
|
|
|
/* clear TMSS register */
|
|
|
|
memset(tmss, 0x00, sizeof(tmss));
|
|
|
|
|
|
|
|
/* VDP access is locked by default */
|
|
|
|
int i;
|
|
|
|
for (i=0xc0; i<0xe0; i+=8)
|
|
|
|
{
|
|
|
|
m68k_memory_map[i].read8 = m68k_lockup_r_8;
|
|
|
|
m68k_memory_map[i].read16 = m68k_lockup_r_16;
|
|
|
|
m68k_memory_map[i].write8 = m68k_lockup_w_8;
|
|
|
|
m68k_memory_map[i].write16 = m68k_lockup_w_16;
|
|
|
|
zbank_memory_map[i].read = zbank_lockup_r;
|
|
|
|
zbank_memory_map[i].write = zbank_lockup_w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OS ROM is mapped at $000000-$0007FF */
|
|
|
|
if (config.tmss & 2)
|
|
|
|
{
|
|
|
|
m68k_memory_map[0].base = bios_rom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-06-15 08:14:35 +02:00
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* reset YM2612 (on hard reset, this is done by sound_reset) */
|
|
|
|
fm_reset(0);
|
2010-06-15 08:14:35 +02:00
|
|
|
}
|
2009-08-14 18:46:19 +02:00
|
|
|
|
2010-08-27 00:31:52 +02:00
|
|
|
/* 68k & Z80 could restart anywhere in VDP frame (Bonkers, Eternal Champions, X-Men 2) */
|
|
|
|
mcycles_68k = mcycles_z80 = (uint32)((MCYCLES_PER_LINE * lines_per_frame) * ((double)rand() / (double)RAND_MAX));
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
if (system_hw == SYSTEM_PBC)
|
|
|
|
{
|
|
|
|
/* reset MS cartridge hardware */
|
|
|
|
sms_cart_reset();
|
2010-06-10 09:57:18 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* Z80 is running */
|
|
|
|
zstate = 1;
|
2009-08-06 20:31:05 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* 68k is halted */
|
2010-05-30 20:42:03 +02:00
|
|
|
m68k_pulse_halt();
|
2011-04-01 00:11:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* reset MD cartridge hardware */
|
|
|
|
md_cart_reset(hard_reset);
|
2010-12-04 18:13:55 +01:00
|
|
|
|
|
|
|
/* Z80 bus is released & Z80 is reseted */
|
|
|
|
m68k_memory_map[0xa0].read8 = m68k_read_bus_8;
|
|
|
|
m68k_memory_map[0xa0].read16 = m68k_read_bus_16;
|
|
|
|
m68k_memory_map[0xa0].write8 = m68k_unused_8_w;
|
|
|
|
m68k_memory_map[0xa0].write16 = m68k_unused_16_w;
|
2011-04-01 00:11:05 +02:00
|
|
|
zstate = 0;
|
2010-12-04 18:13:55 +01:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* assume default bank is $000000-$007FFF */
|
2010-12-04 18:13:55 +01:00
|
|
|
zbank = 0;
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* reset 68k */
|
2010-05-30 20:42:03 +02:00
|
|
|
m68k_pulse_reset();
|
|
|
|
}
|
2011-04-01 00:11:05 +02:00
|
|
|
|
|
|
|
/* reset Z80 */
|
|
|
|
z80_reset();
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2009-08-14 18:46:19 +02:00
|
|
|
void gen_shutdown(void)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2009-04-15 17:33:51 +02:00
|
|
|
z80_exit();
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2010-06-14 10:05:45 +02:00
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
/* OS ROM / TMSS register control functions (Genesis mode) */
|
|
|
|
/*-----------------------------------------------------------------------*/
|
2010-06-14 10:05:45 +02:00
|
|
|
|
|
|
|
void gen_tmss_w(unsigned int offset, unsigned int data)
|
|
|
|
{
|
|
|
|
/* write TMSS regisiter */
|
|
|
|
WRITE_WORD(tmss, offset, data);
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/* VDP requires "SEGA" value to be written in TMSS register */
|
2010-06-14 10:05:45 +02:00
|
|
|
int i;
|
|
|
|
if (strncmp((char *)tmss, "SEGA", 4) == 0)
|
|
|
|
{
|
|
|
|
for (i=0xc0; i<0xe0; i+=8)
|
|
|
|
{
|
|
|
|
m68k_memory_map[i].read8 = vdp_read_byte;
|
|
|
|
m68k_memory_map[i].read16 = vdp_read_word;
|
|
|
|
m68k_memory_map[i].write8 = vdp_write_byte;
|
|
|
|
m68k_memory_map[i].write16 = vdp_write_word;
|
|
|
|
zbank_memory_map[i].read = zbank_read_vdp;
|
|
|
|
zbank_memory_map[i].write = zbank_write_vdp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i=0xc0; i<0xe0; i+=8)
|
|
|
|
{
|
|
|
|
m68k_memory_map[i].read8 = m68k_lockup_r_8;
|
|
|
|
m68k_memory_map[i].read16 = m68k_lockup_r_16;
|
|
|
|
m68k_memory_map[i].write8 = m68k_lockup_w_8;
|
|
|
|
m68k_memory_map[i].write16 = m68k_lockup_w_16;
|
|
|
|
zbank_memory_map[i].read = zbank_lockup_r;
|
|
|
|
zbank_memory_map[i].write = zbank_lockup_w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gen_bankswitch_w(unsigned int data)
|
|
|
|
{
|
2011-04-01 00:11:05 +02:00
|
|
|
/* OS ROM has not been loaded yet */
|
2010-06-14 10:05:45 +02:00
|
|
|
if (!(config.tmss & 2))
|
|
|
|
{
|
|
|
|
config.tmss |= 2;
|
|
|
|
memcpy(bios_rom, cart.rom, 0x800);
|
|
|
|
memset(cart.rom, 0xff, cart.romsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data & 1)
|
|
|
|
{
|
|
|
|
/* enable CART */
|
|
|
|
m68k_memory_map[0].base = cart.base;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* enable internal BIOS ROM */
|
|
|
|
m68k_memory_map[0].base = bios_rom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int gen_bankswitch_r(void)
|
|
|
|
{
|
|
|
|
return (m68k_memory_map[0].base == cart.base);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
/* Z80 Bus controller chip functions (Genesis mode) */
|
|
|
|
/* ----------------------------------------------------------------------*/
|
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
void gen_zbusreq_w(unsigned int data, unsigned int cycles)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
if (data) /* !ZBUSREQ asserted */
|
2008-12-10 19:16:30 +01:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if Z80 is going to be stopped */
|
2010-01-24 12:41:53 +01:00
|
|
|
if (zstate == 1)
|
2010-06-14 10:05:45 +02:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
/* resynchronize with 68k */
|
|
|
|
z80_run(cycles);
|
2010-06-20 22:32:14 +02:00
|
|
|
|
2010-06-17 08:31:30 +02:00
|
|
|
/* enable 68k access to Z80 bus */
|
2011-04-01 00:11:05 +02:00
|
|
|
m68k_memory_map[0xa0].read8 = z80_read_byte;
|
|
|
|
m68k_memory_map[0xa0].read16 = z80_read_word;
|
|
|
|
m68k_memory_map[0xa0].write8 = z80_write_byte;
|
|
|
|
m68k_memory_map[0xa0].write16 = z80_write_word;
|
2010-06-14 10:05:45 +02:00
|
|
|
}
|
2010-06-20 22:32:14 +02:00
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
/* update Z80 bus status */
|
|
|
|
zstate |= 2;
|
2010-06-14 10:05:45 +02:00
|
|
|
}
|
2010-06-17 08:31:30 +02:00
|
|
|
else /* !ZBUSREQ released */
|
2008-12-10 19:16:30 +01:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if Z80 is going to be restarted */
|
2010-01-24 12:41:53 +01:00
|
|
|
if (zstate == 3)
|
2010-06-18 13:02:10 +02:00
|
|
|
{
|
2010-06-20 22:32:14 +02:00
|
|
|
/* resynchronize with 68k */
|
|
|
|
mcycles_z80 = cycles;
|
|
|
|
|
|
|
|
/* disable 68k access to Z80 bus */
|
2011-04-01 00:11:05 +02:00
|
|
|
m68k_memory_map[0xa0].read8 = m68k_read_bus_8;
|
|
|
|
m68k_memory_map[0xa0].read16 = m68k_read_bus_16;
|
|
|
|
m68k_memory_map[0xa0].write8 = m68k_unused_8_w;
|
|
|
|
m68k_memory_map[0xa0].write16 = m68k_unused_16_w;
|
|
|
|
}
|
2008-08-07 14:26:07 +02:00
|
|
|
|
2010-06-17 08:31:30 +02:00
|
|
|
/* update Z80 bus status */
|
2010-01-24 12:41:53 +01:00
|
|
|
zstate &= 1;
|
|
|
|
}
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
void gen_zreset_w(unsigned int data, unsigned int cycles)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
if (data) /* !ZRESET released */
|
2008-12-10 19:16:30 +01:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if Z80 is going to be restarted */
|
|
|
|
if (zstate == 0)
|
|
|
|
{
|
|
|
|
/* resynchronize with 68k */
|
2010-06-20 22:32:14 +02:00
|
|
|
mcycles_z80 = cycles;
|
2011-04-01 00:11:05 +02:00
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
/* reset Z80 & YM2612 */
|
|
|
|
z80_reset();
|
|
|
|
fm_reset(cycles);
|
|
|
|
}
|
2011-04-01 00:11:05 +02:00
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if 68k access to Z80 bus is granted */
|
2010-06-20 22:32:14 +02:00
|
|
|
else if (zstate == 2)
|
2010-06-14 10:05:45 +02:00
|
|
|
{
|
2010-06-17 08:31:30 +02:00
|
|
|
/* enable 68k access to Z80 bus */
|
2011-04-01 00:11:05 +02:00
|
|
|
m68k_memory_map[0xa0].read8 = z80_read_byte;
|
|
|
|
m68k_memory_map[0xa0].read16 = z80_read_word;
|
|
|
|
m68k_memory_map[0xa0].write8 = z80_write_byte;
|
|
|
|
m68k_memory_map[0xa0].write16 = z80_write_word;
|
2010-06-20 22:32:14 +02:00
|
|
|
|
|
|
|
/* reset Z80 & YM2612 */
|
|
|
|
z80_reset();
|
|
|
|
fm_reset(cycles);
|
2010-06-14 10:05:45 +02:00
|
|
|
}
|
2010-06-18 13:02:10 +02:00
|
|
|
|
|
|
|
/* update Z80 bus status */
|
|
|
|
zstate |= 1;
|
2008-12-10 19:16:30 +01:00
|
|
|
}
|
2010-06-17 08:31:30 +02:00
|
|
|
else /* !ZRESET asserted */
|
2008-12-10 19:16:30 +01:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if Z80 is going to be stopped */
|
2010-01-24 12:41:53 +01:00
|
|
|
if (zstate == 1)
|
2010-06-18 13:02:10 +02:00
|
|
|
{
|
|
|
|
/* resynchronize with 68k */
|
2010-05-30 20:42:03 +02:00
|
|
|
z80_run(cycles);
|
2010-06-20 22:32:14 +02:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
/* check if 68k had access to Z80 bus */
|
|
|
|
else if (zstate == 3)
|
|
|
|
{
|
|
|
|
/* disable 68k access to Z80 bus */
|
2011-04-01 00:11:05 +02:00
|
|
|
m68k_memory_map[0xa0].read8 = m68k_read_bus_8;
|
|
|
|
m68k_memory_map[0xa0].read16 = m68k_read_bus_16;
|
|
|
|
m68k_memory_map[0xa0].write8 = m68k_unused_8_w;
|
|
|
|
m68k_memory_map[0xa0].write16 = m68k_unused_16_w;
|
2010-06-18 13:02:10 +02:00
|
|
|
}
|
2010-06-20 22:32:14 +02:00
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
/* stop YM2612 */
|
2010-06-17 08:31:30 +02:00
|
|
|
fm_reset(cycles);
|
|
|
|
|
|
|
|
/* update Z80 bus status */
|
2010-01-24 12:41:53 +01:00
|
|
|
zstate &= 2;
|
|
|
|
}
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:02:10 +02:00
|
|
|
void gen_zbank_w (unsigned int data)
|
2007-08-10 22:34:06 +02:00
|
|
|
{
|
2010-06-18 13:02:10 +02:00
|
|
|
zbank = ((zbank >> 1) | ((data & 1) << 23)) & 0xFF8000;
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 00:11:05 +02:00
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
/* Z80 interrupt callback */
|
|
|
|
/* ----------------------------------------------------------------------*/
|
|
|
|
|
2007-08-10 22:34:06 +02:00
|
|
|
int z80_irq_callback (int param)
|
|
|
|
{
|
2008-12-10 19:16:30 +01:00
|
|
|
return 0xFF;
|
2007-08-10 22:34:06 +02:00
|
|
|
}
|