mirror of
https://github.com/holub/mame
synced 2025-07-04 01:18:59 +03:00
some megadriv modernization (nw)
This commit is contained in:
parent
e43d8ac84e
commit
b0b200159b
@ -667,7 +667,7 @@ DRIVER_INIT_MEMBER(md_boot_state,aladmdb)
|
|||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x220000, 0x220001, FUNC(aladmdb_w));
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x220000, 0x220001, FUNC(aladmdb_w));
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x330000, 0x330001, FUNC(aladmdb_r));
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x330000, 0x330001, FUNC(aladmdb_r));
|
||||||
|
|
||||||
megadrive_6buttons_pad = 0;
|
m_megadrive_6buttons_pad = 0;
|
||||||
DRIVER_INIT_CALL(megadrij);
|
DRIVER_INIT_CALL(megadrij);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ DRIVER_INIT_MEMBER(md_boot_state,mk3mdb)
|
|||||||
|
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(mk3mdb_dsw_r) );
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(mk3mdb_dsw_r) );
|
||||||
|
|
||||||
megadrive_6buttons_pad = 1;
|
m_megadrive_6buttons_pad = 1;
|
||||||
DRIVER_INIT_CALL(megadriv);
|
DRIVER_INIT_CALL(megadriv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,7 +730,7 @@ DRIVER_INIT_MEMBER(md_boot_state,ssf2mdb)
|
|||||||
|
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(ssf2mdb_dsw_r) );
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(ssf2mdb_dsw_r) );
|
||||||
|
|
||||||
megadrive_6buttons_pad = 1;
|
m_megadrive_6buttons_pad = 1;
|
||||||
DRIVER_INIT_CALL(megadrij);
|
DRIVER_INIT_CALL(megadrij);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +759,7 @@ DRIVER_INIT_MEMBER(md_boot_state,srmdb)
|
|||||||
|
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(srmdb_dsw_r) );
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0x770070, 0x770075, FUNC(srmdb_dsw_r) );
|
||||||
|
|
||||||
megadrive_6buttons_pad = 0;
|
m_megadrive_6buttons_pad = 0;
|
||||||
DRIVER_INIT_CALL(megadriv);
|
DRIVER_INIT_CALL(megadriv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ DRIVER_INIT_MEMBER(md_boot_state,topshoot)
|
|||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x200046, 0x200047, "IN2");
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x200046, 0x200047, "IN2");
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x200048, 0x200049, "IN3");
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_port(0x200048, 0x200049, "IN3");
|
||||||
|
|
||||||
megadrive_6buttons_pad = 0;
|
m_megadrive_6buttons_pad = 0;
|
||||||
DRIVER_INIT_CALL(megadriv);
|
DRIVER_INIT_CALL(megadriv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ Bugs:
|
|||||||
|
|
||||||
#define MASTER_CLOCK 53693100
|
#define MASTER_CLOCK 53693100
|
||||||
|
|
||||||
extern UINT8 segae_vintpending;
|
|
||||||
extern UINT8 segae_hintpending;
|
|
||||||
extern UINT8 *segae_vdp_regs[]; /* pointer to vdp's registers */
|
|
||||||
|
|
||||||
// Interrupt handler - from drivers/segasyse.c
|
// Interrupt handler - from drivers/segasyse.c
|
||||||
#if 0
|
#if 0
|
||||||
|
static UINT8 segae_vintpending;
|
||||||
|
static UINT8 segae_hintpending;
|
||||||
|
static UINT8 *segae_vdp_regs[]; /* pointer to vdp's registers */
|
||||||
|
|
||||||
static UINT8 hintcount; /* line interrupt counter, decreased each scanline */
|
static UINT8 hintcount; /* line interrupt counter, decreased each scanline */
|
||||||
|
|
||||||
static INTERRUPT_GEN (megaplay_bios_irq)
|
static INTERRUPT_GEN (megaplay_bios_irq)
|
||||||
@ -373,83 +373,78 @@ INPUT_PORTS_END
|
|||||||
|
|
||||||
/*MEGAPLAY specific*/
|
/*MEGAPLAY specific*/
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_banksel_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_banksel_r )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
return m_bios_bank;
|
||||||
return state->m_bios_bank;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_banksel_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_banksel_w )
|
||||||
{
|
{
|
||||||
/* Multi-slot note:
|
/* Multi-slot note:
|
||||||
Bits 0 and 1 appear to determine the selected game slot.
|
Bits 0 and 1 appear to determine the selected game slot.
|
||||||
It should be possible to multiplex different game ROMs at
|
It should be possible to multiplex different game ROMs at
|
||||||
0x000000-0x3fffff based on these bits.
|
0x000000-0x3fffff based on these bits.
|
||||||
*/
|
*/
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
m_bios_bank = data;
|
||||||
state->m_bios_bank = data;
|
m_bios_mode = MP_ROM;
|
||||||
state->m_bios_mode = MP_ROM;
|
|
||||||
// logerror("BIOS: ROM bank %i selected [0x%02x]\n",bios_bank >> 6, data);
|
// logerror("BIOS: ROM bank %i selected [0x%02x]\n",bios_bank >> 6, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_gamesel_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_gamesel_r )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
return m_bios_6403;
|
||||||
return state->m_bios_6403;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_gamesel_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_gamesel_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
m_bios_6403 = data;
|
||||||
state->m_bios_6403 = data;
|
|
||||||
|
|
||||||
// logerror("BIOS: 0x6403 write: 0x%02x\n",data);
|
// logerror("BIOS: 0x6403 write: 0x%02x\n",data);
|
||||||
state->m_bios_mode = data & 0x10;
|
m_bios_mode = data & 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE16_HANDLER( megaplay_io_write )
|
WRITE16_MEMBER(mplay_state::megaplay_io_write )
|
||||||
{
|
{
|
||||||
if (offset == 0x03)
|
if (offset == 0x03)
|
||||||
megadrive_io_data_regs[2] = (data & megadrive_io_ctrl_regs[2]) | (megadrive_io_data_regs[2] & ~megadrive_io_ctrl_regs[2]);
|
m_megadrive_io_data_regs[2] = (data & m_megadrive_io_ctrl_regs[2]) | (m_megadrive_io_data_regs[2] & ~m_megadrive_io_ctrl_regs[2]);
|
||||||
else
|
else
|
||||||
megadriv_68k_io_write(space, offset & 0x1f, data, 0xffff);
|
megadriv_68k_io_write(space, offset & 0x1f, data, 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ16_HANDLER( megaplay_io_read )
|
READ16_MEMBER(mplay_state::megaplay_io_read )
|
||||||
{
|
{
|
||||||
if (offset == 0x03)
|
if (offset == 0x03)
|
||||||
return megadrive_io_data_regs[2];
|
return m_megadrive_io_data_regs[2];
|
||||||
else
|
else
|
||||||
return megadriv_68k_io_read(space, offset & 0x1f, 0xffff);
|
return megadriv_68k_io_read(space, offset & 0x1f, 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( bank_r )
|
READ8_MEMBER(mplay_state::bank_r )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
UINT8* bank = memregion("mtbios")->base();
|
||||||
UINT8* bank = state->memregion("mtbios")->base();
|
UINT32 fulladdress = m_mp_bios_bank_addr + offset;
|
||||||
UINT32 fulladdress = state->m_mp_bios_bank_addr + offset;
|
|
||||||
|
|
||||||
if (fulladdress <= 0x3fffff) // ROM Addresses
|
if (fulladdress <= 0x3fffff) // ROM Addresses
|
||||||
{
|
{
|
||||||
if (state->m_bios_mode & MP_ROM)
|
if (m_bios_mode & MP_ROM)
|
||||||
{
|
{
|
||||||
int sel = (state->m_bios_bank >> 6) & 0x03;
|
int sel = (m_bios_bank >> 6) & 0x03;
|
||||||
|
|
||||||
if (sel == 0)
|
if (sel == 0)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
else
|
else
|
||||||
return bank[0x10000 + (sel - 1) * 0x8000 + offset];
|
return bank[0x10000 + (sel - 1) * 0x8000 + offset];
|
||||||
}
|
}
|
||||||
else if (state->m_bios_width & 0x08)
|
else if (m_bios_width & 0x08)
|
||||||
{
|
{
|
||||||
if (offset >= 0x2000)
|
if (offset >= 0x2000)
|
||||||
return state->m_ic36_ram[offset - 0x2000];
|
return m_ic36_ram[offset - 0x2000];
|
||||||
else
|
else
|
||||||
return state->m_ic37_ram[(0x2000 * (state->m_bios_bank & 0x03)) + offset];
|
return m_ic37_ram[(0x2000 * (m_bios_bank & 0x03)) + offset];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return space.machine().root_device().memregion("maincpu")->base()[fulladdress ^ 1];
|
return machine().root_device().memregion("maincpu")->base()[fulladdress ^ 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fulladdress >= 0xa10000 && fulladdress <= 0xa1001f) // IO Acess
|
else if (fulladdress >= 0xa10000 && fulladdress <= 0xa1001f) // IO Acess
|
||||||
@ -464,22 +459,21 @@ static READ8_HANDLER( bank_r )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( bank_w )
|
WRITE8_MEMBER(mplay_state::bank_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
UINT32 fulladdress = m_mp_bios_bank_addr + offset;
|
||||||
UINT32 fulladdress = state->m_mp_bios_bank_addr + offset;
|
|
||||||
|
|
||||||
if (fulladdress <= 0x3fffff) // ROM / Megaplay Custom Addresses
|
if (fulladdress <= 0x3fffff) // ROM / Megaplay Custom Addresses
|
||||||
{
|
{
|
||||||
if (offset <= 0x1fff && (state->m_bios_width & 0x08))
|
if (offset <= 0x1fff && (m_bios_width & 0x08))
|
||||||
{
|
{
|
||||||
state->m_ic37_ram[(0x2000 * (state->m_bios_bank & 0x03)) + offset] = data;
|
m_ic37_ram[(0x2000 * (m_bios_bank & 0x03)) + offset] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset >= 0x2000 && (state->m_bios_width & 0x08))
|
if(offset >= 0x2000 && (m_bios_width & 0x08))
|
||||||
{
|
{
|
||||||
// ic36_ram[offset] = data;
|
// ic36_ram[offset] = data;
|
||||||
state->m_ic36_ram[offset - 0x2000] = data;
|
m_ic36_ram[offset - 0x2000] = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fulladdress >= 0xa10000 && fulladdress <=0xa1001f) // IO Access
|
else if (fulladdress >= 0xa10000 && fulladdress <=0xa1001f) // IO Access
|
||||||
@ -496,106 +490,100 @@ static WRITE8_HANDLER( bank_w )
|
|||||||
/* Megaplay BIOS handles regs[2] at start in a different way compared to megadrive */
|
/* Megaplay BIOS handles regs[2] at start in a different way compared to megadrive */
|
||||||
/* other io data/ctrl regs are dealt with exactly like in the console */
|
/* other io data/ctrl regs are dealt with exactly like in the console */
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_6402_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_6402_r )
|
||||||
{
|
{
|
||||||
return megadrive_io_data_regs[2];// & 0xfe;
|
return m_megadrive_io_data_regs[2];// & 0xfe;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_6402_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_6402_w )
|
||||||
{
|
{
|
||||||
megadrive_io_data_regs[2] = (megadrive_io_data_regs[2] & 0x07) | ((data & 0x70) >> 1);
|
m_megadrive_io_data_regs[2] = (m_megadrive_io_data_regs[2] & 0x07) | ((data & 0x70) >> 1);
|
||||||
// logerror("BIOS: 0x6402 write: 0x%02x\n", data);
|
// logerror("BIOS: 0x6402 write: 0x%02x\n", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_6204_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_6204_r )
|
||||||
{
|
{
|
||||||
return megadrive_io_data_regs[2];
|
return m_megadrive_io_data_regs[2];
|
||||||
// return (state->m_bios_width & 0xf8) + (state->m_bios_6204 & 0x07);
|
// return (m_bios_width & 0xf8) + (m_bios_6204 & 0x07);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_width_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_width_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
m_bios_width = data;
|
||||||
state->m_bios_width = data;
|
m_megadrive_io_data_regs[2] = (m_megadrive_io_data_regs[2] & 0x07) | ((data & 0xf8));
|
||||||
megadrive_io_data_regs[2] = (megadrive_io_data_regs[2] & 0x07) | ((data & 0xf8));
|
|
||||||
// logerror("BIOS: 0x6204 - Width write: %02x\n", data);
|
// logerror("BIOS: 0x6204 - Width write: %02x\n", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_6404_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_6404_r )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
|
||||||
// logerror("BIOS: 0x6404 read: returned 0x%02x\n",bios_6404 | (bios_6403 & 0x10) >> 4);
|
// logerror("BIOS: 0x6404 read: returned 0x%02x\n",bios_6404 | (bios_6403 & 0x10) >> 4);
|
||||||
return (state->m_bios_6404 & 0xfe) | ((state->m_bios_6403 & 0x10) >> 4);
|
return (m_bios_6404 & 0xfe) | ((m_bios_6403 & 0x10) >> 4);
|
||||||
// return state->m_bios_6404 | (state->m_bios_6403 & 0x10) >> 4;
|
// return m_bios_6404 | (m_bios_6403 & 0x10) >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_6404_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_6404_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
if(((m_bios_6404 & 0x0c) == 0x00) && ((data & 0x0c) == 0x0c))
|
||||||
if(((state->m_bios_6404 & 0x0c) == 0x00) && ((data & 0x0c) == 0x0c))
|
machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, PULSE_LINE);
|
||||||
space.machine().device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, PULSE_LINE);
|
m_bios_6404 = data;
|
||||||
state->m_bios_6404 = data;
|
|
||||||
|
|
||||||
// logerror("BIOS: 0x6404 write: 0x%02x\n", data);
|
// logerror("BIOS: 0x6404 write: 0x%02x\n", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( megaplay_bios_6600_r )
|
READ8_MEMBER(mplay_state::megaplay_bios_6600_r )
|
||||||
{
|
{
|
||||||
/* Multi-slot note:
|
/* Multi-slot note:
|
||||||
0x6600 appears to be used to check for extra slots being used.
|
0x6600 appears to be used to check for extra slots being used.
|
||||||
Enter the following line in place of the return statement in this
|
Enter the following line in place of the return statement in this
|
||||||
function to make the BIOS check all 4 slots (3 and 4 will be "not used")
|
function to make the BIOS check all 4 slots (3 and 4 will be "not used")
|
||||||
return (state->m_bios_6600 & 0xfe) | (state->m_bios_bank & 0x01);
|
return (m_bios_6600 & 0xfe) | (m_bios_bank & 0x01);
|
||||||
*/
|
*/
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
return m_bios_6600;// & 0xfe;
|
||||||
return state->m_bios_6600;// & 0xfe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_bios_6600_w )
|
WRITE8_MEMBER(mplay_state::megaplay_bios_6600_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
m_bios_6600 = data;
|
||||||
state->m_bios_6600 = data;
|
|
||||||
// logerror("BIOS: 0x6600 write: 0x%02x\n",data);
|
// logerror("BIOS: 0x6600 write: 0x%02x\n",data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( megaplay_game_w )
|
WRITE8_MEMBER(mplay_state::megaplay_game_w )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
if (m_readpos == 1)
|
||||||
if (state->m_readpos == 1)
|
m_game_banksel = 0;
|
||||||
state->m_game_banksel = 0;
|
m_game_banksel |= (1 << (m_readpos - 1)) * (data & 0x01);
|
||||||
state->m_game_banksel |= (1 << (state->m_readpos - 1)) * (data & 0x01);
|
|
||||||
|
|
||||||
state->m_readpos++;
|
m_readpos++;
|
||||||
|
|
||||||
if (state->m_readpos > 9)
|
if (m_readpos > 9)
|
||||||
{
|
{
|
||||||
state->m_bios_mode = MP_GAME;
|
m_bios_mode = MP_GAME;
|
||||||
state->m_readpos = 1;
|
m_readpos = 1;
|
||||||
// popmessage("Game bank selected: 0x%03x", state->m_game_banksel);
|
// popmessage("Game bank selected: 0x%03x", m_game_banksel);
|
||||||
logerror("BIOS [0x%04x]: 68K address space bank selected: 0x%03x\n", space.device().safe_pcbase(), state->m_game_banksel);
|
logerror("BIOS [0x%04x]: 68K address space bank selected: 0x%03x\n", space.device().safe_pcbase(), m_game_banksel);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->m_mp_bios_bank_addr = ((state->m_mp_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
|
m_mp_bios_bank_addr = ((m_mp_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ADDRESS_MAP_START( megaplay_bios_map, AS_PROGRAM, 8, mplay_state )
|
static ADDRESS_MAP_START( megaplay_bios_map, AS_PROGRAM, 8, mplay_state )
|
||||||
AM_RANGE(0x0000, 0x3fff) AM_ROM
|
AM_RANGE(0x0000, 0x3fff) AM_ROM
|
||||||
AM_RANGE(0x4000, 0x4fff) AM_RAM
|
AM_RANGE(0x4000, 0x4fff) AM_RAM
|
||||||
AM_RANGE(0x5000, 0x5fff) AM_RAM
|
AM_RANGE(0x5000, 0x5fff) AM_RAM
|
||||||
AM_RANGE(0x6000, 0x6000) AM_WRITE_LEGACY(megaplay_game_w)
|
AM_RANGE(0x6000, 0x6000) AM_WRITE(megaplay_game_w)
|
||||||
AM_RANGE(0x6200, 0x6200) AM_READ_PORT("DSW0")
|
AM_RANGE(0x6200, 0x6200) AM_READ_PORT("DSW0")
|
||||||
AM_RANGE(0x6201, 0x6201) AM_READ_PORT("DSW1")
|
AM_RANGE(0x6201, 0x6201) AM_READ_PORT("DSW1")
|
||||||
AM_RANGE(0x6203, 0x6203) AM_READWRITE_LEGACY(megaplay_bios_banksel_r, megaplay_bios_banksel_w)
|
AM_RANGE(0x6203, 0x6203) AM_READWRITE(megaplay_bios_banksel_r, megaplay_bios_banksel_w)
|
||||||
AM_RANGE(0x6204, 0x6204) AM_READWRITE_LEGACY(megaplay_bios_6204_r, megaplay_bios_width_w)
|
AM_RANGE(0x6204, 0x6204) AM_READWRITE(megaplay_bios_6204_r, megaplay_bios_width_w)
|
||||||
AM_RANGE(0x6400, 0x6400) AM_READ_PORT("TEST")
|
AM_RANGE(0x6400, 0x6400) AM_READ_PORT("TEST")
|
||||||
AM_RANGE(0x6401, 0x6401) AM_READ_PORT("COIN")
|
AM_RANGE(0x6401, 0x6401) AM_READ_PORT("COIN")
|
||||||
AM_RANGE(0x6402, 0x6402) AM_READWRITE_LEGACY(megaplay_bios_6402_r, megaplay_bios_6402_w)
|
AM_RANGE(0x6402, 0x6402) AM_READWRITE(megaplay_bios_6402_r, megaplay_bios_6402_w)
|
||||||
AM_RANGE(0x6403, 0x6403) AM_READWRITE_LEGACY(megaplay_bios_gamesel_r, megaplay_bios_gamesel_w)
|
AM_RANGE(0x6403, 0x6403) AM_READWRITE(megaplay_bios_gamesel_r, megaplay_bios_gamesel_w)
|
||||||
AM_RANGE(0x6404, 0x6404) AM_READWRITE_LEGACY(megaplay_bios_6404_r, megaplay_bios_6404_w)
|
AM_RANGE(0x6404, 0x6404) AM_READWRITE(megaplay_bios_6404_r, megaplay_bios_6404_w)
|
||||||
AM_RANGE(0x6600, 0x6600) AM_READWRITE_LEGACY(megaplay_bios_6600_r, megaplay_bios_6600_w)
|
AM_RANGE(0x6600, 0x6600) AM_READWRITE(megaplay_bios_6600_r, megaplay_bios_6600_w)
|
||||||
AM_RANGE(0x6001, 0x67ff) AM_WRITEONLY
|
AM_RANGE(0x6001, 0x67ff) AM_WRITEONLY
|
||||||
AM_RANGE(0x6800, 0x77ff) AM_RAM AM_SHARE("ic3_ram")
|
AM_RANGE(0x6800, 0x77ff) AM_RAM AM_SHARE("ic3_ram")
|
||||||
AM_RANGE(0x8000, 0xffff) AM_READWRITE_LEGACY(bank_r, bank_w)
|
AM_RANGE(0x8000, 0xffff) AM_READWRITE(bank_r, bank_w)
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
/* basically from src/drivers/segasyse.c */
|
/* basically from src/drivers/segasyse.c */
|
||||||
@ -830,11 +818,11 @@ ROM_START( mp_shnb3 ) /* Shinobi 3 */
|
|||||||
ROM_END
|
ROM_END
|
||||||
|
|
||||||
|
|
||||||
static void mplay_start(running_machine &machine)
|
void mplay_state::mplay_start()
|
||||||
{
|
{
|
||||||
UINT8 *src = machine.root_device().memregion("mtbios")->base();
|
UINT8 *src = machine().root_device().memregion("mtbios")->base();
|
||||||
UINT8 *instruction_rom = machine.root_device().memregion("user1")->base();
|
UINT8 *instruction_rom = machine().root_device().memregion("user1")->base();
|
||||||
UINT8 *game_rom = machine.root_device().memregion("maincpu")->base();
|
UINT8 *game_rom = machine().root_device().memregion("maincpu")->base();
|
||||||
int offs;
|
int offs;
|
||||||
|
|
||||||
memmove(src + 0x10000, src + 0x8000, 0x18000); // move bios..
|
memmove(src + 0x10000, src + 0x8000, 0x18000); // move bios..
|
||||||
@ -850,26 +838,24 @@ static void mplay_start(running_machine &machine)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ16_HANDLER( megadriv_68k_read_z80_extra_ram )
|
READ16_MEMBER(mplay_state::megadriv_68k_read_z80_extra_ram )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
return m_ic36_ram[(offset << 1) ^ 1] | (m_ic36_ram[(offset << 1)] << 8);
|
||||||
return state->m_ic36_ram[(offset << 1) ^ 1] | (state->m_ic36_ram[(offset << 1)] << 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE16_HANDLER( megadriv_68k_write_z80_extra_ram )
|
WRITE16_MEMBER(mplay_state::megadriv_68k_write_z80_extra_ram )
|
||||||
{
|
{
|
||||||
mplay_state *state = space.machine().driver_data<mplay_state>();
|
|
||||||
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
||||||
{
|
{
|
||||||
state->m_ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
|
m_ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
else if (!ACCESSING_BITS_8_15)
|
else if (!ACCESSING_BITS_8_15)
|
||||||
{
|
{
|
||||||
state->m_ic36_ram[(offset << 1) ^ 1] = (data & 0x00ff);
|
m_ic36_ram[(offset << 1) ^ 1] = (data & 0x00ff);
|
||||||
}
|
}
|
||||||
else // for WORD access only the MSB is used, LSB is ignored
|
else // for WORD access only the MSB is used, LSB is ignored
|
||||||
{
|
{
|
||||||
state->m_ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
|
m_ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,16 +869,16 @@ DRIVER_INIT_MEMBER(mplay_state,megaplay)
|
|||||||
|
|
||||||
DRIVER_INIT_CALL(mpnew);
|
DRIVER_INIT_CALL(mpnew);
|
||||||
|
|
||||||
mplay_start(machine());
|
mplay_start();
|
||||||
|
|
||||||
/* for now ... */
|
/* for now ... */
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa10000, 0xa1001f, FUNC(megaplay_io_read), FUNC(megaplay_io_write));
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa10000, 0xa1001f, read16_delegate(FUNC(mplay_state::megaplay_io_read),this), write16_delegate(FUNC(mplay_state::megaplay_io_write),this));
|
||||||
|
|
||||||
/* megaplay has ram shared with the bios cpu here */
|
/* megaplay has ram shared with the bios cpu here */
|
||||||
machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM).install_ram(0x2000, 0x3fff, &m_ic36_ram[0]);
|
machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM).install_ram(0x2000, 0x3fff, &m_ic36_ram[0]);
|
||||||
|
|
||||||
/* instead of a RAM mirror the 68k sees the extra ram of the 2nd z80 too */
|
/* instead of a RAM mirror the 68k sees the extra ram of the 2nd z80 too */
|
||||||
machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa02000, 0xa03fff, FUNC(megadriv_68k_read_z80_extra_ram), FUNC(megadriv_68k_write_z80_extra_ram));
|
machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa02000, 0xa03fff, read16_delegate(FUNC(mplay_state::megadriv_68k_read_z80_extra_ram),this), write16_delegate(FUNC(mplay_state::megadriv_68k_write_z80_extra_ram),this));
|
||||||
|
|
||||||
init_megatech_bios(machine());
|
init_megatech_bios(machine());
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ static TIMER_CALLBACK( megatech_z80_run_state )
|
|||||||
{
|
{
|
||||||
printf("disabling SMS Z80\n");
|
printf("disabling SMS Z80\n");
|
||||||
state->m_current_game_is_sms = 0;
|
state->m_current_game_is_sms = 0;
|
||||||
megatech_set_megadrive_z80_as_megadrive_z80(machine, "genesis_snd_z80");
|
state->megatech_set_megadrive_z80_as_megadrive_z80("genesis_snd_z80");
|
||||||
machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
|
machine.device("maincpu")->execute().set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
|
||||||
//machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
|
//machine.device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
|
||||||
}
|
}
|
||||||
|
@ -42,20 +42,13 @@ MACHINE_CONFIG_EXTERN( md_bootleg ); // for topshoot.c & hshavoc.c
|
|||||||
extern UINT8 megatech_bios_port_cc_dc_r(running_machine &machine, int offset, int ctrl);
|
extern UINT8 megatech_bios_port_cc_dc_r(running_machine &machine, int offset, int ctrl);
|
||||||
extern void megadriv_stop_scanline_timer(running_machine &machine);
|
extern void megadriv_stop_scanline_timer(running_machine &machine);
|
||||||
|
|
||||||
void megatech_set_megadrive_z80_as_megadrive_z80(running_machine &machine, const char* tag);
|
|
||||||
|
|
||||||
|
|
||||||
/* These handlers are needed by megaplay.c */
|
|
||||||
extern DECLARE_READ16_HANDLER( megadriv_68k_io_read );
|
|
||||||
extern DECLARE_WRITE16_HANDLER( megadriv_68k_io_write );
|
|
||||||
|
|
||||||
|
|
||||||
/* These are needed to create external input handlers (see e.g. MESS) */
|
/* These are needed to create external input handlers (see e.g. MESS) */
|
||||||
/* Regs are also used by Megaplay! */
|
/* Regs are also used by Megaplay! */
|
||||||
extern UINT8 (*megadrive_io_read_data_port_ptr)(running_machine &machine, int offset);
|
extern UINT8 (*megadrive_io_read_data_port_ptr)(running_machine &machine, int offset);
|
||||||
extern void (*megadrive_io_write_data_port_ptr)(running_machine &machine, int offset, UINT16 data);
|
extern void (*megadrive_io_write_data_port_ptr)(running_machine &machine, int offset, UINT16 data);
|
||||||
extern UINT8 megadrive_io_data_regs[3];
|
extern UINT8 m_megadrive_io_data_regs[3];
|
||||||
extern UINT8 megadrive_io_ctrl_regs[3];
|
extern UINT8 m_megadrive_io_ctrl_regs[3];
|
||||||
|
|
||||||
MACHINE_START( megadriv );
|
MACHINE_START( megadriv );
|
||||||
MACHINE_RESET( megadriv );
|
MACHINE_RESET( megadriv );
|
||||||
@ -67,7 +60,7 @@ SCREEN_VBLANK( megadriv );
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int megadrive_6buttons_pad;
|
extern int m_megadrive_6buttons_pad;
|
||||||
|
|
||||||
/* Megaplay - Megatech specific */
|
/* Megaplay - Megatech specific */
|
||||||
/* It might be possible to move the following structs in the drivers */
|
/* It might be possible to move the following structs in the drivers */
|
||||||
@ -121,6 +114,27 @@ public:
|
|||||||
void megadriv_init_common();
|
void megadriv_init_common();
|
||||||
|
|
||||||
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( _32x_cart );
|
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( _32x_cart );
|
||||||
|
|
||||||
|
void megadriv_z80_bank_w(UINT16 data);
|
||||||
|
DECLARE_WRITE16_MEMBER( megadriv_68k_z80_bank_write );
|
||||||
|
DECLARE_WRITE8_MEMBER(megadriv_z80_z80_bank_w);
|
||||||
|
DECLARE_READ16_MEMBER( megadriv_68k_io_read );
|
||||||
|
DECLARE_WRITE16_MEMBER( megadriv_68k_io_write );
|
||||||
|
DECLARE_READ16_MEMBER( megadriv_68k_read_z80_ram );
|
||||||
|
DECLARE_WRITE16_MEMBER( megadriv_68k_write_z80_ram );
|
||||||
|
DECLARE_READ16_MEMBER( megadriv_68k_check_z80_bus );
|
||||||
|
DECLARE_WRITE16_MEMBER( megadriv_68k_req_z80_bus );
|
||||||
|
DECLARE_WRITE16_MEMBER ( megadriv_68k_req_z80_reset );
|
||||||
|
DECLARE_READ8_MEMBER( z80_read_68k_banked_data );
|
||||||
|
DECLARE_WRITE8_MEMBER( z80_write_68k_banked_data );
|
||||||
|
DECLARE_WRITE8_MEMBER( megadriv_z80_vdp_write );
|
||||||
|
DECLARE_READ8_MEMBER( megadriv_z80_vdp_read );
|
||||||
|
DECLARE_READ8_MEMBER( megadriv_z80_unmapped_read );
|
||||||
|
DECLARE_READ8_MEMBER( z80_unmapped_port_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( z80_unmapped_port_w );
|
||||||
|
DECLARE_READ8_MEMBER( z80_unmapped_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( z80_unmapped_w );
|
||||||
|
TIMER_CALLBACK_MEMBER(megadriv_z80_run_state);
|
||||||
};
|
};
|
||||||
|
|
||||||
class md_boot_state : public md_base_state
|
class md_boot_state : public md_base_state
|
||||||
@ -318,6 +332,27 @@ public:
|
|||||||
|
|
||||||
UINT32 screen_update_megplay(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
UINT32 screen_update_megplay(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||||
void screen_eof_megaplay(screen_device &screen, bool state);
|
void screen_eof_megaplay(screen_device &screen, bool state);
|
||||||
|
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_banksel_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_banksel_w );
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_gamesel_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_gamesel_w );
|
||||||
|
DECLARE_WRITE16_MEMBER( megaplay_io_write );
|
||||||
|
DECLARE_READ16_MEMBER( megaplay_io_read );
|
||||||
|
DECLARE_READ8_MEMBER( bank_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( bank_w );
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_6402_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_6402_w );
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_6204_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_width_w );
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_6404_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_6404_w );
|
||||||
|
DECLARE_READ8_MEMBER( megaplay_bios_6600_r );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_bios_6600_w );
|
||||||
|
DECLARE_WRITE8_MEMBER( megaplay_game_w );
|
||||||
|
void mplay_start();
|
||||||
|
DECLARE_READ16_MEMBER( megadriv_68k_read_z80_extra_ram );
|
||||||
|
DECLARE_WRITE16_MEMBER( megadriv_68k_write_z80_extra_ram );
|
||||||
};
|
};
|
||||||
|
|
||||||
class mtech_state : public md_base_state
|
class mtech_state : public md_base_state
|
||||||
@ -358,6 +393,8 @@ public:
|
|||||||
UINT32 screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
UINT32 screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||||
void screen_eof_mtnew(screen_device &screen, bool state);
|
void screen_eof_mtnew(screen_device &screen, bool state);
|
||||||
UINT32 screen_update_megatech_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
UINT32 screen_update_megatech_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||||
|
|
||||||
|
void megatech_set_megadrive_z80_as_megadrive_z80(const char* tag);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ Known Non-Issues (confirmed on Real Genesis)
|
|||||||
|
|
||||||
MACHINE_CONFIG_EXTERN( megadriv );
|
MACHINE_CONFIG_EXTERN( megadriv );
|
||||||
|
|
||||||
timer_device* megadriv_scanline_timer;
|
extern timer_device* megadriv_scanline_timer;
|
||||||
|
|
||||||
|
|
||||||
void megadriv_z80_hold(running_machine &machine)
|
void megadriv_z80_hold(running_machine &machine)
|
||||||
@ -44,35 +44,23 @@ void megadriv_z80_clear(running_machine &machine)
|
|||||||
state->m_z80snd->set_input_line(0, CLEAR_LINE);
|
state->m_z80snd->set_input_line(0, CLEAR_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void megadriv_z80_bank_w(address_space &space, UINT16 data)
|
void md_base_state::megadriv_z80_bank_w(UINT16 data)
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
m_genz80.z80_bank_addr = ((m_genz80.z80_bank_addr >> 1) | (data << 23)) & 0xff8000;
|
||||||
state->m_genz80.z80_bank_addr = ((state->m_genz80.z80_bank_addr >> 1) | (data << 23)) & 0xff8000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE16_HANDLER( megadriv_68k_z80_bank_write )
|
WRITE16_MEMBER(md_base_state::megadriv_68k_z80_bank_write )
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68k writing bit to bank register %01x\n", space.device().safe_pc(),data&0x01);
|
//logerror("%06x: 68k writing bit to bank register %01x\n", space.device().safe_pc(),data&0x01);
|
||||||
megadriv_z80_bank_w(space, data & 0x01);
|
megadriv_z80_bank_w(data & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER(megadriv_z80_z80_bank_w)
|
WRITE8_MEMBER(md_base_state::megadriv_z80_z80_bank_w)
|
||||||
{
|
{
|
||||||
//logerror("%04x: z80 writing bit to bank register %01x\n", space.device().safe_pc(),data&0x01);
|
//logerror("%04x: z80 writing bit to bank register %01x\n", space.device().safe_pc(),data&0x01);
|
||||||
megadriv_z80_bank_w(space, data & 0x01);
|
megadriv_z80_bank_w(data & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DECLARE_READ16_HANDLER( megadriv_68k_check_z80_bus );
|
|
||||||
static DECLARE_WRITE16_HANDLER(megadriv_68k_req_z80_bus);
|
|
||||||
|
|
||||||
static DECLARE_READ16_HANDLER( megadriv_68k_read_z80_ram );
|
|
||||||
static DECLARE_WRITE16_HANDLER( megadriv_68k_write_z80_ram );
|
|
||||||
|
|
||||||
static DECLARE_WRITE16_HANDLER( megadriv_68k_req_z80_reset );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
READ8_MEMBER(md_base_state::megadriv_68k_YM2612_read)
|
READ8_MEMBER(md_base_state::megadriv_68k_YM2612_read)
|
||||||
{
|
{
|
||||||
device_t *device = machine().device("ymsnd");
|
device_t *device = machine().device("ymsnd");
|
||||||
@ -106,12 +94,12 @@ WRITE8_MEMBER(md_base_state::megadriv_68k_YM2612_write)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Megadrive / Genesis has 3 I/O ports */
|
/* Megadrive / Genesis has 3 I/O ports */
|
||||||
static emu_timer *io_timeout[3];
|
static emu_timer *m_io_timeout[3];
|
||||||
static int io_stage[3];
|
static int m_io_stage[3];
|
||||||
|
|
||||||
static TIMER_CALLBACK( io_timeout_timer_callback )
|
static TIMER_CALLBACK( io_timeout_timer_callback )
|
||||||
{
|
{
|
||||||
io_stage[(int)(FPTR)ptr] = -1;
|
m_io_stage[(int)(FPTR)ptr] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_megadri6_io(running_machine &machine)
|
static void init_megadri6_io(running_machine &machine)
|
||||||
@ -120,7 +108,7 @@ static void init_megadri6_io(running_machine &machine)
|
|||||||
|
|
||||||
for (i=0; i<3; i++)
|
for (i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
io_timeout[i] = machine.scheduler().timer_alloc(FUNC(io_timeout_timer_callback), (void*)(FPTR)i);
|
m_io_timeout[i] = machine.scheduler().timer_alloc(FUNC(io_timeout_timer_callback), (void*)(FPTR)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,78 +201,78 @@ INPUT_PORTS_START( megadri6 )
|
|||||||
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(2) PORT_NAME("P2 MODE") // mode
|
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(2) PORT_NAME("P2 MODE") // mode
|
||||||
INPUT_PORTS_END
|
INPUT_PORTS_END
|
||||||
|
|
||||||
UINT8 megadrive_io_data_regs[3];
|
UINT8 m_megadrive_io_data_regs[3];
|
||||||
UINT8 megadrive_io_ctrl_regs[3];
|
UINT8 m_megadrive_io_ctrl_regs[3];
|
||||||
static UINT8 megadrive_io_tx_regs[3];
|
static UINT8 m_megadrive_io_tx_regs[3];
|
||||||
int megadrive_6buttons_pad = 0;
|
int m_megadrive_6buttons_pad = 0;
|
||||||
|
|
||||||
static void megadrive_reset_io(running_machine &machine)
|
static void megadrive_reset_io(running_machine &machine)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
megadrive_io_data_regs[0] = 0x7f;
|
m_megadrive_io_data_regs[0] = 0x7f;
|
||||||
megadrive_io_data_regs[1] = 0x7f;
|
m_megadrive_io_data_regs[1] = 0x7f;
|
||||||
megadrive_io_data_regs[2] = 0x7f;
|
m_megadrive_io_data_regs[2] = 0x7f;
|
||||||
megadrive_io_ctrl_regs[0] = 0x00;
|
m_megadrive_io_ctrl_regs[0] = 0x00;
|
||||||
megadrive_io_ctrl_regs[1] = 0x00;
|
m_megadrive_io_ctrl_regs[1] = 0x00;
|
||||||
megadrive_io_ctrl_regs[2] = 0x00;
|
m_megadrive_io_ctrl_regs[2] = 0x00;
|
||||||
megadrive_io_tx_regs[0] = 0xff;
|
m_megadrive_io_tx_regs[0] = 0xff;
|
||||||
megadrive_io_tx_regs[1] = 0xff;
|
m_megadrive_io_tx_regs[1] = 0xff;
|
||||||
megadrive_io_tx_regs[2] = 0xff;
|
m_megadrive_io_tx_regs[2] = 0xff;
|
||||||
|
|
||||||
for (i=0; i<3; i++)
|
for (i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
io_stage[i] = -1;
|
m_io_stage[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************* 6 buttons version **************************/
|
/************* 6 buttons version **************************/
|
||||||
static UINT8 megadrive_io_read_data_port_6button(running_machine &machine, int portnum)
|
static UINT8 megadrive_io_read_data_port_6button(running_machine &machine, int portnum)
|
||||||
{
|
{
|
||||||
UINT8 retdata, helper = (megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
|
UINT8 retdata, helper = (m_megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from m_megadrive_io_data_regs
|
||||||
static const char *const pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
|
static const char *const pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
|
||||||
static const char *const pad6names[] = { "EXTRA1", "EXTRA2", "IN0", "UNK" };
|
static const char *const pad6names[] = { "EXTRA1", "EXTRA2", "IN0", "UNK" };
|
||||||
|
|
||||||
if (megadrive_io_data_regs[portnum] & 0x40)
|
if (m_megadrive_io_data_regs[portnum] & 0x40)
|
||||||
{
|
{
|
||||||
if (io_stage[portnum] == 2)
|
if (m_io_stage[portnum] == 2)
|
||||||
{
|
{
|
||||||
/* here we read B, C & the additional buttons */
|
/* here we read B, C & the additional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x30) |
|
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x30) |
|
||||||
(machine.root_device().ioport(pad6names[portnum])->read_safe(0) & 0x0f)) & ~helper);
|
(machine.root_device().ioport(pad6names[portnum])->read_safe(0) & 0x0f)) & ~helper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read B, C & the directional buttons */
|
/* here we read B, C & the directional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x3f) & ~helper);
|
((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x3f) & ~helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (io_stage[portnum] == 1)
|
if (m_io_stage[portnum] == 1)
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | 0x00 */
|
/* here we read ((Start & A) >> 2) | 0x00 */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) & ~helper);
|
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) & ~helper);
|
||||||
}
|
}
|
||||||
else if (io_stage[portnum]==2)
|
else if (m_io_stage[portnum]==2)
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | 0x0f */
|
/* here we read ((Start & A) >> 2) | 0x0f */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) | 0x0f) & ~helper);
|
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) | 0x0f) & ~helper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | Up and Down */
|
/* here we read ((Start & A) >> 2) | Up and Down */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
||||||
(machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x03)) & ~helper);
|
(machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x03)) & ~helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mame_printf_debug("read io data port stage %d port %d %02x\n",io_stage[portnum],portnum,retdata);
|
// mame_printf_debug("read io data port stage %d port %d %02x\n",m_io_stage[portnum],portnum,retdata);
|
||||||
|
|
||||||
return retdata | (retdata << 8);
|
return retdata | (retdata << 8);
|
||||||
}
|
}
|
||||||
@ -293,19 +281,19 @@ static UINT8 megadrive_io_read_data_port_6button(running_machine &machine, int p
|
|||||||
/************* 3 buttons version **************************/
|
/************* 3 buttons version **************************/
|
||||||
UINT8 megadrive_io_read_data_port_3button(running_machine &machine, int portnum)
|
UINT8 megadrive_io_read_data_port_3button(running_machine &machine, int portnum)
|
||||||
{
|
{
|
||||||
UINT8 retdata, helper = (megadrive_io_ctrl_regs[portnum] & 0x7f) | 0x80; // bit 7 always comes from megadrive_io_data_regs
|
UINT8 retdata, helper = (m_megadrive_io_ctrl_regs[portnum] & 0x7f) | 0x80; // bit 7 always comes from m_megadrive_io_data_regs
|
||||||
static const char *const pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
|
static const char *const pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
|
||||||
|
|
||||||
if (megadrive_io_data_regs[portnum] & 0x40)
|
if (m_megadrive_io_data_regs[portnum] & 0x40)
|
||||||
{
|
{
|
||||||
/* here we read B, C & the directional buttons */
|
/* here we read B, C & the directional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x3f) | 0x40) & ~helper);
|
(((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x3f) | 0x40) & ~helper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | Up and Down */
|
/* here we read ((Start & A) >> 2) | Up and Down */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper) |
|
||||||
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
((((machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
||||||
(machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x03) | 0x40) & ~helper);
|
(machine.root_device().ioport(pad3names[portnum])->read_safe(0) & 0x03) | 0x40) & ~helper);
|
||||||
}
|
}
|
||||||
@ -343,7 +331,7 @@ UINT8 megatech_bios_port_cc_dc_r(running_machine &machine, int offset, int ctrl)
|
|||||||
static UINT8 megadrive_io_read_ctrl_port(int portnum)
|
static UINT8 megadrive_io_read_ctrl_port(int portnum)
|
||||||
{
|
{
|
||||||
UINT8 retdata;
|
UINT8 retdata;
|
||||||
retdata = megadrive_io_ctrl_regs[portnum];
|
retdata = m_megadrive_io_ctrl_regs[portnum];
|
||||||
//mame_printf_debug("read io ctrl port %d %02x\n",portnum,retdata);
|
//mame_printf_debug("read io ctrl port %d %02x\n",portnum,retdata);
|
||||||
|
|
||||||
return retdata | (retdata << 8);
|
return retdata | (retdata << 8);
|
||||||
@ -352,7 +340,7 @@ static UINT8 megadrive_io_read_ctrl_port(int portnum)
|
|||||||
static UINT8 megadrive_io_read_tx_port(int portnum)
|
static UINT8 megadrive_io_read_tx_port(int portnum)
|
||||||
{
|
{
|
||||||
UINT8 retdata;
|
UINT8 retdata;
|
||||||
retdata = megadrive_io_tx_regs[portnum];
|
retdata = m_megadrive_io_tx_regs[portnum];
|
||||||
return retdata | (retdata << 8);
|
return retdata | (retdata << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,9 +355,8 @@ static UINT8 megadrive_io_read_sctrl_port(int portnum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
READ16_HANDLER( megadriv_68k_io_read )
|
READ16_MEMBER(md_base_state::megadriv_68k_io_read )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
UINT8 retdata;
|
UINT8 retdata;
|
||||||
|
|
||||||
retdata = 0;
|
retdata = 0;
|
||||||
@ -389,9 +376,9 @@ READ16_HANDLER( megadriv_68k_io_read )
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
logerror("%06x read version register\n", space.device().safe_pc());
|
logerror("%06x read version register\n", space.device().safe_pc());
|
||||||
retdata = state->m_export << 7 | // Export
|
retdata = m_export << 7 | // Export
|
||||||
state->m_pal << 6 | // NTSC or PAL?
|
m_pal << 6 | // NTSC or PAL?
|
||||||
(state->m_segacd ? 0x00 : 0x20) | // 0x20 = no sega cd
|
(m_segacd ? 0x00 : 0x20) | // 0x20 = no sega cd
|
||||||
0x00 | // Unused (Always 0)
|
0x00 | // Unused (Always 0)
|
||||||
0x00 | // Bit 3 of Version Number
|
0x00 | // Bit 3 of Version Number
|
||||||
0x00 | // Bit 2 of Version Number
|
0x00 | // Bit 2 of Version Number
|
||||||
@ -436,7 +423,7 @@ READ16_HANDLER( megadriv_68k_io_read )
|
|||||||
|
|
||||||
static void megadrive_io_write_data_port_3button(running_machine &machine, int portnum, UINT16 data)
|
static void megadrive_io_write_data_port_3button(running_machine &machine, int portnum, UINT16 data)
|
||||||
{
|
{
|
||||||
megadrive_io_data_regs[portnum] = data;
|
m_megadrive_io_data_regs[portnum] = data;
|
||||||
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -446,17 +433,17 @@ static void megadrive_io_write_data_port_3button(running_machine &machine, int p
|
|||||||
|
|
||||||
static void megadrive_io_write_data_port_6button(running_machine &machine, int portnum, UINT16 data)
|
static void megadrive_io_write_data_port_6button(running_machine &machine, int portnum, UINT16 data)
|
||||||
{
|
{
|
||||||
if (megadrive_io_ctrl_regs[portnum]&0x40)
|
if (m_megadrive_io_ctrl_regs[portnum]&0x40)
|
||||||
{
|
{
|
||||||
if (((megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40))
|
if (((m_megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40))
|
||||||
{
|
{
|
||||||
io_stage[portnum]++;
|
m_io_stage[portnum]++;
|
||||||
io_timeout[portnum]->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(8192));
|
m_io_timeout[portnum]->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(8192));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
megadrive_io_data_regs[portnum] = data;
|
m_megadrive_io_data_regs[portnum] = data;
|
||||||
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -466,13 +453,13 @@ static void megadrive_io_write_data_port_6button(running_machine &machine, int p
|
|||||||
|
|
||||||
static void megadrive_io_write_ctrl_port(running_machine &machine, int portnum, UINT16 data)
|
static void megadrive_io_write_ctrl_port(running_machine &machine, int portnum, UINT16 data)
|
||||||
{
|
{
|
||||||
megadrive_io_ctrl_regs[portnum] = data;
|
m_megadrive_io_ctrl_regs[portnum] = data;
|
||||||
// mame_printf_debug("Setting IO Control Register #%d data %04x\n",portnum,data);
|
// mame_printf_debug("Setting IO Control Register #%d data %04x\n",portnum,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void megadrive_io_write_tx_port(running_machine &machine, int portnum, UINT16 data)
|
static void megadrive_io_write_tx_port(running_machine &machine, int portnum, UINT16 data)
|
||||||
{
|
{
|
||||||
megadrive_io_tx_regs[portnum] = data;
|
m_megadrive_io_tx_regs[portnum] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void megadrive_io_write_rx_port(running_machine &machine, int portnum, UINT16 data)
|
static void megadrive_io_write_rx_port(running_machine &machine, int portnum, UINT16 data)
|
||||||
@ -484,7 +471,7 @@ static void megadrive_io_write_sctrl_port(running_machine &machine, int portnum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WRITE16_HANDLER( megadriv_68k_io_write )
|
WRITE16_MEMBER(md_base_state::megadriv_68k_io_write )
|
||||||
{
|
{
|
||||||
// mame_printf_debug("IO Write #%02x data %04x mem_mask %04x\n",offset,data,mem_mask);
|
// mame_printf_debug("IO Write #%02x data %04x mem_mask %04x\n",offset,data,mem_mask);
|
||||||
|
|
||||||
@ -532,16 +519,16 @@ static ADDRESS_MAP_START( megadriv_map, AS_PROGRAM, 16, md_base_state )
|
|||||||
AM_RANGE(0x000000, 0x3fffff) AM_ROM
|
AM_RANGE(0x000000, 0x3fffff) AM_ROM
|
||||||
/* (0x000000 - 0x3fffff) == GAME ROM (4Meg Max, Some games have special banking too) */
|
/* (0x000000 - 0x3fffff) == GAME ROM (4Meg Max, Some games have special banking too) */
|
||||||
|
|
||||||
AM_RANGE(0xa00000, 0xa01fff) AM_READWRITE_LEGACY(megadriv_68k_read_z80_ram,megadriv_68k_write_z80_ram)
|
AM_RANGE(0xa00000, 0xa01fff) AM_READWRITE(megadriv_68k_read_z80_ram,megadriv_68k_write_z80_ram)
|
||||||
AM_RANGE(0xa02000, 0xa03fff) AM_WRITE_LEGACY(megadriv_68k_write_z80_ram)
|
AM_RANGE(0xa02000, 0xa03fff) AM_WRITE(megadriv_68k_write_z80_ram)
|
||||||
AM_RANGE(0xa04000, 0xa04003) AM_READWRITE8(megadriv_68k_YM2612_read,megadriv_68k_YM2612_write, 0xffff)
|
AM_RANGE(0xa04000, 0xa04003) AM_READWRITE8(megadriv_68k_YM2612_read,megadriv_68k_YM2612_write, 0xffff)
|
||||||
|
|
||||||
AM_RANGE(0xa06000, 0xa06001) AM_WRITE_LEGACY(megadriv_68k_z80_bank_write)
|
AM_RANGE(0xa06000, 0xa06001) AM_WRITE(megadriv_68k_z80_bank_write)
|
||||||
|
|
||||||
AM_RANGE(0xa10000, 0xa1001f) AM_READWRITE_LEGACY(megadriv_68k_io_read,megadriv_68k_io_write)
|
AM_RANGE(0xa10000, 0xa1001f) AM_READWRITE(megadriv_68k_io_read,megadriv_68k_io_write)
|
||||||
|
|
||||||
AM_RANGE(0xa11100, 0xa11101) AM_READWRITE_LEGACY(megadriv_68k_check_z80_bus,megadriv_68k_req_z80_bus)
|
AM_RANGE(0xa11100, 0xa11101) AM_READWRITE(megadriv_68k_check_z80_bus,megadriv_68k_req_z80_bus)
|
||||||
AM_RANGE(0xa11200, 0xa11201) AM_WRITE_LEGACY(megadriv_68k_req_z80_reset)
|
AM_RANGE(0xa11200, 0xa11201) AM_WRITE(megadriv_68k_req_z80_reset)
|
||||||
|
|
||||||
/* these are fake - remove allocs in VIDEO_START to use these to view ram instead */
|
/* these are fake - remove allocs in VIDEO_START to use these to view ram instead */
|
||||||
// AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_SHARE("megadrive_vdp_vram")
|
// AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_SHARE("megadrive_vdp_vram")
|
||||||
@ -560,14 +547,13 @@ ADDRESS_MAP_END
|
|||||||
/* z80 sounds/sub CPU */
|
/* z80 sounds/sub CPU */
|
||||||
|
|
||||||
|
|
||||||
static READ16_HANDLER( megadriv_68k_read_z80_ram )
|
READ16_MEMBER(md_base_state::megadriv_68k_read_z80_ram )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
//mame_printf_debug("read z80 ram %04x\n",mem_mask);
|
//mame_printf_debug("read z80 ram %04x\n",mem_mask);
|
||||||
|
|
||||||
if ((state->m_genz80.z80_has_bus == 0) && (state->m_genz80.z80_is_reset == 0))
|
if ((m_genz80.z80_has_bus == 0) && (m_genz80.z80_is_reset == 0))
|
||||||
{
|
{
|
||||||
return state->m_genz80.z80_prgram[(offset<<1)^1] | (state->m_genz80.z80_prgram[(offset<<1)]<<8);
|
return m_genz80.z80_prgram[(offset<<1)^1] | (m_genz80.z80_prgram[(offset<<1)]<<8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -576,24 +562,23 @@ static READ16_HANDLER( megadriv_68k_read_z80_ram )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE16_HANDLER( megadriv_68k_write_z80_ram )
|
WRITE16_MEMBER(md_base_state::megadriv_68k_write_z80_ram )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
//logerror("write z80 ram\n");
|
//logerror("write z80 ram\n");
|
||||||
|
|
||||||
if ((state->m_genz80.z80_has_bus == 0) && (state->m_genz80.z80_is_reset == 0))
|
if ((m_genz80.z80_has_bus == 0) && (m_genz80.z80_is_reset == 0))
|
||||||
{
|
{
|
||||||
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
||||||
{
|
{
|
||||||
state->m_genz80.z80_prgram[(offset<<1)] = (data & 0xff00) >> 8;
|
m_genz80.z80_prgram[(offset<<1)] = (data & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
else if (!ACCESSING_BITS_8_15)
|
else if (!ACCESSING_BITS_8_15)
|
||||||
{
|
{
|
||||||
state->m_genz80.z80_prgram[(offset<<1)^1] = (data & 0x00ff);
|
m_genz80.z80_prgram[(offset<<1)^1] = (data & 0x00ff);
|
||||||
}
|
}
|
||||||
else // for WORD access only the MSB is used, LSB is ignored
|
else // for WORD access only the MSB is used, LSB is ignored
|
||||||
{
|
{
|
||||||
state->m_genz80.z80_prgram[(offset<<1)] = (data & 0xff00) >> 8;
|
m_genz80.z80_prgram[(offset<<1)] = (data & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -603,9 +588,8 @@ static WRITE16_HANDLER( megadriv_68k_write_z80_ram )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static READ16_HANDLER( megadriv_68k_check_z80_bus )
|
READ16_MEMBER(md_base_state::megadriv_68k_check_z80_bus )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
UINT16 retvalue;
|
UINT16 retvalue;
|
||||||
|
|
||||||
/* Double Dragon, Shadow of the Beast, Super Off Road, and Time Killers have buggy
|
/* Double Dragon, Shadow of the Beast, Super Off Road, and Time Killers have buggy
|
||||||
@ -621,7 +605,7 @@ static READ16_HANDLER( megadriv_68k_check_z80_bus )
|
|||||||
/* Check if the 68k has the z80 bus */
|
/* Check if the 68k has the z80 bus */
|
||||||
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
if (!ACCESSING_BITS_0_7) // byte (MSB) access
|
||||||
{
|
{
|
||||||
if (state->m_genz80.z80_has_bus || state->m_genz80.z80_is_reset) retvalue = nextvalue | 0x0100;
|
if (m_genz80.z80_has_bus || m_genz80.z80_is_reset) retvalue = nextvalue | 0x0100;
|
||||||
else retvalue = (nextvalue & 0xfeff);
|
else retvalue = (nextvalue & 0xfeff);
|
||||||
|
|
||||||
//logerror("%06x: 68000 check z80 Bus (byte MSB access) returning %04x mask %04x\n", space.device().safe_pc(),retvalue, mem_mask);
|
//logerror("%06x: 68000 check z80 Bus (byte MSB access) returning %04x mask %04x\n", space.device().safe_pc(),retvalue, mem_mask);
|
||||||
@ -631,7 +615,7 @@ static READ16_HANDLER( megadriv_68k_check_z80_bus )
|
|||||||
else if (!ACCESSING_BITS_8_15) // is this valid?
|
else if (!ACCESSING_BITS_8_15) // is this valid?
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 check z80 Bus (byte LSB access) %04x\n", space.device().safe_pc(),mem_mask);
|
//logerror("%06x: 68000 check z80 Bus (byte LSB access) %04x\n", space.device().safe_pc(),mem_mask);
|
||||||
if (state->m_genz80.z80_has_bus || state->m_genz80.z80_is_reset) retvalue = 0x0001;
|
if (m_genz80.z80_has_bus || m_genz80.z80_is_reset) retvalue = 0x0001;
|
||||||
else retvalue = 0x0000;
|
else retvalue = 0x0000;
|
||||||
|
|
||||||
return retvalue;
|
return retvalue;
|
||||||
@ -639,7 +623,7 @@ static READ16_HANDLER( megadriv_68k_check_z80_bus )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 check z80 Bus (word access) %04x\n", space.device().safe_pc(),mem_mask);
|
//logerror("%06x: 68000 check z80 Bus (word access) %04x\n", space.device().safe_pc(),mem_mask);
|
||||||
if (state->m_genz80.z80_has_bus || state->m_genz80.z80_is_reset) retvalue = nextvalue | 0x0100;
|
if (m_genz80.z80_has_bus || m_genz80.z80_is_reset) retvalue = nextvalue | 0x0100;
|
||||||
else retvalue = (nextvalue & 0xfeff);
|
else retvalue = (nextvalue & 0xfeff);
|
||||||
|
|
||||||
// mame_printf_debug("%06x: 68000 check z80 Bus (word access) %04x %04x\n", space.device().safe_pc(),mem_mask, retvalue);
|
// mame_printf_debug("%06x: 68000 check z80 Bus (word access) %04x %04x\n", space.device().safe_pc(),mem_mask, retvalue);
|
||||||
@ -648,42 +632,40 @@ static READ16_HANDLER( megadriv_68k_check_z80_bus )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TIMER_CALLBACK( megadriv_z80_run_state )
|
TIMER_CALLBACK_MEMBER(md_base_state::megadriv_z80_run_state)
|
||||||
{
|
{
|
||||||
md_base_state *state = machine.driver_data<md_base_state>();
|
|
||||||
/* Is the z80 RESET line pulled? */
|
/* Is the z80 RESET line pulled? */
|
||||||
if (state->m_genz80.z80_is_reset)
|
if (m_genz80.z80_is_reset)
|
||||||
{
|
{
|
||||||
state->m_z80snd->reset();
|
m_z80snd->reset();
|
||||||
state->m_z80snd->suspend(SUSPEND_REASON_HALT, 1);
|
m_z80snd->suspend(SUSPEND_REASON_HALT, 1);
|
||||||
machine.device("ymsnd")->reset();
|
machine().device("ymsnd")->reset();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Check if z80 has the bus */
|
/* Check if z80 has the bus */
|
||||||
if (state->m_genz80.z80_has_bus)
|
if (m_genz80.z80_has_bus)
|
||||||
state->m_z80snd->resume(SUSPEND_REASON_HALT);
|
m_z80snd->resume(SUSPEND_REASON_HALT);
|
||||||
else
|
else
|
||||||
state->m_z80snd->suspend(SUSPEND_REASON_HALT, 1);
|
m_z80snd->suspend(SUSPEND_REASON_HALT, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static WRITE16_HANDLER( megadriv_68k_req_z80_bus )
|
WRITE16_MEMBER(md_base_state::megadriv_68k_req_z80_bus )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
/* Request the Z80 bus, allows 68k to read/write Z80 address space */
|
/* Request the Z80 bus, allows 68k to read/write Z80 address space */
|
||||||
if (!ACCESSING_BITS_0_7) // byte access
|
if (!ACCESSING_BITS_0_7) // byte access
|
||||||
{
|
{
|
||||||
if (data & 0x0100)
|
if (data & 0x0100)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 request z80 Bus (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 request z80 Bus (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 0;
|
m_genz80.z80_has_bus = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 return z80 Bus (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 return z80 Bus (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 1;
|
m_genz80.z80_has_bus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!ACCESSING_BITS_8_15) // is this valid?
|
else if (!ACCESSING_BITS_8_15) // is this valid?
|
||||||
@ -691,12 +673,12 @@ static WRITE16_HANDLER( megadriv_68k_req_z80_bus )
|
|||||||
if (data & 0x0001)
|
if (data & 0x0001)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 request z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 request z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 0;
|
m_genz80.z80_has_bus = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 1;
|
m_genz80.z80_has_bus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // word access
|
else // word access
|
||||||
@ -704,34 +686,33 @@ static WRITE16_HANDLER( megadriv_68k_req_z80_bus )
|
|||||||
if (data & 0x0100)
|
if (data & 0x0100)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 request z80 Bus (word access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 request z80 Bus (word access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 0;
|
m_genz80.z80_has_bus = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 return z80 Bus (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_has_bus = 1;
|
m_genz80.z80_has_bus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the z80 is running, sync the z80 execution state */
|
/* If the z80 is running, sync the z80 execution state */
|
||||||
if (!state->m_genz80.z80_is_reset)
|
if (!m_genz80.z80_is_reset)
|
||||||
space.machine().scheduler().timer_set(attotime::zero, FUNC(megadriv_z80_run_state));
|
machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(md_base_state::megadriv_z80_run_state),this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE16_HANDLER ( megadriv_68k_req_z80_reset )
|
WRITE16_MEMBER(md_base_state::megadriv_68k_req_z80_reset )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
|
||||||
if (!ACCESSING_BITS_0_7) // byte access
|
if (!ACCESSING_BITS_0_7) // byte access
|
||||||
{
|
{
|
||||||
if (data & 0x0100)
|
if (data & 0x0100)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 clear z80 reset (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 clear z80 reset (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 0;
|
m_genz80.z80_is_reset = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 start z80 reset (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 start z80 reset (byte MSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 1;
|
m_genz80.z80_is_reset = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!ACCESSING_BITS_8_15) // is this valid?
|
else if (!ACCESSING_BITS_8_15) // is this valid?
|
||||||
@ -739,12 +720,12 @@ static WRITE16_HANDLER ( megadriv_68k_req_z80_reset )
|
|||||||
if (data & 0x0001)
|
if (data & 0x0001)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 clear z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 clear z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 0;
|
m_genz80.z80_is_reset = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 1;
|
m_genz80.z80_is_reset = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // word access
|
else // word access
|
||||||
@ -752,15 +733,15 @@ static WRITE16_HANDLER ( megadriv_68k_req_z80_reset )
|
|||||||
if (data & 0x0100)
|
if (data & 0x0100)
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 clear z80 reset (word access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 clear z80 reset (word access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 0;
|
m_genz80.z80_is_reset = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
//logerror("%06x: 68000 start z80 reset (byte LSB access) %04x %04x\n", space.device().safe_pc(),data,mem_mask);
|
||||||
state->m_genz80.z80_is_reset = 1;
|
m_genz80.z80_is_reset = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
space.machine().scheduler().timer_set( attotime::zero, FUNC(megadriv_z80_run_state ));
|
machine().scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(md_base_state::megadriv_z80_run_state),this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -768,23 +749,21 @@ static WRITE16_HANDLER ( megadriv_68k_req_z80_reset )
|
|||||||
// add-on hardware which changes the cpu mapping like the 32x and SegaCD.
|
// add-on hardware which changes the cpu mapping like the 32x and SegaCD.
|
||||||
// - we might need to add exceptions for example, z80 reading / writing the
|
// - we might need to add exceptions for example, z80 reading / writing the
|
||||||
// z80 area of the 68k if games misbehave
|
// z80 area of the 68k if games misbehave
|
||||||
static READ8_HANDLER( z80_read_68k_banked_data )
|
READ8_MEMBER(md_base_state::z80_read_68k_banked_data )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
address_space &space68k = m_maincpu->space();
|
||||||
address_space &space68k = state->m_maincpu->space();
|
UINT8 ret = space68k.read_byte(m_genz80.z80_bank_addr+offset);
|
||||||
UINT8 ret = space68k.read_byte(state->m_genz80.z80_bank_addr+offset);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( z80_write_68k_banked_data )
|
WRITE8_MEMBER(md_base_state::z80_write_68k_banked_data )
|
||||||
{
|
{
|
||||||
md_base_state *state = space.machine().driver_data<md_base_state>();
|
address_space &space68k = m_maincpu->space();
|
||||||
address_space &space68k = state->m_maincpu->space();
|
space68k.write_byte(m_genz80.z80_bank_addr+offset,data);
|
||||||
space68k.write_byte(state->m_genz80.z80_bank_addr+offset,data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static WRITE8_HANDLER( megadriv_z80_vdp_write )
|
WRITE8_MEMBER(md_base_state::megadriv_z80_vdp_write )
|
||||||
{
|
{
|
||||||
switch (offset)
|
switch (offset)
|
||||||
{
|
{
|
||||||
@ -804,32 +783,32 @@ static WRITE8_HANDLER( megadriv_z80_vdp_write )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static READ8_HANDLER( megadriv_z80_vdp_read )
|
READ8_MEMBER(md_base_state::megadriv_z80_vdp_read )
|
||||||
{
|
{
|
||||||
mame_printf_debug("megadriv_z80_vdp_read %02x\n",offset);
|
mame_printf_debug("megadriv_z80_vdp_read %02x\n",offset);
|
||||||
return space.machine().rand();
|
return space.machine().rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( megadriv_z80_unmapped_read )
|
READ8_MEMBER(md_base_state::megadriv_z80_unmapped_read )
|
||||||
{
|
{
|
||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ADDRESS_MAP_START( megadriv_z80_map, AS_PROGRAM, 8, driver_device )
|
static ADDRESS_MAP_START( megadriv_z80_map, AS_PROGRAM, 8, md_base_state )
|
||||||
AM_RANGE(0x0000, 0x1fff) AM_RAMBANK("bank1") AM_MIRROR(0x2000) // RAM can be accessed by the 68k
|
AM_RANGE(0x0000, 0x1fff) AM_RAMBANK("bank1") AM_MIRROR(0x2000) // RAM can be accessed by the 68k
|
||||||
AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE_LEGACY("ymsnd", ym2612_r,ym2612_w)
|
AM_RANGE(0x4000, 0x4003) AM_DEVREADWRITE_LEGACY("ymsnd", ym2612_r,ym2612_w)
|
||||||
|
|
||||||
AM_RANGE(0x6000, 0x6000) AM_WRITE_LEGACY(megadriv_z80_z80_bank_w)
|
AM_RANGE(0x6000, 0x6000) AM_WRITE(megadriv_z80_z80_bank_w)
|
||||||
AM_RANGE(0x6001, 0x6001) AM_WRITE_LEGACY(megadriv_z80_z80_bank_w) // wacky races uses this address
|
AM_RANGE(0x6001, 0x6001) AM_WRITE(megadriv_z80_z80_bank_w) // wacky races uses this address
|
||||||
|
|
||||||
AM_RANGE(0x6100, 0x7eff) AM_READ_LEGACY(megadriv_z80_unmapped_read)
|
AM_RANGE(0x6100, 0x7eff) AM_READ(megadriv_z80_unmapped_read)
|
||||||
|
|
||||||
AM_RANGE(0x7f00, 0x7fff) AM_READWRITE_LEGACY(megadriv_z80_vdp_read,megadriv_z80_vdp_write)
|
AM_RANGE(0x7f00, 0x7fff) AM_READWRITE(megadriv_z80_vdp_read,megadriv_z80_vdp_write)
|
||||||
|
|
||||||
AM_RANGE(0x8000, 0xffff) AM_READWRITE_LEGACY(z80_read_68k_banked_data,z80_write_68k_banked_data) // The Z80 can read the 68k address space this way
|
AM_RANGE(0x8000, 0xffff) AM_READWRITE(z80_read_68k_banked_data,z80_write_68k_banked_data) // The Z80 can read the 68k address space this way
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
static ADDRESS_MAP_START( megadriv_z80_io_map, AS_IO, 8, driver_device )
|
static ADDRESS_MAP_START( megadriv_z80_io_map, AS_IO, 8, md_base_state )
|
||||||
ADDRESS_MAP_GLOBAL_MASK(0xff)
|
ADDRESS_MAP_GLOBAL_MASK(0xff)
|
||||||
AM_RANGE(0x0000, 0xff) AM_NOP
|
AM_RANGE(0x0000, 0xff) AM_NOP
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
@ -842,14 +821,14 @@ static ADDRESS_MAP_START( md_bootleg_map, AS_PROGRAM, 16, md_boot_state )
|
|||||||
AM_RANGE(0x000000, 0x0fffff) AM_ROM /* Cartridge Program Rom */
|
AM_RANGE(0x000000, 0x0fffff) AM_ROM /* Cartridge Program Rom */
|
||||||
AM_RANGE(0x200000, 0x2023ff) AM_RAM // tested
|
AM_RANGE(0x200000, 0x2023ff) AM_RAM // tested
|
||||||
|
|
||||||
AM_RANGE(0xa00000, 0xa01fff) AM_READWRITE_LEGACY(megadriv_68k_read_z80_ram, megadriv_68k_write_z80_ram)
|
AM_RANGE(0xa00000, 0xa01fff) AM_READWRITE(megadriv_68k_read_z80_ram, megadriv_68k_write_z80_ram)
|
||||||
AM_RANGE(0xa02000, 0xa03fff) AM_WRITE_LEGACY(megadriv_68k_write_z80_ram)
|
AM_RANGE(0xa02000, 0xa03fff) AM_WRITE(megadriv_68k_write_z80_ram)
|
||||||
AM_RANGE(0xa04000, 0xa04003) AM_READWRITE8(megadriv_68k_YM2612_read, megadriv_68k_YM2612_write, 0xffff)
|
AM_RANGE(0xa04000, 0xa04003) AM_READWRITE8(megadriv_68k_YM2612_read, megadriv_68k_YM2612_write, 0xffff)
|
||||||
AM_RANGE(0xa06000, 0xa06001) AM_WRITE_LEGACY(megadriv_68k_z80_bank_write)
|
AM_RANGE(0xa06000, 0xa06001) AM_WRITE(megadriv_68k_z80_bank_write)
|
||||||
|
|
||||||
AM_RANGE(0xa10000, 0xa1001f) AM_READWRITE_LEGACY(megadriv_68k_io_read, megadriv_68k_io_write)
|
AM_RANGE(0xa10000, 0xa1001f) AM_READWRITE(megadriv_68k_io_read, megadriv_68k_io_write)
|
||||||
AM_RANGE(0xa11100, 0xa11101) AM_READWRITE_LEGACY(megadriv_68k_check_z80_bus, megadriv_68k_req_z80_bus)
|
AM_RANGE(0xa11100, 0xa11101) AM_READWRITE(megadriv_68k_check_z80_bus, megadriv_68k_req_z80_bus)
|
||||||
AM_RANGE(0xa11200, 0xa11201) AM_WRITE_LEGACY(megadriv_68k_req_z80_reset)
|
AM_RANGE(0xa11200, 0xa11201) AM_WRITE(megadriv_68k_req_z80_reset)
|
||||||
|
|
||||||
AM_RANGE(0xc00000, 0xc0001f) AM_DEVREADWRITE("gen_vdp", sega_genesis_vdp_device, megadriv_vdp_r,megadriv_vdp_w)
|
AM_RANGE(0xc00000, 0xc0001f) AM_DEVREADWRITE("gen_vdp", sega_genesis_vdp_device, megadriv_vdp_r,megadriv_vdp_w)
|
||||||
AM_RANGE(0xd00000, 0xd0001f) AM_DEVREADWRITE("gen_vdp", sega_genesis_vdp_device, megadriv_vdp_r,megadriv_vdp_w)
|
AM_RANGE(0xd00000, 0xd0001f) AM_DEVREADWRITE("gen_vdp", sega_genesis_vdp_device, megadriv_vdp_r,megadriv_vdp_w)
|
||||||
@ -902,7 +881,7 @@ SCREEN_UPDATE_RGB32(megadriv)
|
|||||||
|
|
||||||
MACHINE_START( megadriv )
|
MACHINE_START( megadriv )
|
||||||
{
|
{
|
||||||
if (megadrive_6buttons_pad)
|
if (m_megadrive_6buttons_pad)
|
||||||
init_megadri6_io(machine);
|
init_megadri6_io(machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,7 +898,7 @@ MACHINE_RESET( megadriv )
|
|||||||
state->m_genz80.z80_has_bus = 1;
|
state->m_genz80.z80_has_bus = 1;
|
||||||
state->m_genz80.z80_bank_addr = 0;
|
state->m_genz80.z80_bank_addr = 0;
|
||||||
state->m_vdp->set_scanline_counter(-1);
|
state->m_vdp->set_scanline_counter(-1);
|
||||||
machine.scheduler().timer_set(attotime::zero, FUNC(megadriv_z80_run_state));
|
machine.scheduler().timer_set(attotime::zero, timer_expired_delegate(FUNC(md_base_state::megadriv_z80_run_state),state));
|
||||||
}
|
}
|
||||||
|
|
||||||
megadrive_reset_io(machine);
|
megadrive_reset_io(machine);
|
||||||
@ -1193,7 +1172,7 @@ void md_base_state::megadriv_init_common()
|
|||||||
m68k_set_tas_callback(machine().device("maincpu"), megadriv_tas_callback);
|
m68k_set_tas_callback(machine().device("maincpu"), megadriv_tas_callback);
|
||||||
|
|
||||||
// the drivers which need 6 buttons pad set this to 1 in their init befare calling the megadrive init
|
// the drivers which need 6 buttons pad set this to 1 in their init befare calling the megadrive init
|
||||||
if (megadrive_6buttons_pad)
|
if (m_megadrive_6buttons_pad)
|
||||||
{
|
{
|
||||||
megadrive_io_read_data_port_ptr = megadrive_io_read_data_port_6button;
|
megadrive_io_read_data_port_ptr = megadrive_io_read_data_port_6button;
|
||||||
megadrive_io_write_data_port_ptr = megadrive_io_write_data_port_6button;
|
megadrive_io_write_data_port_ptr = megadrive_io_write_data_port_6button;
|
||||||
@ -1320,54 +1299,53 @@ DRIVER_INIT_MEMBER(md_base_state,mpnew)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* used by megatech */
|
/* used by megatech */
|
||||||
static READ8_HANDLER( z80_unmapped_port_r )
|
READ8_MEMBER(md_base_state::z80_unmapped_port_r )
|
||||||
{
|
{
|
||||||
// printf("unmapped z80 port read %04x\n",offset);
|
// printf("unmapped z80 port read %04x\n",offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( z80_unmapped_port_w )
|
WRITE8_MEMBER(md_base_state::z80_unmapped_port_w )
|
||||||
{
|
{
|
||||||
// printf("unmapped z80 port write %04x\n",offset);
|
// printf("unmapped z80 port write %04x\n",offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static READ8_HANDLER( z80_unmapped_r )
|
READ8_MEMBER(md_base_state::z80_unmapped_r )
|
||||||
{
|
{
|
||||||
printf("unmapped z80 read %04x\n",offset);
|
printf("unmapped z80 read %04x\n",offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WRITE8_HANDLER( z80_unmapped_w )
|
WRITE8_MEMBER(md_base_state::z80_unmapped_w )
|
||||||
{
|
{
|
||||||
printf("unmapped z80 write %04x\n",offset);
|
printf("unmapped z80 write %04x\n",offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* sets the megadrive z80 to it's normal ports / map */
|
/* sets the megadrive z80 to it's normal ports / map */
|
||||||
void megatech_set_megadrive_z80_as_megadrive_z80(running_machine &machine, const char* tag)
|
void mtech_state::megatech_set_megadrive_z80_as_megadrive_z80(const char* tag)
|
||||||
{
|
{
|
||||||
md_base_state *state = machine.driver_data<md_base_state>();
|
device_t *ym = machine().device("ymsnd");
|
||||||
device_t *ym = machine.device("ymsnd");
|
|
||||||
|
|
||||||
/* INIT THE PORTS *********************************************************************************************/
|
/* INIT THE PORTS *********************************************************************************************/
|
||||||
machine.device(tag)->memory().space(AS_IO).install_legacy_readwrite_handler(0x0000, 0xffff, FUNC(z80_unmapped_port_r), FUNC(z80_unmapped_port_w));
|
machine().device(tag)->memory().space(AS_IO).install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_port_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_port_w),this));
|
||||||
|
|
||||||
/* catch any addresses that don't get mapped */
|
/* catch any addresses that don't get mapped */
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x0000, 0xffff, FUNC(z80_unmapped_r), FUNC(z80_unmapped_w));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_w),this));
|
||||||
|
|
||||||
|
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_readwrite_bank(0x0000, 0x1fff, "bank1");
|
machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_bank(0x0000, 0x1fff, "bank1");
|
||||||
machine.root_device().membank("bank1")->set_base(state->m_genz80.z80_prgram);
|
machine().root_device().membank("bank1")->set_base(m_genz80.z80_prgram);
|
||||||
|
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_ram(0x0000, 0x1fff, state->m_genz80.z80_prgram);
|
machine().device(tag)->memory().space(AS_PROGRAM).install_ram(0x0000, 0x1fff, m_genz80.z80_prgram);
|
||||||
|
|
||||||
|
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(*ym, 0x4000, 0x4003, FUNC(ym2612_r), FUNC(ym2612_w));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(*ym, 0x4000, 0x4003, FUNC(ym2612_r), FUNC(ym2612_w));
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_write_handler (0x6000, 0x6000, FUNC(megadriv_z80_z80_bank_w));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_write_handler (0x6000, 0x6000, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this));
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_write_handler (0x6001, 0x6001, FUNC(megadriv_z80_z80_bank_w));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_write_handler (0x6001, 0x6001, write8_delegate(FUNC(mtech_state::megadriv_z80_z80_bank_w),this));
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_read_handler (0x6100, 0x7eff, FUNC(megadriv_z80_unmapped_read));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_read_handler (0x6100, 0x7eff, read8_delegate(FUNC(mtech_state::megadriv_z80_unmapped_read),this));
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x7f00, 0x7fff, FUNC(megadriv_z80_vdp_read), FUNC(megadriv_z80_vdp_write));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x7f00, 0x7fff, read8_delegate(FUNC(mtech_state::megadriv_z80_vdp_read),this), write8_delegate(FUNC(mtech_state::megadriv_z80_vdp_write),this));
|
||||||
machine.device(tag)->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x8000, 0xffff, FUNC(z80_read_68k_banked_data), FUNC(z80_write_68k_banked_data));
|
machine().device(tag)->memory().space(AS_PROGRAM).install_readwrite_handler(0x8000, 0xffff, read8_delegate(FUNC(mtech_state::z80_read_68k_banked_data),this), write8_delegate(FUNC(mtech_state::z80_write_68k_banked_data),this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "sound/sn76496.h"
|
#include "sound/sn76496.h"
|
||||||
|
|
||||||
extern timer_device* megadriv_scanline_timer;
|
timer_device* megadriv_scanline_timer;
|
||||||
|
|
||||||
|
|
||||||
#define MAX_HPOSITION 480
|
#define MAX_HPOSITION 480
|
||||||
|
@ -85,8 +85,8 @@ static UINT8 mess_md_io_read_data_port(running_machine &machine, int portnum)
|
|||||||
|
|
||||||
UINT8 retdata;
|
UINT8 retdata;
|
||||||
int controller;
|
int controller;
|
||||||
UINT8 helper_6b = (megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
|
UINT8 helper_6b = (m_megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
|
||||||
UINT8 helper_3b = (megadrive_io_ctrl_regs[portnum] & 0x7f) | 0x80; // bit 7 always comes from megadrive_io_data_regs
|
UINT8 helper_3b = (m_megadrive_io_ctrl_regs[portnum] & 0x7f) | 0x80; // bit 7 always comes from megadrive_io_data_regs
|
||||||
|
|
||||||
switch (portnum)
|
switch (portnum)
|
||||||
{
|
{
|
||||||
@ -106,19 +106,19 @@ static UINT8 mess_md_io_read_data_port(running_machine &machine, int portnum)
|
|||||||
/* Are we using a 6 buttons Joypad? */
|
/* Are we using a 6 buttons Joypad? */
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
if (megadrive_io_data_regs[portnum] & 0x40)
|
if (m_megadrive_io_data_regs[portnum] & 0x40)
|
||||||
{
|
{
|
||||||
if (state->m_mess_io_stage[portnum] == 2)
|
if (state->m_mess_io_stage[portnum] == 2)
|
||||||
{
|
{
|
||||||
/* here we read B, C & the additional buttons */
|
/* here we read B, C & the additional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_6b) |
|
||||||
(((state->ioport(pad6names[0][portnum])->read_safe(0) & 0x30) |
|
(((state->ioport(pad6names[0][portnum])->read_safe(0) & 0x30) |
|
||||||
(state->ioport(pad6names[1][portnum])->read_safe(0) & 0x0f)) & ~helper_6b);
|
(state->ioport(pad6names[1][portnum])->read_safe(0) & 0x0f)) & ~helper_6b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read B, C & the directional buttons */
|
/* here we read B, C & the directional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_6b) |
|
||||||
((state->ioport(pad6names[0][portnum])->read_safe(0) & 0x3f) & ~helper_6b);
|
((state->ioport(pad6names[0][portnum])->read_safe(0) & 0x3f) & ~helper_6b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,19 +127,19 @@ static UINT8 mess_md_io_read_data_port(running_machine &machine, int portnum)
|
|||||||
if (state->m_mess_io_stage[portnum] == 1)
|
if (state->m_mess_io_stage[portnum] == 1)
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | 0x00 */
|
/* here we read ((Start & A) >> 2) | 0x00 */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_6b) |
|
||||||
(((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) & ~helper_6b);
|
(((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) & ~helper_6b);
|
||||||
}
|
}
|
||||||
else if (state->m_mess_io_stage[portnum]==2)
|
else if (state->m_mess_io_stage[portnum]==2)
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | 0x0f */
|
/* here we read ((Start & A) >> 2) | 0x0f */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_6b) |
|
||||||
((((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) | 0x0f) & ~helper_6b);
|
((((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) | 0x0f) & ~helper_6b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | Up and Down */
|
/* here we read ((Start & A) >> 2) | Up and Down */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_6b) |
|
||||||
((((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) |
|
((((state->ioport(pad6names[0][portnum])->read_safe(0) & 0xc0) >> 2) |
|
||||||
(state->ioport(pad6names[0][portnum])->read_safe(0) & 0x03)) & ~helper_6b);
|
(state->ioport(pad6names[0][portnum])->read_safe(0) & 0x03)) & ~helper_6b);
|
||||||
}
|
}
|
||||||
@ -159,18 +159,18 @@ static UINT8 mess_md_io_read_data_port(running_machine &machine, int portnum)
|
|||||||
// handle test input for SVP test
|
// handle test input for SVP test
|
||||||
if (portnum == 0 && svp_test)
|
if (portnum == 0 && svp_test)
|
||||||
{
|
{
|
||||||
retdata = (megadrive_io_data_regs[0] & 0xc0);
|
retdata = (m_megadrive_io_data_regs[0] & 0xc0);
|
||||||
}
|
}
|
||||||
else if (megadrive_io_data_regs[portnum] & 0x40)
|
else if (m_megadrive_io_data_regs[portnum] & 0x40)
|
||||||
{
|
{
|
||||||
/* here we read B, C & the directional buttons */
|
/* here we read B, C & the directional buttons */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_3b) |
|
||||||
(((state->ioport(pad3names[portnum])->read_safe(0) & 0x3f) | 0x40) & ~helper_3b);
|
(((state->ioport(pad3names[portnum])->read_safe(0) & 0x3f) | 0x40) & ~helper_3b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* here we read ((Start & A) >> 2) | Up and Down */
|
/* here we read ((Start & A) >> 2) | Up and Down */
|
||||||
retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
|
retdata = (m_megadrive_io_data_regs[portnum] & helper_3b) |
|
||||||
((((state->ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
((((state->ioport(pad3names[portnum])->read_safe(0) & 0xc0) >> 2) |
|
||||||
(state->ioport(pad3names[portnum])->read_safe(0) & 0x03) | 0x40) & ~helper_3b);
|
(state->ioport(pad3names[portnum])->read_safe(0) & 0x03) | 0x40) & ~helper_3b);
|
||||||
}
|
}
|
||||||
@ -202,9 +202,9 @@ static void mess_md_io_write_data_port(running_machine &machine, int portnum, UI
|
|||||||
|
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
if (megadrive_io_ctrl_regs[portnum] & 0x40)
|
if (m_megadrive_io_ctrl_regs[portnum] & 0x40)
|
||||||
{
|
{
|
||||||
if (((megadrive_io_data_regs[portnum] & 0x40) == 0x00) && ((data & 0x40) == 0x40))
|
if (((m_megadrive_io_data_regs[portnum] & 0x40) == 0x00) && ((data & 0x40) == 0x40))
|
||||||
{
|
{
|
||||||
state->m_mess_io_stage[portnum]++;
|
state->m_mess_io_stage[portnum]++;
|
||||||
state->m_mess_io_timeout[portnum]->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(8192));
|
state->m_mess_io_timeout[portnum]->adjust(machine.device<cpu_device>("maincpu")->cycles_to_attotime(8192));
|
||||||
@ -212,7 +212,7 @@ static void mess_md_io_write_data_port(running_machine &machine, int portnum, UI
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
megadrive_io_data_regs[portnum] = data;
|
m_megadrive_io_data_regs[portnum] = data;
|
||||||
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
//mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user