summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/megaplay.c71
-rw-r--r--src/mame/drivers/megatech.c126
-rw-r--r--src/mame/includes/megadriv.h165
-rw-r--r--src/mame/machine/megadriv.c60
4 files changed, 175 insertions, 247 deletions
diff --git a/src/mame/drivers/megaplay.c b/src/mame/drivers/megaplay.c
index cda917d4088..42c71aecc8b 100644
--- a/src/mame/drivers/megaplay.c
+++ b/src/mame/drivers/megaplay.c
@@ -324,12 +324,12 @@ INPUT_PORTS_END
/*MEGAPLAY specific*/
-READ8_MEMBER(mplay_state::megaplay_bios_banksel_r)
+READ8_MEMBER(mplay_state::bios_banksel_r)
{
return m_bios_bank;
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_banksel_w)
+WRITE8_MEMBER(mplay_state::bios_banksel_w)
{
/* Multi-slot note:
Bits 0 and 1 appear to determine the selected game slot.
@@ -341,12 +341,12 @@ WRITE8_MEMBER(mplay_state::megaplay_bios_banksel_w)
// logerror("BIOS: ROM bank %i selected [0x%02x]\n",bios_bank >> 6, data);
}
-READ8_MEMBER(mplay_state::megaplay_bios_gamesel_r)
+READ8_MEMBER(mplay_state::bios_gamesel_r)
{
return m_bios_6403;
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_gamesel_w)
+WRITE8_MEMBER(mplay_state::bios_gamesel_w)
{
m_bios_6403 = data;
@@ -354,7 +354,7 @@ WRITE8_MEMBER(mplay_state::megaplay_bios_gamesel_w)
m_bios_mode = data & 0x10;
}
-WRITE16_MEMBER(mplay_state::megaplay_io_write)
+WRITE16_MEMBER(mplay_state::mp_io_write)
{
if (offset == 0x03)
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]);
@@ -362,7 +362,7 @@ WRITE16_MEMBER(mplay_state::megaplay_io_write)
megadriv_68k_io_write(space, offset & 0x1f, data, 0xffff);
}
-READ16_MEMBER(mplay_state::megaplay_io_read)
+READ16_MEMBER(mplay_state::mp_io_read)
{
if (offset == 0x03)
return m_megadrive_io_data_regs[2];
@@ -373,7 +373,7 @@ READ16_MEMBER(mplay_state::megaplay_io_read)
READ8_MEMBER(mplay_state::bank_r)
{
UINT8* bank = memregion("mtbios")->base();
- UINT32 fulladdress = m_mp_bios_bank_addr + offset;
+ UINT32 fulladdress = m_bios_bank_addr + offset;
if (fulladdress <= 0x3fffff) // ROM Addresses
{
@@ -400,7 +400,7 @@ READ8_MEMBER(mplay_state::bank_r)
}
else if (fulladdress >= 0xa10000 && fulladdress <= 0xa1001f) // IO Acess
{
- return megaplay_io_read(space, (offset & 0x1f) / 2, 0xffff);
+ return mp_io_read(space, (offset & 0x1f) / 2, 0xffff);
}
else
{
@@ -412,7 +412,7 @@ READ8_MEMBER(mplay_state::bank_r)
WRITE8_MEMBER(mplay_state::bank_w)
{
- UINT32 fulladdress = m_mp_bios_bank_addr + offset;
+ UINT32 fulladdress = m_bios_bank_addr + offset;
if (fulladdress <= 0x3fffff) // ROM / Megaplay Custom Addresses
{
@@ -429,7 +429,7 @@ WRITE8_MEMBER(mplay_state::bank_w)
}
else if (fulladdress >= 0xa10000 && fulladdress <=0xa1001f) // IO Access
{
- megaplay_io_write(space, (offset & 0x1f) / 2, data, 0xffff);
+ mp_io_write(space, (offset & 0x1f) / 2, data, 0xffff);
}
else
{
@@ -441,38 +441,38 @@ WRITE8_MEMBER(mplay_state::bank_w)
/* 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 */
-READ8_MEMBER(mplay_state::megaplay_bios_6402_r)
+READ8_MEMBER(mplay_state::bios_6402_r)
{
return m_megadrive_io_data_regs[2];// & 0xfe;
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_6402_w)
+WRITE8_MEMBER(mplay_state::bios_6402_w)
{
m_megadrive_io_data_regs[2] = (m_megadrive_io_data_regs[2] & 0x07) | ((data & 0x70) >> 1);
// logerror("BIOS: 0x6402 write: 0x%02x\n", data);
}
-READ8_MEMBER(mplay_state::megaplay_bios_6204_r)
+READ8_MEMBER(mplay_state::bios_6204_r)
{
return m_megadrive_io_data_regs[2];
// return (m_bios_width & 0xf8) + (m_bios_6204 & 0x07);
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_width_w)
+WRITE8_MEMBER(mplay_state::bios_width_w)
{
m_bios_width = data;
m_megadrive_io_data_regs[2] = (m_megadrive_io_data_regs[2] & 0x07) | ((data & 0xf8));
// logerror("BIOS: 0x6204 - Width write: %02x\n", data);
}
-READ8_MEMBER(mplay_state::megaplay_bios_6404_r)
+READ8_MEMBER(mplay_state::bios_6404_r)
{
// logerror("BIOS: 0x6404 read: returned 0x%02x\n",bios_6404 | (bios_6403 & 0x10) >> 4);
return (m_bios_6404 & 0xfe) | ((m_bios_6403 & 0x10) >> 4);
// return m_bios_6404 | (m_bios_6403 & 0x10) >> 4;
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_6404_w)
+WRITE8_MEMBER(mplay_state::bios_6404_w)
{
if(((m_bios_6404 & 0x0c) == 0x00) && ((data & 0x0c) == 0x0c))
m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
@@ -481,7 +481,7 @@ WRITE8_MEMBER(mplay_state::megaplay_bios_6404_w)
// logerror("BIOS: 0x6404 write: 0x%02x\n", data);
}
-READ8_MEMBER(mplay_state::megaplay_bios_6600_r)
+READ8_MEMBER(mplay_state::bios_6600_r)
{
/* Multi-slot note:
0x6600 appears to be used to check for extra slots being used.
@@ -492,13 +492,13 @@ READ8_MEMBER(mplay_state::megaplay_bios_6600_r)
return m_bios_6600;// & 0xfe;
}
-WRITE8_MEMBER(mplay_state::megaplay_bios_6600_w)
+WRITE8_MEMBER(mplay_state::bios_6600_w)
{
m_bios_6600 = data;
// logerror("BIOS: 0x6600 write: 0x%02x\n",data);
}
-WRITE8_MEMBER(mplay_state::megaplay_game_w)
+WRITE8_MEMBER(mplay_state::game_w)
{
if (m_readpos == 1)
m_game_banksel = 0;
@@ -514,24 +514,24 @@ WRITE8_MEMBER(mplay_state::megaplay_game_w)
logerror("BIOS [0x%04x]: 68K address space bank selected: 0x%03x\n", space.device().safe_pcbase(), m_game_banksel);
}
- m_mp_bios_bank_addr = ((m_mp_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
+ m_bios_bank_addr = ((m_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
}
static ADDRESS_MAP_START( megaplay_bios_map, AS_PROGRAM, 8, mplay_state )
AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x4000, 0x4fff) AM_RAM
AM_RANGE(0x5000, 0x5fff) AM_RAM
- AM_RANGE(0x6000, 0x6000) AM_WRITE(megaplay_game_w)
+ AM_RANGE(0x6000, 0x6000) AM_WRITE(game_w)
AM_RANGE(0x6200, 0x6200) AM_READ_PORT("DSW0")
AM_RANGE(0x6201, 0x6201) AM_READ_PORT("DSW1")
- AM_RANGE(0x6203, 0x6203) AM_READWRITE(megaplay_bios_banksel_r, megaplay_bios_banksel_w)
- AM_RANGE(0x6204, 0x6204) AM_READWRITE(megaplay_bios_6204_r, megaplay_bios_width_w)
+ AM_RANGE(0x6203, 0x6203) AM_READWRITE(bios_banksel_r, bios_banksel_w)
+ AM_RANGE(0x6204, 0x6204) AM_READWRITE(bios_6204_r, bios_width_w)
AM_RANGE(0x6400, 0x6400) AM_READ_PORT("TEST")
AM_RANGE(0x6401, 0x6401) AM_READ_PORT("COIN")
- AM_RANGE(0x6402, 0x6402) AM_READWRITE(megaplay_bios_6402_r, megaplay_bios_6402_w)
- AM_RANGE(0x6403, 0x6403) AM_READWRITE(megaplay_bios_gamesel_r, megaplay_bios_gamesel_w)
- AM_RANGE(0x6404, 0x6404) AM_READWRITE(megaplay_bios_6404_r, megaplay_bios_6404_w)
- AM_RANGE(0x6600, 0x6600) AM_READWRITE(megaplay_bios_6600_r, megaplay_bios_6600_w)
+ AM_RANGE(0x6402, 0x6402) AM_READWRITE(bios_6402_r, bios_6402_w)
+ AM_RANGE(0x6403, 0x6403) AM_READWRITE(bios_gamesel_r, bios_gamesel_w)
+ AM_RANGE(0x6404, 0x6404) AM_READWRITE(bios_6404_r, bios_6404_w)
+ AM_RANGE(0x6600, 0x6600) AM_READWRITE(bios_6600_r, bios_6600_w)
AM_RANGE(0x6001, 0x67ff) AM_WRITEONLY
AM_RANGE(0x6800, 0x77ff) AM_RAM AM_SHARE("ic3_ram")
AM_RANGE(0x8000, 0xffff) AM_READWRITE(bank_r, bank_w)
@@ -583,7 +583,7 @@ UINT32 mplay_state::screen_update_megplay(screen_device &screen, bitmap_rgb32 &b
MACHINE_RESET_MEMBER(mplay_state,megaplay)
{
m_bios_mode = MP_ROM;
- m_mp_bios_bank_addr = 0;
+ m_bios_bank_addr = 0;
m_readpos = 1;
MACHINE_RESET_CALL_MEMBER(megadriv);
}
@@ -808,12 +808,12 @@ void mplay_state::mplay_start()
}
}
-READ16_MEMBER(mplay_state::megadriv_68k_read_z80_extra_ram )
+READ16_MEMBER(mplay_state::extra_ram_r )
{
return m_ic36_ram[(offset << 1) ^ 1] | (m_ic36_ram[(offset << 1)] << 8);
}
-WRITE16_MEMBER(mplay_state::megadriv_68k_write_z80_extra_ram )
+WRITE16_MEMBER(mplay_state::extra_ram_w )
{
if (!ACCESSING_BITS_0_7) // byte (MSB) access
{
@@ -835,20 +835,21 @@ DRIVER_INIT_MEMBER(mplay_state,megaplay)
/* to support the old code.. */
m_ic36_ram = auto_alloc_array(machine(), UINT16, 0x10000 / 2);
m_ic37_ram = auto_alloc_array(machine(), UINT8, 0x10000);
- m_genesis_io_ram = auto_alloc_array(machine(), UINT16, 0x20 / 2);
-
- DRIVER_INIT_CALL(mpnew);
+ DRIVER_INIT_CALL(megadrij);
+ m_megadrive_io_read_data_port_ptr = read8_delegate(FUNC(md_base_state::megadrive_io_read_data_port_3button),this);
+ m_megadrive_io_write_data_port_ptr = write16_delegate(FUNC(md_base_state::megadrive_io_write_data_port_3button),this);
+
mplay_start();
/* for now ... */
- m_maincpu->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));
+ m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa10000, 0xa1001f, read16_delegate(FUNC(mplay_state::mp_io_read),this), write16_delegate(FUNC(mplay_state::mp_io_write),this));
/* megaplay has ram shared with the bios cpu here */
m_z80snd->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 */
- m_maincpu->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));
+ m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xa02000, 0xa03fff, read16_delegate(FUNC(mplay_state::extra_ram_r),this), write16_delegate(FUNC(mplay_state::extra_ram_w),this));
}
/*
diff --git a/src/mame/drivers/megatech.c b/src/mame/drivers/megatech.c
index e2917e038f2..d0b692205bd 100644
--- a/src/mame/drivers/megatech.c
+++ b/src/mame/drivers/megatech.c
@@ -205,7 +205,7 @@ static INPUT_PORTS_START( megatech ) /* Genesis Input Ports */
INPUT_PORTS_END
/* MEGATECH specific */
-READ8_MEMBER(mtech_state::megatech_cart_select_r )
+READ8_MEMBER(mtech_state::cart_select_r )
{
return m_mt_cart_select_reg;
}
@@ -215,10 +215,10 @@ void mtech_state::device_timer(emu_timer &timer, device_timer_id id, int param,
switch (id)
{
case TIMER_Z80_RUN_STATE:
- megatech_z80_run_state(ptr, param);
+ z80_run_state(ptr, param);
break;
case TIMER_Z80_STOP_STATE:
- megatech_z80_stop_state(ptr, param);
+ z80_stop_state(ptr, param);
break;
default:
assert_always(FALSE, "Unknown id in mtech_state::device_timer");
@@ -227,7 +227,7 @@ void mtech_state::device_timer(emu_timer &timer, device_timer_id id, int param,
READ8_MEMBER(mtech_state::sms_count_r)
{
- address_space &prg = machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM);
+ address_space &prg = m_z80snd->space(AS_PROGRAM);
if (offset & 0x01)
return m_vdp->hcount_read(prg, offset);
else
@@ -235,7 +235,6 @@ READ8_MEMBER(mtech_state::sms_count_r)
}
-/* the SMS inputs should be more complex, like the megadrive ones */
READ8_MEMBER (mtech_state::sms_ioport_dc_r)
{
/* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */
@@ -253,10 +252,10 @@ READ8_MEMBER (mtech_state::sms_ioport_dd_r)
WRITE8_MEMBER( mtech_state::mt_sms_standard_rom_bank_w )
{
- int bank = data&0x1f;
+ int bank = data & 0x1f;
//logerror("bank w %02x %02x\n", offset, data);
- sms_mainram[0x1ffc+offset] = data;
+ sms_mainram[0x1ffc + offset] = data;
switch (offset)
{
case 0:
@@ -278,10 +277,10 @@ WRITE8_MEMBER( mtech_state::mt_sms_standard_rom_bank_w )
}
}
-void mtech_state::megatech_set_genz80_as_sms(const char* tag)
+void mtech_state::set_genz80_as_sms()
{
- address_space &prg = machine().device(tag)->memory().space(AS_PROGRAM);
- address_space &io = machine().device(tag)->memory().space(AS_IO);
+ address_space &prg = machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM);
+ address_space &io = machine().device("genesis_snd_z80")->memory().space(AS_IO);
sn76496_base_device *sn = machine().device<sn76496_base_device>("snsnd");
// main ram area
@@ -311,18 +310,11 @@ void mtech_state::megatech_set_genz80_as_sms(const char* tag)
/* sets the megadrive z80 to it's normal ports / map */
-void mtech_state::megatech_set_genz80_as_md(const char* tag)
+void mtech_state::set_genz80_as_md()
{
- address_space &prg = machine().device(tag)->memory().space(AS_PROGRAM);
- address_space &io = machine().device(tag)->memory().space(AS_IO);
+ address_space &prg = machine().device("genesis_snd_z80")->memory().space(AS_PROGRAM);
ym2612_device *ym2612 = machine().device<ym2612_device>("ymsnd");
-
- 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 */
- prg.install_readwrite_handler(0x0000, 0xffff, read8_delegate(FUNC(mtech_state::z80_unmapped_r),this), write8_delegate(FUNC(mtech_state::z80_unmapped_w),this));
-
-
+
prg.install_readwrite_bank(0x0000, 0x1fff, "bank1");
machine().root_device().membank("bank1")->set_base(m_genz80.z80_prgram);
@@ -337,8 +329,7 @@ void mtech_state::megatech_set_genz80_as_md(const char* tag)
}
-
-TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_run_state )
+TIMER_CALLBACK_MEMBER(mtech_state::z80_run_state )
{
char tempname[20];
UINT8* game_region;
@@ -350,28 +341,27 @@ TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_run_state )
if (!m_cart_is_genesis[param])
{
- printf("enabling SMS Z80\n");
+ logerror("enabling SMS Z80\n");
m_current_game_is_sms = 1;
- megatech_set_genz80_as_sms("genesis_snd_z80");
+ set_genz80_as_sms();
//m_z80snd->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
m_z80snd->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
}
else
{
- printf("disabling SMS Z80\n");
+ logerror("disabling SMS Z80\n");
m_current_game_is_sms = 0;
- megatech_set_genz80_as_md("genesis_snd_z80");
+ set_genz80_as_md();
m_maincpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
//m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
}
}
-TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_stop_state )
+TIMER_CALLBACK_MEMBER(mtech_state::z80_stop_state )
{
UINT8* game_region;
char tempname[20];
-
- printf("megatech_select_game %d\n", param+1);
+ logerror("select game %d\n", param + 1);
sprintf(tempname, "game%d", param);
game_region = memregion(tempname)->base();
@@ -400,20 +390,14 @@ TIMER_CALLBACK_MEMBER(mtech_state::megatech_z80_stop_state )
return;
}
-void mtech_state::megatech_select_game(int gameno)
-{
- timer_set(attotime::zero, TIMER_Z80_STOP_STATE, gameno);
-}
-
-WRITE8_MEMBER(mtech_state::megatech_cart_select_w )
+WRITE8_MEMBER(mtech_state::cart_select_w )
{
/* seems to write the slot number..
but it stores something in (banked?) ram
because it always seems to show the
same instructions ... */
m_mt_cart_select_reg = data;
-
- megatech_select_game(m_mt_cart_select_reg);
+ timer_set(attotime::zero, TIMER_Z80_STOP_STATE, m_mt_cart_select_reg);
}
@@ -443,14 +427,14 @@ WRITE8_MEMBER(mtech_state::bios_ctrl_w )
/* this sets 0x300000 which may indicate that the 68k can see the instruction rom
there, this limiting the max game rom capacity to 3meg. */
-READ8_MEMBER(mtech_state::megatech_z80_read_68k_banked_data )
+READ8_MEMBER(mtech_state::read_68k_banked_data )
{
address_space &space68k = m_maincpu->space();
UINT8 ret = space68k.read_byte(m_mt_bank_addr + offset);
return ret;
}
-WRITE8_MEMBER(mtech_state::megatech_z80_write_68k_banked_data )
+WRITE8_MEMBER(mtech_state::write_68k_banked_data )
{
address_space &space68k = m_maincpu->space();
space68k.write_byte(m_mt_bank_addr + offset,data);
@@ -461,47 +445,63 @@ WRITE8_MEMBER(mtech_state::mt_z80_bank_w )
m_mt_bank_addr = ((m_mt_bank_addr >> 1) | (data << 23)) & 0xff8000;
}
-READ8_MEMBER(mtech_state::megatech_banked_ram_r )
+READ8_MEMBER(mtech_state::banked_ram_r )
{
- return m_megatech_banked_ram[offset + 0x1000 * (m_mt_cart_select_reg & 0x07)];
+ return m_banked_ram[offset + 0x1000 * (m_mt_cart_select_reg & 0x07)];
}
-WRITE8_MEMBER(mtech_state::megatech_banked_ram_w )
+WRITE8_MEMBER(mtech_state::banked_ram_w )
{
- m_megatech_banked_ram[offset + 0x1000 * (m_mt_cart_select_reg & 0x07)] = data;
+ m_banked_ram[offset + 0x1000 * (m_mt_cart_select_reg & 0x07)] = data;
}
static ADDRESS_MAP_START( megatech_bios_map, AS_PROGRAM, 8, mtech_state )
AM_RANGE(0x0000, 0x2fff) AM_ROM // from bios rom (0x0000-0x2fff populated in ROM)
- AM_RANGE(0x3000, 0x3fff) AM_READWRITE(megatech_banked_ram_r, megatech_banked_ram_w) // copies instruction data here at startup, must be banked
+ AM_RANGE(0x3000, 0x3fff) AM_READWRITE(banked_ram_r, banked_ram_w) // copies instruction data here at startup, must be banked
AM_RANGE(0x4000, 0x5fff) AM_RAM // plain ram?
AM_RANGE(0x6000, 0x6000) AM_WRITE(mt_z80_bank_w )
AM_RANGE(0x6400, 0x6400) AM_READ_PORT("BIOS_DSW0")
AM_RANGE(0x6401, 0x6401) AM_READ_PORT("BIOS_DSW1")
- AM_RANGE(0x6404, 0x6404) AM_READWRITE(megatech_cart_select_r, megatech_cart_select_w) // cart select & ram bank
+ AM_RANGE(0x6404, 0x6404) AM_READWRITE(cart_select_r, cart_select_w) // cart select & ram bank
AM_RANGE(0x6800, 0x6800) AM_READ_PORT("BIOS_IN0")
AM_RANGE(0x6801, 0x6801) AM_READ_PORT("BIOS_IN1")
AM_RANGE(0x6802, 0x6807) AM_READWRITE(bios_ctrl_r, bios_ctrl_w)
// AM_RANGE(0x6805, 0x6805) AM_READ_PORT("???")
AM_RANGE(0x7000, 0x77ff) AM_ROM // from bios rom (0x7000-0x77ff populated in ROM)
//AM_RANGE(0x7800, 0x7fff) AM_RAM // ?
- AM_RANGE(0x8000, 0x9fff) AM_READWRITE(megatech_z80_read_68k_banked_data, megatech_z80_write_68k_banked_data) // window into 68k address space, reads instr rom and writes to reset banks on z80 carts?
+ AM_RANGE(0x8000, 0x9fff) AM_READWRITE(read_68k_banked_data, write_68k_banked_data) // window into 68k address space, reads instr rom and writes to reset banks on z80 carts?
ADDRESS_MAP_END
-WRITE8_MEMBER(mtech_state::megatech_bios_port_ctrl_w )
+WRITE8_MEMBER(mtech_state::bios_port_ctrl_w )
{
m_bios_port_ctrl = data;
}
-READ8_MEMBER(mtech_state::megatech_bios_joypad_r )
+/* the test mode accesses the joypad/stick inputs like this */
+READ8_MEMBER(mtech_state::bios_joypad_r )
{
- return megatech_bios_port_cc_dc_r(offset, m_bios_port_ctrl);
+ UINT8 retdata = 0;
+
+ if (m_bios_port_ctrl == 0x55)
+ {
+ /* A keys */
+ retdata = ((m_io_pad_3b[0]->read() & 0x40) >> 2) | ((m_io_pad_3b[1]->read() & 0x40) >> 4) | 0xeb;
+ }
+ else
+ {
+ if (offset == 0)
+ retdata = (m_io_pad_3b[0]->read() & 0x3f) | ((m_io_pad_3b[1]->read() & 0x03) << 6);
+ else
+ retdata = ((m_io_pad_3b[1]->read() & 0x3c) >> 2) | 0xf0;
+
+ }
+ return retdata;
}
-WRITE8_MEMBER(mtech_state::megatech_bios_port_7f_w)
+WRITE8_MEMBER(mtech_state::bios_port_7f_w)
{
// popmessage("CPU #3: I/O port 0x7F write, data %02x", data);
}
@@ -518,21 +518,21 @@ READ8_MEMBER(mtech_state::vdp1_count_r)
static ADDRESS_MAP_START( megatech_bios_portmap, AS_IO, 8, mtech_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
- AM_RANGE(0x3f, 0x3f) AM_WRITE(megatech_bios_port_ctrl_w)
- AM_RANGE(0x7f, 0x7f) AM_WRITE(megatech_bios_port_7f_w)
+ AM_RANGE(0x3f, 0x3f) AM_WRITE(bios_port_ctrl_w)
+ AM_RANGE(0x7f, 0x7f) AM_WRITE(bios_port_7f_w)
AM_RANGE(0x40, 0x41) AM_MIRROR(0x3e) AM_READ(vdp1_count_r)
AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_DEVREADWRITE("vdp1", sega315_5124_device, vram_read, vram_write)
AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_DEVREADWRITE("vdp1", sega315_5124_device, register_read, register_write)
- AM_RANGE(0xdc, 0xdd) AM_READ(megatech_bios_joypad_r) // player inputs
+ AM_RANGE(0xdc, 0xdd) AM_READ(bios_joypad_r) // player inputs
ADDRESS_MAP_END
DRIVER_INIT_MEMBER(mtech_state,mt_slot)
{
- m_megatech_banked_ram = auto_alloc_array(machine(), UINT8, 0x1000*8);
+ m_banked_ram = auto_alloc_array(machine(), UINT8, 0x1000*8);
DRIVER_INIT_CALL(megadriv);
@@ -549,7 +549,7 @@ DRIVER_INIT_MEMBER(mtech_state,mt_crt)
}
-UINT32 mtech_state::screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
+UINT32 mtech_state::screen_update_main(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
/* if we're running an sms game then use the SMS update.. maybe this should be moved to the megadrive emulation core as compatibility mode is a feature of the chip */
if (!m_current_game_is_sms)
@@ -569,20 +569,20 @@ UINT32 mtech_state::screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bit
return 0;
}
-void mtech_state::screen_eof_mtnew(screen_device &screen, bool state)
+void mtech_state::screen_eof_main(screen_device &screen, bool state)
{
if (!m_current_game_is_sms)
screen_eof_megadriv(screen, state);
}
-MACHINE_RESET_MEMBER(mtech_state,mtnew)
+MACHINE_RESET_MEMBER(mtech_state, megatech)
{
m_mt_bank_addr = 0;
MACHINE_RESET_CALL_MEMBER(megadriv);
- megatech_select_game(0);
+ timer_set(attotime::zero, TIMER_Z80_STOP_STATE, 0);
}
-UINT32 mtech_state::screen_update_megatech_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
+UINT32 mtech_state::screen_update_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
m_vdp1->screen_update(screen,bitmap,cliprect);
return 0;
@@ -625,7 +625,7 @@ static MACHINE_CONFIG_START( megatech, mtech_state )
MCFG_CPU_PROGRAM_MAP(megatech_bios_map)
MCFG_CPU_IO_MAP(megatech_bios_portmap)
- MCFG_MACHINE_RESET_OVERRIDE(mtech_state,mtnew)
+ MCFG_MACHINE_RESET_OVERRIDE(mtech_state, megatech)
MCFG_DEFAULT_LAYOUT(layout_dualhovu)
@@ -633,8 +633,8 @@ static MACHINE_CONFIG_START( megatech, mtech_state )
MCFG_SCREEN_RAW_PARAMS(XTAL_10_738635MHz/2, \
SEGA315_5124_WIDTH , SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH, SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH + 256, \
SEGA315_5124_HEIGHT_NTSC, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT + 224)
- MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_mtnew)
- MCFG_SCREEN_VBLANK_DRIVER(mtech_state, screen_eof_mtnew)
+ MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_main)
+ MCFG_SCREEN_VBLANK_DRIVER(mtech_state, screen_eof_main)
MCFG_DEVICE_REMOVE("gen_vdp")
MCFG_DEVICE_ADD("gen_vdp", SEGA_GEN_VDP, 0)
@@ -649,7 +649,7 @@ static MACHINE_CONFIG_START( megatech, mtech_state )
MCFG_SCREEN_RAW_PARAMS(XTAL_10_738635MHz/2, \
SEGA315_5124_WIDTH , SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH, SEGA315_5124_LBORDER_START + SEGA315_5124_LBORDER_WIDTH + 256, \
SEGA315_5124_HEIGHT_NTSC, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT, SEGA315_5124_TBORDER_START + SEGA315_5124_NTSC_224_TBORDER_HEIGHT + 224)
- MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_megatech_menu)
+ MCFG_SCREEN_UPDATE_DRIVER(mtech_state, screen_update_menu)
MCFG_SEGA315_5246_ADD("vdp1", bios_vdp_intf)
MCFG_SEGA315_5246_SET_SCREEN("menu")
diff --git a/src/mame/includes/megadriv.h b/src/mame/includes/megadriv.h
index 511f97389a2..3c2cecc94fe 100644
--- a/src/mame/includes/megadriv.h
+++ b/src/mame/includes/megadriv.h
@@ -113,10 +113,6 @@ public:
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);
/* Megadrive / Genesis has 3 I/O ports */
@@ -136,7 +132,6 @@ public:
void megadrive_reset_io();
DECLARE_READ8_MEMBER(megadrive_io_read_data_port_6button);
DECLARE_READ8_MEMBER(megadrive_io_read_data_port_3button);
- UINT8 megatech_bios_port_cc_dc_r(int offset, int ctrl);
UINT8 megadrive_io_read_ctrl_port(int portnum);
UINT8 megadrive_io_read_tx_port(int portnum);
UINT8 megadrive_io_read_rx_port(int portnum);
@@ -156,7 +151,6 @@ public:
DECLARE_VIDEO_START( megadriv );
UINT32 screen_update_megadriv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void screen_eof_megadriv(screen_device &screen, bool state);
-
};
class md_boot_state : public md_base_state
@@ -295,55 +289,55 @@ public:
m_bioscpu(*this, "mtbios")
{ }
- UINT32 m_bios_mode; // determines whether ROM banks or Game data
- // is to read from 0x8000-0xffff
-
+ DECLARE_READ16_MEMBER(extra_ram_r);
+ DECLARE_WRITE16_MEMBER(extra_ram_w);
+ DECLARE_READ8_MEMBER(bios_banksel_r);
+ DECLARE_WRITE8_MEMBER(bios_banksel_w);
+ DECLARE_READ8_MEMBER(bios_gamesel_r);
+ DECLARE_WRITE8_MEMBER(bios_gamesel_w);
+ DECLARE_WRITE16_MEMBER(mp_io_write);
+ DECLARE_READ16_MEMBER(mp_io_read);
+ DECLARE_READ8_MEMBER(bank_r);
+ DECLARE_WRITE8_MEMBER(bank_w);
+ DECLARE_READ8_MEMBER(bios_6402_r);
+ DECLARE_WRITE8_MEMBER(bios_6402_w);
+ DECLARE_READ8_MEMBER(bios_6204_r);
+ DECLARE_WRITE8_MEMBER(bios_width_w);
+ DECLARE_READ8_MEMBER(bios_6404_r);
+ DECLARE_WRITE8_MEMBER(bios_6404_w);
+ DECLARE_READ8_MEMBER(bios_6600_r);
+ DECLARE_WRITE8_MEMBER(bios_6600_w);
+ DECLARE_WRITE8_MEMBER(game_w);
+ DECLARE_READ8_MEMBER(vdp_count_r);
+ DECLARE_WRITE_LINE_MEMBER(bios_int_callback);
+ void mplay_start();
+
+ DECLARE_DRIVER_INIT(megaplay);
+ DECLARE_VIDEO_START(megplay);
+ DECLARE_MACHINE_RESET(megaplay);
+ UINT32 screen_update_megplay(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
+
+private:
+
+ UINT32 m_bios_mode; // determines whether ROM banks or Game data is to read from 0x8000-0xffff
+
UINT32 m_bios_bank; // ROM bank selection
UINT16 m_game_banksel; // Game bank selection
UINT32 m_readpos; // serial bank selection position (9-bit)
- UINT32 m_mp_bios_bank_addr;
-
+ UINT32 m_bios_bank_addr;
+
UINT32 m_bios_width; // determines the way the game info ROM is read
UINT8 m_bios_ctrl[6];
UINT8 m_bios_6600;
UINT8 m_bios_6403;
UINT8 m_bios_6404;
+
+ UINT16 *m_ic36_ram;
+ UINT8* m_ic37_ram;
- UINT16 *m_genesis_io_ram;
- required_shared_ptr<UINT8> m_ic3_ram;
+ required_shared_ptr<UINT8> m_ic3_ram;
optional_device<sega315_5124_device> m_vdp1;
required_device<cpu_device> m_bioscpu;
- UINT8* m_ic37_ram;
- UINT16 *m_ic36_ram;
- DECLARE_WRITE_LINE_MEMBER( bios_int_callback );
- READ8_MEMBER(vdp_count_r);
- DECLARE_DRIVER_INIT(megaplay);
- DECLARE_VIDEO_START(megplay);
- DECLARE_MACHINE_RESET(megaplay);
-
- UINT32 screen_update_megplay(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- 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
@@ -361,66 +355,59 @@ public:
m_bioscpu(*this, "mtbios")
{ }
-
- required_device<sega315_5124_device> m_vdp1;
- required_device<cpu_device> m_bioscpu;
-
-
DECLARE_WRITE_LINE_MEMBER( snd_int_callback );
DECLARE_WRITE_LINE_MEMBER( bios_int_callback );
-
+ DECLARE_READ8_MEMBER(cart_select_r);
+ DECLARE_WRITE8_MEMBER(cart_select_w);
+ DECLARE_READ8_MEMBER(bios_ctrl_r);
+ DECLARE_WRITE8_MEMBER(bios_ctrl_w);
+ DECLARE_READ8_MEMBER(read_68k_banked_data);
+ DECLARE_WRITE8_MEMBER(write_68k_banked_data);
+ DECLARE_WRITE8_MEMBER(mt_z80_bank_w);
+ DECLARE_READ8_MEMBER(banked_ram_r);
+ DECLARE_WRITE8_MEMBER(banked_ram_w);
+ DECLARE_WRITE8_MEMBER(bios_port_ctrl_w);
+ DECLARE_READ8_MEMBER(bios_joypad_r);
+ DECLARE_WRITE8_MEMBER(bios_port_7f_w);
+ DECLARE_READ8_MEMBER(vdp1_count_r);
+ DECLARE_READ8_MEMBER(sms_count_r);
+ DECLARE_READ8_MEMBER(sms_ioport_dc_r);
+ DECLARE_READ8_MEMBER(sms_ioport_dd_r);
+ DECLARE_WRITE8_MEMBER(mt_sms_standard_rom_bank_w);
+
+ DECLARE_DRIVER_INIT(mt_crt);
+ DECLARE_DRIVER_INIT(mt_slot);
+ DECLARE_MACHINE_RESET(megatech);
+ DECLARE_DEVICE_IMAGE_LOAD_MEMBER(megatech_cart);
+ UINT32 screen_update_main(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
+ UINT32 screen_update_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
+ void screen_eof_main(screen_device &screen, bool state);
+
+protected:
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+
+private:
UINT8 m_mt_cart_select_reg;
UINT32 m_bios_port_ctrl;
int m_current_game_is_sms; // is the current game SMS based (running on genesis z80, in VDP compatibility mode)
UINT32 m_bios_ctrl_inputs;
UINT8 m_bios_ctrl[6];
-
int m_mt_bank_addr;
int m_cart_is_genesis[8];
- DECLARE_DEVICE_IMAGE_LOAD_MEMBER( megatech_cart );
+ void set_genz80_as_md();
+ void set_genz80_as_sms();
- /* Megatech BIOS specific */
- UINT8* m_megatech_banked_ram;
- DECLARE_DRIVER_INIT(mt_crt);
- DECLARE_DRIVER_INIT(mt_slot);
- DECLARE_VIDEO_START(mtnew);
- DECLARE_MACHINE_RESET(mtnew);
- UINT32 screen_update_mtnew(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- void screen_eof_mtnew(screen_device &screen, bool state);
- UINT32 screen_update_megatech_menu(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- void megatech_set_genz80_as_md(const char* tag);
- void megatech_set_genz80_as_sms(const char* tag);
- UINT32 screen_update_megatech_sms2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- DECLARE_READ8_MEMBER( megatech_cart_select_r );
- TIMER_CALLBACK_MEMBER( megatech_z80_run_state );
- TIMER_CALLBACK_MEMBER( megatech_z80_stop_state );
- void megatech_select_game(int gameno);
- DECLARE_WRITE8_MEMBER( megatech_cart_select_w );
- DECLARE_READ8_MEMBER( bios_ctrl_r );
- DECLARE_WRITE8_MEMBER( bios_ctrl_w );
- DECLARE_READ8_MEMBER( megatech_z80_read_68k_banked_data );
- DECLARE_WRITE8_MEMBER( megatech_z80_write_68k_banked_data );
- DECLARE_WRITE8_MEMBER( mt_z80_bank_w );
- DECLARE_READ8_MEMBER( megatech_banked_ram_r );
- DECLARE_WRITE8_MEMBER( megatech_banked_ram_w );
- DECLARE_WRITE8_MEMBER( megatech_bios_port_ctrl_w );
- DECLARE_READ8_MEMBER( megatech_bios_joypad_r );
- DECLARE_WRITE8_MEMBER (megatech_bios_port_7f_w);
- READ8_MEMBER(vdp1_count_r);
- READ8_MEMBER(sms_count_r);
- READ8_MEMBER(sms_ioport_dc_r);
- READ8_MEMBER(sms_ioport_dd_r);
- WRITE8_MEMBER(mt_sms_standard_rom_bank_w);
-
-protected:
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ TIMER_CALLBACK_MEMBER(z80_run_state);
+ TIMER_CALLBACK_MEMBER(z80_stop_state);
+ UINT8* m_banked_ram;
UINT8* sms_mainram;
UINT8* sms_rom;
+
+ required_device<sega315_5124_device> m_vdp1;
+ required_device<cpu_device> m_bioscpu;
};
class _32x_state : public md_base_state
diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c
index aa7fac5f87c..ec996f5fef7 100644
--- a/src/mame/machine/megadriv.c
+++ b/src/mame/machine/megadriv.c
@@ -25,7 +25,6 @@ Known Non-Issues (confirmed on Real Genesis)
#include "includes/megadriv.h"
-
MACHINE_CONFIG_EXTERN( megadriv );
void megadriv_z80_hold(running_machine &machine)
@@ -274,33 +273,6 @@ READ8_MEMBER(md_base_state::megadrive_io_read_data_port_3button)
return retdata;
}
-/* used by megatech bios, the test mode accesses the joypad/stick inputs like this */
-UINT8 md_base_state::megatech_bios_port_cc_dc_r(int offset, int ctrl)
-{
- UINT8 retdata;
-
- if (ctrl == 0x55)
- {
- /* A keys */
- retdata = ((m_io_pad_3b[0]->read() & 0x40) >> 2) |
- ((m_io_pad_3b[1]->read() & 0x40) >> 4) | 0xeb;
- }
- else
- {
- if (offset == 0)
- {
- retdata = (m_io_pad_3b[0]->read() & 0x3f) | ((m_io_pad_3b[1]->read() & 0x03) << 6);
- }
- else
- {
- retdata = ((m_io_pad_3b[1]->read() & 0x3c) >> 2) | 0xf0;
- }
-
- }
-
- return retdata;
-}
-
UINT8 md_base_state::megadrive_io_read_ctrl_port(int portnum)
{
UINT8 retdata;
@@ -1213,38 +1185,6 @@ DRIVER_INIT_MEMBER(md_base_state,megadrie)
m_pal = 1;
}
-DRIVER_INIT_MEMBER(md_base_state,mpnew)
-{
- DRIVER_INIT_CALL(megadrij);
- m_megadrive_io_read_data_port_ptr = read8_delegate(FUNC(md_base_state::megadrive_io_read_data_port_3button),this);
- m_megadrive_io_write_data_port_ptr = write16_delegate(FUNC(md_base_state::megadrive_io_write_data_port_3button),this);
-}
-
-/* used by megatech */
-READ8_MEMBER(md_base_state::z80_unmapped_port_r )
-{
-// printf("unmapped z80 port read %04x\n",offset);
- return 0;
-}
-
-WRITE8_MEMBER(md_base_state::z80_unmapped_port_w )
-{
-// printf("unmapped z80 port write %04x\n",offset);
-}
-
-READ8_MEMBER(md_base_state::z80_unmapped_r )
-{
- printf("unmapped z80 read %04x\n",offset);
- return 0;
-}
-
-WRITE8_MEMBER(md_base_state::z80_unmapped_w )
-{
- printf("unmapped z80 write %04x\n",offset);
-}
-
-
-
void md_base_state::screen_eof_megadriv(screen_device &screen, bool state)
{
if (m_io_reset->read_safe(0x00) & 0x01)