First (small) step towards driver class for megadrive-based drivers [Fabio Priuli]

out of whatsnew: this can be considered as preliminary. things like the empty md_base_state class have been done in purpose to reduce as much as possible changes in machine/megadriv.c (so to avoid overlaps/conflicts with Haze's work on segacd). next steps will start to move megadrive variables to the class.
This commit is contained in:
Fabio Priuli 2011-02-12 06:32:43 +00:00
parent 6dd5dc47db
commit e6d1b6cf45
9 changed files with 794 additions and 644 deletions

View File

@ -249,34 +249,31 @@ a tilemap-like structure, from which data is copied)
*************************************/
/* We need to always initialize 6 buttons pad */
static emu_timer *mess_io_timeout[3];
static int mess_io_stage[3];
static TIMER_CALLBACK( mess_io_timeout_timer_callback )
{
mess_io_stage[(int)(FPTR)ptr] = -1;
md_cons_state *state = machine->driver_data<md_cons_state>();
state->mess_io_stage[(int)(FPTR)ptr] = -1;
}
/* J-Cart controller port */
static UINT8 jcart_io_data[2];
WRITE16_HANDLER( jcart_ctrl_w )
{
jcart_io_data[0] = (data & 1) << 6;
jcart_io_data[1] = (data & 1) << 6;
md_cons_state *state = space->machine->driver_data<md_cons_state>();
state->jcart_io_data[0] = (data & 1) << 6;
state->jcart_io_data[1] = (data & 1) << 6;
}
READ16_HANDLER( jcart_ctrl_r )
{
UINT16 retdata = 0;
UINT8 joy[2];
md_cons_state *state = space->machine->driver_data<md_cons_state>();
UINT16 retdata = 0;
UINT8 joy[2];
if (jcart_io_data[0] & 0x40)
if (state->jcart_io_data[0] & 0x40)
{
joy[0] = input_port_read_safe(space->machine, "JCART3_3B", 0);
joy[1] = input_port_read_safe(space->machine, "JCART4_3B", 0);
retdata = (jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
retdata = (state->jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
else
{
@ -284,19 +281,20 @@ READ16_HANDLER( jcart_ctrl_r )
(input_port_read_safe(space->machine, "JCART3_3B", 0) & 0x03);
joy[1] = ((input_port_read_safe(space->machine, "JCART4_3B", 0) & 0xc0) >> 2) |
(input_port_read_safe(space->machine, "JCART4_3B", 0) & 0x03);
retdata = (jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
retdata = (state->jcart_io_data[0] & 0x40) | joy[0] | (joy[1] << 8);
}
return retdata;
}
static void mess_init_6buttons_pad(running_machine *machine)
{
md_cons_state *state = machine->driver_data<md_cons_state>();
int i;
for (i = 0; i < 3; i++)
{
mess_io_timeout[i] = machine->scheduler().timer_alloc(FUNC(mess_io_timeout_timer_callback), (void*)(FPTR)i);
mess_io_stage[i] = -1;
state->mess_io_timeout[i] = machine->scheduler().timer_alloc(FUNC(mess_io_timeout_timer_callback), (void*)(FPTR)i);
state->mess_io_stage[i] = -1;
}
}
@ -304,6 +302,7 @@ static void mess_init_6buttons_pad(running_machine *machine)
/* They're needed to give the users the choice between different controllers */
static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
{
md_cons_state *state = machine->driver_data<md_cons_state>();
static const char *const pad6names[2][4] = {
{ "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" },
{ "EXTRA1", "EXTRA2", "UNUSED", "UNUSED" }
@ -335,7 +334,7 @@ static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
{
if (megadrive_io_data_regs[portnum] & 0x40)
{
if (mess_io_stage[portnum] == 2)
if (state->mess_io_stage[portnum] == 2)
{
/* here we read B, C & the additional buttons */
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
@ -351,13 +350,13 @@ static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
}
else
{
if (mess_io_stage[portnum] == 1)
if (state->mess_io_stage[portnum] == 1)
{
/* here we read ((Start & A) >> 2) | 0x00 */
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
(((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) & ~helper_6b);
}
else if (mess_io_stage[portnum]==2)
else if (state->mess_io_stage[portnum]==2)
{
/* here we read ((Start & A) >> 2) | 0x0f */
retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
@ -400,6 +399,7 @@ static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
static void mess_md_io_write_data_port(running_machine *machine, int portnum, UINT16 data)
{
md_cons_state *state = machine->driver_data<md_cons_state>();
int controller;
switch (portnum)
@ -423,8 +423,8 @@ static void mess_md_io_write_data_port(running_machine *machine, int portnum, UI
{
if (((megadrive_io_data_regs[portnum] & 0x40) == 0x00) && ((data & 0x40) == 0x40))
{
mess_io_stage[portnum]++;
mess_io_timeout[portnum]->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192));
state->mess_io_stage[portnum]++;
state->mess_io_timeout[portnum]->adjust(machine->device<cpu_device>("maincpu")->cycles_to_attotime(8192));
}
}
@ -573,7 +573,8 @@ static MACHINE_RESET( ms_megadriv )
MACHINE_RESET_CALL( megadriv );
}
static MACHINE_CONFIG_DERIVED( ms_megadriv, megadriv )
static MACHINE_CONFIG_START( ms_megadriv, md_cons_state )
MCFG_FRAGMENT_ADD( md_ntsc )
MCFG_MACHINE_START( ms_megadriv )
MCFG_MACHINE_RESET( ms_megadriv )
@ -581,7 +582,8 @@ static MACHINE_CONFIG_DERIVED( ms_megadriv, megadriv )
MCFG_FRAGMENT_ADD( genesis_cartslot )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( ms_megadpal, megadpal )
static MACHINE_CONFIG_START( ms_megadpal, md_cons_state )
MCFG_FRAGMENT_ADD( md_pal )
MCFG_MACHINE_START( ms_megadriv )
MCFG_MACHINE_RESET( ms_megadriv )
@ -589,7 +591,9 @@ static MACHINE_CONFIG_DERIVED( ms_megadpal, megadpal )
MCFG_FRAGMENT_ADD( genesis_cartslot )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( ms_megdsvp, megdsvp )
static MACHINE_CONFIG_START( ms_megdsvp, md_cons_state )
MCFG_FRAGMENT_ADD( md_ntsc )
MCFG_FRAGMENT_ADD( md_svp )
MCFG_MACHINE_START( ms_megadriv )
MCFG_MACHINE_RESET( ms_megadriv )
@ -879,44 +883,42 @@ ROM_END
static UINT16 pico_read_penpos(running_machine *machine, int pen)
{
UINT16 penpos = 0;
UINT16 penpos = 0;
switch (pen)
switch (pen)
{
case PICO_PENX:
penpos = input_port_read_safe(machine, "PENX", 0);
penpos |= 0x6;
penpos = penpos * 320 / 255;
penpos += 0x3d;
break;
case PICO_PENY:
penpos = input_port_read_safe(machine, "PENY", 0);
penpos |= 0x6;
penpos = penpos * 251 / 255;
penpos += 0x1fc;
break;
case PICO_PENX:
penpos = input_port_read_safe(machine, "PENX", 0);
penpos |= 0x6;
penpos = penpos * 320 / 255;
penpos += 0x3d;
break;
case PICO_PENY:
penpos = input_port_read_safe(machine, "PENY", 0);
penpos |= 0x6;
penpos = penpos * 251 / 255;
penpos += 0x1fc;
break;
}
return penpos;
return penpos;
}
static READ16_HANDLER( pico_68k_io_read )
{
UINT8 retdata;
static UINT8 page_register = 0;
retdata = 0;
pico_state *state = space->machine->driver_data<pico_state>();
UINT8 retdata = 0;
switch (offset)
{
case 0: /* Version register ?XX?????? where XX is 00 for japan, 01 for europe and 10 for USA*/
retdata = (megadrive_region_export << 6) | (megadrive_region_pal << 5);
break;
case 1:
retdata = input_port_read_safe(space->machine, "PAD", 0);
break;
{
case 0: /* Version register ?XX?????? where XX is 00 for japan, 01 for europe and 10 for USA*/
retdata = (megadrive_region_export << 6) | (megadrive_region_pal << 5);
break;
case 1:
retdata = input_port_read_safe(space->machine, "PAD", 0);
break;
/*
/*
Still notes from notaz for the pen :
The pen can be used to 'draw' either on the drawing pad or on the storyware
@ -926,61 +928,60 @@ static READ16_HANDLER( pico_68k_io_read )
x: 0x03c - 0x17c
y: 0x1fc - 0x2f7 (drawing pad)
0x2f8 - 0x3f3 (storyware)
*/
case 2:
retdata = pico_read_penpos(space->machine, PICO_PENX) >> 8;
break;
case 3:
retdata = pico_read_penpos(space->machine, PICO_PENX) & 0x00ff;
break;
case 4:
retdata = pico_read_penpos(space->machine, PICO_PENY) >> 8;
break;
case 5:
retdata = pico_read_penpos(space->machine, PICO_PENY) & 0x00ff;
break;
case 6:
*/
case 2:
retdata = pico_read_penpos(space->machine, PICO_PENX) >> 8;
break;
case 3:
retdata = pico_read_penpos(space->machine, PICO_PENX) & 0x00ff;
break;
case 4:
retdata = pico_read_penpos(space->machine, PICO_PENY) >> 8;
break;
case 5:
retdata = pico_read_penpos(space->machine, PICO_PENY) & 0x00ff;
break;
case 6:
/* Page register :
00 - storyware closed
01, 03, 07, 0f, 1f, 3f - pages 1-6
either page 5 or page 6 is often unused.
*/
{
UINT8 tmp;
tmp = input_port_read_safe(space->machine, "PAGE", 0);
if (tmp == 2 && page_register != 0x3f)
{
page_register <<= 1;
page_register |= 1;
}
if (tmp == 1 && page_register != 0x00)
page_register >>= 1;
retdata = page_register;
break;
}
case 7:
/* Returns free bytes left in the PCM FIFO buffer */
retdata = 0x00;
break;
case 8:
{
UINT8 tmp = input_port_read_safe(space->machine, "PAGE", 0);
if (tmp == 2 && state->page_register != 0x3f)
{
state->page_register <<= 1;
state->page_register |= 1;
}
if (tmp == 1 && state->page_register != 0x00)
state->page_register >>= 1;
retdata = state->page_register;
break;
}
case 7:
/* Returns free bytes left in the PCM FIFO buffer */
retdata = 0x00;
break;
case 8:
/*
For reads, if bit 15 is cleared, it means PCM is 'busy' or
something like that, as games sometimes wait for it to become 1.
*/
retdata = 0x00;
}
return retdata | retdata <<8;
retdata = 0x00;
}
return retdata | retdata << 8;
}
static WRITE16_HANDLER( pico_68k_io_write )
{
switch (offset)
{
}
{
}
}
static ADDRESS_MAP_START( _pico_mem, ADDRESS_SPACE_PROGRAM, 16 )
static ADDRESS_MAP_START( pico_mem, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x3fffff) AM_ROM
AM_RANGE(0x800000, 0x80001f) AM_READWRITE(pico_68k_io_read, pico_68k_io_write)
@ -1019,10 +1020,11 @@ static INPUT_PORTS_START( pico )
INPUT_PORTS_END
static MACHINE_CONFIG_DERIVED( pico, megadriv )
static MACHINE_CONFIG_START( pico, pico_state )
MCFG_FRAGMENT_ADD( md_ntsc )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(_pico_mem)
MCFG_CPU_PROGRAM_MAP(pico_mem)
MCFG_DEVICE_REMOVE("genesis_snd_z80")
@ -1031,10 +1033,11 @@ static MACHINE_CONFIG_DERIVED( pico, megadriv )
MCFG_FRAGMENT_ADD( pico_cartslot )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( picopal, megadpal )
static MACHINE_CONFIG_START( picopal, pico_state )
MCFG_FRAGMENT_ADD( md_pal )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(_pico_mem)
MCFG_CPU_PROGRAM_MAP(pico_mem)
MCFG_DEVICE_REMOVE("genesis_snd_z80")

View File

@ -278,14 +278,13 @@ static WRITE16_HANDLER( aladmdb_w )
static READ16_HANDLER( aladmdb_r )
{
md_boot_state *state = space->machine->driver_data<md_boot_state>();
if (cpu_get_pc(space->cpu)==0x1b2a56)
{
static UINT16 mcu_port;
state->aladmdb_mcu_port = input_port_read(space->machine, "MCU");
mcu_port = input_port_read(space->machine, "MCU");
if(mcu_port & 0x100)
return ((mcu_port & 0x0f) | 0x100); // coin inserted, calculate the number of coins
if (state->aladmdb_mcu_port & 0x100)
return ((state->aladmdb_mcu_port & 0x0f) | 0x100); // coin inserted, calculate the number of coins
else
return (0x100); //MCU status, needed if you fall into a pitfall
}
@ -316,7 +315,7 @@ static READ16_HANDLER( srmdb_dsw_r )
return input_port_read(space->machine, dswname[offset]);
}
static READ16_HANDLER(topshoot_200051_r)
static READ16_HANDLER( topshoot_200051_r )
{
return -0x5b;
}
@ -570,6 +569,16 @@ static INPUT_PORTS_START( topshoot ) /* Top Shooter Input Ports */
PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END
/*************************************
*
* Machine Configuration
*
*************************************/
static MACHINE_CONFIG_START( megadrvb, md_boot_state )
MCFG_FRAGMENT_ADD(md_ntsc)
MACHINE_CONFIG_END
/*************************************
*
* ROM definition(s)
@ -658,6 +667,7 @@ static DRIVER_INIT( aladmdb )
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x220000, 0x220001, 0, 0, aladmdb_w);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x330000, 0x330001, 0, 0, aladmdb_r);
megadrive_6buttons_pad = 0;
DRIVER_INIT_CALL(megadrij);
}
@ -665,28 +675,27 @@ static DRIVER_INIT( aladmdb )
// after this decode look like intentional changes
static DRIVER_INIT( mk3mdb )
{
int x;
UINT8 *rom = machine->region("maincpu")->base();
for (x=0x000001;x<0x100001;x+=2)
for (int x = 0x000001; x < 0x100001; x += 2)
{
if (x&0x80000)
if (x & 0x80000)
{
rom[x] = rom[x]^0xff;
rom[x] = rom[x] ^ 0xff;
rom[x] = BITSWAP8(rom[x], 0,3,2,5,4,6,7,1);
}
else
{
rom[x] = rom[x]^0xff;
rom[x] = rom[x] ^ 0xff;
rom[x] = BITSWAP8(rom[x], 4,0,7,1,3,6,2,5);
}
}
for (x=0x100001;x<0x400000;x+=2)
for (int x = 0x100001; x < 0x400000; x += 2)
{
if (x&0x80000)
if (x & 0x80000)
{
rom[x] = rom[x]^0xff;
rom[x] = rom[x] ^ 0xff;
rom[x] = BITSWAP8(rom[x], 2,7,5,4,1,0,3,6);
}
else
@ -708,7 +717,6 @@ static DRIVER_INIT( mk3mdb )
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770075, 0, 0, mk3mdb_dsw_r );
megadrive_6buttons_pad = 1;
DRIVER_INIT_CALL(megadriv);
}
@ -723,35 +731,33 @@ static DRIVER_INIT( ssf2mdb )
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770075, 0, 0, ssf2mdb_dsw_r );
megadrive_6buttons_pad = 1;
DRIVER_INIT_CALL(megadrij);
}
static DRIVER_INIT( srmdb )
{
int x;
UINT8* rom = machine->region("maincpu")->base();
/* todo, reduce bitswaps to single swap */
for (x=0x00001;x<0x40000;x+=2)
for (int x = 0x00001; x < 0x40000; x += 2)
{
rom[x] = rom[x] ^ 0xff;
rom[x] = BITSWAP8(rom[x], 7,6,5,4,3,2,1,0 );
rom[x] = BITSWAP8(rom[x], 1,6,5,4,3,2,7,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,3,4,2,1,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,2,3,4,1,0 );
rom[x] = BITSWAP8(rom[x], 5,6,7,4,3,2,1,0 );
rom[x] = BITSWAP8(rom[x], 7,5,6,4,3,2,1,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,4,3,2,1,0);
rom[x] = BITSWAP8(rom[x], 1,6,5,4,3,2,7,0);
rom[x] = BITSWAP8(rom[x], 7,6,5,3,4,2,1,0);
rom[x] = BITSWAP8(rom[x], 7,6,5,2,3,4,1,0);
rom[x] = BITSWAP8(rom[x], 5,6,7,4,3,2,1,0);
rom[x] = BITSWAP8(rom[x], 7,5,6,4,3,2,1,0);
}
for (x=0x40001;x<0x80000;x+=2)
for (int x = 0x40001; x < 0x80000; x += 2)
{
rom[x] = BITSWAP8(rom[x], 7,6,5,4,3,2,1,0 );
rom[x] = BITSWAP8(rom[x], 7,6,1,4,3,2,5,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,4,0,2,1,3 );
rom[x] = BITSWAP8(rom[x], 2,6,5,4,3,7,1,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,0,3,2,1,4 );
rom[x] = BITSWAP8(rom[x], 7,6,5,1,3,2,4,0 );
rom[x] = BITSWAP8(rom[x], 7,6,5,4,3,2,1,0);
rom[x] = BITSWAP8(rom[x], 7,6,1,4,3,2,5,0);
rom[x] = BITSWAP8(rom[x], 7,6,5,4,0,2,1,3);
rom[x] = BITSWAP8(rom[x], 2,6,5,4,3,7,1,0);
rom[x] = BITSWAP8(rom[x], 7,6,5,0,3,2,1,4);
rom[x] = BITSWAP8(rom[x], 7,6,5,1,3,2,4,0);
}
@ -766,6 +772,7 @@ static DRIVER_INIT( srmdb )
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770075, 0, 0, srmdb_dsw_r );
megadrive_6buttons_pad = 0;
DRIVER_INIT_CALL(megadriv);
}
@ -777,6 +784,7 @@ static DRIVER_INIT(topshoot)
memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200046, 0x200047, 0, 0, "IN2");
memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200048, 0x200049, 0, 0, "IN3");
megadrive_6buttons_pad = 0;
DRIVER_INIT_CALL(megadriv);
}
@ -786,8 +794,8 @@ static DRIVER_INIT(topshoot)
*
*************************************/
GAME( 1993, aladmdb, 0, megadriv, aladmdb, aladmdb, ROT0, "bootleg / Sega", "Aladdin (bootleg of Japanese Megadrive version)", 0)
GAME( 1996, mk3mdb, 0, megadriv, mk3mdb, mk3mdb, ROT0, "bootleg / Midway", "Mortal Kombat 3 (bootleg of Megadrive version)", 0)
GAME( 1994, ssf2mdb, 0, megadriv, ssf2mdb, ssf2mdb, ROT0, "bootleg / Capcom", "Super Street Fighter II - The New Challengers (bootleg of Japanese MegaDrive version)", 0)
GAME( 1993, srmdb, 0, megadriv, srmdb, srmdb, ROT0, "bootleg / Konami", "Sunset Riders (bootleg of Megadrive version)", 0)
GAME( 1993, aladmdb, 0, megadrvb, aladmdb, aladmdb, ROT0, "bootleg / Sega", "Aladdin (bootleg of Japanese Megadrive version)", 0)
GAME( 1996, mk3mdb, 0, megadrvb, mk3mdb, mk3mdb, ROT0, "bootleg / Midway", "Mortal Kombat 3 (bootleg of Megadrive version)", 0)
GAME( 1994, ssf2mdb, 0, megadrvb, ssf2mdb, ssf2mdb, ROT0, "bootleg / Capcom", "Super Street Fighter II - The New Challengers (bootleg of Japanese MegaDrive version)", 0)
GAME( 1993, srmdb, 0, megadrvb, srmdb, srmdb, ROT0, "bootleg / Konami", "Sunset Riders (bootleg of Megadrive version)", 0)
GAME( 1995, topshoot, 0, md_bootleg, topshoot, topshoot, ROT0, "Sun Mixing", "Top Shooter", 0)

View File

@ -59,25 +59,14 @@ Bugs:
#define MASTER_CLOCK 53693100
struct _mplay_bios mplay_bios;
static UINT16 *genesis_io_ram;
static UINT8* ic3_ram;
static UINT8* ic37_ram;
static UINT16 *ic36_ram;
//static UINT8 ic36_ram[0x4000];
//static UINT8 hintcount; /* line interrupt counter, decreased each scanline */
extern UINT8 segae_vintpending;
extern UINT8 segae_hintpending;
extern UINT8 *segae_vdp_regs[]; /* pointer to vdp's registers */
// Interrupt handler - from drivers/segasyse.c
#if 0
static UINT8 hintcount; /* line interrupt counter, decreased each scanline */
static INTERRUPT_GEN (megaplay_bios_irq)
{
int sline;
@ -388,7 +377,8 @@ INPUT_PORTS_END
static READ8_HANDLER( megaplay_bios_banksel_r )
{
return mplay_bios.bios_bank;
mplay_state *state = space->machine->driver_data<mplay_state>();
return state->bios_bank;
}
static WRITE8_HANDLER( megaplay_bios_banksel_w )
@ -398,22 +388,25 @@ static WRITE8_HANDLER( megaplay_bios_banksel_w )
It should be possible to multiplex different game ROMs at
0x000000-0x3fffff based on these bits.
*/
mplay_bios.bios_bank = data;
mplay_bios.bios_mode = MP_ROM;
mplay_state *state = space->machine->driver_data<mplay_state>();
state->bios_bank = data;
state->bios_mode = MP_ROM;
// logerror("BIOS: ROM bank %i selected [0x%02x]\n",bios_bank >> 6, data);
}
static READ8_HANDLER( megaplay_bios_gamesel_r )
{
return mplay_bios.bios_6403;
mplay_state *state = space->machine->driver_data<mplay_state>();
return state->bios_6403;
}
static WRITE8_HANDLER( megaplay_bios_gamesel_w )
{
mplay_bios.bios_6403 = data;
mplay_state *state = space->machine->driver_data<mplay_state>();
state->bios_6403 = data;
// logerror("BIOS: 0x6403 write: 0x%02x\n",data);
mplay_bios.bios_mode = data & 0x10;
state->bios_mode = data & 0x10;
}
static WRITE16_HANDLER( megaplay_io_write )
@ -434,29 +427,27 @@ static READ16_HANDLER( megaplay_io_read )
static READ8_HANDLER( bank_r )
{
UINT32 fulladdress;
mplay_state *state = space->machine->driver_data<mplay_state>();
UINT8* bank = space->machine->region("mtbios")->base();
fulladdress = mplay_bios.mp_bios_bank_addr + offset;
UINT32 fulladdress = state->mp_bios_bank_addr + offset;
if ((fulladdress >= 0x000000) && (fulladdress <= 0x3fffff)) // ROM Addresses
{
if (mplay_bios.bios_mode & MP_ROM)
if (state->bios_mode & MP_ROM)
{
int sel = (mplay_bios.bios_bank >> 6) & 0x03;
int sel = (state->bios_bank >> 6) & 0x03;
if (sel == 0)
return 0xff;
else
return bank[0x10000 + (sel - 1) * 0x8000 + offset];
}
else if (mplay_bios.bios_width & 0x08)
else if (state->bios_width & 0x08)
{
if(offset >= 0x2000)
return ic36_ram[offset - 0x2000];
if (offset >= 0x2000)
return state->ic36_ram[offset - 0x2000];
else
return ic37_ram[(0x2000 * (mplay_bios.bios_bank & 0x03)) + offset];
return state->ic37_ram[(0x2000 * (state->bios_bank & 0x03)) + offset];
}
else
{
@ -477,20 +468,20 @@ static READ8_HANDLER( bank_r )
static WRITE8_HANDLER( bank_w )
{
UINT32 fulladdress;
fulladdress = mplay_bios.mp_bios_bank_addr + offset;
mplay_state *state = space->machine->driver_data<mplay_state>();
UINT32 fulladdress = state->mp_bios_bank_addr + offset;
if ((fulladdress >= 0x000000) && (fulladdress <= 0x3fffff)) // ROM / Megaplay Custom Addresses
{
if (offset <= 0x1fff && (mplay_bios.bios_width & 0x08))
if (offset <= 0x1fff && (state->bios_width & 0x08))
{
ic37_ram[(0x2000 * (mplay_bios.bios_bank & 0x03)) + offset] = data;
state->ic37_ram[(0x2000 * (state->bios_bank & 0x03)) + offset] = data;
}
if(offset >= 0x2000 && (mplay_bios.bios_width & 0x08))
if(offset >= 0x2000 && (state->bios_width & 0x08))
{
// ic36_ram[offset] = data;
ic36_ram[offset - 0x2000] = data;
state->ic36_ram[offset - 0x2000] = data;
}
}
else if (fulladdress >= 0xa10000 && fulladdress <=0xa1001f) // IO Access
@ -520,29 +511,32 @@ static WRITE8_HANDLER( megaplay_bios_6402_w )
static READ8_HANDLER( megaplay_bios_6204_r )
{
return (megadrive_io_data_regs[2]);
// return (mplay_bios.bios_width & 0xf8) + (mplay_bios.bios_6204 & 0x07);
return megadrive_io_data_regs[2];
// return (state->bios_width & 0xf8) + (state->bios_6204 & 0x07);
}
static WRITE8_HANDLER( megaplay_bios_width_w )
{
mplay_bios.bios_width = data;
mplay_state *state = space->machine->driver_data<mplay_state>();
state->bios_width = data;
megadrive_io_data_regs[2] = (megadrive_io_data_regs[2] & 0x07) | ((data & 0xf8));
// logerror("BIOS: 0x6204 - Width write: %02x\n", data);
}
static READ8_HANDLER( 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);
return (mplay_bios.bios_6404 & 0xfe) | ((mplay_bios.bios_6403 & 0x10) >> 4);
// return mplay_bios.bios_6404 | (mplay_bios.bios_6403 & 0x10) >> 4;
return (state->bios_6404 & 0xfe) | ((state->bios_6403 & 0x10) >> 4);
// return state->bios_6404 | (state->bios_6403 & 0x10) >> 4;
}
static WRITE8_HANDLER( megaplay_bios_6404_w )
{
if(((mplay_bios.bios_6404 & 0x0c) == 0x00) && ((data & 0x0c) == 0x0c))
mplay_state *state = space->machine->driver_data<mplay_state>();
if(((state->bios_6404 & 0x0c) == 0x00) && ((data & 0x0c) == 0x0c))
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
mplay_bios.bios_6404 = data;
state->bios_6404 = data;
// logerror("BIOS: 0x6404 write: 0x%02x\n", data);
}
@ -553,34 +547,37 @@ static READ8_HANDLER( megaplay_bios_6600_r )
0x6600 appears to be used to check for extra slots being used.
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")
return (mplay_bios.bios_6600 & 0xfe) | (mplay_bios.bios_bank & 0x01);
return (state->bios_6600 & 0xfe) | (state->bios_bank & 0x01);
*/
return mplay_bios.bios_6600;// & 0xfe;
mplay_state *state = space->machine->driver_data<mplay_state>();
return state->bios_6600;// & 0xfe;
}
static WRITE8_HANDLER( megaplay_bios_6600_w )
{
mplay_bios.bios_6600 = data;
mplay_state *state = space->machine->driver_data<mplay_state>();
state->bios_6600 = data;
// logerror("BIOS: 0x6600 write: 0x%02x\n",data);
}
static WRITE8_HANDLER( megaplay_game_w )
{
if (mplay_bios.readpos == 1)
mplay_bios.game_banksel = 0;
mplay_bios.game_banksel |= (1 << (mplay_bios.readpos - 1)) * (data & 0x01);
mplay_state *state = space->machine->driver_data<mplay_state>();
if (state->readpos == 1)
state->game_banksel = 0;
state->game_banksel |= (1 << (state->readpos - 1)) * (data & 0x01);
mplay_bios.readpos++;
state->readpos++;
if (mplay_bios.readpos > 9)
if (state->readpos > 9)
{
mplay_bios.bios_mode = MP_GAME;
mplay_bios.readpos = 1;
// popmessage("Game bank selected: 0x%03x", mplay_bios.game_banksel);
logerror("BIOS [0x%04x]: 68K address space bank selected: 0x%03x\n", cpu_get_previouspc(space->cpu), mplay_bios.game_banksel);
state->bios_mode = MP_GAME;
state->readpos = 1;
// popmessage("Game bank selected: 0x%03x", state->game_banksel);
logerror("BIOS [0x%04x]: 68K address space bank selected: 0x%03x\n", cpu_get_previouspc(space->cpu), state->game_banksel);
}
mplay_bios.mp_bios_bank_addr = ((mplay_bios.mp_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
state->mp_bios_bank_addr = ((state->mp_bios_bank_addr >> 1) | (data << 23)) & 0xff8000;
}
static ADDRESS_MAP_START( megaplay_bios_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -599,7 +596,7 @@ static ADDRESS_MAP_START( megaplay_bios_map, ADDRESS_SPACE_PROGRAM, 8 )
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(0x6001, 0x67ff) AM_WRITEONLY
AM_RANGE(0x6800, 0x77ff) AM_RAM AM_BASE(&ic3_ram)
AM_RANGE(0x6800, 0x77ff) AM_RAM AM_BASE_MEMBER(mplay_state, ic3_ram)
AM_RANGE(0x8000, 0xffff) AM_READWRITE(bank_r, bank_w)
ADDRESS_MAP_END
@ -632,24 +629,25 @@ static VIDEO_UPDATE(megplay)
//extern VIDEO_EOF(megadriv);
static MACHINE_RESET( mpnew )
static MACHINE_RESET( megaplay )
{
mplay_bios.bios_mode = MP_ROM;
mplay_bios.mp_bios_bank_addr = 0;
mplay_bios.readpos = 1;
mplay_state *state = machine->driver_data<mplay_state>();
state->bios_mode = MP_ROM;
state->mp_bios_bank_addr = 0;
state->readpos = 1;
MACHINE_RESET_CALL(megadriv);
MACHINE_RESET_CALL(megatech_bios);
}
static VIDEO_EOF( mpnew )
static VIDEO_EOF( megaplay )
{
VIDEO_EOF_CALL(megadriv);
VIDEO_EOF_CALL(megatech_bios);
}
static MACHINE_CONFIG_DERIVED( mpnew, megadriv )
static MACHINE_CONFIG_START( megaplay, mplay_state )
/* basic machine hardware */
MCFG_FRAGMENT_ADD(md_ntsc)
/* The Megaplay has an extra BIOS cpu which drives an SMS VDP
which includes an SN76496 for sound */
@ -658,8 +656,8 @@ static MACHINE_CONFIG_DERIVED( mpnew, megadriv )
MCFG_CPU_IO_MAP(megaplay_bios_io_map)
//MCFG_CPU_VBLANK_INT_HACK(megaplay_bios_irq, 262)
MCFG_MACHINE_RESET( mpnew )
MCFG_VIDEO_EOF( mpnew )
MCFG_MACHINE_RESET( megaplay )
MCFG_VIDEO_EOF( megaplay )
MCFG_QUANTUM_TIME(attotime::from_hz(6000))
@ -836,51 +834,50 @@ static void mplay_start(running_machine *machine)
UINT8 *game_rom = machine->region("maincpu")->base();
int offs;
memmove(src + 0x10000, src + 0x8000, 0x18000); // move bios..
/* copy game instruction rom to main map.. maybe this should just be accessed
through a handler instead?.. */
for (offs = 0; offs < 0x8000; offs++)
{
UINT8 dat;
dat = instruction_rom[offs];
UINT8 dat = instruction_rom[offs];
game_rom[0x300000 + offs * 2] = dat;
game_rom[0x300001 + offs * 2] = dat;
}
}
static READ16_HANDLER( megadriv_68k_read_z80_extra_ram )
{
return ic36_ram[(offset << 1) ^ 1] | (ic36_ram[(offset << 1)] << 8);
mplay_state *state = space->machine->driver_data<mplay_state>();
return state->ic36_ram[(offset << 1) ^ 1] | (state->ic36_ram[(offset << 1)] << 8);
}
static WRITE16_HANDLER( megadriv_68k_write_z80_extra_ram )
{
mplay_state *state = space->machine->driver_data<mplay_state>();
if (!ACCESSING_BITS_0_7) // byte (MSB) access
{
ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
state->ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
}
else if (!ACCESSING_BITS_8_15)
{
ic36_ram[(offset << 1) ^ 1] = (data & 0x00ff);
state->ic36_ram[(offset << 1) ^ 1] = (data & 0x00ff);
}
else // for WORD access only the MSB is used, LSB is ignored
{
ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
state->ic36_ram[(offset << 1)] = (data & 0xff00) >> 8;
}
}
static DRIVER_INIT (megaplay)
static DRIVER_INIT(megaplay)
{
mplay_state *state = machine->driver_data<mplay_state>();
/* to support the old code.. */
ic36_ram = auto_alloc_array(machine, UINT16, 0x10000 / 2);
ic37_ram = auto_alloc_array(machine, UINT8, 0x10000);
genesis_io_ram = auto_alloc_array(machine, UINT16, 0x20 / 2);
state->ic36_ram = auto_alloc_array(machine, UINT16, 0x10000 / 2);
state->ic37_ram = auto_alloc_array(machine, UINT8, 0x10000);
state->genesis_io_ram = auto_alloc_array(machine, UINT16, 0x20 / 2);
DRIVER_INIT_CALL(mpnew);
@ -890,7 +887,7 @@ static DRIVER_INIT (megaplay)
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa10000, 0xa1001f, 0, 0, megaplay_io_read, megaplay_io_write);
/* megaplay has ram shared with the bios cpu here */
memory_install_ram(cputag_get_address_space(machine, "genesis_snd_z80", ADDRESS_SPACE_PROGRAM), 0x2000, 0x3fff, 0, 0, &ic36_ram[0]);
memory_install_ram(cputag_get_address_space(machine, "genesis_snd_z80", ADDRESS_SPACE_PROGRAM), 0x2000, 0x3fff, 0, 0, &state->ic36_ram[0]);
/* instead of a RAM mirror the 68k sees the extra ram of the 2nd z80 too */
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa02000, 0xa03fff, 0, 0, megadriv_68k_read_z80_extra_ram, megadriv_68k_write_z80_extra_ram);
@ -927,20 +924,20 @@ Mazin Wars 171-6215A 837-9165-11 610-0297-11 MPR-1646
didn't have original Sega part numbers it's probably a converted TWC cart
*/
/* -- */ GAME( 1993, megaplay, 0, mpnew, megaplay, megaplay, ROT0, "Sega", "Mega Play BIOS", GAME_IS_BIOS_ROOT )
/* 01 */ GAME( 1993, mp_sonic, megaplay, mpnew, mp_sonic, megaplay, ROT0, "Sega", "Sonic The Hedgehog (Mega Play)" , 0 )
/* 02 */ GAME( 1993, mp_gaxe2, megaplay, mpnew, mp_gaxe2, megaplay, ROT0, "Sega", "Golden Axe II (Mega Play)" , 0 )
/* 03 */ GAME( 1993, mp_gslam, megaplay, mpnew, mp_gslam, megaplay, ROT0, "Sega", "Grand Slam (Mega Play)",0 )
/* 04 */ GAME( 1993, mp_twc, megaplay, mpnew, mp_twc, megaplay, ROT0, "Sega", "Tecmo World Cup (Mega Play)" , 0 )
/* 05 */ GAME( 1993, mp_sor2, megaplay, mpnew, mp_sor2, megaplay, ROT0, "Sega", "Streets of Rage II (Mega Play)" , 0 )
/* 06 */ GAME( 1993, mp_bio, megaplay, mpnew, mp_bio, megaplay, ROT0, "Sega", "Bio-hazard Battle (Mega Play)" , 0 )
/* 07 */ GAME( 1993, mp_soni2, megaplay, mpnew, mp_soni2, megaplay, ROT0, "Sega", "Sonic The Hedgehog 2 (Mega Play)" , 0 )
/* -- */ GAME( 1993, megaplay, 0, megaplay, megaplay, megaplay, ROT0, "Sega", "Mega Play BIOS", GAME_IS_BIOS_ROOT )
/* 01 */ GAME( 1993, mp_sonic, megaplay, megaplay, mp_sonic, megaplay, ROT0, "Sega", "Sonic The Hedgehog (Mega Play)" , 0 )
/* 02 */ GAME( 1993, mp_gaxe2, megaplay, megaplay, mp_gaxe2, megaplay, ROT0, "Sega", "Golden Axe II (Mega Play)" , 0 )
/* 03 */ GAME( 1993, mp_gslam, megaplay, megaplay, mp_gslam, megaplay, ROT0, "Sega", "Grand Slam (Mega Play)",0 )
/* 04 */ GAME( 1993, mp_twc, megaplay, megaplay, mp_twc, megaplay, ROT0, "Sega", "Tecmo World Cup (Mega Play)" , 0 )
/* 05 */ GAME( 1993, mp_sor2, megaplay, megaplay, mp_sor2, megaplay, ROT0, "Sega", "Streets of Rage II (Mega Play)" , 0 )
/* 06 */ GAME( 1993, mp_bio, megaplay, megaplay, mp_bio, megaplay, ROT0, "Sega", "Bio-hazard Battle (Mega Play)" , 0 )
/* 07 */ GAME( 1993, mp_soni2, megaplay, megaplay, mp_soni2, megaplay, ROT0, "Sega", "Sonic The Hedgehog 2 (Mega Play)" , 0 )
/* 08 */
/* 09 */ GAME( 1993, mp_shnb3, megaplay, mpnew, mp_shnb3, megaplay, ROT0, "Sega", "Shinobi III (Mega Play)" , 0 )
/* 09 */ GAME( 1993, mp_shnb3, megaplay, megaplay, mp_shnb3, megaplay, ROT0, "Sega", "Shinobi III (Mega Play)" , 0 )
/* 10 */
/* 11 */ GAME( 1993, mp_mazin, megaplay, mpnew, mp_mazin, megaplay, ROT0, "Sega", "Mazin Wars / Mazin Saga (Mega Play)",0 )
/* 11 */ GAME( 1993, mp_mazin, megaplay, megaplay, mp_mazin, megaplay, ROT0, "Sega", "Mazin Wars / Mazin Saga (Mega Play)",0 )
/* ?? */ GAME( 1993, mp_col3, megaplay, mpnew, megaplay, megaplay, ROT0, "Sega", "Columns III (Mega Play)" , 0 )
/* ?? */ GAME( 1993, mp_col3, megaplay, megaplay, megaplay, megaplay, ROT0, "Sega", "Columns III (Mega Play)" , 0 )
/* Also confirmed to exist:

View File

@ -62,7 +62,7 @@ Bonanza Bros. 171-5782 837-6963-49 610-0239-49 MPR
Streets of Rage 171-5782 837-6963-51 610-0239-51 MPR-14125-SM (uPD23C4000) EPR-12368-51 (27C256) n/a
Sonic The Hedgehog 171-5782 837-6963-52 610-0239-52 MPR-13913-F (834200A) EPR-12368-52 (27C256) n/a
Spider-Man 171-5782 837-6963-54 610-0239-54 MPR-14027-SM (uPD23C4000) EPR-12368-54 (27C256) n/a
California Game 171-5834 837-6963-55-01 610-0239-55 EPR-14494 (27C020) EPR-14495 (27C020) EPR-12368-55 (27C256)
California Games 171-5834 837-6963-55-01 610-0239-55 EPR-14494 (27C020) EPR-14495 (27C020) EPR-12368-55 (27C256)
Mario Lemeux Hockey 171-5782 837-6963-59 610-0239-59 MPR-14376-H (234000) EPR-12368-59 (27256) n/a
Turbo Outrun 171-5782 837-6963-61 610-0239-61 MPR-14674 (uPD23C4000) EPR-12368-61 (27256) n/a
Sonic Hedgehog 2 171-6215A 837-6963-62 610-0239-62 MPR-15000A-F (838200) EPR-12368-62 (27256) n/a
@ -77,12 +77,6 @@ Sonic Hedgehog 2 171-6215A 837-6963-62 610-0239-62 MPR
#include "includes/megadriv.h"
#include "imagedev/cartslot.h"
static struct _mtech_bios mtech_bios;
static int cart_is_genesis[8];
/* Megatech BIOS specific */
static UINT8* megatech_banked_ram;
#define MASTER_CLOCK 53693100
/* not currently used */
@ -215,13 +209,15 @@ INPUT_PORTS_END
/* MEGATECH specific */
static READ8_HANDLER( megatech_cart_select_r )
{
return mtech_bios.mt_cart_select_reg;
mtech_state *state = space->machine->driver_data<mtech_state>();
return state->mt_cart_select_reg;
}
static TIMER_CALLBACK( megatech_z80_run_state )
{
mtech_state *state = machine->driver_data<mtech_state>();
char tempname[20];
UINT8* game_region;
@ -230,18 +226,18 @@ static TIMER_CALLBACK( megatech_z80_run_state )
memcpy(machine->region("maincpu")->base(), game_region, 0x400000);
if (!cart_is_genesis[param])
if (!state->cart_is_genesis[param])
{
printf("enabling SMS Z80\n");
mtech_bios.current_game_is_sms = 1;
state->current_game_is_sms = 1;
megatech_set_genz80_as_sms_standard_map(machine, "genesis_snd_z80", MAPPER_STANDARD);
//cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_HALT, CLEAR_LINE);
cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_RESET, CLEAR_LINE);
}
else
{
mtech_bios.current_game_is_sms = 0;
printf("disabling SMS Z80\n");
state->current_game_is_sms = 0;
megatech_set_megadrive_z80_as_megadrive_z80(machine, "genesis_snd_z80");
cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, CLEAR_LINE);
//cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);
@ -264,7 +260,6 @@ static TIMER_CALLBACK( megatech_z80_stop_state )
//cputag_set_input_line(machine, "genesis_snd_z80", INPUT_LINE_HALT, ASSERT_LINE);
devtag_reset(machine, "ymsnd");
megadriv_stop_scanline_timer();// stop the scanline timer for the genesis vdp... it can be restarted in video eof when needed
segae_md_sms_stop_scanline_timer();// stop the scanline timer for the sms vdp
@ -273,7 +268,7 @@ static TIMER_CALLBACK( megatech_z80_stop_state )
if (game_region)
{
{
machine->scheduler().timer_set( attotime::zero, FUNC(megatech_z80_run_state ), param);
machine->scheduler().timer_set(attotime::zero, FUNC(megatech_z80_run_state), param);
}
}
else
@ -288,7 +283,7 @@ static TIMER_CALLBACK( megatech_z80_stop_state )
static void megatech_select_game(running_machine *machine, int gameno)
{
machine->scheduler().timer_set( attotime::zero, FUNC(megatech_z80_stop_state ), gameno);
machine->scheduler().timer_set(attotime::zero, FUNC(megatech_z80_stop_state), gameno);
}
static WRITE8_HANDLER( megatech_cart_select_w )
@ -297,32 +292,33 @@ static WRITE8_HANDLER( megatech_cart_select_w )
but it stores something in (banked?) ram
because it always seems to show the
same instructions ... */
mtech_state *state = space->machine->driver_data<mtech_state>();
state->mt_cart_select_reg = data;
mtech_bios.mt_cart_select_reg = data;
megatech_select_game(space->machine, mtech_bios.mt_cart_select_reg);
megatech_select_game(space->machine, state->mt_cart_select_reg);
}
static READ8_HANDLER( bios_ctrl_r )
{
mtech_state *state = space->machine->driver_data<mtech_state>();
if(offset == 0)
if (offset == 0)
return 0;
if(offset == 2)
return mtech_bios.bios_ctrl[offset] & 0xfe;
if (offset == 2)
return state->bios_ctrl[offset] & 0xfe;
return mtech_bios.bios_ctrl[offset];
return state->bios_ctrl[offset];
}
static WRITE8_HANDLER( bios_ctrl_w )
{
if(offset == 1)
mtech_state *state = space->machine->driver_data<mtech_state>();
if (offset == 1)
{
mtech_bios.bios_ctrl_inputs = data & 0x04; // Genesis/SMS input ports disable bit
state->bios_ctrl_inputs = data & 0x04; // Genesis/SMS input ports disable bit
}
mtech_bios.bios_ctrl[offset] = data;
state->bios_ctrl[offset] = data;
}
/* this sets 0x300000 which may indicate that the 68k can see the instruction rom
@ -330,36 +326,40 @@ static WRITE8_HANDLER( bios_ctrl_w )
static READ8_HANDLER( megatech_z80_read_68k_banked_data )
{
mtech_state *state = space->machine->driver_data<mtech_state>();
address_space *space68k = space->machine->device<legacy_cpu_device>("maincpu")->space();
UINT8 ret = space68k->read_byte(mtech_bios.mt_bank_addr+offset);
UINT8 ret = space68k->read_byte(state->mt_bank_addr + offset);
return ret;
}
static WRITE8_HANDLER( megatech_z80_write_68k_banked_data )
{
mtech_state *state = space->machine->driver_data<mtech_state>();
address_space *space68k = space->machine->device<legacy_cpu_device>("maincpu")->space();
space68k->write_byte(mtech_bios.mt_bank_addr+offset,data);
space68k->write_byte(state->mt_bank_addr + offset,data);
}
static void megatech_z80_bank_w(UINT16 data)
static void megatech_z80_bank_w(running_machine *machine, UINT16 data)
{
mtech_bios.mt_bank_addr = ( ( mtech_bios.mt_bank_addr >> 1 ) | ( data << 23 ) ) & 0xff8000;
mtech_state *state = machine->driver_data<mtech_state>();
state->mt_bank_addr = ((state->mt_bank_addr >> 1) | (data << 23)) & 0xff8000;
}
static WRITE8_HANDLER (mt_z80_bank_w)
static WRITE8_HANDLER( mt_z80_bank_w )
{
megatech_z80_bank_w(data&1);
megatech_z80_bank_w(space->machine, data & 1);
}
static READ8_HANDLER( megatech_banked_ram_r )
{
return megatech_banked_ram[offset + 0x1000 * (mtech_bios.mt_cart_select_reg & 0x07)];
mtech_state *state = space->machine->driver_data<mtech_state>();
return state->megatech_banked_ram[offset + 0x1000 * (state->mt_cart_select_reg & 0x07)];
}
static WRITE8_HANDLER( megatech_banked_ram_w )
{
megatech_banked_ram[offset + 0x1000 * (mtech_bios.mt_cart_select_reg & 0x07)] = data;
mtech_state *state = space->machine->driver_data<mtech_state>();
state->megatech_banked_ram[offset + 0x1000 * (state->mt_cart_select_reg & 0x07)] = data;
}
@ -382,18 +382,18 @@ static ADDRESS_MAP_START( megatech_bios_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END
static WRITE8_HANDLER (megatech_bios_port_ctrl_w)
static WRITE8_HANDLER( megatech_bios_port_ctrl_w )
{
mtech_bios.bios_port_ctrl = data;
mtech_state *state = space->machine->driver_data<mtech_state>();
state->bios_port_ctrl = data;
}
static READ8_HANDLER (megatech_bios_joypad_r)
static READ8_HANDLER( megatech_bios_joypad_r )
{
return megatech_bios_port_cc_dc_r(space->machine, offset, mtech_bios.bios_port_ctrl);
mtech_state *state = space->machine->driver_data<mtech_state>();
return megatech_bios_port_cc_dc_r(space->machine, offset, state->bios_port_ctrl);
}
static WRITE8_HANDLER (megatech_bios_port_7f_w)
{
// popmessage("CPU #3: I/O port 0x7F write, data %02x", data);
@ -416,54 +416,66 @@ ADDRESS_MAP_END
static DRIVER_INIT(mt_slot)
{
megatech_banked_ram = auto_alloc_array(machine, UINT8, 0x1000*8);
mtech_state *state = machine->driver_data<mtech_state>();
state->megatech_banked_ram = auto_alloc_array(machine, UINT8, 0x1000*8);
DRIVER_INIT_CALL(megadriv);
DRIVER_INIT_CALL(megatech_bios);
// this gets set in DEVICE_IMAGE_LOAD
memset(cart_is_genesis, 0, ARRAY_LENGTH(cart_is_genesis));
memset(state->cart_is_genesis, 0, ARRAY_LENGTH(state->cart_is_genesis));
}
static DRIVER_INIT(mt_crt)
{
mtech_state *state = machine->driver_data<mtech_state>();
UINT8* pin = machine->region("sms_pin")->base();
DRIVER_INIT_CALL(mt_slot);
cart_is_genesis[0] = !pin[0] ? 1 : 0;;
state->cart_is_genesis[0] = !pin[0] ? 1 : 0;;
}
static VIDEO_START(mtnew)
{
init_for_megadrive(machine); // create an sms vdp too, for comptibility mode
init_for_megadrive(machine); // create an sms vdp too, for compatibility mode
VIDEO_START_CALL(megadriv);
}
//attotime::never
static VIDEO_UPDATE(mtnew)
{
mtech_state *state = screen->machine->driver_data<mtech_state>();
device_t *megadriv_screen = screen->machine->device("megadriv");
device_t *menu_screen = screen->machine->device("menu");
device_t *menu_screen = screen->machine->device("menu");
if (screen == megadriv_screen)
{
/* 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 (!mtech_bios.current_game_is_sms) VIDEO_UPDATE_CALL(megadriv);
else VIDEO_UPDATE_CALL(megatech_md_sms);
if (!state->current_game_is_sms)
VIDEO_UPDATE_CALL(megadriv);
else
VIDEO_UPDATE_CALL(megatech_md_sms);
}
else if (screen == menu_screen) VIDEO_UPDATE_CALL(megatech_bios);
else if (screen == menu_screen)
VIDEO_UPDATE_CALL(megatech_bios);
return 0;
}
static VIDEO_EOF(mtnew)
{
if (!mtech_bios.current_game_is_sms) VIDEO_EOF_CALL(megadriv);
else VIDEO_EOF_CALL(megatech_md_sms);
mtech_state *state = machine->driver_data<mtech_state>();
if (!state->current_game_is_sms)
VIDEO_EOF_CALL(megadriv);
else
VIDEO_EOF_CALL(megatech_md_sms);
VIDEO_EOF_CALL(megatech_bios);
}
static MACHINE_RESET(mtnew)
{
mtech_bios.mt_bank_addr = 0;
mtech_state *state = machine->driver_data<mtech_state>();
state->mt_bank_addr = 0;
MACHINE_RESET_CALL(megadriv);
MACHINE_RESET_CALL(megatech_bios);
@ -471,9 +483,9 @@ static MACHINE_RESET(mtnew)
megatech_select_game(machine, 0);
}
static MACHINE_CONFIG_DERIVED( megatech, megadriv )
static MACHINE_CONFIG_START( megatech, mtech_state )
/* basic machine hardware */
MCFG_FRAGMENT_ADD(md_ntsc)
/* Megatech has an extra SMS based bios *and* an additional screen */
MCFG_CPU_ADD("mtbios", Z80, MASTER_CLOCK / 15) /* ?? */
@ -524,6 +536,7 @@ static const struct megatech_cart_region megatech_cart_table[] =
static DEVICE_IMAGE_LOAD( megatech_cart )
{
mtech_state *state = image.device().machine->driver_data<mtech_state>();
const struct megatech_cart_region *mt_cart = &megatech_cart_table[0], *this_cart;
const char *pcb_name;
@ -555,12 +568,12 @@ static DEVICE_IMAGE_LOAD( megatech_cart )
if (!mame_stricmp("genesis", pcb_name))
{
printf("%s is genesis\n", mt_cart->tag);
cart_is_genesis[this_cart->slot] = 1;
state->cart_is_genesis[this_cart->slot] = 1;
}
else if (!mame_stricmp("sms", pcb_name))
{
printf("%s is sms\n", mt_cart->tag);
cart_is_genesis[this_cart->slot] = 0;
state->cart_is_genesis[this_cart->slot] = 0;
}
else
{
@ -1278,5 +1291,4 @@ ROM_END
/* 61 */ GAME( 1992, mt_tout, megatech, megatech, megatech, mt_crt, ROT0, "Sega", "Turbo Outrun (Mega-Tech)", GAME_NOT_WORKING )
/* 62 */ GAME( 1992, mt_soni2, megatech, megatech, megatech, mt_crt, ROT0, "Sega", "Sonic The Hedgehog 2 (Mega-Tech)", GAME_NOT_WORKING )
/* more? */

View File

@ -164,7 +164,8 @@ static ADDRESS_MAP_START( puckpkmna_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x70001c, 0x70001d) AM_READ(puckpkmna_70001c_r)
ADDRESS_MAP_END
static MACHINE_CONFIG_DERIVED( puckpkmn, megadriv )
static MACHINE_CONFIG_START( puckpkmn, md_boot_state )
MCFG_FRAGMENT_ADD(md_ntsc)
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_PROGRAM_MAP(puckpkmn_map)
@ -259,8 +260,8 @@ Screenshots available on my site at http://guru.mameworld.info/oldnews2001.html
static DRIVER_INIT( puckpkmn )
{
UINT8 *rom = machine->region("maincpu")->base();
size_t len = machine->region("maincpu")->bytes();
UINT8 *rom = machine->region("maincpu")->base();
size_t len = machine->region("maincpu")->bytes();
int i;
for (i = 0; i < len; i++)

View File

@ -86,31 +86,7 @@
#define LOG_IOCHIP 0
static void recompute_palette_tables(void);
static int segac2_enable_display;
/******************************************************************************
Global variables
******************************************************************************/
/* internal states */
static UINT8 misc_io_data[0x10]; /* holds values written to the I/O chip */
/* protection-related tracking */
static int (*prot_func)(int in); /* emulation of protection chip */
static UINT8 prot_write_buf; /* remembers what was written */
static UINT8 prot_read_buf; /* remembers what was returned */
/* palette-related variables */
static UINT8 segac2_alt_palette_mode;
static UINT8 palbank;
static UINT8 bg_palbase;
static UINT8 sp_palbase;
/* sound-related variables */
static UINT8 sound_banks; /* number of sound banks */
static void recompute_palette_tables( running_machine *machine );
/******************************************************************************
Machine init
@ -123,43 +99,41 @@ static UINT8 sound_banks; /* number of sound banks */
static MACHINE_START( segac2 )
{
state_save_register_global_array(machine, misc_io_data);
state_save_register_global(machine, prot_write_buf);
state_save_register_global(machine, prot_read_buf);
segac2_state *state = machine->driver_data<segac2_state>();
// MACHINE_START_CALL(genesis);
state_save_register_global_array(machine, state->misc_io_data);
state_save_register_global(machine, state->prot_write_buf);
state_save_register_global(machine, state->prot_read_buf);
}
static MACHINE_RESET( segac2 )
{
segac2_state *state = machine->driver_data<segac2_state>();
megadrive_ram = reinterpret_cast<UINT16 *>(memory_get_shared(*machine, "nvram"));
/* set up interrupts and such */
MACHINE_RESET_CALL(megadriv);
/* determine how many sound banks */
sound_banks = 0;
state->sound_banks = 0;
if (machine->region("upd")->base())
sound_banks = machine->region("upd")->bytes() / 0x20000;
state->sound_banks = machine->region("upd")->bytes() / 0x20000;
/* reset the protection */
prot_write_buf = 0;
prot_read_buf = 0;
segac2_alt_palette_mode = 0;
state->prot_write_buf = 0;
state->prot_read_buf = 0;
state->segac2_alt_palette_mode = 0;
palbank = 0;
bg_palbase = 0;
sp_palbase = 0;
state->palbank = 0;
state->bg_palbase = 0;
state->sp_palbase = 0;
recompute_palette_tables();
recompute_palette_tables(machine);
}
/******************************************************************************
Sound handlers
*******************************************************************************
@ -176,8 +150,10 @@ static MACHINE_RESET( segac2 )
/* handle writes to the UPD7759 */
static WRITE16_DEVICE_HANDLER( segac2_upd7759_w )
{
segac2_state *state = device->machine->driver_data<segac2_state>();
/* make sure we have a UPD chip */
if (!sound_banks)
if (!state->sound_banks)
return;
/* only works if we're accessing the low byte */
@ -190,7 +166,6 @@ static WRITE16_DEVICE_HANDLER( segac2_upd7759_w )
}
/******************************************************************************
Palette RAM Read / Write Handlers
*******************************************************************************
@ -211,27 +186,30 @@ static WRITE16_DEVICE_HANDLER( segac2_upd7759_w )
/* handle reads from the paletteram */
static READ16_HANDLER( palette_r )
{
segac2_state *state = space->machine->driver_data<segac2_state>();
offset &= 0x1ff;
if (segac2_alt_palette_mode)
if (state->segac2_alt_palette_mode)
offset = ((offset << 1) & 0x100) | ((offset << 2) & 0x80) | ((~offset >> 2) & 0x40) | ((offset >> 1) & 0x20) | (offset & 0x1f);
return space->machine->generic.paletteram.u16[offset + palbank * 0x200];
return state->paletteram[offset + state->palbank * 0x200];
}
/* handle writes to the paletteram */
static WRITE16_HANDLER( palette_w )
{
int r,g,b,newword;
int tmpr,tmpg,tmpb;
segac2_state *state = space->machine->driver_data<segac2_state>();
int r, g, b, newword;
int tmpr, tmpg, tmpb;
/* adjust for the palette bank */
offset &= 0x1ff;
if (segac2_alt_palette_mode)
if (state->segac2_alt_palette_mode)
offset = ((offset << 1) & 0x100) | ((offset << 2) & 0x80) | ((~offset >> 2) & 0x40) | ((offset >> 1) & 0x20) | (offset & 0x1f);
offset += palbank * 0x200;
offset += state->palbank * 0x200;
/* combine data */
COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
newword = space->machine->generic.paletteram.u16[offset];
COMBINE_DATA(&state->paletteram[offset]);
newword = state->paletteram[offset];
/* up to 8 bits */
r = ((newword << 1) & 0x1e) | ((newword >> 12) & 0x01);
@ -241,19 +219,22 @@ static WRITE16_HANDLER( palette_w )
/* set the color */
palette_set_color_rgb(space->machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
megadrive_vdp_palette_lookup[offset] = (b) | (g<<5) | (r<<10);
megadrive_vdp_palette_lookup_sprite[offset] = (b) | (g<<5) | (r<<10);
megadrive_vdp_palette_lookup[offset] = (b) | (g << 5) | (r << 10);
megadrive_vdp_palette_lookup_sprite[offset] = (b) | (g << 5) | (r << 10);
tmpr = r>>1;tmpg=g>>1;tmpb=b>>1;
megadrive_vdp_palette_lookup_shadow[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
tmpr = r >> 1;
tmpg = g >> 1;
tmpb = b >> 1;
megadrive_vdp_palette_lookup_shadow[offset] = (tmpb) | (tmpg << 5) | (tmpr << 10);
// how is it calculated on c2?
tmpr = tmpr|0x10; tmpg = tmpg|0x10; tmpb = tmpb|0x10;
megadrive_vdp_palette_lookup_highlight[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
tmpr = tmpr | 0x10;
tmpg = tmpg | 0x10;
tmpb = tmpb | 0x10;
megadrive_vdp_palette_lookup_highlight[offset] = (tmpb) | (tmpg << 5) | (tmpr << 10);
}
/******************************************************************************
Palette Tables
*******************************************************************************
@ -284,31 +265,31 @@ static WRITE16_HANDLER( palette_w )
******************************************************************************/
static void recompute_palette_tables(void)
static void recompute_palette_tables( running_machine *machine )
{
segac2_state *state = machine->driver_data<segac2_state>();
int i;
for (i = 0; i < 4; i++)
{
int bgpal = 0x000 + bg_palbase * 0x40 + i * 0x10;
int sppal = 0x100 + sp_palbase * 0x40 + i * 0x10;
int bgpal = 0x000 + state->bg_palbase * 0x40 + i * 0x10;
int sppal = 0x100 + state->sp_palbase * 0x40 + i * 0x10;
if (!segac2_alt_palette_mode)
if (!state->segac2_alt_palette_mode)
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + bgpal;
segac2_sp_pal_lookup[i] = 0x200 * palbank + sppal;
segac2_bg_pal_lookup[i] = 0x200 * state->palbank + bgpal;
segac2_sp_pal_lookup[i] = 0x200 * state->palbank + sppal;
}
else
{
segac2_bg_pal_lookup[i] = 0x200 * palbank + ((bgpal << 1) & 0x180) + ((~bgpal >> 2) & 0x40) + (bgpal & 0x30);
segac2_sp_pal_lookup[i] = 0x200 * palbank + ((~sppal << 2) & 0x100) + ((sppal << 2) & 0x80) + ((~sppal >> 2) & 0x40) + ((sppal >> 2) & 0x20) + (sppal & 0x10);
segac2_bg_pal_lookup[i] = 0x200 * state->palbank + ((bgpal << 1) & 0x180) + ((~bgpal >> 2) & 0x40) + (bgpal & 0x30);
segac2_sp_pal_lookup[i] = 0x200 * state->palbank + ((~sppal << 2) & 0x100) + ((sppal << 2) & 0x80) + ((~sppal >> 2) & 0x40) + ((sppal >> 2) & 0x20) + (sppal & 0x10);
}
}
}
/******************************************************************************
I/O Read & Write Handlers
*******************************************************************************
@ -323,6 +304,7 @@ static void recompute_palette_tables(void)
static READ16_HANDLER( io_chip_r )
{
segac2_state *state = space->machine->driver_data<segac2_state>();
static const char *const portnames[] = { "P1", "P2", "PORTC", "PORTD", "SERVICE", "COINAGE", "DSW", "PORTH" };
offset &= 0x1f/2;
@ -338,11 +320,11 @@ static READ16_HANDLER( io_chip_r )
case 0x0c/2:
case 0x0e/2:
/* if the port is configured as an output, return the last thing written */
if (misc_io_data[0x1e/2] & (1 << offset))
return misc_io_data[offset];
if (state->misc_io_data[0x1e/2] & (1 << offset))
return state->misc_io_data[offset];
/* otherwise, return an input port */
if (offset == 0x04/2 && sound_banks)
if (offset == 0x04/2 && state->sound_banks)
return (input_port_read(space->machine, portnames[offset]) & 0xbf) | (upd7759_busy_r(space->machine->device("upd")) << 6);
return input_port_read(space->machine, portnames[offset]);
@ -359,12 +341,12 @@ static READ16_HANDLER( io_chip_r )
/* CNT register & mirror */
case 0x18/2:
case 0x1c/2:
return misc_io_data[0x1c/2];
return state->misc_io_data[0x1c/2];
/* port direction register & mirror */
case 0x1a/2:
case 0x1e/2:
return misc_io_data[0x1e/2];
return state->misc_io_data[0x1e/2];
}
return 0xffff;
}
@ -372,13 +354,14 @@ static READ16_HANDLER( io_chip_r )
static WRITE16_HANDLER( io_chip_w )
{
segac2_state *state = space->machine->driver_data<segac2_state>();
UINT8 newbank;
UINT8 old;
/* generic implementation */
offset &= 0x1f/2;
old = misc_io_data[offset];
misc_io_data[offset] = data;
old = state->misc_io_data[offset];
state->misc_io_data[offset] = data;
switch (offset)
{
@ -422,23 +405,23 @@ static WRITE16_HANDLER( io_chip_w )
D0 : To A9 of color RAM
*/
newbank = data & 3;
if (newbank != palbank)
if (newbank != state->palbank)
{
//space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() + 1);
palbank = newbank;
recompute_palette_tables();
state->palbank = newbank;
recompute_palette_tables(space->machine);
}
if (sound_banks > 1)
if (state->sound_banks > 1)
{
device_t *upd = space->machine->device("upd");
newbank = (data >> 2) & (sound_banks - 1);
newbank = (data >> 2) & (state->sound_banks - 1);
upd7759_set_bank_base(upd, newbank * 0x20000);
}
break;
/* CNT register */
case 0x1c/2:
if (sound_banks > 1)
if (state->sound_banks > 1)
{
device_t *upd = space->machine->device("upd");
upd7759_reset_w(upd, (data >> 1) & 1);
@ -448,7 +431,6 @@ static WRITE16_HANDLER( io_chip_w )
}
/******************************************************************************
Control Write Handler
*******************************************************************************
@ -461,6 +443,7 @@ static WRITE16_HANDLER( io_chip_w )
static WRITE16_HANDLER( control_w )
{
segac2_state *state = space->machine->driver_data<segac2_state>();
/* skip if not LSB */
if (!ACCESSING_BITS_0_7)
return;
@ -468,19 +451,18 @@ static WRITE16_HANDLER( control_w )
/* bit 0 controls display enable */
//segac2_enable_display(space->machine, ~data & 1);
segac2_enable_display = ~data & 1;
state->segac2_enable_display = ~data & 1;
/* bit 1 resets the protection */
if (!(data & 2))
prot_write_buf = prot_read_buf = 0;
state->prot_write_buf = state->prot_read_buf = 0;
/* bit 2 controls palette shuffling; only ribbit and twinsqua use this feature */
segac2_alt_palette_mode = ((~data & 4) >> 2);
recompute_palette_tables();
state->segac2_alt_palette_mode = ((~data & 4) >> 2);
recompute_palette_tables(space->machine);
}
/******************************************************************************
Protection Read / Write Handlers
*******************************************************************************
@ -497,14 +479,16 @@ static WRITE16_HANDLER( control_w )
/* protection chip reads */
static READ16_HANDLER( prot_r )
{
if (LOG_PROTECTION) logerror("%06X:protection r=%02X\n", cpu_get_previouspc(space->cpu), prot_func ? prot_read_buf : 0xff);
return prot_read_buf | 0xf0;
segac2_state *state = space->machine->driver_data<segac2_state>();
if (LOG_PROTECTION) logerror("%06X:protection r=%02X\n", cpu_get_previouspc(space->cpu), state->prot_func ? state->prot_read_buf : 0xff);
return state->prot_read_buf | 0xf0;
}
/* protection chip writes */
static WRITE16_HANDLER( prot_w )
{
segac2_state *state = space->machine->driver_data<segac2_state>();
int new_sp_palbase = (data >> 2) & 3;
int new_bg_palbase = data & 3;
int table_index;
@ -514,29 +498,28 @@ static WRITE16_HANDLER( prot_w )
return;
/* compute the table index */
table_index = (prot_write_buf << 4) | prot_read_buf;
table_index = (state->prot_write_buf << 4) | state->prot_read_buf;
/* keep track of the last write for the next table lookup */
prot_write_buf = data & 0x0f;
state->prot_write_buf = data & 0x0f;
/* determine the value to return, should a read occur */
if (prot_func)
prot_read_buf = prot_func(table_index);
if (LOG_PROTECTION) logerror("%06X:protection w=%02X, new result=%02X\n", cpu_get_previouspc(space->cpu), data & 0x0f, prot_read_buf);
if (state->prot_func)
state->prot_read_buf = state->prot_func(table_index);
if (LOG_PROTECTION) logerror("%06X:protection w=%02X, new result=%02X\n", cpu_get_previouspc(space->cpu), data & 0x0f, state->prot_read_buf);
/* if the palette changed, force an update */
if (new_sp_palbase != sp_palbase || new_bg_palbase != bg_palbase)
if (new_sp_palbase != state->sp_palbase || new_bg_palbase != state->bg_palbase)
{
//space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() + 1);
sp_palbase = new_sp_palbase;
bg_palbase = new_bg_palbase;
recompute_palette_tables();
if (LOG_PALETTE) logerror("Set palbank: %d/%d (scan=%d)\n", bg_palbase, sp_palbase, space->machine->primary_screen->vpos());
state->sp_palbase = new_sp_palbase;
state->bg_palbase = new_bg_palbase;
recompute_palette_tables(space->machine);
if (LOG_PALETTE) logerror("Set palbank: %d/%d (scan=%d)\n", state->bg_palbase, state->sp_palbase, space->machine->primary_screen->vpos());
}
}
/******************************************************************************
Counter/timer I/O
*******************************************************************************
@ -588,7 +571,6 @@ static WRITE16_HANDLER( counter_timer_w )
}
/******************************************************************************
Print Club camera handling
*******************************************************************************
@ -597,21 +579,19 @@ static WRITE16_HANDLER( counter_timer_w )
******************************************************************************/
static int cam_data;
static READ16_HANDLER( printer_r )
{
return cam_data;
segac2_state *state = space->machine->driver_data<segac2_state>();
return state->cam_data;
}
static WRITE16_HANDLER( print_club_camera_w )
{
cam_data = data;
segac2_state *state = space->machine->driver_data<segac2_state>();
state->cam_data = data;
}
/******************************************************************************
Memory Maps
*******************************************************************************
@ -629,13 +609,12 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x840000, 0x84001f) AM_MIRROR(0x13fee0) AM_READWRITE(io_chip_r, io_chip_w)
AM_RANGE(0x840100, 0x840107) AM_MIRROR(0x13fef8) AM_DEVREADWRITE8("ymsnd", ym3438_r, ym3438_w, 0x00ff)
AM_RANGE(0x880100, 0x880101) AM_MIRROR(0x13fefe) AM_WRITE(counter_timer_w)
AM_RANGE(0x8c0000, 0x8c0fff) AM_MIRROR(0x13f000) AM_READWRITE(palette_r, palette_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x8c0000, 0x8c0fff) AM_MIRROR(0x13f000) AM_READWRITE(palette_r, palette_w) AM_BASE_MEMBER(segac2_state, paletteram)
AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x18ff00) AM_READWRITE(megadriv_vdp_r, megadriv_vdp_w)
AM_RANGE(0xe00000, 0xe0ffff) AM_MIRROR(0x1f0000) AM_RAM AM_SHARE("nvram")
ADDRESS_MAP_END
/******************************************************************************
Input Ports
*******************************************************************************
@ -1325,7 +1304,6 @@ static const ym3438_interface ym3438_intf =
};
/******************************************************************************
Machine Drivers
*******************************************************************************
@ -1342,7 +1320,6 @@ static VIDEO_START(segac2_new)
{
VIDEO_START_CALL(megadriv);
megadrive_vdp_palette_lookup = auto_alloc_array(machine, UINT16, 0x1000/2);
megadrive_vdp_palette_lookup_sprite = auto_alloc_array(machine, UINT16, 0x1000/2);
megadrive_vdp_palette_lookup_shadow = auto_alloc_array(machine, UINT16, 0x1000/2);
@ -1351,7 +1328,8 @@ static VIDEO_START(segac2_new)
static VIDEO_UPDATE(segac2_new)
{
if (!segac2_enable_display)
segac2_state *state = screen->machine->driver_data<segac2_state>();
if (!state->segac2_enable_display)
{
bitmap_fill(bitmap, NULL, get_black_pen(screen->machine));
return 0;
@ -1362,7 +1340,7 @@ static VIDEO_UPDATE(segac2_new)
}
static MACHINE_CONFIG_START( segac, driver_device )
static MACHINE_CONFIG_START( segac, segac2_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, XL2_CLOCK/6)
@ -1834,11 +1812,12 @@ it should be, otherwise I don't see how the formula could be computed.
static void segac2_common_init(running_machine* machine, int (*func)(int in))
{
segac2_state *state = machine->driver_data<segac2_state>();
device_t *upd = machine->device("upd");
DRIVER_INIT_CALL( megadriv_c2 );
prot_func = func;
state->prot_func = func;
genvdp_use_cram = 0;
genesis_always_irq6 = 1;
@ -2167,7 +2146,6 @@ static DRIVER_INIT( ichirj )
static DRIVER_INIT( ichirjbl )
{
/* when did this actually work? - the protection is patched but the new check fails? */
UINT16 *rom = (UINT16 *)machine->region("maincpu")->base();
rom[0x390/2] = 0x6600;

View File

@ -19,6 +19,9 @@ INPUT_PORTS_EXTERN( mk3mdb );
INPUT_PORTS_EXTERN( megdsvp );
MACHINE_CONFIG_EXTERN( megadriv_timers );
MACHINE_CONFIG_EXTERN( md_ntsc );
MACHINE_CONFIG_EXTERN( md_pal );
MACHINE_CONFIG_EXTERN( md_svp );
MACHINE_CONFIG_EXTERN( megdsvppal );
MACHINE_CONFIG_EXTERN( megadriv );
@ -33,6 +36,7 @@ MACHINE_CONFIG_EXTERN( md_bootleg ); // for topshoot.c & hshavoc.c
extern UINT16* megadriv_backupram;
extern int megadriv_backupram_length;
extern UINT16* megadrive_ram;
extern UINT8 megatech_bios_port_cc_dc_r(running_machine *machine, int offset, int ctrl);
extern void megadriv_stop_scanline_timer(void);
@ -85,36 +89,171 @@ extern int megadrive_region_pal;
#define MP_ROM 0x10
#define MP_GAME 0
struct _mplay_bios /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
class md_base_state : public driver_device
{
UINT32 bios_mode; // determines whether ROM banks or Game data
// is to read from 0x8000-0xffff
public:
md_base_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
};
class md_boot_state : public md_base_state
{
public:
md_boot_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
// bootleg specific
int aladmdb_mcu_port;
};
class segac2_state : public md_base_state
{
public:
segac2_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
// for Print Club only
int cam_data;
int segac2_enable_display;
UINT16* paletteram;
/* internal states */
UINT8 misc_io_data[0x10]; /* holds values written to the I/O chip */
/* protection-related tracking */
int (*prot_func)(int in); /* emulation of protection chip */
UINT8 prot_write_buf; /* remembers what was written */
UINT8 prot_read_buf; /* remembers what was returned */
/* palette-related variables */
UINT8 segac2_alt_palette_mode;
UINT8 palbank;
UINT8 bg_palbase;
UINT8 sp_palbase;
/* sound-related variables */
UINT8 sound_banks; /* number of sound banks */
};
class mplay_state : public md_base_state
{
public:
mplay_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
UINT32 bios_mode; // determines whether ROM banks or Game data
// is to read from 0x8000-0xffff
UINT32 bios_bank; // ROM bank selection
UINT16 game_banksel; // Game bank selection
UINT32 readpos; // serial bank selection position (9-bit)
UINT32 mp_bios_bank_addr;
UINT32 bios_width; // determines the way the game info ROM is read
UINT8 bios_ctrl[6];
UINT8 bios_6600;
UINT8 bios_6403;
UINT8 bios_6404;
UINT16 *genesis_io_ram;
UINT8* ic3_ram;
UINT8* ic37_ram;
UINT16 *ic36_ram;
};
extern struct _mplay_bios mplay_bios; // defined in megaplay.c
struct _mtech_bios /* once all the regs are saved in this structure, it would be better to reorganize it a bit... */
class mtech_state : public md_base_state
{
public:
mtech_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
UINT8 mt_cart_select_reg;
UINT32 bios_port_ctrl;
int current_game_is_sms; // is the current game SMS based (running on genesis z80, in VDP compatibility mode)
UINT32 bios_ctrl_inputs;
UINT8 bios_ctrl[6];
int mt_bank_addr;
int cart_is_genesis[8];
/* Megatech BIOS specific */
UINT8* megatech_banked_ram;
};
typedef struct _megadriv_cart megadriv_cart;
struct _megadriv_cart
{
int type;
// SRAM related
UINT16 *sram;
int last_loaded_image_length;
int sram_start, sram_end;
int sram_active, sram_readonly;
int sram_handlers_installed;
int sram_detected;
// EEPROM related
int has_serial_eeprom;
// I2C related
UINT8 i2c_mem, i2c_clk;
// mapper related (mostly for pirate carts)
UINT16 squirrel_king_extra;
UINT16 lion2_prot1_data, lion2_prot2_data;
UINT16 realtec_bank_addr, realtec_bank_size, realtec_old_bank_addr;
UINT16 l3alt_pdat, l3alt_pcmd;
int ssf2_lastoff, ssf2_lastdata;
};
class md_cons_state : public md_base_state
{
public:
md_cons_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
emu_timer *mess_io_timeout[3];
int mess_io_stage[3];
UINT8 jcart_io_data[2];
megadriv_cart md_cart;
};
class pico_state : public md_base_state
{
public:
pico_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
UINT8 page_register;
};
class mdsvp_state : public md_base_state
{
public:
mdsvp_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
};
class _32x_state : public md_base_state
{
public:
_32x_state(running_machine &machine, const driver_device_config_base &config)
: md_base_state(machine, config) { }
};
class segacd_state : public _32x_state // use _32x_state as base to make easier the combo 32X + SCD
{
public:
segacd_state(running_machine &machine, const driver_device_config_base &config)
: _32x_state(machine, config) { }
};
/*----------- defined in machine/md_cart.c -----------*/
MACHINE_CONFIG_EXTERN( genesis_cartslot );

File diff suppressed because it is too large Load Diff

View File

@ -6310,6 +6310,12 @@ INPUT_PORTS_START( megdsvp )
PORT_DIPSETTING( 0x01, DEF_STR( On ) )
INPUT_PORTS_END
MACHINE_CONFIG_FRAGMENT( md_svp )
MCFG_CPU_ADD("svp", SSP1601, MASTER_CLOCK_NTSC / 7 * 3) /* ~23 MHz (guessed) */
MCFG_CPU_PROGRAM_MAP(svp_ssp_map)
MCFG_CPU_IO_MAP(svp_ext_map)
MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED( megdsvp, megadriv )
MCFG_CPU_ADD("svp", SSP1601, MASTER_CLOCK_NTSC / 7 * 3) /* ~23 MHz (guessed) */
@ -8652,7 +8658,7 @@ MACHINE_CONFIG_FRAGMENT( megadriv_timers )
MACHINE_CONFIG_END
MACHINE_CONFIG_START( megadriv, driver_device )
MACHINE_CONFIG_FRAGMENT( md_ntsc )
MCFG_CPU_ADD("maincpu", M68000, MASTER_CLOCK_NTSC / 7) /* 7.67 MHz */
MCFG_CPU_PROGRAM_MAP(megadriv_map)
/* IRQs are handled via the timers */
@ -8697,9 +8703,13 @@ MACHINE_CONFIG_START( megadriv, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker",0.25) /* 3.58 MHz */
MACHINE_CONFIG_END
MACHINE_CONFIG_START( megadriv, driver_device )
MCFG_FRAGMENT_ADD(md_ntsc)
MACHINE_CONFIG_END
/************ PAL hardware has a different master clock *************/
MACHINE_CONFIG_START( megadpal, driver_device )
MACHINE_CONFIG_FRAGMENT( md_pal )
MCFG_CPU_ADD("maincpu", M68000, MASTER_CLOCK_PAL / 7) /* 7.67 MHz */
MCFG_CPU_PROGRAM_MAP(megadriv_map)
/* IRQs are handled via the timers */
@ -8744,6 +8754,9 @@ MACHINE_CONFIG_START( megadpal, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker",0.25) /* 3.58 MHz */
MACHINE_CONFIG_END
MACHINE_CONFIG_START( megadpal, driver_device )
MCFG_FRAGMENT_ADD(md_pal)
MACHINE_CONFIG_END
static int _32x_fifo_available_callback(UINT32 src, UINT32 dst, UINT32 data, int size)