Added driver_data struct and save states to the following drivers: matmania.c, metlclsh.c, mexico86.c, mouser.c, mrflea.c, mrjong.c, munchmo.c and mwarr.c

Added driver_data struct to the following drivers: mgolf.c, minivadr.c, mosaic.c and mrdo.c

Enabled save states to mugsmash.c (everything was already saved)
This commit is contained in:
Fabio Priuli 2010-02-23 19:18:49 +00:00
parent 84070c2bfa
commit a47eb26d5b
36 changed files with 2158 additions and 1282 deletions

7
.gitattributes vendored
View File

@ -2640,6 +2640,7 @@ src/mame/includes/megasys1.h svneol=native#text/plain
src/mame/includes/megazone.h svneol=native#text/plain src/mame/includes/megazone.h svneol=native#text/plain
src/mame/includes/mermaid.h svneol=native#text/plain src/mame/includes/mermaid.h svneol=native#text/plain
src/mame/includes/metalmx.h svneol=native#text/plain src/mame/includes/metalmx.h svneol=native#text/plain
src/mame/includes/metlclsh.h svneol=native#text/plain
src/mame/includes/mexico86.h svneol=native#text/plain src/mame/includes/mexico86.h svneol=native#text/plain
src/mame/includes/mhavoc.h svneol=native#text/plain src/mame/includes/mhavoc.h svneol=native#text/plain
src/mame/includes/micro3d.h svneol=native#text/plain src/mame/includes/micro3d.h svneol=native#text/plain
@ -2656,8 +2657,14 @@ src/mame/includes/model2.h svneol=native#text/plain
src/mame/includes/model3.h svneol=native#text/plain src/mame/includes/model3.h svneol=native#text/plain
src/mame/includes/momoko.h svneol=native#text/plain src/mame/includes/momoko.h svneol=native#text/plain
src/mame/includes/moo.h svneol=native#text/plain src/mame/includes/moo.h svneol=native#text/plain
src/mame/includes/mosaic.h svneol=native#text/plain
src/mame/includes/mouser.h svneol=native#text/plain
src/mame/includes/mrdo.h svneol=native#text/plain
src/mame/includes/mrflea.h svneol=native#text/plain
src/mame/includes/mrjong.h svneol=native#text/plain
src/mame/includes/ms32.h svneol=native#text/plain src/mame/includes/ms32.h svneol=native#text/plain
src/mame/includes/mugsmash.h svneol=native#text/plain src/mame/includes/mugsmash.h svneol=native#text/plain
src/mame/includes/munchmo.h svneol=native#text/plain
src/mame/includes/mw8080bw.h svneol=native#text/plain src/mame/includes/mw8080bw.h svneol=native#text/plain
src/mame/includes/mystston.h svneol=native#text/plain src/mame/includes/mystston.h svneol=native#text/plain
src/mame/includes/n64.h svneol=native#text/plain src/mame/includes/n64.h svneol=native#text/plain

View File

@ -39,53 +39,66 @@ The driver has been updated accordingly.
#include "sound/3526intf.h" #include "sound/3526intf.h"
#include "includes/matmania.h" #include "includes/matmania.h"
/*************************************
*
* Memory handlers
*
*************************************/
static WRITE8_HANDLER( matmania_sh_command_w ) static WRITE8_HANDLER( matmania_sh_command_w )
{ {
soundlatch_w(space,offset,data); matmania_state *state = (matmania_state *)space->machine->driver_data;
cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE); soundlatch_w(space, offset, data);
cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
} }
static WRITE8_HANDLER( maniach_sh_command_w ) static WRITE8_HANDLER( maniach_sh_command_w )
{ {
matmania_state *state = (matmania_state *)space->machine->driver_data;
soundlatch_w(space, offset, data); soundlatch_w(space, offset, data);
cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE); cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE);
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( matmania_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( matmania_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x077f) AM_RAM AM_RANGE(0x0000, 0x077f) AM_RAM
AM_RANGE(0x0780, 0x07df) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x0780, 0x07df) AM_WRITEONLY AM_BASE_SIZE_MEMBER(matmania_state, spriteram, spriteram_size)
AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size) AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram2, videoram2_size)
AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2) AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram2)
AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size) AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram, videoram_size)
AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram) AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram)
AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size) AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram3, videoram3_size)
AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3) AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram3)
AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect) AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, pageselect)
AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(matmania_sh_command_w) AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(matmania_sh_command_w)
AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE(&matmania_scroll) AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, scroll)
AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */ AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */
AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_MEMBER(matmania_state, paletteram)
AM_RANGE(0x4000, 0xffff) AM_ROM AM_RANGE(0x4000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( maniach_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( maniach_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x077f) AM_RAM AM_RANGE(0x0000, 0x077f) AM_RAM
AM_RANGE(0x0780, 0x07df) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x0780, 0x07df) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, spriteram, spriteram_size)
AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size) AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram2, videoram2_size)
AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2) AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram2)
AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size) AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram, videoram_size)
AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram) AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram)
AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size) AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram3, videoram3_size)
AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3) AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram3)
AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect) AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, pageselect)
AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(maniach_sh_command_w) AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(maniach_sh_command_w)
AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE(&matmania_scroll) AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, scroll)
AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */ AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */
AM_RANGE(0x3040, 0x3040) AM_READWRITE(maniach_mcu_r,maniach_mcu_w) AM_RANGE(0x3040, 0x3040) AM_READWRITE(maniach_mcu_r,maniach_mcu_w)
AM_RANGE(0x3041, 0x3041) AM_READ(maniach_mcu_status_r) AM_RANGE(0x3041, 0x3041) AM_READ(maniach_mcu_status_r)
AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_MEMBER(matmania_state, paletteram)
AM_RANGE(0x4000, 0xffff) AM_ROM AM_RANGE(0x4000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -110,17 +123,23 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( maniach_mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( maniach_mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(maniach_68705_portA_r,maniach_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READWRITE(maniach_68705_port_a_r,maniach_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(maniach_68705_portB_r,maniach_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READWRITE(maniach_68705_port_b_r,maniach_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(maniach_68705_portC_r,maniach_68705_portC_w) AM_RANGE(0x0002, 0x0002) AM_READWRITE(maniach_68705_port_c_r,maniach_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(maniach_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(maniach_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(maniach_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(maniach_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(maniach_68705_ddrC_w) AM_RANGE(0x0006, 0x0006) AM_WRITE(maniach_68705_ddr_c_w)
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM AM_RANGE(0x0080, 0x07ff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( matmania ) static INPUT_PORTS_START( matmania )
PORT_START("IN0") PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
@ -191,6 +210,12 @@ static INPUT_PORTS_START( maniach )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout charlayout = static const gfx_layout charlayout =
{ {
8,8, /* 8*8 characters */ 8,8, /* 8*8 characters */
@ -268,8 +293,26 @@ GFXDECODE_END
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( matmania )
{
matmania_state *state = (matmania_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->mcu = devtag_get_device(machine, "mcu");
}
static MACHINE_DRIVER_START( matmania ) static MACHINE_DRIVER_START( matmania )
/* driver data */
MDRV_DRIVER_DATA(matmania_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, 1500000) /* 1.5 MHz ???? */ MDRV_CPU_ADD("maincpu", M6502, 1500000) /* 1.5 MHz ???? */
MDRV_CPU_PROGRAM_MAP(matmania_map) MDRV_CPU_PROGRAM_MAP(matmania_map)
@ -281,6 +324,8 @@ static MACHINE_DRIVER_START( matmania )
/* IRQs are caused by the main CPU */ /* IRQs are caused by the main CPU */
MDRV_QUANTUM_TIME(HZ(600)) MDRV_QUANTUM_TIME(HZ(600))
MDRV_MACHINE_START(matmania)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -314,7 +359,8 @@ MACHINE_DRIVER_END
/* handler called by the 3526 emulator when the internal timers cause an IRQ */ /* handler called by the 3526 emulator when the internal timers cause an IRQ */
static void irqhandler(running_device *device, int linestate) static void irqhandler(running_device *device, int linestate)
{ {
cputag_set_input_line(device->machine, "audiocpu", 1, linestate); matmania_state *state = (matmania_state *)device->machine->driver_data;
cpu_set_input_line(state->audiocpu, 1, linestate);
} }
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
@ -323,8 +369,51 @@ static const ym3526_interface ym3526_config =
}; };
static MACHINE_START( maniach )
{
matmania_state *state = (matmania_state *)machine->driver_data;
MACHINE_START_CALL(matmania);
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
state_save_register_global(machine, state->mcu_sent);
state_save_register_global(machine, state->main_sent);
state_save_register_global(machine, state->from_main);
state_save_register_global(machine, state->from_mcu);
}
static MACHINE_RESET( maniach )
{
matmania_state *state = (matmania_state *)machine->driver_data;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
state->mcu_sent = 0;
state->main_sent = 0;
state->from_main = 0;
state->from_mcu = 0;
}
static MACHINE_DRIVER_START( maniach ) static MACHINE_DRIVER_START( maniach )
/* driver data */
MDRV_DRIVER_DATA(matmania_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, 1500000) /* 1.5 MHz ???? */ MDRV_CPU_ADD("maincpu", M6502, 1500000) /* 1.5 MHz ???? */
MDRV_CPU_PROGRAM_MAP(maniach_map) MDRV_CPU_PROGRAM_MAP(maniach_map)
@ -339,6 +428,9 @@ static MACHINE_DRIVER_START( maniach )
MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slice per frame - high interleaving to sync main and mcu */ MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slice per frame - high interleaving to sync main and mcu */
MDRV_MACHINE_START(maniach)
MDRV_MACHINE_RESET(maniach)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -365,11 +457,11 @@ static MACHINE_DRIVER_START( maniach )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************************************************** /*************************************
*
Mat Mania driver * ROM definition(s)
*
***************************************************************************/ *************************************/
ROM_START( matmania ) ROM_START( matmania )
ROM_REGION( 0x10000, "maincpu", 0 ) ROM_REGION( 0x10000, "maincpu", 0 )
@ -593,7 +685,13 @@ ROM_END
GAME( 1985, matmania, 0, matmania, matmania, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", 0 ) /*************************************
GAME( 1985, excthour, matmania, matmania, maniach, 0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", 0 ) *
GAME( 1986, maniach, 0, maniach, maniach, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", 0 ) * Game driver(s)
GAME( 1986, maniach2, maniach, maniach, maniach, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)" , 0) /* earlier version? */ *
*************************************/
GAME( 1985, matmania, 0, matmania, matmania, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", GAME_SUPPORTS_SAVE )
GAME( 1985, excthour, matmania, matmania, maniach, 0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE )
GAME( 1986, maniach, 0, maniach, maniach, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE )
GAME( 1986, maniach2, maniach, maniach, maniach, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE ) /* earlier version? */

View File

@ -36,20 +36,8 @@ metlclsh:
#include "cpu/m6809/m6809.h" #include "cpu/m6809/m6809.h"
#include "sound/2203intf.h" #include "sound/2203intf.h"
#include "sound/3526intf.h" #include "sound/3526intf.h"
#include "includes/metlclsh.h"
/* Variables defined in video: */
extern UINT8 *metlclsh_bgram, *metlclsh_fgram, *metlclsh_scrollx;
/* Functions defined in video: */
WRITE8_HANDLER( metlclsh_bgram_w );
WRITE8_HANDLER( metlclsh_fgram_w );
WRITE8_HANDLER( metlclsh_gfxbank_w );
WRITE8_HANDLER( metlclsh_rambank_w );
VIDEO_START( metlclsh );
VIDEO_UPDATE( metlclsh );
/*************************************************************************** /***************************************************************************
@ -59,12 +47,14 @@ VIDEO_UPDATE( metlclsh );
static WRITE8_HANDLER( metlclsh_cause_irq ) static WRITE8_HANDLER( metlclsh_cause_irq )
{ {
cputag_set_input_line(space->machine, "sub", M6809_IRQ_LINE, ASSERT_LINE); metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
cpu_set_input_line(state->subcpu, M6809_IRQ_LINE, ASSERT_LINE);
} }
static WRITE8_HANDLER( metlclsh_ack_nmi ) static WRITE8_HANDLER( metlclsh_ack_nmi )
{ {
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, CLEAR_LINE);
} }
static ADDRESS_MAP_START( metlclsh_master_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( metlclsh_master_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -81,9 +71,9 @@ static ADDRESS_MAP_START( metlclsh_master_map, ADDRESS_SPACE_PROGRAM, 8 )
/**/AM_RANGE(0xc800, 0xc82f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split1_w) AM_BASE_GENERIC(paletteram) /**/AM_RANGE(0xc800, 0xc82f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split1_w) AM_BASE_GENERIC(paletteram)
/**/AM_RANGE(0xcc00, 0xcc2f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split2_w) AM_BASE_GENERIC(paletteram2) /**/AM_RANGE(0xcc00, 0xcc2f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xd000, 0xd001) AM_DEVREADWRITE("ym1", ym2203_r,ym2203_w) AM_RANGE(0xd000, 0xd001) AM_DEVREADWRITE("ym1", ym2203_r,ym2203_w)
/**/AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(metlclsh_fgram_w) AM_BASE(&metlclsh_fgram) /**/AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(metlclsh_fgram_w) AM_BASE_MEMBER(metlclsh_state, fgram)
AM_RANGE(0xe000, 0xe001) AM_DEVWRITE("ym2", ym3526_w ) AM_RANGE(0xe000, 0xe001) AM_DEVWRITE("ym2", ym3526_w )
AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_MEMBER(metlclsh_state, spriteram, spriteram_size)
AM_RANGE(0xfff0, 0xffff) AM_ROM // Reset/IRQ vectors AM_RANGE(0xfff0, 0xffff) AM_ROM // Reset/IRQ vectors
ADDRESS_MAP_END ADDRESS_MAP_END
@ -96,17 +86,20 @@ ADDRESS_MAP_END
static WRITE8_HANDLER( metlclsh_cause_nmi2 ) static WRITE8_HANDLER( metlclsh_cause_nmi2 )
{ {
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, ASSERT_LINE);
} }
static WRITE8_HANDLER( metlclsh_ack_irq2 ) static WRITE8_HANDLER( metlclsh_ack_irq2 )
{ {
cputag_set_input_line(space->machine, "sub", M6809_IRQ_LINE, CLEAR_LINE); metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
cpu_set_input_line(state->subcpu, M6809_IRQ_LINE, CLEAR_LINE);
} }
static WRITE8_HANDLER( metlclsh_ack_nmi2 ) static WRITE8_HANDLER( metlclsh_ack_nmi2 )
{ {
cputag_set_input_line(space->machine, "sub", INPUT_LINE_NMI, CLEAR_LINE); metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
cpu_set_input_line(state->subcpu, INPUT_LINE_NMI, CLEAR_LINE);
} }
static WRITE8_HANDLER( metlclsh_flipscreen_w ) static WRITE8_HANDLER( metlclsh_flipscreen_w )
@ -123,10 +116,10 @@ static ADDRESS_MAP_START( metlclsh_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc003, 0xc003) AM_READ_PORT("DSW") AM_RANGE(0xc003, 0xc003) AM_READ_PORT("DSW")
AM_RANGE(0xc0c0, 0xc0c0) AM_WRITE(metlclsh_cause_nmi2) // cause nmi on cpu #1 AM_RANGE(0xc0c0, 0xc0c0) AM_WRITE(metlclsh_cause_nmi2) // cause nmi on cpu #1
AM_RANGE(0xc0c1, 0xc0c1) AM_WRITE(metlclsh_ack_irq2) // irq ack AM_RANGE(0xc0c1, 0xc0c1) AM_WRITE(metlclsh_ack_irq2) // irq ack
AM_RANGE(0xd000, 0xd7ff) AM_ROMBANK("bank1") AM_WRITE(metlclsh_bgram_w) AM_BASE(&metlclsh_bgram) // this is banked AM_RANGE(0xd000, 0xd7ff) AM_ROMBANK("bank1") AM_WRITE(metlclsh_bgram_w) AM_BASE_MEMBER(metlclsh_state, bgram) // this is banked
AM_RANGE(0xe301, 0xe301) AM_WRITE(metlclsh_flipscreen_w) // 0/1 AM_RANGE(0xe301, 0xe301) AM_WRITE(metlclsh_flipscreen_w) // 0/1
AM_RANGE(0xe401, 0xe401) AM_WRITE(metlclsh_rambank_w) AM_RANGE(0xe401, 0xe401) AM_WRITE(metlclsh_rambank_w)
AM_RANGE(0xe402, 0xe403) AM_WRITEONLY AM_BASE(&metlclsh_scrollx) AM_RANGE(0xe402, 0xe403) AM_WRITEONLY AM_BASE_MEMBER(metlclsh_state, scrollx)
// AM_RANGE(0xe404, 0xe404) AM_WRITENOP // ? 0 // AM_RANGE(0xe404, 0xe404) AM_WRITENOP // ? 0
// AM_RANGE(0xe410, 0xe410) AM_WRITENOP // ? 0 on startup only // AM_RANGE(0xe410, 0xe410) AM_WRITENOP // ? 0 on startup only
AM_RANGE(0xe417, 0xe417) AM_WRITE(metlclsh_ack_nmi2) // nmi ack AM_RANGE(0xe417, 0xe417) AM_WRITE(metlclsh_ack_nmi2) // nmi ack
@ -167,22 +160,22 @@ static INPUT_PORTS_START( metlclsh )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("IN1") /* c001 */ PORT_START("IN1") /* c001 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
PORT_START("IN2") /* c002 */ PORT_START("IN2") /* c002 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_COCKTAIL PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_COCKTAIL
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
@ -262,7 +255,8 @@ GFXDECODE_END
static void metlclsh_irqhandler(running_device *device, int linestate) static void metlclsh_irqhandler(running_device *device, int linestate)
{ {
cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, linestate); metlclsh_state *state = (metlclsh_state *)device->machine->driver_data;
cpu_set_input_line(state->maincpu, M6809_IRQ_LINE, linestate);
} }
static const ym3526_interface ym3526_config = static const ym3526_interface ym3526_config =
@ -279,13 +273,32 @@ static INTERRUPT_GEN( metlclsh_interrupt2 )
cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE); cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE);
} }
static MACHINE_START( metlclsh )
{
metlclsh_state *state = (metlclsh_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->subcpu = devtag_get_device(machine, "sub");
state_save_register_global(machine, state->write_mask);
state_save_register_global(machine, state->gfxbank);
}
static MACHINE_RESET( metlclsh ) static MACHINE_RESET( metlclsh )
{ {
metlclsh_state *state = (metlclsh_state *)machine->driver_data;
flip_screen_set(machine, 0); flip_screen_set(machine, 0);
state->write_mask = 0;
state->gfxbank = 0;
} }
static MACHINE_DRIVER_START( metlclsh ) static MACHINE_DRIVER_START( metlclsh )
/* driver data */
MDRV_DRIVER_DATA(metlclsh_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6809, 1500000) // ? MDRV_CPU_ADD("maincpu", M6809, 1500000) // ?
MDRV_CPU_PROGRAM_MAP(metlclsh_master_map) MDRV_CPU_PROGRAM_MAP(metlclsh_master_map)
@ -296,6 +309,7 @@ static MACHINE_DRIVER_START( metlclsh )
MDRV_CPU_VBLANK_INT_HACK(metlclsh_interrupt2,2) MDRV_CPU_VBLANK_INT_HACK(metlclsh_interrupt2,2)
// IRQ by cpu #1, NMI by coins insertion // IRQ by cpu #1, NMI by coins insertion
MDRV_MACHINE_START(metlclsh)
MDRV_MACHINE_RESET(metlclsh) MDRV_MACHINE_RESET(metlclsh)
/* video hardware */ /* video hardware */
@ -430,4 +444,4 @@ ROM_START( metlclsh )
ROM_LOAD( "82s123.prm", 0x0000, 0x20, CRC(6844cc88) SHA1(89d23367aa6ff541205416e82781fe938dfeeb52) ) ROM_LOAD( "82s123.prm", 0x0000, 0x20, CRC(6844cc88) SHA1(89d23367aa6ff541205416e82781fe938dfeeb52) )
ROM_END ROM_END
GAME( 1985, metlclsh, 0, metlclsh, metlclsh, 0, ROT0, "Data East", "Metal Clash (Japan)", 0 ) GAME( 1985, metlclsh, 0, metlclsh, metlclsh, 0, ROT0, "Data East", "Metal Clash (Japan)", GAME_SUPPORTS_SAVE )

View File

@ -41,7 +41,7 @@ Notes:
Note MCU labeling: Note MCU labeling:
Bubble Bobble KiKi KaiKai Kick and RUN Bubble Bobble KiKi KaiKai Kick and Run
------------- ------------- ------------- ------------- ------------- -------------
TAITO A78-01 TAITO A85-01 TAITO A87-01 TAITO A78-01 TAITO A85-01 TAITO A87-01
JPH1011P JPH1020P JPH1021P JPH1011P JPH1020P JPH1021P
@ -57,24 +57,38 @@ PS4 J8635 PS4 J8541 PS4 J8648
#include "sound/2203intf.h" #include "sound/2203intf.h"
#include "includes/mexico86.h" #include "includes/mexico86.h"
//AT
/*************************************
*
* Memory handlers
*
*************************************/
static READ8_DEVICE_HANDLER( kiki_ym2203_r ) static READ8_DEVICE_HANDLER( kiki_ym2203_r )
{ {
UINT8 result = ym2203_r(device, offset); UINT8 result = ym2203_r(device, offset);
if (offset == 0) if (offset == 0)
result &= 0x7f; result &= 0x7f;
return result; return result;
} }
//ZT
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( mexico86_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mexico86_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") /* banked roms */ AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") /* banked roms */
AM_RANGE(0xc000, 0xe7ff) AM_RAM AM_SHARE("share1") /* shared with sound cpu */ AM_RANGE(0xc000, 0xe7ff) AM_RAM AM_SHARE("share1") /* shared with sound cpu */
AM_RANGE(0xd500, 0xd7ff) AM_RAM AM_BASE(&mexico86_objectram) AM_SIZE(&mexico86_objectram_size) AM_RANGE(0xd500, 0xd7ff) AM_RAM AM_BASE_SIZE_MEMBER(mexico86_state, objectram, objectram_size)
AM_RANGE(0xe800, 0xe8ff) AM_RAM AM_BASE(&mexico86_protection_ram) /* shared with mcu */ AM_RANGE(0xe800, 0xe8ff) AM_RAM AM_BASE_MEMBER(mexico86_state, protection_ram) /* shared with mcu */
AM_RANGE(0xe900, 0xefff) AM_RAM AM_RANGE(0xe900, 0xefff) AM_RAM
AM_RANGE(0xc000, 0xd4ff) AM_RAM AM_BASE(&mexico86_videoram) //AT: corrected size AM_RANGE(0xc000, 0xd4ff) AM_RAM AM_BASE_MEMBER(mexico86_state, videoram)
AM_RANGE(0xf000, 0xf000) AM_WRITE(mexico86_bankswitch_w) /* program and gfx ROM banks */ AM_RANGE(0xf000, 0xf000) AM_WRITE(mexico86_bankswitch_w) /* program and gfx ROM banks */
AM_RANGE(0xf008, 0xf008) AM_WRITE(mexico86_f008_w) /* cpu reset lines + other unknown stuff */ AM_RANGE(0xf008, 0xf008) AM_WRITE(mexico86_f008_w) /* cpu reset lines + other unknown stuff */
AM_RANGE(0xf010, 0xf010) AM_READ_PORT("IN3") AM_RANGE(0xf010, 0xf010) AM_READ_PORT("IN3")
@ -91,11 +105,11 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( mexico86_m68705_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mexico86_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(mexico86_68705_portA_r,mexico86_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READWRITE(mexico86_68705_port_a_r,mexico86_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(mexico86_68705_portB_r,mexico86_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READWRITE(mexico86_68705_port_b_r,mexico86_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READ_PORT("IN0") /* COIN */ AM_RANGE(0x0002, 0x0002) AM_READ_PORT("IN0") /* COIN */
AM_RANGE(0x0004, 0x0004) AM_WRITE(mexico86_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(mexico86_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(mexico86_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(mexico86_68705_ddr_b_w)
AM_RANGE(0x000a, 0x000a) AM_WRITENOP /* looks like a bug in the code, writes to */ AM_RANGE(0x000a, 0x000a) AM_WRITENOP /* looks like a bug in the code, writes to */
/* 0x0a (=10dec) instead of 0x10 */ /* 0x0a (=10dec) instead of 0x10 */
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
@ -121,8 +135,14 @@ static ADDRESS_MAP_START( mexico86_sub_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc004, 0xc004) AM_WRITE(mexico86_sub_output_w) AM_RANGE(0xc004, 0xc004) AM_WRITE(mexico86_sub_output_w)
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( mexico86 ) static INPUT_PORTS_START( mexico86 )
PORT_START("IN0") /* IN0 */ PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -132,7 +152,7 @@ static INPUT_PORTS_START( mexico86 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN1") /* IN1 */ PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
@ -142,7 +162,7 @@ static INPUT_PORTS_START( mexico86 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) /* service 2 */ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) /* service 2 */
PORT_START("IN2") /* IN2 */ PORT_START("IN2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
@ -247,7 +267,7 @@ static INPUT_PORTS_START( mexico86 )
INPUT_PORTS_END INPUT_PORTS_END
static INPUT_PORTS_START( kikikai ) static INPUT_PORTS_START( kikikai )
PORT_START("IN0") /* IN0 */ PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -257,7 +277,7 @@ static INPUT_PORTS_START( kikikai )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN1") /* IN1 */ PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
@ -267,7 +287,7 @@ static INPUT_PORTS_START( kikikai )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN2") /* IN2 */ PORT_START("IN2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
@ -277,8 +297,7 @@ static INPUT_PORTS_START( kikikai )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
//AT PORT_START("DSW0")
PORT_START("DSW0") /* DSW0 */
PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:1") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:1")
PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) )
@ -315,7 +334,7 @@ static INPUT_PORTS_START( kikikai )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) )
PORT_START("DSW1") /* DSW1 */ PORT_START("DSW1")
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2") PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2")
PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x02, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) PORT_DIPSETTING( 0x03, DEF_STR( Normal ) )
@ -337,7 +356,6 @@ static INPUT_PORTS_START( kikikai )
PORT_DIPNAME( 0x80, 0x00, "Number Match" ) PORT_DIPLOCATION("SW2:8") PORT_DIPNAME( 0x80, 0x00, "Number Match" ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) )
//ZT
PORT_START("IN3") PORT_START("IN3")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
@ -352,6 +370,12 @@ INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout charlayout = static const gfx_layout charlayout =
{ {
8,8, 8,8,
@ -369,6 +393,12 @@ GFXDECODE_END
/*************************************
*
* Sound interfaces
*
*************************************/
static const ym2203_interface ym2203_config = static const ym2203_interface ym2203_config =
{ {
{ {
@ -383,15 +413,69 @@ static const ym2203_interface ym2203_config =
}; };
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( mexico86 )
{
mexico86_state *state = (mexico86_state *)machine->driver_data;
UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, "bank1", 0, 6, &ROM[0x10000], 0x4000);
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->subcpu = devtag_get_device(machine, "sub");
state->mcu = devtag_get_device(machine, "mcu");
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->address);
state_save_register_global(machine, state->latch);
state_save_register_global(machine, state->mcu_running);
state_save_register_global(machine, state->mcu_initialised);
state_save_register_global(machine, state->coin_last);
state_save_register_global(machine, state->charbank);
}
static MACHINE_RESET( mexico86 ) static MACHINE_RESET( mexico86 )
{ {
mexico86_state *state = (mexico86_state *)machine->driver_data;
/*TODO: check the PCB and see how the halt / reset lines are connected. */ /*TODO: check the PCB and see how the halt / reset lines are connected. */
if (devtag_get_device(machine, "sub") != NULL) if (devtag_get_device(machine, "sub") != NULL)
cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, (input_port_read(machine, "DSW1") & 0x80) ? ASSERT_LINE : CLEAR_LINE); cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, (input_port_read(machine, "DSW1") & 0x80) ? ASSERT_LINE : CLEAR_LINE);
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->address = 0;
state->latch = 0;
state->mcu_running = 0;
state->mcu_initialised = 0;
state->coin_last = 0;
state->charbank = 0;
} }
static MACHINE_DRIVER_START( mexico86 ) static MACHINE_DRIVER_START( mexico86 )
/* driver data */
MDRV_DRIVER_DATA(mexico86_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu",Z80, 24000000/4) /* 6 MHz, Uses clock divided 24MHz OSC */ MDRV_CPU_ADD("maincpu",Z80, 24000000/4) /* 6 MHz, Uses clock divided 24MHz OSC */
MDRV_CPU_PROGRAM_MAP(mexico86_map) MDRV_CPU_PROGRAM_MAP(mexico86_map)
@ -408,9 +492,9 @@ static MACHINE_DRIVER_START( mexico86 )
MDRV_CPU_PROGRAM_MAP(mexico86_sub_cpu_map) MDRV_CPU_PROGRAM_MAP(mexico86_sub_cpu_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame - an high value to ensure proper */ MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame - an high value to ensure proper synchronization of the CPUs */
/* synchronization of the CPUs */
MDRV_MACHINE_START(mexico86)
MDRV_MACHINE_RESET(mexico86) MDRV_MACHINE_RESET(mexico86)
/* video hardware */ /* video hardware */
@ -466,11 +550,11 @@ static MACHINE_DRIVER_START( kikikai )
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************************************************** /*************************************
*
Game driver(s) * ROM definition(s)
*
***************************************************************************/ *************************************/
ROM_START( kikikai ) ROM_START( kikikai )
ROM_REGION( 0x28000, "maincpu", 0 ) ROM_REGION( 0x28000, "maincpu", 0 )
@ -622,8 +706,14 @@ ROM_START( mexico86 )
ROM_END ROM_END
GAME( 1986, kikikai, 0, kikikai, kikikai, 0, ROT90, "Taito Corporation", "KiKi KaiKai", 0 ) /*************************************
GAME( 1986, knightb, kikikai, knightb, kikikai, 0, ROT90, "bootleg", "Knight Boy", 0 ) *
GAME( 1986, kicknrun, 0, mexico86, mexico86, 0, ROT0, "Taito Corporation", "Kick and Run (World)", 0 ) * Game driver(s)
GAME( 1986, kicknrunu,kicknrun, mexico86, mexico86, 0, ROT0, "Taito America Corp", "Kick and Run (US)", 0 ) *
GAME( 1986, mexico86, kicknrun, mexico86, mexico86, 0, ROT0, "bootleg", "Mexico 86", 0 ) *************************************/
GAME( 1986, kikikai, 0, kikikai, kikikai, 0, ROT90, "Taito Corporation", "KiKi KaiKai", GAME_SUPPORTS_SAVE )
GAME( 1986, knightb, kikikai, knightb, kikikai, 0, ROT90, "bootleg", "Knight Boy", GAME_SUPPORTS_SAVE )
GAME( 1986, kicknrun, 0, mexico86, mexico86, 0, ROT0, "Taito Corporation", "Kick and Run (World)", GAME_SUPPORTS_SAVE )
GAME( 1986, kicknrunu,kicknrun, mexico86, mexico86, 0, ROT0, "Taito America Corp", "Kick and Run (US)", GAME_SUPPORTS_SAVE )
GAME( 1986, mexico86, kicknrun, mexico86, mexico86, 0, ROT0, "bootleg", "Mexico 86", GAME_SUPPORTS_SAVE )

View File

@ -7,20 +7,30 @@
#include "emu.h" #include "emu.h"
#include "cpu/m6502/m6502.h" #include "cpu/m6502/m6502.h"
static UINT8* mgolf_video_ram; typedef struct _mgolf_state mgolf_state;
struct _mgolf_state
{
/* memory pointers */
UINT8* video_ram;
static attotime time_pushed; /* video-related */
static attotime time_released; tilemap_t* bg_tilemap;
static UINT8 prev = 0; /* misc */
static UINT8 mask = 0; UINT8 prev;
UINT8 mask;
attotime time_pushed;
attotime time_released;
static tilemap_t* bg_tilemap; /* devices */
running_device *maincpu;
};
static TILE_GET_INFO( get_tile_info ) static TILE_GET_INFO( get_tile_info )
{ {
UINT8 code = mgolf_video_ram[tile_index]; mgolf_state *state = (mgolf_state *)machine->driver_data;
UINT8 code = state->video_ram[tile_index];
SET_TILE_INFO(0, code, code >> 7, 0); SET_TILE_INFO(0, code, code >> 7, 0);
} }
@ -28,75 +38,78 @@ static TILE_GET_INFO( get_tile_info )
static WRITE8_HANDLER( mgolf_vram_w ) static WRITE8_HANDLER( mgolf_vram_w )
{ {
mgolf_video_ram[offset] = data; mgolf_state *state = (mgolf_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset); state->video_ram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
static VIDEO_START( mgolf ) static VIDEO_START( mgolf )
{ {
bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32); mgolf_state *state = (mgolf_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
} }
static VIDEO_UPDATE( mgolf ) static VIDEO_UPDATE( mgolf )
{ {
mgolf_state *state = (mgolf_state *)screen->machine->driver_data;
int i; int i;
/* draw playfield */ /* draw playfield */
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
/* draw sprites */ /* draw sprites */
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
mgolf_video_ram[0x399 + 4 * i], state->video_ram[0x399 + 4 * i],
i, i,
0, 0, 0, 0,
mgolf_video_ram[0x390 + 2 * i] - 7, state->video_ram[0x390 + 2 * i] - 7,
mgolf_video_ram[0x398 + 4 * i] - 16, 0); state->video_ram[0x398 + 4 * i] - 16, 0);
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
mgolf_video_ram[0x39b + 4 * i], state->video_ram[0x39b + 4 * i],
i, i,
0, 0, 0, 0,
mgolf_video_ram[0x390 + 2 * i] - 15, state->video_ram[0x390 + 2 * i] - 15,
mgolf_video_ram[0x39a + 4 * i] - 16, 0); state->video_ram[0x39a + 4 * i] - 16, 0);
} }
return 0; return 0;
} }
static void update_plunger(running_machine *machine) static void update_plunger( running_machine *machine )
{ {
mgolf_state *state = (mgolf_state *)machine->driver_data;
UINT8 val = input_port_read(machine, "BUTTON"); UINT8 val = input_port_read(machine, "BUTTON");
if (prev != val) if (state->prev != val)
{ {
if (val == 0) if (val == 0)
{ {
time_released = timer_get_time(machine); state->time_released = timer_get_time(machine);
if (!mask) if (!state->mask)
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
} }
else else
time_pushed = timer_get_time(machine); state->time_pushed = timer_get_time(machine);
prev = val; state->prev = val;
} }
} }
static TIMER_CALLBACK( interrupt_callback ) static TIMER_CALLBACK( interrupt_callback )
{ {
mgolf_state *state = (mgolf_state *)machine->driver_data;
int scanline = param; int scanline = param;
update_plunger(machine); update_plunger(machine);
generic_pulse_irq_line(devtag_get_device(machine, "maincpu"), 0); generic_pulse_irq_line(state->maincpu, 0);
scanline = scanline + 32; scanline = scanline + 32;
@ -109,28 +122,15 @@ static TIMER_CALLBACK( interrupt_callback )
static double calc_plunger_pos(running_machine *machine) static double calc_plunger_pos(running_machine *machine)
{ {
return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2); mgolf_state *state = (mgolf_state *)machine->driver_data;
} return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2);
static MACHINE_RESET( mgolf )
{
timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback);
}
static PALETTE_INIT( mgolf )
{
palette_set_color(machine, 0, MAKE_RGB(0x80, 0x80, 0x80));
palette_set_color(machine, 1, MAKE_RGB(0x00, 0x00, 0x00));
palette_set_color(machine, 2, MAKE_RGB(0x80, 0x80, 0x80));
palette_set_color(machine, 3, MAKE_RGB(0xff, 0xff, 0xff));
} }
static READ8_HANDLER( mgolf_wram_r ) static READ8_HANDLER( mgolf_wram_r )
{ {
return mgolf_video_ram[0x380 + offset]; mgolf_state *state = (mgolf_state *)space->machine->driver_data;
return state->video_ram[0x380 + offset];
} }
@ -172,7 +172,8 @@ static READ8_HANDLER( mgolf_misc_r )
static WRITE8_HANDLER( mgolf_wram_w ) static WRITE8_HANDLER( mgolf_wram_w )
{ {
mgolf_video_ram[0x380 + offset] = data; mgolf_state *state = (mgolf_state *)space->machine->driver_data;
state->video_ram[0x380 + offset] = data;
} }
@ -201,7 +202,7 @@ static ADDRESS_MAP_START( cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x006d, 0x006d) AM_WRITENOP AM_RANGE(0x006d, 0x006d) AM_WRITENOP
AM_RANGE(0x0080, 0x00ff) AM_WRITE(mgolf_wram_w) AM_RANGE(0x0080, 0x00ff) AM_WRITE(mgolf_wram_w)
AM_RANGE(0x0180, 0x01ff) AM_WRITE(mgolf_wram_w) AM_RANGE(0x0180, 0x01ff) AM_WRITE(mgolf_wram_w)
AM_RANGE(0x0800, 0x0bff) AM_WRITE(mgolf_vram_w) AM_BASE(&mgolf_video_ram) AM_RANGE(0x0800, 0x0bff) AM_WRITE(mgolf_vram_w) AM_BASE_MEMBER(mgolf_state, video_ram)
AM_RANGE(0x2000, 0x3fff) AM_ROM AM_RANGE(0x2000, 0x3fff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -209,7 +210,7 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( mgolf ) static INPUT_PORTS_START( mgolf )
PORT_START("40") /* 40 */ PORT_START("40")
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Language ) ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Language ) )
PORT_DIPSETTING( 0x00, DEF_STR( English ) ) PORT_DIPSETTING( 0x00, DEF_STR( English ) )
PORT_DIPSETTING( 0x10, DEF_STR( French ) ) PORT_DIPSETTING( 0x10, DEF_STR( French ) )
@ -221,19 +222,19 @@ static INPUT_PORTS_START( mgolf )
PORT_DIPSETTING( 0x80, "35" ) PORT_DIPSETTING( 0x80, "35" )
PORT_DIPSETTING( 0xc0, "40" ) PORT_DIPSETTING( 0xc0, "40" )
PORT_START("41") /* 41 */ PORT_START("41")
PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL A */ PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL A */
PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL B */ PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL B */
PORT_BIT ( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT ( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK ) PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
PORT_START("60") /* 60 */ PORT_START("60")
PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1)
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1)
PORT_START("61") /* 61 */ PORT_START("61")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Course Select") PORT_CODE(KEYCODE_SPACE) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Course Select") PORT_CODE(KEYCODE_SPACE)
PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 1 */ PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 1 */
PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 2 */ PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 2 */
@ -248,6 +249,14 @@ static INPUT_PORTS_START( mgolf )
INPUT_PORTS_END INPUT_PORTS_END
static PALETTE_INIT( mgolf )
{
palette_set_color(machine, 0, MAKE_RGB(0x80, 0x80, 0x80));
palette_set_color(machine, 1, MAKE_RGB(0x00, 0x00, 0x00));
palette_set_color(machine, 2, MAKE_RGB(0x80, 0x80, 0x80));
palette_set_color(machine, 3, MAKE_RGB(0xff, 0xff, 0xff));
}
static const gfx_layout tile_layout = static const gfx_layout tile_layout =
{ {
8, 8, 8, 8,
@ -287,12 +296,36 @@ static GFXDECODE_START( mgolf )
GFXDECODE_END GFXDECODE_END
static MACHINE_START( mgolf )
{
mgolf_state *state = (mgolf_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state_save_register_global(machine, state->prev);
state_save_register_global(machine, state->mask);
}
static MACHINE_RESET( mgolf )
{
mgolf_state *state = (mgolf_state *)machine->driver_data;
timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback);
state->mask = 0;
state->prev = 0;
}
static MACHINE_DRIVER_START( mgolf ) static MACHINE_DRIVER_START( mgolf )
/* driver data */
MDRV_DRIVER_DATA(mgolf_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, 12096000 / 16) /* ? */ MDRV_CPU_ADD("maincpu", M6502, 12096000 / 16) /* ? */
MDRV_CPU_PROGRAM_MAP(cpu_map) MDRV_CPU_PROGRAM_MAP(cpu_map)
MDRV_MACHINE_START(mgolf)
MDRV_MACHINE_RESET(mgolf) MDRV_MACHINE_RESET(mgolf)
/* video hardware */ /* video hardware */

View File

@ -14,6 +14,13 @@ Japan). It has no sound.
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
typedef struct _minivadr_state minivadr_state;
struct _minivadr_state
{
/* memory pointers */
UINT8 * videoram;
size_t videoram_size;
};
/************************************* /*************************************
* *
@ -23,15 +30,16 @@ Japan). It has no sound.
static VIDEO_UPDATE( minivadr ) static VIDEO_UPDATE( minivadr )
{ {
minivadr_state *state = (minivadr_state *)screen->machine->driver_data;
offs_t offs; offs_t offs;
for (offs = 0; offs < screen->machine->generic.videoram_size; offs++) for (offs = 0; offs < state->videoram_size; offs++)
{ {
int i; int i;
UINT8 x = offs << 3; UINT8 x = offs << 3;
int y = offs >> 5; int y = offs >> 5;
UINT8 data = screen->machine->generic.videoram.u8[offs]; UINT8 data = state->videoram[offs];
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
@ -49,7 +57,7 @@ static VIDEO_UPDATE( minivadr )
static ADDRESS_MAP_START( minivadr_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( minivadr_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram) AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE_SIZE_MEMBER(minivadr_state, videoram, videoram_size)
AM_RANGE(0xe008, 0xe008) AM_READ_PORT("INPUTS") AM_WRITENOP // W - ??? AM_RANGE(0xe008, 0xe008) AM_READ_PORT("INPUTS") AM_WRITENOP // W - ???
ADDRESS_MAP_END ADDRESS_MAP_END
@ -69,6 +77,9 @@ INPUT_PORTS_END
static MACHINE_DRIVER_START( minivadr ) static MACHINE_DRIVER_START( minivadr )
/* driver data */
MDRV_DRIVER_DATA(minivadr_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,24000000 / 6) /* 4 MHz ? */ MDRV_CPU_ADD("maincpu", Z80,24000000 / 6) /* 4 MHz ? */
MDRV_CPU_PROGRAM_MAP(minivadr_map) MDRV_CPU_PROGRAM_MAP(minivadr_map)
@ -100,4 +111,4 @@ ROM_START( minivadr )
ROM_END ROM_END
GAME( 1990, minivadr, 0, minivadr, minivadr, 0, ROT0, "Taito Corporation", "Minivader", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW) GAME( 1990, minivadr, 0, minivadr, minivadr, 0, ROT0, "Taito Corporation", "Minivader", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW )

View File

@ -1,34 +1,25 @@
/*************************************************************************** /***************************************************************************
Mosaic (c) 1990 Space Mosaic (c) 1990 Space
Notes: Notes:
- the ROM OK / RAM OK message in service mode is fake: ROM and RAM are not tested. - the ROM OK / RAM OK message in service mode is fake: ROM and RAM are not tested.
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "cpu/z180/z180.h" #include "cpu/z180/z180.h"
#include "sound/2203intf.h" #include "sound/2203intf.h"
#include "includes/mosaic.h"
extern UINT8 *mosaic_fgvideoram;
extern UINT8 *mosaic_bgvideoram;
WRITE8_HANDLER( mosaic_fgvideoram_w );
WRITE8_HANDLER( mosaic_bgvideoram_w );
VIDEO_START( mosaic );
VIDEO_UPDATE( mosaic );
static int prot_val;
static WRITE8_HANDLER( protection_w ) static WRITE8_HANDLER( protection_w )
{ {
if ((data & 0x80) == 0) mosaic_state *state = (mosaic_state *)space->machine->driver_data;
if (!BIT(data, 7))
{ {
/* simply increment given value */ /* simply increment given value */
prot_val = (data + 1) << 8; state->prot_val = (data + 1) << 8;
} }
else else
{ {
@ -43,24 +34,27 @@ static WRITE8_HANDLER( protection_w )
0x411f, 0x473f 0x411f, 0x473f
}; };
prot_val = jumptable[data & 0x7f]; state->prot_val = jumptable[data & 0x7f];
} }
} }
static READ8_HANDLER( protection_r ) static READ8_HANDLER( protection_r )
{ {
int res = (prot_val >> 8) & 0xff; mosaic_state *state = (mosaic_state *)space->machine->driver_data;
int res = (state->prot_val >> 8) & 0xff;
logerror("%06x: protection_r %02x\n",cpu_get_pc(space->cpu),res); logerror("%06x: protection_r %02x\n", cpu_get_pc(space->cpu), res);
prot_val <<= 8; state->prot_val <<= 8;
return res; return res;
} }
static WRITE8_HANDLER( gfire2_protection_w ) static WRITE8_HANDLER( gfire2_protection_w )
{ {
logerror("%06x: protection_w %02x\n",cpu_get_pc(space->cpu),data); mosaic_state *state = (mosaic_state *)space->machine->driver_data;
logerror("%06x: protection_w %02x\n", cpu_get_pc(space->cpu), data);
switch(data) switch(data)
{ {
@ -68,28 +62,29 @@ static WRITE8_HANDLER( gfire2_protection_w )
/* written repeatedly; no effect?? */ /* written repeatedly; no effect?? */
break; break;
case 0x02: case 0x02:
prot_val = 0x0a10; state->prot_val = 0x0a10;
break; break;
case 0x04: case 0x04:
prot_val = 0x0a15; state->prot_val = 0x0a15;
break; break;
case 0x06: case 0x06:
prot_val = 0x80e3; state->prot_val = 0x80e3;
break; break;
case 0x08: case 0x08:
prot_val = 0x0965; state->prot_val = 0x0965;
break; break;
case 0x0a: case 0x0a:
prot_val = 0x04b4; state->prot_val = 0x04b4;
break; break;
} }
} }
static READ8_HANDLER( gfire2_protection_r ) static READ8_HANDLER( gfire2_protection_r )
{ {
int res = prot_val & 0xff; mosaic_state *state = (mosaic_state *)space->machine->driver_data;
int res = state->prot_val & 0xff;
prot_val >>= 8; state->prot_val >>= 8;
return res; return res;
} }
@ -99,16 +94,16 @@ static READ8_HANDLER( gfire2_protection_r )
static ADDRESS_MAP_START( mosaic_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mosaic_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_RANGE(0x00000, 0x0ffff) AM_ROM
AM_RANGE(0x20000, 0x21fff) AM_RAM AM_RANGE(0x20000, 0x21fff) AM_RAM
AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE(&mosaic_bgvideoram) AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE_MEMBER(mosaic_state, bgvideoram)
AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE(&mosaic_fgvideoram) AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE_MEMBER(mosaic_state, fgvideoram)
AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( gfire2_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( gfire2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_RANGE(0x00000, 0x0ffff) AM_ROM
AM_RANGE(0x10000, 0x17fff) AM_RAM AM_RANGE(0x10000, 0x17fff) AM_RAM
AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE(&mosaic_bgvideoram) AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE_MEMBER(mosaic_state, bgvideoram)
AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE(&mosaic_fgvideoram) AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE_MEMBER(mosaic_state, fgvideoram)
AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -258,12 +253,34 @@ static const ym2203_interface ym2203_config =
static MACHINE_START( mosaic )
{
mosaic_state *state = (mosaic_state *)machine->driver_data;
state_save_register_global(machine, state->prot_val);
}
static MACHINE_RESET( mosaic )
{
mosaic_state *state = (mosaic_state *)machine->driver_data;
state->prot_val = 0;
}
static MACHINE_DRIVER_START( mosaic ) static MACHINE_DRIVER_START( mosaic )
/* driver data */
MDRV_DRIVER_DATA(mosaic_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z180, 7000000) /* ??? */ MDRV_CPU_ADD("maincpu", Z180, 7000000) /* ??? */
MDRV_CPU_PROGRAM_MAP(mosaic_map) MDRV_CPU_PROGRAM_MAP(mosaic_map)
MDRV_CPU_IO_MAP(mosaic_io_map) MDRV_CPU_IO_MAP(mosaic_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(mosaic)
MDRV_MACHINE_RESET(mosaic)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)

View File

@ -16,30 +16,21 @@
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "deprecat.h" #include "deprecat.h"
#include "sound/ay8910.h" #include "sound/ay8910.h"
#include "includes/mouser.h"
static UINT8 mouser_sound_byte;
static UINT8 mouser_nmi_enable;
/* From "video/mouser.c" */
extern UINT8 *mouser_videoram;
extern UINT8 *mouser_colorram;
PALETTE_INIT( mouser );
WRITE8_HANDLER( mouser_flip_screen_x_w );
WRITE8_HANDLER( mouser_flip_screen_y_w );
VIDEO_UPDATE( mouser );
/* Mouser has external masking circuitry around /* Mouser has external masking circuitry around
* the NMI input on the main CPU */ * the NMI input on the main CPU */
static WRITE8_HANDLER( mouser_nmi_enable_w ) static WRITE8_HANDLER( mouser_nmi_enable_w )
{ {
mouser_nmi_enable = data; mouser_state *state = (mouser_state *)space->machine->driver_data;
state->nmi_enable = data;
} }
static INTERRUPT_GEN( mouser_nmi_interrupt ) static INTERRUPT_GEN( mouser_nmi_interrupt )
{ {
if ((mouser_nmi_enable & 1) == 1) mouser_state *state = (mouser_state *)device->machine->driver_data;
if (BIT(state->nmi_enable, 0))
nmi_line_pulse(device); nmi_line_pulse(device);
} }
@ -47,22 +38,24 @@ static INTERRUPT_GEN( mouser_nmi_interrupt )
static WRITE8_HANDLER( mouser_sound_interrupt_w ) static WRITE8_HANDLER( mouser_sound_interrupt_w )
{ {
mouser_sound_byte = data; mouser_state *state = (mouser_state *)space->machine->driver_data;
cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); state->sound_byte = data;
cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
} }
static READ8_HANDLER( mouser_sound_byte_r ) static READ8_HANDLER( mouser_sound_byte_r )
{ {
return mouser_sound_byte; mouser_state *state = (mouser_state *)space->machine->driver_data;
return state->sound_byte;
} }
static ADDRESS_MAP_START( mouser_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mouser_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x6bff) AM_RAM AM_RANGE(0x6000, 0x6bff) AM_RAM
AM_RANGE(0x8800, 0x88ff) AM_WRITENOP /* unknown */ AM_RANGE(0x8800, 0x88ff) AM_WRITENOP /* unknown */
AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE(&mouser_videoram) AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE_MEMBER(mouser_state, videoram)
AM_RANGE(0x9800, 0x9cff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x9800, 0x9cff) AM_RAM AM_BASE_SIZE_MEMBER(mouser_state, spriteram, spriteram_size)
AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE(&mouser_colorram) AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE_MEMBER(mouser_state, colorram)
AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(mouser_nmi_enable_w) /* bit 0 = NMI Enable */ AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(mouser_nmi_enable_w) /* bit 0 = NMI Enable */
AM_RANGE(0xa001, 0xa001) AM_WRITE(mouser_flip_screen_x_w) AM_RANGE(0xa001, 0xa001) AM_WRITE(mouser_flip_screen_x_w)
AM_RANGE(0xa002, 0xa002) AM_WRITE(mouser_flip_screen_y_w) AM_RANGE(0xa002, 0xa002) AM_WRITE(mouser_flip_screen_y_w)
@ -178,8 +171,30 @@ static GFXDECODE_START( mouser )
GFXDECODE_END GFXDECODE_END
static MACHINE_START( mouser )
{
mouser_state *state = (mouser_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state_save_register_global(machine, state->sound_byte);
state_save_register_global(machine, state->nmi_enable);
}
static MACHINE_RESET( mouser )
{
mouser_state *state = (mouser_state *)machine->driver_data;
state->sound_byte = 0;
state->nmi_enable = 0;
}
static MACHINE_DRIVER_START( mouser ) static MACHINE_DRIVER_START( mouser )
/* driver data */
MDRV_DRIVER_DATA(mouser_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz ? */ MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz ? */
MDRV_CPU_PROGRAM_MAP(mouser_map) MDRV_CPU_PROGRAM_MAP(mouser_map)
@ -190,6 +205,9 @@ static MACHINE_DRIVER_START( mouser )
MDRV_CPU_IO_MAP(mouser_sound_io_map) MDRV_CPU_IO_MAP(mouser_sound_io_map)
MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,4) /* ??? This controls the sound tempo */ MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,4) /* ??? This controls the sound tempo */
MDRV_MACHINE_START(mouser)
MDRV_MACHINE_RESET(mouser)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -275,12 +293,12 @@ static DRIVER_INIT( mouser )
memory_set_decrypted_region(space, 0x0000, 0x5fff, decrypted); memory_set_decrypted_region(space, 0x0000, 0x5fff, decrypted);
for (i = 0;i < 0x6000;i++) for (i = 0; i < 0x6000; i++)
{ {
decrypted[i] = table[rom[i]]; decrypted[i] = table[rom[i]];
} }
} }
GAME( 1983, mouser, 0, mouser, mouser, mouser, ROT90, "UPL", "Mouser", 0 ) GAME( 1983, mouser, 0, mouser, mouser, mouser, ROT90, "UPL", "Mouser", GAME_SUPPORTS_SAVE )
GAME( 1983, mouserc, mouser, mouser, mouser, mouser, ROT90, "[UPL] (Cosmos license)", "Mouser (Cosmos)", 0 ) GAME( 1983, mouserc, mouser, mouser, mouser, mouser, ROT90, "[UPL] (Cosmos license)", "Mouser (Cosmos)", GAME_SUPPORTS_SAVE )

View File

@ -22,38 +22,29 @@ There's a chance that certain bootlegs might have the different 8/20 MHz XTALS.
#include "emu.h" #include "emu.h"
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "sound/sn76496.h" #include "sound/sn76496.h"
#include "includes/mrdo.h"
#define MAIN_CLOCK XTAL_8_2MHz #define MAIN_CLOCK XTAL_8_2MHz
#define VIDEO_CLOCK XTAL_19_6MHz #define VIDEO_CLOCK XTAL_19_6MHz
extern UINT8 *mrdo_bgvideoram,*mrdo_fgvideoram;
WRITE8_HANDLER( mrdo_bgvideoram_w );
WRITE8_HANDLER( mrdo_fgvideoram_w );
WRITE8_HANDLER( mrdo_scrollx_w );
WRITE8_HANDLER( mrdo_scrolly_w );
WRITE8_HANDLER( mrdo_flipscreen_w );
PALETTE_INIT( mrdo );
VIDEO_START( mrdo );
VIDEO_UPDATE( mrdo );
/* this looks like some kind of protection. The game doesn't clear the screen */ /* this looks like some kind of protection. The game doesn't clear the screen */
/* if a read from this address doesn't return the value it expects. */ /* if a read from this address doesn't return the value it expects. */
static READ8_HANDLER( mrdo_SECRE_r ) static READ8_HANDLER( mrdo_SECRE_r )
{ {
UINT8 *RAM = memory_region(space->machine, "maincpu"); UINT8 *RAM = memory_region(space->machine, "maincpu");
return RAM[ cpu_get_reg(space->cpu, Z80_HL) ]; return RAM[cpu_get_reg(space->cpu, Z80_HL)];
} }
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(mrdo_bgvideoram_w) AM_BASE(&mrdo_bgvideoram) AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(mrdo_bgvideoram_w) AM_BASE_MEMBER(mrdo_state, bgvideoram)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(mrdo_fgvideoram_w) AM_BASE(&mrdo_fgvideoram) AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(mrdo_fgvideoram_w) AM_BASE_MEMBER(mrdo_state, fgvideoram)
AM_RANGE(0x9000, 0x90ff) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x9000, 0x90ff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(mrdo_state, spriteram, spriteram_size)
AM_RANGE(0x9800, 0x9800) AM_WRITE(mrdo_flipscreen_w) /* screen flip + playfield priority */ AM_RANGE(0x9800, 0x9800) AM_WRITE(mrdo_flipscreen_w) /* screen flip + playfield priority */
AM_RANGE(0x9801, 0x9801) AM_DEVWRITE("sn1", sn76496_w) AM_RANGE(0x9801, 0x9801) AM_DEVWRITE("sn1", sn76496_w)
AM_RANGE(0x9802, 0x9802) AM_DEVWRITE("sn2", sn76496_w) AM_RANGE(0x9802, 0x9802) AM_DEVWRITE("sn2", sn76496_w)
@ -176,6 +167,9 @@ GFXDECODE_END
static MACHINE_DRIVER_START( mrdo ) static MACHINE_DRIVER_START( mrdo )
/* driver data */
MDRV_DRIVER_DATA(mrdo_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, MAIN_CLOCK/2) /* Verified */ MDRV_CPU_ADD("maincpu", Z80, MAIN_CLOCK/2) /* Verified */
MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_PROGRAM_MAP(main_map)

View File

@ -43,19 +43,231 @@ Video Board
#include "deprecat.h" #include "deprecat.h"
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "sound/ay8910.h" #include "sound/ay8910.h"
#include "includes/mrflea.h"
static int mrflea_io;
static int mrflea_main;
static int mrflea_status; /*************************************
*
* Memory handlers
*
*************************************/
static int mrflea_select1; static WRITE8_HANDLER( mrflea_main_w )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
state->status |= 0x01; // pending command to main CPU
state->main = data;
}
extern WRITE8_HANDLER( mrflea_gfx_bank_w ); static WRITE8_HANDLER( mrflea_io_w )
extern WRITE8_HANDLER( mrflea_videoram_w ); {
extern WRITE8_HANDLER( mrflea_spriteram_w ); mrflea_state *state = (mrflea_state *)space->machine->driver_data;
extern VIDEO_START( mrflea ); state->status |= 0x08; // pending command to IO CPU
extern VIDEO_UPDATE( mrflea ); state->io = data;
cpu_set_input_line(state->subcpu, 0, HOLD_LINE );
}
static READ8_HANDLER( mrflea_main_r )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
state->status &= ~0x01; // main CPU command read
return state->main;
}
static READ8_HANDLER( mrflea_io_r )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
state->status &= ~0x08; // IO CPU command read
return state->io;
}
static READ8_HANDLER( mrflea_main_status_r )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
/* 0x01: main CPU command pending
0x08: io cpu ready */
return state->status ^ 0x08;
}
static READ8_HANDLER( mrflea_io_status_r )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
/* 0x08: IO CPU command pending
0x01: main cpu ready */
return state->status ^ 0x01;
}
static INTERRUPT_GEN( mrflea_slave_interrupt )
{
mrflea_state *state = (mrflea_state *)device->machine->driver_data;
if (cpu_getiloops(device) == 0 || (state->status & 0x08))
cpu_set_input_line(device, 0, HOLD_LINE);
}
static READ8_HANDLER( mrflea_interrupt_type_r )
{
/* there are two interrupt types:
1. triggered (in response to sound command)
2. heartbeat (for music timing)
*/
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
if (state->status & 0x08 )
return 0x00; /* process command */
return 0x01; /* music/sound update? */
}
static WRITE8_HANDLER( mrflea_select1_w )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
state->select1 = data;
}
static READ8_HANDLER( mrflea_input1_r )
{
return 0x00;
}
static WRITE8_HANDLER( mrflea_data1_w )
{
}
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( mrflea_master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(mrflea_videoram_w) AM_BASE_MEMBER(mrflea_state, videoram)
AM_RANGE(0xe800, 0xe83f) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_le_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xec00, 0xecff) AM_RAM_WRITE(mrflea_spriteram_w) AM_BASE_MEMBER(mrflea_state, spriteram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrflea_master_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_WRITENOP /* watchdog? */
AM_RANGE(0x40, 0x40) AM_WRITE(mrflea_io_w)
AM_RANGE(0x41, 0x41) AM_READ(mrflea_main_r)
AM_RANGE(0x42, 0x42) AM_READ(mrflea_main_status_r)
AM_RANGE(0x43, 0x43) AM_WRITENOP /* 0xa6,0x0d,0x05 */
AM_RANGE(0x60, 0x60) AM_WRITE(mrflea_gfx_bank_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrflea_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0fff) AM_ROM
AM_RANGE(0x2000, 0x3fff) AM_ROM
AM_RANGE(0x8000, 0x80ff) AM_RAM
AM_RANGE(0x9000, 0x905a) AM_RAM /* ? */
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrflea_slave_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_WRITENOP /* watchdog */
AM_RANGE(0x10, 0x10) AM_READ(mrflea_interrupt_type_r) AM_WRITENOP /* ? / irq ACK */
AM_RANGE(0x11, 0x11) AM_WRITENOP /* 0x83,0x00,0xfc */
AM_RANGE(0x20, 0x20) AM_READ(mrflea_io_r)
AM_RANGE(0x21, 0x21) AM_WRITE(mrflea_main_w)
AM_RANGE(0x22, 0x22) AM_READ(mrflea_io_status_r)
AM_RANGE(0x23, 0x23) AM_WRITENOP /* 0xb4,0x09,0x05 */
AM_RANGE(0x40, 0x40) AM_DEVREAD("ay1", ay8910_r)
AM_RANGE(0x40, 0x41) AM_DEVWRITE("ay1", ay8910_data_address_w)
AM_RANGE(0x42, 0x42) AM_READWRITE(mrflea_input1_r, mrflea_data1_w)
AM_RANGE(0x43, 0x43) AM_WRITE(mrflea_select1_w)
AM_RANGE(0x44, 0x44) AM_DEVREAD("ay2", ay8910_r)
AM_RANGE(0x44, 0x45) AM_DEVWRITE("ay2", ay8910_data_address_w)
AM_RANGE(0x46, 0x46) AM_DEVREAD("ay3", ay8910_r)
AM_RANGE(0x46, 0x47) AM_DEVWRITE("ay3", ay8910_data_address_w)
ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( mrflea )
PORT_START("IN0")
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN1")
PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("DSW1")
/*
------xx
-----x--
----x---
*/
PORT_DIPNAME( 0x03, 0x03, "Bonus?" )
PORT_DIPSETTING( 0x03, "A" )
PORT_DIPSETTING( 0x02, "B" )
PORT_DIPSETTING( 0x01, "C" )
PORT_DIPSETTING( 0x00, "D" )
PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSW2")
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x0c, "3" )
PORT_DIPSETTING( 0x08, "4" )
PORT_DIPSETTING( 0x04, "5" )
PORT_DIPSETTING( 0x00, "7" )
PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x30, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x20, DEF_STR( Medium ) )
PORT_DIPSETTING( 0x10, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout tile_layout = { static const gfx_layout tile_layout = {
8,8, 8,8,
@ -85,128 +297,11 @@ static GFXDECODE_START( mrflea )
GFXDECODE_ENTRY( "gfx2", 0, tile_layout, 0x00, 1 ) GFXDECODE_ENTRY( "gfx2", 0, tile_layout, 0x00, 1 )
GFXDECODE_END GFXDECODE_END
/*******************************************************/ /*************************************
*
static WRITE8_HANDLER( mrflea_main_w ) * Sound interfaces
{ *
mrflea_status |= 0x01; // pending command to main CPU *************************************/
mrflea_main = data;
}
static WRITE8_HANDLER( mrflea_io_w )
{
mrflea_status |= 0x08; // pending command to IO CPU
mrflea_io = data;
cputag_set_input_line(space->machine, "sub", 0, HOLD_LINE );
}
static READ8_HANDLER( mrflea_main_r )
{
mrflea_status &= ~0x01; // main CPU command read
return mrflea_main;
}
static READ8_HANDLER( mrflea_io_r )
{
mrflea_status &= ~0x08; // IO CPU command read
return mrflea_io;
}
/*******************************************************/
static READ8_HANDLER( mrflea_main_status_r )
{
/* 0x01: main CPU command pending
0x08: io cpu ready */
return mrflea_status^0x08;
}
static READ8_HANDLER( mrflea_io_status_r )
{
/* 0x08: IO CPU command pending
0x01: main cpu ready */
return mrflea_status^0x01;
}
static INTERRUPT_GEN( mrflea_slave_interrupt )
{
if( cpu_getiloops(device)==0 || (mrflea_status&0x08) )
cpu_set_input_line(device, 0, HOLD_LINE);
}
static READ8_HANDLER( mrflea_interrupt_type_r )
{
/* there are two interrupt types:
1. triggered (in response to sound command)
2. heartbeat (for music timing)
*/
if( mrflea_status&0x08 ) return 0x00; /* process command */
return 0x01; /* music/sound update? */
}
/*******************************************************/
static ADDRESS_MAP_START( mrflea_master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(mrflea_videoram_w) AM_BASE_GENERIC(videoram)
AM_RANGE(0xe800, 0xe83f) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_le_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xec00, 0xecff) AM_RAM_WRITE(mrflea_spriteram_w) AM_BASE_GENERIC(spriteram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrflea_master_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_WRITENOP /* watchdog? */
AM_RANGE(0x40, 0x40) AM_WRITE(mrflea_io_w)
AM_RANGE(0x41, 0x41) AM_READ(mrflea_main_r)
AM_RANGE(0x42, 0x42) AM_READ(mrflea_main_status_r)
AM_RANGE(0x43, 0x43) AM_WRITENOP /* 0xa6,0x0d,0x05 */
AM_RANGE(0x60, 0x60) AM_WRITE(mrflea_gfx_bank_w)
ADDRESS_MAP_END
/*******************************************************/
static WRITE8_HANDLER( mrflea_select1_w )
{
mrflea_select1 = data;
}
static READ8_HANDLER( mrflea_input1_r )
{
return 0x00;
}
static WRITE8_HANDLER( mrflea_data1_w )
{
}
static ADDRESS_MAP_START( mrflea_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0fff) AM_ROM
AM_RANGE(0x2000, 0x3fff) AM_ROM
AM_RANGE(0x8000, 0x80ff) AM_RAM
AM_RANGE(0x9000, 0x905a) AM_RAM /* ? */
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrflea_slave_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_WRITENOP /* watchdog */
AM_RANGE(0x10, 0x10) AM_READ(mrflea_interrupt_type_r) AM_WRITENOP /* ? / irq ACK */
AM_RANGE(0x11, 0x11) AM_WRITENOP /* 0x83,0x00,0xfc */
AM_RANGE(0x20, 0x20) AM_READ(mrflea_io_r)
AM_RANGE(0x21, 0x21) AM_WRITE(mrflea_main_w)
AM_RANGE(0x22, 0x22) AM_READ(mrflea_io_status_r)
AM_RANGE(0x23, 0x23) AM_WRITENOP /* 0xb4,0x09,0x05 */
AM_RANGE(0x40, 0x40) AM_DEVREAD("ay1", ay8910_r)
AM_RANGE(0x40, 0x41) AM_DEVWRITE("ay1", ay8910_data_address_w)
AM_RANGE(0x42, 0x42) AM_READWRITE(mrflea_input1_r, mrflea_data1_w)
AM_RANGE(0x43, 0x43) AM_WRITE(mrflea_select1_w)
AM_RANGE(0x44, 0x44) AM_DEVREAD("ay2", ay8910_r)
AM_RANGE(0x44, 0x45) AM_DEVWRITE("ay2", ay8910_data_address_w)
AM_RANGE(0x46, 0x46) AM_DEVREAD("ay3", ay8910_r)
AM_RANGE(0x46, 0x47) AM_DEVWRITE("ay3", ay8910_data_address_w)
ADDRESS_MAP_END
/*******************************************************/
static const ay8910_interface mrflea_ay8910_interface_0 = static const ay8910_interface mrflea_ay8910_interface_0 =
{ {
@ -224,8 +319,42 @@ static const ay8910_interface mrflea_ay8910_interface_1 =
DEVCB_INPUT_PORT("DSW1") DEVCB_INPUT_PORT("DSW1")
}; };
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( mrflea )
{
mrflea_state *state = (mrflea_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->subcpu = devtag_get_device(machine, "sub");
state_save_register_global(machine, state->gfx_bank);
state_save_register_global(machine, state->io);
state_save_register_global(machine, state->main);
state_save_register_global(machine, state->status);
state_save_register_global(machine, state->select1);
}
static MACHINE_RESET( mrflea )
{
mrflea_state *state = (mrflea_state *)machine->driver_data;
state->gfx_bank = 0;
state->io = 0;
state->main = 0;
state->status = 0;
state->select1 = 0;
}
static MACHINE_DRIVER_START( mrflea ) static MACHINE_DRIVER_START( mrflea )
/* driver data */
MDRV_DRIVER_DATA(mrflea_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz? */ MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz? */
MDRV_CPU_PROGRAM_MAP(mrflea_master_map) MDRV_CPU_PROGRAM_MAP(mrflea_master_map)
@ -239,6 +368,9 @@ static MACHINE_DRIVER_START( mrflea )
MDRV_QUANTUM_TIME(HZ(6000)) MDRV_QUANTUM_TIME(HZ(6000))
MDRV_MACHINE_START(mrflea)
MDRV_MACHINE_RESET(mrflea)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -250,7 +382,6 @@ static MACHINE_DRIVER_START( mrflea )
MDRV_GFXDECODE(mrflea) MDRV_GFXDECODE(mrflea)
MDRV_PALETTE_LENGTH(32) MDRV_PALETTE_LENGTH(32)
MDRV_VIDEO_START(mrflea)
MDRV_VIDEO_UPDATE(mrflea) MDRV_VIDEO_UPDATE(mrflea)
/* sound hardware */ /* sound hardware */
@ -268,6 +399,12 @@ static MACHINE_DRIVER_START( mrflea )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( mrflea ) ROM_START( mrflea )
ROM_REGION( 0x10000, "maincpu", 0 ) /* Z80 code; main CPU */ ROM_REGION( 0x10000, "maincpu", 0 ) /* Z80 code; main CPU */
ROM_LOAD( "cpu_d1", 0x0000, 0x2000, CRC(d286217c) SHA1(d750d64bb70f735a38b737881abb9a5fbde1c98c) ) ROM_LOAD( "cpu_d1", 0x0000, 0x2000, CRC(d286217c) SHA1(d750d64bb70f735a38b737881abb9a5fbde1c98c) )
@ -303,76 +440,10 @@ ROM_START( mrflea )
ROM_LOAD( "vd_l4", 0xe000, 0x2000, CRC(423735a5) SHA1(4ee93f93cd2b08560e148525e08880d64c64fcd2) ) ROM_LOAD( "vd_l4", 0xe000, 0x2000, CRC(423735a5) SHA1(4ee93f93cd2b08560e148525e08880d64c64fcd2) )
ROM_END ROM_END
static INPUT_PORTS_START( mrflea ) /*************************************
PORT_START("IN0") *
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY * Game driver(s)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY *
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY *************************************/
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN1")
PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("DSW1") /* DSW1 */
/*
------xx
-----x--
----x---
*/
PORT_DIPNAME( 0x03, 0x03, "Bonus?" )
PORT_DIPSETTING( 0x03, "A" )
PORT_DIPSETTING( 0x02, "B" )
PORT_DIPSETTING( 0x01, "C" )
PORT_DIPSETTING( 0x00, "D" )
PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSW2") /* DSW2 */
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x0c, "3" )
PORT_DIPSETTING( 0x08, "4" )
PORT_DIPSETTING( 0x04, "5" )
PORT_DIPSETTING( 0x00, "7" )
PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x30, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x20, DEF_STR( Medium ) )
PORT_DIPSETTING( 0x10, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
GAME( 1982, mrflea, 0, mrflea, mrflea, 0, ROT270, "Pacific Novelty", "The Amazing Adventures of Mr. F. Lea" , 0 )
GAME( 1982, mrflea, 0, mrflea, mrflea, 0, ROT270, "Pacific Novelty", "The Amazing Adventures of Mr. F. Lea" , GAME_SUPPORTS_SAVE )

View File

@ -1,15 +1,16 @@
/*************************************************************************** /***************************************************************************
Mr.Jong Mr. Jong
(c)1983 Kiwako (This game is distributed by Sanritsu.) (c)1983 Kiwako (This game is distributed by Sanritsu.)
Crazy Blocks Crazy Blocks
(c)1983 Kiwako/ECI (c)1983 Kiwako/ECI
Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 2000/03/20 - Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 2000/03/20 -
Block Buster
(c)1983 Kiwako/ECI
Block Buster
(c)1983 Kiwako/ECI
PCB Layout PCB Layout
---------- ----------
@ -45,32 +46,14 @@ ROMs 6A, 7A, 8A, 9A: 2764
#include "emu.h" #include "emu.h"
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "sound/sn76496.h" #include "sound/sn76496.h"
#include "includes/mrjong.h"
extern UINT8 *mrjong_videoram; /*************************************
extern UINT8 *mrjong_colorram; *
* Memory handlers
extern WRITE8_HANDLER( mrjong_videoram_w ); *
extern WRITE8_HANDLER( mrjong_colorram_w ); *************************************/
extern WRITE8_HANDLER( mrjong_flipscreen_w );
extern PALETTE_INIT( mrjong );
extern VIDEO_START( mrjong );
extern VIDEO_UPDATE( mrjong );
static ADDRESS_MAP_START( mrjong_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0xa000, 0xa7ff) AM_RAM
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE(&mrjong_videoram)
AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE(&mrjong_colorram)
ADDRESS_MAP_END
static WRITE8_HANDLER( io_0x00_w )
{
mrjong_flipscreen_w(space, 0, ((data & 0x04) > 2));
}
static READ8_HANDLER( io_0x03_r ) static READ8_HANDLER( io_0x03_r )
{ {
@ -78,14 +61,34 @@ static READ8_HANDLER( io_0x03_r )
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( mrjong_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0xa000, 0xa7ff) AM_RAM
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE_MEMBER(mrjong_state, videoram)
AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE_MEMBER(mrjong_state, colorram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( mrjong_io_map, ADDRESS_SPACE_IO, 8 ) static ADDRESS_MAP_START( mrjong_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff) ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_READ_PORT("P2") AM_WRITE(io_0x00_w) AM_RANGE(0x00, 0x00) AM_READ_PORT("P2") AM_WRITE(mrjong_flipscreen_w)
AM_RANGE(0x01, 0x01) AM_READ_PORT("P1") AM_DEVWRITE("sn1", sn76496_w) AM_RANGE(0x01, 0x01) AM_READ_PORT("P1") AM_DEVWRITE("sn1", sn76496_w)
AM_RANGE(0x02, 0x02) AM_READ_PORT("DSW") AM_DEVWRITE("sn2", sn76496_w) AM_RANGE(0x02, 0x02) AM_READ_PORT("DSW") AM_DEVWRITE("sn2", sn76496_w)
AM_RANGE(0x03, 0x03) AM_READ(io_0x03_r) // Unknown AM_RANGE(0x03, 0x03) AM_READ(io_0x03_r) // Unknown
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( mrjong ) static INPUT_PORTS_START( mrjong )
PORT_START("P2") PORT_START("P2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2)
@ -133,6 +136,12 @@ static INPUT_PORTS_START( mrjong )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout tilelayout = static const gfx_layout tilelayout =
{ {
8, 8, /* 8*8 characters */ 8, 8, /* 8*8 characters */
@ -163,8 +172,17 @@ static GFXDECODE_START( mrjong )
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_DRIVER_START( mrjong ) static MACHINE_DRIVER_START( mrjong )
/* driver data */
MDRV_DRIVER_DATA(mrjong_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,15468000/6) /* 2.578 MHz?? */ MDRV_CPU_ADD("maincpu", Z80,15468000/6) /* 2.578 MHz?? */
MDRV_CPU_PROGRAM_MAP(mrjong_map) MDRV_CPU_PROGRAM_MAP(mrjong_map)
@ -189,19 +207,19 @@ static MACHINE_DRIVER_START( mrjong )
/* sound hardware */ /* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SPEAKER_STANDARD_MONO("mono")
MDRV_SOUND_ADD("sn1", SN76489, 15468000/6) MDRV_SOUND_ADD("sn1", SN76489, 15468000/6)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MDRV_SOUND_ADD("sn2", SN76489, 15468000/6) MDRV_SOUND_ADD("sn2", SN76489, 15468000/6)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************************************************** /*************************************
*
Game driver(s) * ROM definition(s)
*
***************************************************************************/ *************************************/
ROM_START( mrjong ) ROM_START( mrjong )
ROM_REGION( 0x10000, "maincpu", 0 ) /* code */ ROM_REGION( 0x10000, "maincpu", 0 ) /* code */
@ -251,7 +269,12 @@ ROM_START( blkbustr )
ROM_LOAD( "clr.g5", 0x0020, 0x0100, CRC(bcb1e2e3) SHA1(c09731836a9d4e50316a84b86f61b599a1ef944d) ) ROM_LOAD( "clr.g5", 0x0020, 0x0100, CRC(bcb1e2e3) SHA1(c09731836a9d4e50316a84b86f61b599a1ef944d) )
ROM_END ROM_END
GAME( 1983, mrjong, 0, mrjong, mrjong, 0, ROT90, "Kiwako", "Mr. Jong (Japan)", 0 ) /*************************************
GAME( 1983, crazyblk, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "Crazy Blocks", 0 ) *
GAME( 1983, blkbustr, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "BlockBuster", 0 ) * Game driver(s)
*
*************************************/
GAME( 1983, mrjong, 0, mrjong, mrjong, 0, ROT90, "Kiwako", "Mr. Jong (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1983, crazyblk, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "Crazy Blocks", GAME_SUPPORTS_SAVE )
GAME( 1983, blkbustr, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "BlockBuster", GAME_SUPPORTS_SAVE )

View File

@ -49,6 +49,7 @@ behavior we use .
static WRITE16_HANDLER( mugsmash_reg2_w ) static WRITE16_HANDLER( mugsmash_reg2_w )
{ {
mugsmash_state *state = (mugsmash_state *)space->machine->driver_data; mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
state->regs2[offset] = data; state->regs2[offset] = data;
//popmessage ("Regs2 %04x, %04x, %04x, %04x", state->regs2[0], state->regs2[1], state->regs2[2], state->regs2[3]); //popmessage ("Regs2 %04x, %04x, %04x, %04x", state->regs2[0], state->regs2[1], state->regs2[2], state->regs2[3]);
@ -56,7 +57,7 @@ static WRITE16_HANDLER( mugsmash_reg2_w )
{ {
case 1: case 1:
soundlatch_w(space, 1, data & 0xff); soundlatch_w(space, 1, data & 0xff);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE ); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE );
break; break;
default: default:
@ -173,14 +174,14 @@ static READ16_HANDLER ( mugsmash_input_ports_r )
static ADDRESS_MAP_START( mugsmash_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( mugsmash_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x000000, 0x07ffff) AM_ROM
AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(mugsmash_videoram1_w) AM_BASE_MEMBER(mugsmash_state,videoram1) AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(mugsmash_videoram1_w) AM_BASE_MEMBER(mugsmash_state, videoram1)
AM_RANGE(0x082000, 0x082fff) AM_RAM_WRITE(mugsmash_videoram2_w) AM_BASE_MEMBER(mugsmash_state,videoram2) AM_RANGE(0x082000, 0x082fff) AM_RAM_WRITE(mugsmash_videoram2_w) AM_BASE_MEMBER(mugsmash_state, videoram2)
AM_RANGE(0x0c0000, 0x0c0007) AM_WRITE(mugsmash_reg_w) AM_BASE_MEMBER(mugsmash_state,regs1) /* video registers*/ AM_RANGE(0x0c0000, 0x0c0007) AM_WRITE(mugsmash_reg_w) AM_BASE_MEMBER(mugsmash_state, regs1) /* video registers*/
AM_RANGE(0x100000, 0x1005ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x100000, 0x1005ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x140000, 0x140007) AM_WRITE(mugsmash_reg2_w) AM_BASE_MEMBER(mugsmash_state,regs2) /* sound + ? */ AM_RANGE(0x140000, 0x140007) AM_WRITE(mugsmash_reg2_w) AM_BASE_MEMBER(mugsmash_state, regs2) /* sound + ? */
AM_RANGE(0x1c0000, 0x1c3fff) AM_RAM /* main ram? */ AM_RANGE(0x1c0000, 0x1c3fff) AM_RAM /* main ram? */
AM_RANGE(0x1c4000, 0x1cffff) AM_RAM AM_RANGE(0x1c4000, 0x1cffff) AM_RAM
AM_RANGE(0x200000, 0x203fff) AM_RAM AM_BASE_MEMBER(mugsmash_state,spriteram) /* sprite ram */ AM_RANGE(0x200000, 0x203fff) AM_RAM AM_BASE_MEMBER(mugsmash_state, spriteram) /* sprite ram */
#if USE_FAKE_INPUT_PORTS #if USE_FAKE_INPUT_PORTS
AM_RANGE(0x180000, 0x180007) AM_READ(mugsmash_input_ports_r) AM_RANGE(0x180000, 0x180007) AM_READ(mugsmash_input_ports_r)
#else #else
@ -390,7 +391,8 @@ GFXDECODE_END
static void irq_handler(running_device *device, int irq) static void irq_handler(running_device *device, int irq)
{ {
cputag_set_input_line(device->machine, "audiocpu", 0 , irq ? ASSERT_LINE : CLEAR_LINE ); mugsmash_state *state = (mugsmash_state *)device->machine->driver_data;
cpu_set_input_line(state->audiocpu, 0 , irq ? ASSERT_LINE : CLEAR_LINE );
} }
static const ym2151_interface ym2151_config = static const ym2151_interface ym2151_config =
@ -398,6 +400,14 @@ static const ym2151_interface ym2151_config =
irq_handler irq_handler
}; };
static MACHINE_START( mugsmash )
{
mugsmash_state *state = (mugsmash_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
}
static MACHINE_DRIVER_START( mugsmash ) static MACHINE_DRIVER_START( mugsmash )
MDRV_DRIVER_DATA( mugsmash_state ) MDRV_DRIVER_DATA( mugsmash_state )
@ -409,6 +419,8 @@ static MACHINE_DRIVER_START( mugsmash )
MDRV_CPU_ADD("audiocpu", Z80, 4000000) /* Guess */ MDRV_CPU_ADD("audiocpu", Z80, 4000000) /* Guess */
MDRV_CPU_PROGRAM_MAP(mugsmash_sound_map) MDRV_CPU_PROGRAM_MAP(mugsmash_sound_map)
MDRV_MACHINE_START(mugsmash)
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
@ -462,4 +474,4 @@ ROM_START( mugsmash )
ROM_LOAD( "mugs_15.bin", 0x180000, 0x080000, CRC(82e8187c) SHA1(c7a0e1b3d90dbbe2588886a27a07a9c336447ae3) ) ROM_LOAD( "mugs_15.bin", 0x180000, 0x080000, CRC(82e8187c) SHA1(c7a0e1b3d90dbbe2588886a27a07a9c336447ae3) )
ROM_END ROM_END
GAME( 1990?, mugsmash, 0, mugsmash, mugsmash, 0, ROT0, "Electronic Devices Italy / 3D Games England", "Mug Smashers", 0 ) GAME( 1990?, mugsmash, 0, mugsmash, mugsmash, 0, ROT0, "Electronic Devices Italy / 3D Games England", "Mug Smashers", GAME_SUPPORTS_SAVE )

View File

@ -28,58 +28,62 @@ Stephh's notes (based on the game Z80 code and some tests) :
#include "deprecat.h" #include "deprecat.h"
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "sound/ay8910.h" #include "sound/ay8910.h"
#include "includes/munchmo.h"
extern UINT8 *mnchmobl_vreg;
extern UINT8 *mnchmobl_status_vram;
extern UINT8 *mnchmobl_sprite_xpos;
extern UINT8 *mnchmobl_sprite_attr;
extern UINT8 *mnchmobl_sprite_tile;
PALETTE_INIT( mnchmobl );
VIDEO_START( mnchmobl );
WRITE8_HANDLER( mnchmobl_palette_bank_w );
WRITE8_HANDLER( mnchmobl_flipscreen_w );
VIDEO_UPDATE( mnchmobl );
/***************************************************************************/ /*************************************
*
static int mnchmobl_nmi_enable = 0; * Memory handlers
*
*************************************/
static WRITE8_HANDLER( mnchmobl_nmi_enable_w ) static WRITE8_HANDLER( mnchmobl_nmi_enable_w )
{ {
mnchmobl_nmi_enable = data; munchmo_state *state = (munchmo_state *)space->machine->driver_data;
state->nmi_enable = data;
} }
static INTERRUPT_GEN( mnchmobl_interrupt ) static INTERRUPT_GEN( mnchmobl_interrupt )
{ {
static int which; munchmo_state *state = (munchmo_state *)device->machine->driver_data;
which = !which; state->which = !state->which;
if( which ) cpu_set_input_line(device, 0, HOLD_LINE);
else if( mnchmobl_nmi_enable ) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); if (state->which)
cpu_set_input_line(device, 0, HOLD_LINE);
else if (state->nmi_enable)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
} }
static WRITE8_HANDLER( mnchmobl_soundlatch_w ) static WRITE8_HANDLER( mnchmobl_soundlatch_w )
{ {
soundlatch_w( space, offset, data ); munchmo_state *state = (munchmo_state *)space->machine->driver_data;
cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE );
soundlatch_w(space, offset, data);
cpu_set_input_line(state->audiocpu, 0, HOLD_LINE );
} }
static WRITE8_HANDLER( sound_nmi_ack_w ) static WRITE8_HANDLER( sound_nmi_ack_w )
{ {
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE); munchmo_state *state = (munchmo_state *)space->machine->driver_data;
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( mnchmobl_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mnchmobl_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_RANGE(0x8000, 0x83ff) AM_RAM
AM_RANGE(0xa000, 0xa3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_xpos) AM_RANGE(0xa000, 0xa3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_xpos)
AM_RANGE(0xa800, 0xabff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_tile) AM_RANGE(0xa800, 0xabff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_tile)
AM_RANGE(0xb000, 0xb3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_attr) AM_RANGE(0xb000, 0xb3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_attr)
AM_RANGE(0xb800, 0xb8ff) AM_MIRROR(0x0100) AM_RAM AM_BASE_GENERIC(videoram) AM_RANGE(0xb800, 0xb8ff) AM_MIRROR(0x0100) AM_RAM AM_BASE_MEMBER(munchmo_state, videoram)
AM_RANGE(0xbaba, 0xbaba) AM_WRITENOP /* ? */ AM_RANGE(0xbaba, 0xbaba) AM_WRITENOP /* ? */
AM_RANGE(0xbc00, 0xbc7f) AM_RAM AM_BASE(&mnchmobl_status_vram) AM_RANGE(0xbc00, 0xbc7f) AM_RAM AM_BASE_MEMBER(munchmo_state, status_vram)
AM_RANGE(0xbe00, 0xbe00) AM_WRITE(mnchmobl_soundlatch_w) AM_RANGE(0xbe00, 0xbe00) AM_WRITE(mnchmobl_soundlatch_w)
AM_RANGE(0xbe01, 0xbe01) AM_WRITE(mnchmobl_palette_bank_w) AM_RANGE(0xbe01, 0xbe01) AM_WRITE(mnchmobl_palette_bank_w)
AM_RANGE(0xbe02, 0xbe02) AM_READ_PORT("DSW1") AM_RANGE(0xbe02, 0xbe02) AM_READ_PORT("DSW1")
@ -89,7 +93,7 @@ static ADDRESS_MAP_START( mnchmobl_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xbe31, 0xbe31) AM_WRITENOP /* ? */ AM_RANGE(0xbe31, 0xbe31) AM_WRITENOP /* ? */
AM_RANGE(0xbe41, 0xbe41) AM_WRITE(mnchmobl_flipscreen_w) AM_RANGE(0xbe41, 0xbe41) AM_WRITE(mnchmobl_flipscreen_w)
AM_RANGE(0xbe61, 0xbe61) AM_WRITE(mnchmobl_nmi_enable_w) /* ENI 1-10C */ AM_RANGE(0xbe61, 0xbe61) AM_WRITE(mnchmobl_nmi_enable_w) /* ENI 1-10C */
AM_RANGE(0xbf00, 0xbf07) AM_WRITEONLY AM_BASE(&mnchmobl_vreg) /* MY0 1-8C */ AM_RANGE(0xbf00, 0xbf07) AM_WRITEONLY AM_BASE_MEMBER(munchmo_state, vreg) /* MY0 1-8C */
AM_RANGE(0xbf01, 0xbf01) AM_READ_PORT("SYSTEM") AM_RANGE(0xbf01, 0xbf01) AM_READ_PORT("SYSTEM")
AM_RANGE(0xbf02, 0xbf02) AM_READ_PORT("P1") AM_RANGE(0xbf02, 0xbf02) AM_READ_PORT("P1")
AM_RANGE(0xbf03, 0xbf03) AM_READ_PORT("P2") AM_RANGE(0xbf03, 0xbf03) AM_READ_PORT("P2")
@ -109,6 +113,12 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( mnchmobl ) static INPUT_PORTS_START( mnchmobl )
PORT_START("SYSTEM") PORT_START("SYSTEM")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
@ -199,6 +209,12 @@ static INPUT_PORTS_START( mnchmobl )
PORT_DIPSETTING( 0x80, DEF_STR( Yes ) ) PORT_DIPSETTING( 0x80, DEF_STR( Yes ) )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout char_layout = static const gfx_layout char_layout =
{ {
8,8, 8,8,
@ -268,8 +284,40 @@ static GFXDECODE_START( mnchmobl )
GFXDECODE_ENTRY( "gfx4", 0, sprite_layout2, 128, 16 ) /* colors 128-255 */ GFXDECODE_ENTRY( "gfx4", 0, sprite_layout2, 128, 16 ) /* colors 128-255 */
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( munchmo )
{
munchmo_state *state = (munchmo_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state_save_register_global(machine, state->palette_bank);
state_save_register_global(machine, state->flipscreen);
state_save_register_global(machine, state->nmi_enable);
state_save_register_global(machine, state->which);
}
static MACHINE_RESET( munchmo )
{
munchmo_state *state = (munchmo_state *)machine->driver_data;
state->palette_bank = 0;
state->flipscreen = 0;
state->nmi_enable = 0;
state->which = 0;
}
static MACHINE_DRIVER_START( mnchmobl ) static MACHINE_DRIVER_START( mnchmobl )
/* driver data */
MDRV_DRIVER_DATA(munchmo_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, XTAL_15MHz/4) /* ? */ MDRV_CPU_ADD("maincpu", Z80, XTAL_15MHz/4) /* ? */
MDRV_CPU_PROGRAM_MAP(mnchmobl_map) MDRV_CPU_PROGRAM_MAP(mnchmobl_map)
@ -279,6 +327,9 @@ static MACHINE_DRIVER_START( mnchmobl )
MDRV_CPU_PROGRAM_MAP(sound_map) MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_VBLANK_INT("screen", nmi_line_assert) MDRV_CPU_VBLANK_INT("screen", nmi_line_assert)
MDRV_MACHINE_START(munchmo)
MDRV_MACHINE_RESET(munchmo)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57) MDRV_SCREEN_REFRESH_RATE(57)
@ -306,6 +357,12 @@ static MACHINE_DRIVER_START( mnchmobl )
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( joyfulr ) ROM_START( joyfulr )
ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for CPUA */ ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for CPUA */
ROM_LOAD( "m1j.10e", 0x0000, 0x2000, CRC(1fe86e25) SHA1(e13abc20741dfd8a260f354efda3b3a25c820343) ) ROM_LOAD( "m1j.10e", 0x0000, 0x2000, CRC(1fe86e25) SHA1(e13abc20741dfd8a260f354efda3b3a25c820343) )
@ -363,5 +420,11 @@ ROM_START( mnchmobl )
ROM_END ROM_END
GAME( 1983, joyfulr, 0, mnchmobl, mnchmobl, 0, ROT270, "SNK", "Joyful Road (Japan)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) /*************************************
GAME( 1983, mnchmobl, joyfulr, mnchmobl, mnchmobl, 0, ROT270, "SNK (Centuri license)", "Munch Mobile (US)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL ) *
* Game driver(s)
*
*************************************/
GAME( 1983, joyfulr, 0, mnchmobl, mnchmobl, 0, ROT270, "SNK", "Joyful Road (Japan)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1983, mnchmobl, joyfulr, mnchmobl, mnchmobl, 0, ROT270, "SNK (Centuri license)", "Munch Mobile (US)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )

View File

@ -42,36 +42,64 @@ Notes:
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "sound/okim6295.h" #include "sound/okim6295.h"
#define MASTER_CLOCK XTAL_12MHz #define MASTER_CLOCK XTAL_12MHz
#define SOUND_CLOCK XTAL_45MHz #define SOUND_CLOCK XTAL_45MHz
static tilemap_t *bg_tilemap, *mlow_tilemap, *mhigh_tilemap, *tx_tilemap;
static UINT16 *bg_videoram, *mlow_videoram, *mhigh_videoram, *tx_videoram, *sprites_buffer; typedef struct _mwarr_state mwarr_state;
static UINT16 *bg_scrollram, *mlow_scrollram, *mhigh_scrollram, *vidattrram; struct _mwarr_state
static UINT16 *mwarr_ram; {
/* memory pointers */
UINT16 *bg_videoram, *mlow_videoram, *mhigh_videoram, *tx_videoram, *sprites_buffer;
UINT16 *bg_scrollram, *mlow_scrollram, *mhigh_scrollram, *vidattrram;
UINT16 *spriteram;
// UINT16 *paletteram; // currently this uses generic palette handling
UINT16 *mwarr_ram;
/* video-related */
tilemap_t *bg_tilemap, *mlow_tilemap, *mhigh_tilemap, *tx_tilemap;
/* misc */
int which;
};
/*************************************
*
* Memory handlers
*
*************************************/
static WRITE16_HANDLER( bg_videoram_w ) static WRITE16_HANDLER( bg_videoram_w )
{ {
COMBINE_DATA(&bg_videoram[offset]); mwarr_state *state = (mwarr_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
COMBINE_DATA(&state->bg_videoram[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
} }
static WRITE16_HANDLER( mlow_videoram_w ) static WRITE16_HANDLER( mlow_videoram_w )
{ {
COMBINE_DATA(&mlow_videoram[offset]); mwarr_state *state = (mwarr_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(mlow_tilemap,offset);
COMBINE_DATA(&state->mlow_videoram[offset]);
tilemap_mark_tile_dirty(state->mlow_tilemap,offset);
} }
static WRITE16_HANDLER( mhigh_videoram_w ) static WRITE16_HANDLER( mhigh_videoram_w )
{ {
COMBINE_DATA(&mhigh_videoram[offset]); mwarr_state *state = (mwarr_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(mhigh_tilemap,offset);
COMBINE_DATA(&state->mhigh_videoram[offset]);
tilemap_mark_tile_dirty(state->mhigh_tilemap,offset);
} }
static WRITE16_HANDLER( tx_videoram_w ) static WRITE16_HANDLER( tx_videoram_w )
{ {
COMBINE_DATA(&tx_videoram[offset]); mwarr_state *state = (mwarr_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(tx_tilemap,offset);
COMBINE_DATA(&state->tx_videoram[offset]);
tilemap_mark_tile_dirty(state->tx_tilemap,offset);
} }
static WRITE16_DEVICE_HANDLER( oki1_bank_w ) static WRITE16_DEVICE_HANDLER( oki1_bank_w )
@ -81,30 +109,30 @@ static WRITE16_DEVICE_HANDLER( oki1_bank_w )
static WRITE16_HANDLER( sprites_commands_w ) static WRITE16_HANDLER( sprites_commands_w )
{ {
static int which = 0; mwarr_state *state = (mwarr_state *)space->machine->driver_data;
if( which ) if (state->which)
{ {
int i; int i;
switch(data) switch (data)
{ {
case 0: case 0:
/* clear sprites on screen */ /* clear sprites on screen */
for( i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)
{ {
sprites_buffer[i] = 0; state->sprites_buffer[i] = 0;
} }
which = 0; state->which = 0;
break; break;
default: default:
logerror("used unknown sprites command %02X\n",data); logerror("used unknown sprites command %02X\n",data);
case 0xf: case 0xf:
/* refresh sprites on screen */ /* refresh sprites on screen */
for( i = 0; i < 0x800; i++) for (i = 0; i < 0x800; i++)
{ {
sprites_buffer[i] = space->machine->generic.spriteram.u16[i]; state->sprites_buffer[i] = state->spriteram[i];
} }
break; break;
@ -114,47 +142,61 @@ static WRITE16_HANDLER( sprites_commands_w )
} }
} }
which ^= 1; state->which ^= 1;
} }
static WRITE16_HANDLER( mwarr_brightness_w ) static WRITE16_HANDLER( mwarr_brightness_w )
{ {
mwarr_state *state = (mwarr_state *)space->machine->driver_data;
int i; int i;
double brightness; double brightness;
COMBINE_DATA(&mwarr_ram[0x14/2]); COMBINE_DATA(&state->mwarr_ram[0x14 / 2]);
brightness = (double)(data & 0xff); brightness = (double)(data & 0xff);
for (i=0;i<0x800;i++) for (i = 0; i < 0x800; i++)
{ {
palette_set_pen_contrast(space->machine, i, brightness/255); palette_set_pen_contrast(space->machine, i, brightness/255);
} }
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( mwarr_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( mwarr_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x1007ff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram) AM_RANGE(0x100000, 0x1007ff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(mwarr_state, bg_videoram)
AM_RANGE(0x100800, 0x100fff) AM_RAM_WRITE(mlow_videoram_w) AM_BASE(&mlow_videoram) AM_RANGE(0x100800, 0x100fff) AM_RAM_WRITE(mlow_videoram_w) AM_BASE_MEMBER(mwarr_state, mlow_videoram)
AM_RANGE(0x101000, 0x1017ff) AM_RAM_WRITE(mhigh_videoram_w) AM_BASE(&mhigh_videoram) AM_RANGE(0x101000, 0x1017ff) AM_RAM_WRITE(mhigh_videoram_w) AM_BASE_MEMBER(mwarr_state, mhigh_videoram)
AM_RANGE(0x101800, 0x1027ff) AM_RAM_WRITE(tx_videoram_w) AM_BASE(&tx_videoram) AM_RANGE(0x101800, 0x1027ff) AM_RAM_WRITE(tx_videoram_w) AM_BASE_MEMBER(mwarr_state, tx_videoram)
AM_RANGE(0x103000, 0x1033ff) AM_RAM AM_BASE(&bg_scrollram) AM_RANGE(0x103000, 0x1033ff) AM_RAM AM_BASE_MEMBER(mwarr_state, bg_scrollram)
AM_RANGE(0x103400, 0x1037ff) AM_RAM AM_BASE(&mlow_scrollram) AM_RANGE(0x103400, 0x1037ff) AM_RAM AM_BASE_MEMBER(mwarr_state, mlow_scrollram)
AM_RANGE(0x103800, 0x103bff) AM_RAM AM_BASE(&mhigh_scrollram) AM_RANGE(0x103800, 0x103bff) AM_RAM AM_BASE_MEMBER(mwarr_state, mhigh_scrollram)
AM_RANGE(0x103c00, 0x103fff) AM_RAM AM_BASE(&vidattrram) AM_RANGE(0x103c00, 0x103fff) AM_RAM AM_BASE_MEMBER(mwarr_state, vidattrram)
AM_RANGE(0x104000, 0x104fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x104000, 0x104fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x108000, 0x108fff) AM_RAM AM_BASE_GENERIC(spriteram) AM_RANGE(0x108000, 0x108fff) AM_RAM AM_BASE_MEMBER(mwarr_state, spriteram)
AM_RANGE(0x110000, 0x110001) AM_READ_PORT("P1_P2") AM_RANGE(0x110000, 0x110001) AM_READ_PORT("P1_P2")
AM_RANGE(0x110002, 0x110003) AM_READ_PORT("SYSTEM") AM_RANGE(0x110002, 0x110003) AM_READ_PORT("SYSTEM")
AM_RANGE(0x110004, 0x110005) AM_READ_PORT("DSW") AM_RANGE(0x110004, 0x110005) AM_READ_PORT("DSW")
AM_RANGE(0x110010, 0x110011) AM_DEVWRITE("oki2", oki1_bank_w) AM_RANGE(0x110010, 0x110011) AM_DEVWRITE("oki2", oki1_bank_w)
AM_RANGE(0x110014, 0x110015) AM_WRITE(mwarr_brightness_w) AM_RANGE(0x110014, 0x110015) AM_WRITE(mwarr_brightness_w)
AM_RANGE(0x110016, 0x110017) AM_WRITE(sprites_commands_w) AM_RANGE(0x110016, 0x110017) AM_WRITE(sprites_commands_w)
AM_RANGE(0x110000, 0x11ffff) AM_RAM AM_BASE(&mwarr_ram) AM_RANGE(0x110000, 0x11ffff) AM_RAM AM_BASE_MEMBER(mwarr_state, mwarr_ram)
AM_RANGE(0x180000, 0x180001) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x180000, 0x180001) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff)
AM_RANGE(0x190000, 0x190001) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x190000, 0x190001) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x00ff)
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( mwarr ) static INPUT_PORTS_START( mwarr )
PORT_START("P1_P2") PORT_START("P1_P2")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
@ -229,6 +271,12 @@ static INPUT_PORTS_START( mwarr )
PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW ) PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout mwarr_tile8_layout = static const gfx_layout mwarr_tile8_layout =
{ {
8,8, 8,8,
@ -271,75 +319,82 @@ static GFXDECODE_START( mwarr )
GFXDECODE_ENTRY( "gfx5", 0, mwarr_tile16_layout, 0, 8 ) GFXDECODE_ENTRY( "gfx5", 0, mwarr_tile16_layout, 0, 8 )
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Video emulation
*
*************************************/
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int tileno,colour; mwarr_state *state = (mwarr_state *)machine->driver_data;
int tileno = state->bg_videoram[tile_index] & 0x1fff;
int colour = (state->bg_videoram[tile_index] & 0xe000) >> 13;
tileno = bg_videoram[tile_index] & 0x1fff; SET_TILE_INFO(4, tileno, colour, 0);
colour = (bg_videoram[tile_index] & 0xe000) >> 13;
SET_TILE_INFO(4,tileno,colour,0);
} }
static TILE_GET_INFO( get_mlow_tile_info ) static TILE_GET_INFO( get_mlow_tile_info )
{ {
int tileno,colour; mwarr_state *state = (mwarr_state *)machine->driver_data;
int tileno = state->mlow_videoram[tile_index] & 0x1fff;
int colour = (state->mlow_videoram[tile_index] & 0xe000) >> 13;
tileno = mlow_videoram[tile_index] & 0x1fff; SET_TILE_INFO(3, tileno, colour, 0);
colour = (mlow_videoram[tile_index] & 0xe000) >> 13;
SET_TILE_INFO(3,tileno,colour,0);
} }
static TILE_GET_INFO( get_mhigh_tile_info ) static TILE_GET_INFO( get_mhigh_tile_info )
{ {
int tileno,colour; mwarr_state *state = (mwarr_state *)machine->driver_data;
int tileno = state->mhigh_videoram[tile_index] & 0x1fff;
int colour = (state->mhigh_videoram[tile_index] & 0xe000) >> 13;
tileno = mhigh_videoram[tile_index] & 0x1fff; SET_TILE_INFO(2, tileno, colour, 0);
colour = (mhigh_videoram[tile_index] & 0xe000) >> 13;
SET_TILE_INFO(2,tileno,colour,0);
} }
static TILE_GET_INFO( get_tx_tile_info ) static TILE_GET_INFO( get_tx_tile_info )
{ {
int tileno,colour; mwarr_state *state = (mwarr_state *)machine->driver_data;
int tileno = state->tx_videoram[tile_index] & 0x1fff;
int colour = (state->tx_videoram[tile_index] & 0xe000) >> 13;
tileno = tx_videoram[tile_index] & 0x1fff; SET_TILE_INFO(1, tileno, colour, 0);
colour = (tx_videoram[tile_index] & 0xe000) >> 13;
SET_TILE_INFO(1,tileno,colour,0);
} }
static VIDEO_START( mwarr ) static VIDEO_START( mwarr )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols, 16, 16,64,16); mwarr_state *state = (mwarr_state *)machine->driver_data;
mlow_tilemap = tilemap_create(machine, get_mlow_tile_info, tilemap_scan_cols, 16, 16,64,16);
mhigh_tilemap = tilemap_create(machine, get_mhigh_tile_info,tilemap_scan_cols, 16, 16,64,16);
tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8,64,32);
sprites_buffer = auto_alloc_array(machine, UINT16, 0x800); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols, 16, 16, 64, 16);
state->mlow_tilemap = tilemap_create(machine, get_mlow_tile_info, tilemap_scan_cols, 16, 16, 64, 16);
state->mhigh_tilemap = tilemap_create(machine, get_mhigh_tile_info, tilemap_scan_cols, 16, 16, 64, 16);
state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_transparent_pen(mlow_tilemap,0); state->sprites_buffer = auto_alloc_array(machine, UINT16, 0x800);
tilemap_set_transparent_pen(mhigh_tilemap,0);
tilemap_set_transparent_pen(tx_tilemap,0);
tilemap_set_scroll_rows(bg_tilemap, 256); tilemap_set_transparent_pen(state->mlow_tilemap, 0);
tilemap_set_scroll_rows(mlow_tilemap, 256); tilemap_set_transparent_pen(state->mhigh_tilemap, 0);
tilemap_set_scroll_rows(mhigh_tilemap, 256); tilemap_set_transparent_pen(state->tx_tilemap, 0);
tilemap_set_scroll_rows(state->bg_tilemap, 256);
tilemap_set_scroll_rows(state->mlow_tilemap, 256);
tilemap_set_scroll_rows(state->mhigh_tilemap, 256);
state_save_register_global_pointer(machine, state->sprites_buffer, 0x800);
} }
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
const UINT16 *source = sprites_buffer+0x800-4; mwarr_state *state = (mwarr_state *)machine->driver_data;
const UINT16 *finish = sprites_buffer; const UINT16 *source = state->sprites_buffer + 0x800 - 4;
const UINT16 *finish = state->sprites_buffer;
const gfx_element *gfx = machine->gfx[0]; const gfx_element *gfx = machine->gfx[0];
int x, y, color, flipx, dy, pri, pri_mask, i; int x, y, color, flipx, dy, pri, pri_mask, i;
while( source>=finish ) while (source >= finish)
{ {
/* draw sprite */ /* draw sprite */
if( source[0] & 0x0800 ) if (source[0] & 0x0800)
{ {
y = 512 - (source[0] & 0x01ff); y = 512 - (source[0] & 0x01ff);
x = (source[3] & 0x3ff) - 9; x = (source[3] & 0x3ff) - 9;
@ -347,12 +402,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
color = source[1] & 0x000f; color = source[1] & 0x000f;
flipx = source[1] & 0x0200; flipx = source[1] & 0x0200;
dy = (source[0] & 0xf000)>>12; dy = (source[0] & 0xf000) >> 12;
pri = ((source[1] & 0x3c00)>>10); // Priority (1 = Low) pri = ((source[1] & 0x3c00) >> 10); // Priority (1 = Low)
pri_mask = ~((1 << (pri+1)) - 1); // Above the first "pri" levels pri_mask = ~((1 << (pri + 1)) - 1); // Above the first "pri" levels
for(i=0;i<=dy;i++) for (i = 0; i <= dy; i++)
{ {
pdrawgfx_transpen( bitmap, pdrawgfx_transpen( bitmap,
cliprect, cliprect,
@ -401,66 +456,93 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static VIDEO_UPDATE( mwarr ) static VIDEO_UPDATE( mwarr )
{ {
mwarr_state *state = (mwarr_state *)screen->machine->driver_data;
int i; int i;
bitmap_fill(screen->machine->priority_bitmap,cliprect,0); bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
if(vidattrram[6] & 1) if (BIT(state->vidattrram[6], 0))
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(bg_tilemap, i, bg_scrollram[i]+20); tilemap_set_scrollx(state->bg_tilemap, i, state->bg_scrollram[i] + 20);
} }
else else
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(bg_tilemap, i, bg_scrollram[0]+19); tilemap_set_scrollx(state->bg_tilemap, i, state->bg_scrollram[0] + 19);
} }
if(vidattrram[6] & 4) if (BIT(state->vidattrram[6], 2))
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(mlow_tilemap, i, mlow_scrollram[i]+19); tilemap_set_scrollx(state->mlow_tilemap, i, state->mlow_scrollram[i] + 19);
} }
else else
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(mlow_tilemap, i, mlow_scrollram[0]+19); tilemap_set_scrollx(state->mlow_tilemap, i, state->mlow_scrollram[0] + 19);
} }
if(vidattrram[6] & 0x10) if (BIT(state->vidattrram[6], 4))
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(mhigh_tilemap, i, mhigh_scrollram[i]+19); tilemap_set_scrollx(state->mhigh_tilemap, i, state->mhigh_scrollram[i] + 19);
} }
else else
{ {
for(i=0;i<256;i++) for (i = 0; i < 256; i++)
tilemap_set_scrollx(mhigh_tilemap, i, mhigh_scrollram[0]+19); tilemap_set_scrollx(state->mhigh_tilemap, i, state->mhigh_scrollram[0] + 19);
} }
tilemap_set_scrolly(bg_tilemap, 0, vidattrram[1]+1); tilemap_set_scrolly(state->bg_tilemap, 0, state->vidattrram[1] + 1);
tilemap_set_scrolly(mlow_tilemap, 0, vidattrram[2]+1); tilemap_set_scrolly(state->mlow_tilemap, 0, state->vidattrram[2] + 1);
tilemap_set_scrolly(mhigh_tilemap, 0, vidattrram[3]+1); tilemap_set_scrolly(state->mhigh_tilemap, 0, state->vidattrram[3] + 1);
tilemap_set_scrollx(tx_tilemap, 0, vidattrram[0]+16); tilemap_set_scrollx(state->tx_tilemap, 0, state->vidattrram[0] + 16);
tilemap_set_scrolly(tx_tilemap, 0, vidattrram[4]+1); tilemap_set_scrolly(state->tx_tilemap, 0, state->vidattrram[4] + 1);
tilemap_draw(bitmap,cliprect,bg_tilemap, 0,0x01); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0x01);
tilemap_draw(bitmap,cliprect,mlow_tilemap, 0,0x02); tilemap_draw(bitmap, cliprect, state->mlow_tilemap, 0, 0x02);
tilemap_draw(bitmap,cliprect,mhigh_tilemap,0,0x04); tilemap_draw(bitmap, cliprect, state->mhigh_tilemap, 0, 0x04);
tilemap_draw(bitmap,cliprect,tx_tilemap, 0,0x10); tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0x10);
draw_sprites(screen->machine, bitmap,cliprect); draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( mwarr )
{
mwarr_state *state = (mwarr_state *)machine->driver_data;
state_save_register_global(machine, state->which);
}
static MACHINE_RESET( mwarr )
{
mwarr_state *state = (mwarr_state *)machine->driver_data;
state->which = 0;
}
static MACHINE_DRIVER_START( mwarr ) static MACHINE_DRIVER_START( mwarr )
/* driver data */
MDRV_DRIVER_DATA(mwarr_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK) MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK)
MDRV_CPU_PROGRAM_MAP(mwarr_map) MDRV_CPU_PROGRAM_MAP(mwarr_map)
MDRV_CPU_VBLANK_INT("screen", irq4_line_hold) MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
MDRV_GFXDECODE(mwarr) MDRV_MACHINE_START(mwarr)
MDRV_MACHINE_RESET(mwarr)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(54) MDRV_SCREEN_REFRESH_RATE(54)
MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
@ -468,11 +550,13 @@ static MACHINE_DRIVER_START( mwarr )
MDRV_SCREEN_SIZE(64*8, 32*8) MDRV_SCREEN_SIZE(64*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(8+1, 48*8-1-8-1, 0, 30*8-1) MDRV_SCREEN_VISIBLE_AREA(8+1, 48*8-1-8-1, 0, 30*8-1)
MDRV_GFXDECODE(mwarr)
MDRV_PALETTE_LENGTH(0x800) MDRV_PALETTE_LENGTH(0x800)
MDRV_VIDEO_START(mwarr) MDRV_VIDEO_START(mwarr)
MDRV_VIDEO_UPDATE(mwarr) MDRV_VIDEO_UPDATE(mwarr)
/* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SPEAKER_STANDARD_MONO("mono")
MDRV_SOUND_ADD("oki1", OKIM6295, SOUND_CLOCK/48 ) MDRV_SOUND_ADD("oki1", OKIM6295, SOUND_CLOCK/48 )
@ -485,6 +569,12 @@ static MACHINE_DRIVER_START( mwarr )
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( mwarr ) ROM_START( mwarr )
ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 Code */ ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 Code */
ROM_LOAD16_BYTE( "prg_ev", 0x00000, 0x80000, CRC(d1d5e0a6) SHA1(f47955459d41c904b96de000b32cae156ee3bcba) ) ROM_LOAD16_BYTE( "prg_ev", 0x00000, 0x80000, CRC(d1d5e0a6) SHA1(f47955459d41c904b96de000b32cae156ee3bcba) )
@ -545,4 +635,10 @@ ROM_START( mwarr )
ROM_COPY( "user1", 0x060000, 0x0e0000, 0x020000) ROM_COPY( "user1", 0x060000, 0x0e0000, 0x020000)
ROM_END ROM_END
GAME( 199?, mwarr, 0, mwarr, mwarr, 0, ROT0, "Elettronica Video-Games S.R.L.", "Mighty Warriors", 0 ) /*************************************
*
* Game driver(s)
*
*************************************/
GAME( 199?, mwarr, 0, mwarr, mwarr, 0, ROT0, "Elettronica Video-Games S.R.L.", "Mighty Warriors", GAME_SUPPORTS_SAVE )

View File

@ -1,14 +1,52 @@
typedef struct _matmania_state matmania_state;
struct _matmania_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * videoram2;
UINT8 * videoram3;
UINT8 * colorram;
UINT8 * colorram2;
UINT8 * colorram3;
UINT8 * scroll;
UINT8 * pageselect;
UINT8 * spriteram;
UINT8 * paletteram;
size_t videoram_size;
size_t videoram2_size;
size_t videoram3_size;
size_t spriteram_size;
/* video-related */
bitmap_t *tmpbitmap;
bitmap_t *tmpbitmap2;
/* mcu */
/* maniach 68705 protection */
UINT8 port_a_in, port_a_out, ddr_a;
UINT8 port_b_in, port_b_out, ddr_b;
UINT8 port_c_in, port_c_out, ddr_c;
UINT8 from_main, from_mcu;
int mcu_sent, main_sent;
/* devices */
running_device *maincpu;
running_device *audiocpu;
running_device *mcu;
};
/*----------- defined in machine/maniach.c -----------*/ /*----------- defined in machine/maniach.c -----------*/
READ8_HANDLER( maniach_68705_portA_r ); READ8_HANDLER( maniach_68705_port_a_r );
WRITE8_HANDLER( maniach_68705_portA_w ); WRITE8_HANDLER( maniach_68705_port_a_w );
READ8_HANDLER( maniach_68705_portB_r ); READ8_HANDLER( maniach_68705_port_b_r );
WRITE8_HANDLER( maniach_68705_portB_w ); WRITE8_HANDLER( maniach_68705_port_b_w );
READ8_HANDLER( maniach_68705_portC_r ); READ8_HANDLER( maniach_68705_port_c_r );
WRITE8_HANDLER( maniach_68705_portC_w ); WRITE8_HANDLER( maniach_68705_port_c_w );
WRITE8_HANDLER( maniach_68705_ddrA_w ); WRITE8_HANDLER( maniach_68705_ddr_a_w );
WRITE8_HANDLER( maniach_68705_ddrB_w ); WRITE8_HANDLER( maniach_68705_ddr_b_w );
WRITE8_HANDLER( maniach_68705_ddrC_w ); WRITE8_HANDLER( maniach_68705_ddr_c_w );
WRITE8_HANDLER( maniach_mcu_w ); WRITE8_HANDLER( maniach_mcu_w );
READ8_HANDLER( maniach_mcu_r ); READ8_HANDLER( maniach_mcu_r );
READ8_HANDLER( maniach_mcu_status_r ); READ8_HANDLER( maniach_mcu_status_r );
@ -16,15 +54,6 @@ READ8_HANDLER( maniach_mcu_status_r );
/*----------- defined in video/matmania.c -----------*/ /*----------- defined in video/matmania.c -----------*/
extern UINT8 *matmania_videoram,*matmania_colorram;
extern size_t matmania_videoram_size;
extern UINT8 *matmania_videoram2,*matmania_colorram2;
extern size_t matmania_videoram2_size;
extern UINT8 *matmania_videoram3,*matmania_colorram3;
extern size_t matmania_videoram3_size;
extern UINT8 *matmania_scroll;
extern UINT8 *matmania_pageselect;
WRITE8_HANDLER( matmania_paletteram_w ); WRITE8_HANDLER( matmania_paletteram_w );
PALETTE_INIT( matmania ); PALETTE_INIT( matmania );
VIDEO_UPDATE( maniach ); VIDEO_UPDATE( maniach );

View File

@ -0,0 +1,38 @@
/*************************************************************************
Metal Clash
*************************************************************************/
typedef struct _metlclsh_state metlclsh_state;
struct _metlclsh_state
{
/* memory pointers */
UINT8 * bgram;
UINT8 * fgram;
UINT8 * scrollx;
UINT8 * otherram;
// UINT8 * paletteram; // currently this uses generic palette handling
// UINT8 * paletteram2; // currently this uses generic palette handling
UINT8 * spriteram;
size_t spriteram_size;
/* video-related */
tilemap_t *bg_tilemap,*fg_tilemap;
UINT8 write_mask, gfxbank;
/* devices */
running_device *maincpu;
running_device *subcpu;
};
/*----------- defined in video/metlclsh.c -----------*/
WRITE8_HANDLER( metlclsh_bgram_w );
WRITE8_HANDLER( metlclsh_fgram_w );
WRITE8_HANDLER( metlclsh_gfxbank_w );
WRITE8_HANDLER( metlclsh_rambank_w );
VIDEO_START( metlclsh );
VIDEO_UPDATE( metlclsh );

View File

@ -1,23 +1,49 @@
/*----------- defined in machine/mexico86.c -----------*/
extern UINT8 *mexico86_protection_ram; typedef struct _mexico86_state mexico86_state;
struct _mexico86_state
{
/* memory pointers */
UINT8 * protection_ram;
UINT8 * videoram;
UINT8 * objectram;
size_t objectram_size;
/* video-related */
int charbank;
/* mcu */
/* mexico86 68705 protection */
UINT8 port_a_in, port_a_out, ddr_a;
UINT8 port_b_in, port_b_out, ddr_b;
int address, latch;
/* kikikai mcu simulation */
int mcu_running, mcu_initialised;
int coin_last;
/* devices */
running_device *maincpu;
running_device *audiocpu;
running_device *subcpu;
running_device *mcu;
};
/*----------- defined in machine/mexico86.c -----------*/
WRITE8_HANDLER( mexico86_f008_w ); WRITE8_HANDLER( mexico86_f008_w );
INTERRUPT_GEN( kikikai_interrupt ); INTERRUPT_GEN( kikikai_interrupt );
INTERRUPT_GEN( mexico86_m68705_interrupt ); INTERRUPT_GEN( mexico86_m68705_interrupt );
READ8_HANDLER( mexico86_68705_portA_r ); READ8_HANDLER( mexico86_68705_port_a_r );
WRITE8_HANDLER( mexico86_68705_portA_w ); WRITE8_HANDLER( mexico86_68705_port_a_w );
WRITE8_HANDLER( mexico86_68705_ddrA_w ); WRITE8_HANDLER( mexico86_68705_ddr_a_w );
READ8_HANDLER( mexico86_68705_portB_r ); READ8_HANDLER( mexico86_68705_port_b_r );
WRITE8_HANDLER( mexico86_68705_portB_w ); WRITE8_HANDLER( mexico86_68705_port_b_w );
WRITE8_HANDLER( mexico86_68705_ddrB_w ); WRITE8_HANDLER( mexico86_68705_ddr_b_w );
/*----------- defined in video/mexico86.c -----------*/ /*----------- defined in video/mexico86.c -----------*/
extern UINT8 *mexico86_videoram,*mexico86_objectram;
extern size_t mexico86_objectram_size;
WRITE8_HANDLER( mexico86_bankswitch_w ); WRITE8_HANDLER( mexico86_bankswitch_w );
VIDEO_UPDATE( mexico86 ); VIDEO_UPDATE( mexico86 );
VIDEO_UPDATE( kikikai ); VIDEO_UPDATE( kikikai );

View File

@ -0,0 +1,29 @@
/*************************************************************************
Mosaic
*************************************************************************/
typedef struct _mosaic_state mosaic_state;
struct _mosaic_state
{
/* memory pointers */
UINT8 * fgvideoram;
UINT8 * bgvideoram;
// UINT8 * paletteram; // currently this uses generic palette handling
/* video-related */
tilemap_t *bg_tilemap,*fg_tilemap;
/* misc */
int prot_val;
};
/*----------- defined in video/mosaic.c -----------*/
WRITE8_HANDLER( mosaic_fgvideoram_w );
WRITE8_HANDLER( mosaic_bgvideoram_w );
VIDEO_START( mosaic );
VIDEO_UPDATE( mosaic );

View File

@ -0,0 +1,31 @@
/*************************************************************************
Mouser
*************************************************************************/
typedef struct _mouser_state mouser_state;
struct _mouser_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
size_t spriteram_size;
/* misc */
UINT8 sound_byte;
UINT8 nmi_enable;
/* devices */
running_device *maincpu;
running_device *audiocpu;
};
/*----------- defined in video/mouser.c -----------*/
WRITE8_HANDLER( mouser_flip_screen_x_w );
WRITE8_HANDLER( mouser_flip_screen_y_w );
PALETTE_INIT( mouser );
VIDEO_UPDATE( mouser );

32
src/mame/includes/mrdo.h Normal file
View File

@ -0,0 +1,32 @@
/*************************************************************************
Mr. Do
*************************************************************************/
typedef struct _mrdo_state mrdo_state;
struct _mrdo_state
{
/* memory pointers */
UINT8 * bgvideoram;
UINT8 * fgvideoram;
UINT8 * spriteram;
size_t spriteram_size;
/* video-related */
tilemap_t *bg_tilemap, *fg_tilemap;
int flipscreen;
};
/*----------- defined in video/mrdo.c -----------*/
WRITE8_HANDLER( mrdo_bgvideoram_w );
WRITE8_HANDLER( mrdo_fgvideoram_w );
WRITE8_HANDLER( mrdo_scrollx_w );
WRITE8_HANDLER( mrdo_scrolly_w );
WRITE8_HANDLER( mrdo_flipscreen_w );
PALETTE_INIT( mrdo );
VIDEO_START( mrdo );
VIDEO_UPDATE( mrdo );

View File

@ -0,0 +1,36 @@
/*************************************************************************
Mr. Flea
*************************************************************************/
typedef struct _mrflea_state mrflea_state;
struct _mrflea_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * spriteram;
// UINT8 * paletteram; // currently this uses generic palette handling
/* video-related */
int gfx_bank;
/* misc */
int io;
int main;
int status;
int select1;
/* devices */
running_device *maincpu;
running_device *subcpu;
};
/*----------- defined in video/mrflea.c -----------*/
WRITE8_HANDLER( mrflea_gfx_bank_w );
WRITE8_HANDLER( mrflea_videoram_w );
WRITE8_HANDLER( mrflea_spriteram_w );
VIDEO_UPDATE( mrflea );

View File

@ -0,0 +1,27 @@
/*************************************************************************
Mr. Jong
*************************************************************************/
typedef struct _mrjong_state mrjong_state;
struct _mrjong_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
/* video-related */
tilemap_t *bg_tilemap;
};
/*----------- defined in video/mrjong.c -----------*/
WRITE8_HANDLER( mrjong_videoram_w );
WRITE8_HANDLER( mrjong_colorram_w );
WRITE8_HANDLER( mrjong_flipscreen_w );
PALETTE_INIT( mrjong );
VIDEO_START( mrjong );
VIDEO_UPDATE( mrjong );

View File

@ -1,3 +1,4 @@
typedef struct _mugsmash_state mugsmash_state; typedef struct _mugsmash_state mugsmash_state;
struct _mugsmash_state struct _mugsmash_state
{ {
@ -6,8 +7,12 @@ struct _mugsmash_state
UINT16 *spriteram; UINT16 *spriteram;
UINT16 *regs1; UINT16 *regs1;
UINT16 *regs2; UINT16 *regs2;
tilemap_t *tilemap1; tilemap_t *tilemap1;
tilemap_t *tilemap2; tilemap_t *tilemap2;
running_device *maincpu;
running_device *audiocpu;
}; };

View File

@ -0,0 +1,40 @@
/*************************************************************************
Munch Mobile
*************************************************************************/
typedef struct _munchmo_state munchmo_state;
struct _munchmo_state
{
/* memory pointers */
UINT8 * vreg;
UINT8 * status_vram;
UINT8 * sprite_xpos;
UINT8 * sprite_attr;
UINT8 * sprite_tile;
UINT8 * videoram;
/* video-related */
bitmap_t *tmpbitmap;
int palette_bank;
int flipscreen;
/* misc */
int nmi_enable;
int which;
/* devices */
running_device *maincpu;
running_device *audiocpu;
};
/*----------- defined in video/munchmo.c -----------*/
WRITE8_HANDLER( mnchmobl_palette_bank_w );
WRITE8_HANDLER( mnchmobl_flipscreen_w );
PALETTE_INIT( mnchmobl );
VIDEO_START( mnchmobl );
VIDEO_UPDATE( mnchmobl );

View File

@ -11,10 +11,6 @@
#include "includes/matmania.h" #include "includes/matmania.h"
static UINT8 from_main,from_mcu;
static int mcu_sent = 0,main_sent = 0;
/*************************************************************************** /***************************************************************************
Mania Challenge 68705 protection interface Mania Challenge 68705 protection interface
@ -23,23 +19,26 @@ static int mcu_sent = 0,main_sent = 0;
***************************************************************************/ ***************************************************************************/
static UINT8 portA_in,portA_out,ddrA; READ8_HANDLER( maniach_68705_port_a_r )
READ8_HANDLER( maniach_68705_portA_r )
{ {
//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in); matmania_state *state = (matmania_state *)space->machine->driver_data;
return (portA_out & ddrA) | (portA_in & ~ddrA);
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
} }
WRITE8_HANDLER( maniach_68705_portA_w ) WRITE8_HANDLER( maniach_68705_port_a_w )
{ {
//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data); matmania_state *state = (matmania_state *)space->machine->driver_data;
portA_out = data;
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
state->port_a_out = data;
} }
WRITE8_HANDLER( maniach_68705_ddrA_w ) WRITE8_HANDLER( maniach_68705_ddr_a_w )
{ {
ddrA = data; matmania_state *state = (matmania_state *)space->machine->driver_data;
state->ddr_a = data;
} }
@ -53,85 +52,103 @@ WRITE8_HANDLER( maniach_68705_ddrA_w )
* 2 W when 0->1, copies port A to the latch for the main CPU * 2 W when 0->1, copies port A to the latch for the main CPU
*/ */
static UINT8 portB_in,portB_out,ddrB; READ8_HANDLER( maniach_68705_port_b_r )
READ8_HANDLER( maniach_68705_portB_r )
{ {
return (portB_out & ddrB) | (portB_in & ~ddrB); matmania_state *state = (matmania_state *)space->machine->driver_data;
return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
} }
WRITE8_HANDLER( maniach_68705_portB_w ) WRITE8_HANDLER( maniach_68705_port_b_w )
{ {
//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data); matmania_state *state = (matmania_state *)space->machine->driver_data;
if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02)) //logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
if (BIT(state->ddr_b, 1) && BIT(~data, 1) && BIT(state->port_b_out, 1))
{ {
portA_in = from_main; state->port_a_in = state->from_main;
main_sent = 0; state->main_sent = 0;
//logerror("read command %02x from main cpu\n",portA_in); //logerror("read command %02x from main cpu\n", state->port_a_in);
} }
if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04)) if (BIT(state->ddr_b, 2) && BIT(data, 2) && BIT(~state->port_b_out, 2))
{ {
//logerror("send command %02x to main cpu\n",portA_out); //logerror("send command %02x to main cpu\n", state->port_a_out);
from_mcu = portA_out; state->from_mcu = state->port_a_out;
mcu_sent = 1; state->mcu_sent = 1;
} }
portB_out = data; state->port_b_out = data;
} }
WRITE8_HANDLER( maniach_68705_ddrB_w ) WRITE8_HANDLER( maniach_68705_ddr_b_w )
{ {
ddrB = data; matmania_state *state = (matmania_state *)space->machine->driver_data;
state->ddr_b = data;
} }
static UINT8 portC_in,portC_out,ddrC; READ8_HANDLER( maniach_68705_port_c_r )
READ8_HANDLER( maniach_68705_portC_r )
{ {
portC_in = 0; matmania_state *state = (matmania_state *)space->machine->driver_data;
if (main_sent) portC_in |= 0x01;
if (!mcu_sent) portC_in |= 0x02; state->port_c_in = 0;
//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),portC_in);
return (portC_out & ddrC) | (portC_in & ~ddrC); if (state->main_sent)
state->port_c_in |= 0x01;
if (!state->mcu_sent)
state->port_c_in |= 0x02;
//logerror("%04x: 68705 port C read %02x\n",state->cpu_get_pc(space->cpu), state->port_c_in);
return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
} }
WRITE8_HANDLER( maniach_68705_portC_w ) WRITE8_HANDLER( maniach_68705_port_c_w )
{ {
//logerror("%04x: 68705 port C write %02x\n",cpu_get_pc(space->cpu),data); matmania_state *state = (matmania_state *)space->machine->driver_data;
portC_out = data;
//logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(space->cpu), data);
state->port_c_out = data;
} }
WRITE8_HANDLER( maniach_68705_ddrC_w ) WRITE8_HANDLER( maniach_68705_ddr_c_w )
{ {
ddrC = data; matmania_state *state = (matmania_state *)space->machine->driver_data;
state->ddr_c = data;
} }
WRITE8_HANDLER( maniach_mcu_w ) WRITE8_HANDLER( maniach_mcu_w )
{ {
//logerror("%04x: 3040_w %02x\n",cpu_get_pc(space->cpu),data); matmania_state *state = (matmania_state *)space->machine->driver_data;
from_main = data;
main_sent = 1; //logerror("%04x: 3040_w %02x\n", cpu_get_pc(space->cpu), data);
state->from_main = data;
state->main_sent = 1;
} }
READ8_HANDLER( maniach_mcu_r ) READ8_HANDLER( maniach_mcu_r )
{ {
//logerror("%04x: 3040_r %02x\n",cpu_get_pc(space->cpu),from_mcu); matmania_state *state = (matmania_state *)space->machine->driver_data;
mcu_sent = 0;
return from_mcu; //logerror("%04x: 3040_r %02x\n", cpu_get_pc(space->cpu), state->from_mcu);
state->mcu_sent = 0;
return state->from_mcu;
} }
READ8_HANDLER( maniach_mcu_status_r ) READ8_HANDLER( maniach_mcu_status_r )
{ {
matmania_state *state = (matmania_state *)space->machine->driver_data;
int res = 0; int res = 0;
/* bit 0 = when 0, mcu has sent data to the main cpu */ /* bit 0 = when 0, mcu has sent data to the main cpu */
/* bit 1 = when 1, mcu is ready to receive data from main cpu */ /* bit 1 = when 1, mcu is ready to receive data from main cpu */
//logerror("%04x: 3041_r\n",cpu_get_pc(space->cpu)); //logerror("%04x: 3041_r\n", cpu_get_pc(space->cpu));
if (!mcu_sent) res |= 0x01; if (!state->mcu_sent)
if (!main_sent) res |= 0x02; res |= 0x01;
if (!state->main_sent)
res |= 0x02;
return res; return res;
} }

View File

@ -2,13 +2,6 @@
#include "deprecat.h" #include "deprecat.h"
#include "includes/mexico86.h" #include "includes/mexico86.h"
UINT8 *mexico86_protection_ram;
static int kikikai_mcu_running, kikikai_mcu_initialised;
/* /*
$f008 - write $f008 - write
bit 7 = ? (unused?) bit 7 = ? (unused?)
@ -22,18 +15,22 @@ bit 0 = ? (unused?)
*/ */
WRITE8_HANDLER( mexico86_f008_w ) WRITE8_HANDLER( mexico86_f008_w )
{ {
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
if (devtag_get_device(space->machine, "mcu") != NULL)
cpu_set_input_line(state->audiocpu, INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE);
if (state->mcu != NULL)
{ {
// mexico 86, knight boy // mexico 86, knight boy
cputag_set_input_line(space->machine, "mcu", INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE); cpu_set_input_line(state->mcu, INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
} }
else else
{ {
// simulation for KiKi KaiKai // simulation for KiKi KaiKai
kikikai_mcu_running = data & 2; state->mcu_running = data & 2;
if (!kikikai_mcu_running)
kikikai_mcu_initialised = 0; if (!state->mcu_running)
state->mcu_initialised = 0;
} }
} }
@ -47,67 +44,66 @@ WRITE8_HANDLER( mexico86_f008_w )
***************************************************************************/ ***************************************************************************/
static void mcu_simulate(running_machine *machine) static void mcu_simulate( running_machine *machine )
{ {
if (!kikikai_mcu_initialised) mexico86_state *state = (mexico86_state *)machine->driver_data;
if (!state->mcu_initialised)
{ {
if (mexico86_protection_ram[0x01] == 0x00) if (state->protection_ram[0x01] == 0x00)
{ {
logerror("initialising MCU\n"); logerror("initialising MCU\n");
mexico86_protection_ram[0x04] = 0xfc; // coin inputs state->protection_ram[0x04] = 0xfc; // coin inputs
mexico86_protection_ram[0x02] = 0xff; // player 1 state->protection_ram[0x02] = 0xff; // player 1
mexico86_protection_ram[0x03] = 0xff; // player 2 state->protection_ram[0x03] = 0xff; // player 2
mexico86_protection_ram[0x1b] = 0xff; // active player state->protection_ram[0x1b] = 0xff; // active player
mexico86_protection_ram[0x06] = 0xff; // must be FF otherwise PS4 ERROR state->protection_ram[0x06] = 0xff; // must be FF otherwise PS4 ERROR
mexico86_protection_ram[0x07] = 0x03; // must be 03 otherwise PS4 ERROR state->protection_ram[0x07] = 0x03; // must be 03 otherwise PS4 ERROR
mexico86_protection_ram[0x00] = 0x00; state->protection_ram[0x00] = 0x00;
kikikai_mcu_initialised = 1; state->mcu_initialised = 1;
} }
} }
if (kikikai_mcu_initialised) if (state->mcu_initialised)
{ {
int i; int i;
static int coin_last;
int coin_curr; int coin_curr;
coin_curr = ~input_port_read(machine, "IN0") & 1; coin_curr = ~input_port_read(machine, "IN0") & 1;
if (coin_curr && !coin_last && mexico86_protection_ram[0x01] < 9) if (coin_curr && !state->coin_last && state->protection_ram[0x01] < 9)
{ {
mexico86_protection_ram[0x01]++; // increase credits counter state->protection_ram[0x01]++; // increase credits counter
mexico86_protection_ram[0x0a] = 0x01; // set flag (coin inserted sound is not played otherwise) state->protection_ram[0x0a] = 0x01; // set flag (coin inserted sound is not played otherwise)
} }
coin_last = coin_curr; state->coin_last = coin_curr;
mexico86_protection_ram[0x04] = 0x3c; // coin inputs state->protection_ram[0x04] = 0x3c; // coin inputs
mexico86_protection_ram[0x02] = BITSWAP8(input_port_read(machine, "IN1"), 7,6,5,4,2,3,1,0); // player 1 state->protection_ram[0x02] = BITSWAP8(input_port_read(machine, "IN1"), 7,6,5,4,2,3,1,0); // player 1
mexico86_protection_ram[0x03] = BITSWAP8(input_port_read(machine, "IN2"), 7,6,5,4,2,3,1,0); // player 2 state->protection_ram[0x03] = BITSWAP8(input_port_read(machine, "IN2"), 7,6,5,4,2,3,1,0); // player 2
if (mexico86_protection_ram[0x19] == 0xaa) // player 2 active if (state->protection_ram[0x19] == 0xaa) // player 2 active
mexico86_protection_ram[0x1b] = mexico86_protection_ram[0x03]; state->protection_ram[0x1b] = state->protection_ram[0x03];
else else
mexico86_protection_ram[0x1b] = mexico86_protection_ram[0x02]; state->protection_ram[0x1b] = state->protection_ram[0x02];
for (i = 0; i < 0x10; i += 2) for (i = 0; i < 0x10; i += 2)
mexico86_protection_ram[i + 0xb1] = mexico86_protection_ram[i + 0xb0]; state->protection_ram[i + 0xb1] = state->protection_ram[i + 0xb0];
for (i = 0; i < 0x0a; i++) for (i = 0; i < 0x0a; i++)
mexico86_protection_ram[i + 0xc0] = mexico86_protection_ram[i + 0x90] + 1; state->protection_ram[i + 0xc0] = state->protection_ram[i + 0x90] + 1;
if (mexico86_protection_ram[0xd1] == 0xff) if (state->protection_ram[0xd1] == 0xff)
{ {
if (mexico86_protection_ram[0xd0] > 0 && mexico86_protection_ram[0xd0] < 4) if (state->protection_ram[0xd0] > 0 && state->protection_ram[0xd0] < 4)
{ {
mexico86_protection_ram[0xd2] = 0x81; state->protection_ram[0xd2] = 0x81;
mexico86_protection_ram[0xd0] = 0xff; state->protection_ram[0xd0] = 0xff;
} }
} }
if (state->protection_ram[0xe0] > 0 && state->protection_ram[0xe0] < 4)
if (mexico86_protection_ram[0xe0] > 0 && mexico86_protection_ram[0xe0] < 4)
{ {
static const UINT8 answers[3][16] = static const UINT8 answers[3][16] =
{ {
@ -115,17 +111,17 @@ logerror("initialising MCU\n");
{ 0x00,0x04,0x08,0x0C,0x10,0x14,0x18,0x1C,0x20,0x31,0x2B,0x35,0x00,0x00,0x00,0x00 }, { 0x00,0x04,0x08,0x0C,0x10,0x14,0x18,0x1C,0x20,0x31,0x2B,0x35,0x00,0x00,0x00,0x00 },
{ 0x00,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x03,0x0A,0x0B,0x14,0x00,0x00,0x00,0x00 }, { 0x00,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x03,0x0A,0x0B,0x14,0x00,0x00,0x00,0x00 },
}; };
int table = mexico86_protection_ram[0xe0] - 1; int table = state->protection_ram[0xe0] - 1;
for (i = 1; i < 0x10; i++) for (i = 1; i < 0x10; i++)
mexico86_protection_ram[0xe0 + i] = answers[table][i]; state->protection_ram[0xe0 + i] = answers[table][i];
mexico86_protection_ram[0xe0] = 0xff; state->protection_ram[0xe0] = 0xff;
} }
if (mexico86_protection_ram[0xf0] > 0 && mexico86_protection_ram[0xf0] < 4) if (state->protection_ram[0xf0] > 0 && state->protection_ram[0xf0] < 4)
{ {
mexico86_protection_ram[0xf1] = 0xb3; state->protection_ram[0xf1] = 0xb3;
mexico86_protection_ram[0xf0] = 0xff; state->protection_ram[0xf0] = 0xff;
} }
@ -133,21 +129,21 @@ logerror("initialising MCU\n");
// this should be equivalent to the obfuscated kiki_clogic() below // this should be equivalent to the obfuscated kiki_clogic() below
{ {
static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00}; static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
UINT16 sy = mexico86_protection_ram[0xa0] + ((0x18)>>1); UINT16 sy = state->protection_ram[0xa0] + ((0x18) >> 1);
UINT16 sx = mexico86_protection_ram[0xa1] + ((0x18)>>1); UINT16 sx = state->protection_ram[0xa1] + ((0x18) >> 1);
for (i = 0; i < 0x38; i += 8) for (i = 0; i < 0x38; i += 8)
{ {
UINT8 hw = db[mexico86_protection_ram[0x20 + i] & 0xf]; UINT8 hw = db[state->protection_ram[0x20 + i] & 0xf];
if (hw) if (hw)
{ {
UINT16 xdiff = sx - ((UINT16)mexico86_protection_ram[0x20 + i+6] << 8 | mexico86_protection_ram[0x20 + i+7]); UINT16 xdiff = sx - ((UINT16)state->protection_ram[0x20 + i + 6] << 8 | state->protection_ram[0x20 + i + 7]);
if (xdiff < hw) if (xdiff < hw)
{ {
UINT16 ydiff = sy - ((UINT16)mexico86_protection_ram[0x20 + i+4] << 8 | mexico86_protection_ram[0x20 + i+5]); UINT16 ydiff = sy - ((UINT16)state->protection_ram[0x20 + i + 4] << 8 | state->protection_ram[0x20 + i + 5]);
if (ydiff < hw) if (ydiff < hw)
mexico86_protection_ram[0xa2] = 1; // we have a collision state->protection_ram[0xa2] = 1; // we have a collision
} }
} }
} }
@ -158,11 +154,13 @@ logerror("initialising MCU\n");
INTERRUPT_GEN( kikikai_interrupt ) INTERRUPT_GEN( kikikai_interrupt )
{ {
if (kikikai_mcu_running) mexico86_state *state = (mexico86_state *)device->machine->driver_data;
if (state->mcu_running)
mcu_simulate(device->machine); mcu_simulate(device->machine);
cpu_set_input_line_vector(device,0,mexico86_protection_ram[0]); cpu_set_input_line_vector(device, 0, state->protection_ram[0]);
cpu_set_input_line(device,0,HOLD_LINE); cpu_set_input_line(device, 0, HOLD_LINE);
} }
@ -179,8 +177,9 @@ INTERRUPT_GEN( kikikai_interrupt )
#define DCWIDTH 0 #define DCWIDTH 0
#define DCHEIGHT 0 #define DCHEIGHT 0
static void kiki_clogic(int address, int latch) static void kiki_clogic(running_machine *machine, int address, int latch)
{ {
mexico86_state *state = (mexico86_state *)machine->driver_data;
static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00}; static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
static UINT8 queue[64]; static UINT8 queue[64];
static int qfront = 0, state = 0; static int qfront = 0, state = 0;
@ -208,7 +207,7 @@ static void kiki_clogic(int address, int latch)
diff1 = sy - (short)(queue[(qptr+4)&0x3f]<<8|queue[(qptr+5)&0x3f]) + DCHEIGHT; diff1 = sy - (short)(queue[(qptr+4)&0x3f]<<8|queue[(qptr+5)&0x3f]) + DCHEIGHT;
diff2 = diff1 - (hw + DCHEIGHT); diff2 = diff1 - (hw + DCHEIGHT);
if ((diff1^diff2)<0) if ((diff1^diff2)<0)
mexico86_protection_ram[KIKI_CL_OUT] = 1; // we have a collision state->protection_ram[KIKI_CL_OUT] = 1; // we have a collision
} }
} }
} }
@ -229,30 +228,32 @@ INTERRUPT_GEN( mexico86_m68705_interrupt )
{ {
/* I don't know how to handle the interrupt line so I just toggle it every time. */ /* I don't know how to handle the interrupt line so I just toggle it every time. */
if (cpu_getiloops(device) & 1) if (cpu_getiloops(device) & 1)
cpu_set_input_line(device,0,CLEAR_LINE); cpu_set_input_line(device, 0, CLEAR_LINE);
else else
cpu_set_input_line(device,0,ASSERT_LINE); cpu_set_input_line(device, 0, ASSERT_LINE);
} }
READ8_HANDLER( mexico86_68705_port_a_r )
static UINT8 portA_in,portA_out,ddrA;
READ8_HANDLER( mexico86_68705_portA_r )
{ {
//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
return (portA_out & ddrA) | (portA_in & ~ddrA);
//logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
} }
WRITE8_HANDLER( mexico86_68705_portA_w ) WRITE8_HANDLER( mexico86_68705_port_a_w )
{ {
//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
portA_out = data;
//logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
state->port_a_out = data;
} }
WRITE8_HANDLER( mexico86_68705_ddrA_w ) WRITE8_HANDLER( mexico86_68705_ddr_a_w )
{ {
ddrA = data; mexico86_state *state = (mexico86_state *)space->machine->driver_data;
state->ddr_a = data;
} }
@ -273,67 +274,71 @@ WRITE8_HANDLER( mexico86_68705_ddrA_w )
* 7 W not used? * 7 W not used?
*/ */
static UINT8 portB_in,portB_out,ddrB; READ8_HANDLER( mexico86_68705_port_b_r )
READ8_HANDLER( mexico86_68705_portB_r )
{ {
return (portB_out & ddrB) | (portB_in & ~ddrB); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
} }
static int address,latch; WRITE8_HANDLER( mexico86_68705_port_b_w )
WRITE8_HANDLER( mexico86_68705_portB_w )
{ {
//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
//logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
if ((ddrB & 0x01) && (~data & 0x01) && (portB_out & 0x01)) if (BIT(state->ddr_b, 0) && BIT(~data, 0) && BIT(state->port_b_out, 0))
{ {
portA_in = latch; state->port_a_in = state->latch;
} }
if ((ddrB & 0x02) && (data & 0x02) && (~portB_out & 0x02)) /* positive edge trigger */
if (BIT(state->ddr_b, 1) && BIT(data, 1) && BIT(~state->port_b_out, 1)) /* positive edge trigger */
{ {
address = portA_out; state->address = state->port_a_out;
//if (address >= 0x80) logerror("%04x: 68705 address %02x\n",cpu_get_pc(space->cpu),portA_out); //if (state->address >= 0x80) logerror("%04x: 68705 address %02x\n", cpu_get_pc(space->cpu), state->port_a_out);
} }
if ((ddrB & 0x08) && (~data & 0x08) && (portB_out & 0x08))
if (BIT(state->ddr_b, 3) && BIT(~data, 3) && BIT(state->port_b_out, 3))
{ {
if (data & 0x10) /* read */ if (data & 0x10) /* read */
{ {
if (data & 0x04) if (data & 0x04)
{ {
//logerror("%04x: 68705 read %02x from address %04x\n",cpu_get_pc(space->cpu),shared[0x800+address],address); //logerror("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(space->cpu), state->protection_ram[state->address], state->address);
latch = mexico86_protection_ram[address]; state->latch = state->protection_ram[state->address];
} }
else else
{ {
//logerror("%04x: 68705 read input port %04x\n",cpu_get_pc(space->cpu),address); //logerror("%04x: 68705 read input port %04x\n", cpu_get_pc(space->cpu), state->address);
latch = input_port_read(space->machine, (address & 1) ? "IN2" : "IN1"); state->latch = input_port_read(space->machine, (state->address & 1) ? "IN2" : "IN1");
} }
} }
else /* write */ else /* write */
{ {
//logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu),portA_out,address); //logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu), port_a_out, state->address);
mexico86_protection_ram[address] = portA_out; state->protection_ram[state->address] = state->port_a_out;
} }
} }
if ((ddrB & 0x20) && (data & 0x20) && (~portB_out & 0x20))
if (BIT(state->ddr_b, 5) && BIT(data, 5) && BIT(~state->port_b_out, 5))
{ {
cpu_set_input_line_vector(devtag_get_device(space->machine, "maincpu"), 0, mexico86_protection_ram[0]); cpu_set_input_line_vector(state->maincpu, 0, state->protection_ram[0]);
cputag_set_input_line(space->machine, "maincpu", 0, HOLD_LINE); //AT: HOLD_LINE works better in Z80 interrupt mode 1. cpu_set_input_line(state->maincpu, 0, HOLD_LINE); //AT: HOLD_LINE works better in Z80 interrupt mode 1.
}
if ((ddrB & 0x40) && (~data & 0x40) && (portB_out & 0x40))
{
logerror("%04x: 68705 unknown port B bit %02x\n",cpu_get_pc(space->cpu),data);
}
if ((ddrB & 0x80) && (~data & 0x80) && (portB_out & 0x80))
{
logerror("%04x: 68705 unknown port B bit %02x\n",cpu_get_pc(space->cpu),data);
} }
portB_out = data; if (BIT(state->ddr_b, 6) && BIT(~data, 6) && BIT(state->port_b_out, 6))
{
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(space->cpu), data);
}
if (BIT(state->ddr_b, 7) && BIT(~data, 7) && BIT(state->port_b_out, 7))
{
logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(space->cpu), data);
}
state->port_b_out = data;
} }
WRITE8_HANDLER( mexico86_68705_ddrB_w ) WRITE8_HANDLER( mexico86_68705_ddr_b_w )
{ {
ddrB = data; mexico86_state *state = (mexico86_state *)space->machine->driver_data;
state->ddr_b = data;
} }

View File

@ -16,19 +16,6 @@
#include "includes/matmania.h" #include "includes/matmania.h"
UINT8 *matmania_videoram,*matmania_colorram;
size_t matmania_videoram_size;
UINT8 *matmania_videoram2,*matmania_colorram2;
size_t matmania_videoram2_size;
UINT8 *matmania_videoram3,*matmania_colorram3;
size_t matmania_videoram3_size;
UINT8 *matmania_scroll;
static bitmap_t *tmpbitmap;
static bitmap_t *tmpbitmap2;
UINT8 *matmania_pageselect;
/*************************************************************************** /***************************************************************************
Convert the color PROMs into a more useable format. Convert the color PROMs into a more useable format.
@ -58,25 +45,24 @@ PALETTE_INIT( matmania )
{ {
int i; int i;
for (i = 0;i < 64;i++) for (i = 0; i < 64; i++)
{ {
int bit0,bit1,bit2,bit3,r,g,b; int bit0, bit1, bit2, bit3, r, g, b;
bit0 = BIT(color_prom[0], 0);
bit0 = (color_prom[0] >> 0) & 0x01; bit1 = BIT(color_prom[0], 1);
bit1 = (color_prom[0] >> 1) & 0x01; bit2 = BIT(color_prom[0], 2);
bit2 = (color_prom[0] >> 2) & 0x01; bit3 = BIT(color_prom[0], 3);
bit3 = (color_prom[0] >> 3) & 0x01;
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
bit0 = (color_prom[0] >> 4) & 0x01; bit0 = BIT(color_prom[0], 4);
bit1 = (color_prom[0] >> 5) & 0x01; bit1 = BIT(color_prom[0], 5);
bit2 = (color_prom[0] >> 6) & 0x01; bit2 = BIT(color_prom[0], 6);
bit3 = (color_prom[0] >> 7) & 0x01; bit3 = BIT(color_prom[0], 7);
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
bit0 = (color_prom[64] >> 0) & 0x01; bit0 = BIT(color_prom[64], 0);
bit1 = (color_prom[64] >> 1) & 0x01; bit1 = BIT(color_prom[64], 1);
bit2 = (color_prom[64] >> 2) & 0x01; bit2 = BIT(color_prom[64], 2);
bit3 = (color_prom[64] >> 3) & 0x01; bit3 = BIT(color_prom[64], 3);
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette_set_color(machine,i,MAKE_RGB(r,g,b)); palette_set_color(machine,i,MAKE_RGB(r,g,b));
@ -88,33 +74,33 @@ PALETTE_INIT( matmania )
WRITE8_HANDLER( matmania_paletteram_w ) WRITE8_HANDLER( matmania_paletteram_w )
{ {
int bit0,bit1,bit2,bit3,val; matmania_state *state = (matmania_state *)space->machine->driver_data;
int r,g,b; int bit0, bit1, bit2, bit3, val;
int r, g, b;
int offs2; int offs2;
state->paletteram[offset] = data;
space->machine->generic.paletteram.u8[offset] = data;
offs2 = offset & 0x0f; offs2 = offset & 0x0f;
val = space->machine->generic.paletteram.u8[offs2]; val = state->paletteram[offs2];
bit0 = (val >> 0) & 0x01; bit0 = BIT(val, 0);
bit1 = (val >> 1) & 0x01; bit1 = BIT(val, 1);
bit2 = (val >> 2) & 0x01; bit2 = BIT(val, 2);
bit3 = (val >> 3) & 0x01; bit3 = BIT(val, 3);
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
val = space->machine->generic.paletteram.u8[offs2 | 0x10]; val = state->paletteram[offs2 | 0x10];
bit0 = (val >> 0) & 0x01; bit0 = BIT(val, 0);
bit1 = (val >> 1) & 0x01; bit1 = BIT(val, 1);
bit2 = (val >> 2) & 0x01; bit2 = BIT(val, 2);
bit3 = (val >> 3) & 0x01; bit3 = BIT(val, 3);
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
val = space->machine->generic.paletteram.u8[offs2 | 0x20]; val = state->paletteram[offs2 | 0x20];
bit0 = (val >> 0) & 0x01; bit0 = BIT(val, 0);
bit1 = (val >> 1) & 0x01; bit1 = BIT(val, 1);
bit2 = (val >> 2) & 0x01; bit2 = BIT(val, 2);
bit3 = (val >> 3) & 0x01; bit3 = BIT(val, 3);
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette_set_color(space->machine,offs2 + 64,MAKE_RGB(r,g,b)); palette_set_color(space->machine,offs2 + 64,MAKE_RGB(r,g,b));
@ -126,97 +112,87 @@ WRITE8_HANDLER( matmania_paletteram_w )
Start the video hardware emulation. Start the video hardware emulation.
***************************************************************************/ ***************************************************************************/
VIDEO_START( matmania ) VIDEO_START( matmania )
{ {
matmania_state *state = (matmania_state *)machine->driver_data;
int width = video_screen_get_width(machine->primary_screen); int width = video_screen_get_width(machine->primary_screen);
int height = video_screen_get_height(machine->primary_screen); int height = video_screen_get_height(machine->primary_screen);
bitmap_format format = video_screen_get_format(machine->primary_screen); bitmap_format format = video_screen_get_format(machine->primary_screen);
/* Mat Mania has a virtual screen twice as large as the visible screen */ /* Mat Mania has a virtual screen twice as large as the visible screen */
tmpbitmap = auto_bitmap_alloc(machine, width, 2*height, format); state->tmpbitmap = auto_bitmap_alloc(machine, width, 2 * height, format);
tmpbitmap2 = auto_bitmap_alloc(machine, width, 2*height, format); state->tmpbitmap2 = auto_bitmap_alloc(machine, width, 2 * height, format);
} }
VIDEO_UPDATE( matmania ) VIDEO_UPDATE( matmania )
{ {
UINT8 *spriteram = screen->machine->generic.spriteram.u8; matmania_state *state = (matmania_state *)screen->machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
/* Update the tiles in the left tile ram bank */ /* Update the tiles in the left tile ram bank */
for (offs = matmania_videoram_size - 1;offs >= 0;offs--) for (offs = state->videoram_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 15 - offs / 32;
int sy = offs % 32;
drawgfx_opaque(state->tmpbitmap, 0, screen->machine->gfx[1],
sx = 15 - offs / 32; state->videoram[offs] + ((state->colorram[offs] & 0x08) << 5),
sy = offs % 32; (state->colorram[offs] & 0x30) >> 4,
drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
matmania_videoram[offs] + ((matmania_colorram[offs] & 0x08) << 5),
(matmania_colorram[offs] & 0x30) >> 4,
0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */ 0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */
16*sx,16*sy); 16 * sx, 16 * sy);
} }
/* Update the tiles in the right tile ram bank */ /* Update the tiles in the right tile ram bank */
for (offs = matmania_videoram3_size - 1;offs >= 0;offs--) for (offs = state->videoram3_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 15 - offs / 32;
int sy = offs % 32;
drawgfx_opaque(state->tmpbitmap2, 0, screen->machine->gfx[1],
sx = 15 - offs / 32; state->videoram3[offs] + ((state->colorram3[offs] & 0x08) << 5),
sy = offs % 32; (state->colorram3[offs] & 0x30) >> 4,
drawgfx_opaque(tmpbitmap2,0,screen->machine->gfx[1],
matmania_videoram3[offs] + ((matmania_colorram3[offs] & 0x08) << 5),
(matmania_colorram3[offs] & 0x30) >> 4,
0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */ 0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */
16*sx,16*sy); 16*sx,16*sy);
} }
/* copy the temporary bitmap to the screen */ /* copy the temporary bitmap to the screen */
{ {
int scrolly; int scrolly = -*state->scroll;
if (state->pageselect[0] & 0x01) // maniach sets 0x20 sometimes, which must have a different meaning
copyscrollbitmap(bitmap, state->tmpbitmap2, 0, 0, 1, &scrolly, cliprect);
scrolly = -*matmania_scroll;
if (matmania_pageselect[0]&0x01) // maniach sets 0x20 sometimes, which must have a different meaning
copyscrollbitmap(bitmap,tmpbitmap2,0,0,1,&scrolly,cliprect);
else else
copyscrollbitmap(bitmap,tmpbitmap,0,0,1,&scrolly,cliprect); copyscrollbitmap(bitmap, state->tmpbitmap, 0, 0, 1, &scrolly, cliprect);
} }
/* Draw the sprites */ /* Draw the sprites */
for (offs = 0;offs < screen->machine->generic.spriteram_size;offs += 4) for (offs = 0; offs < state->spriteram_size; offs += 4)
{ {
if (spriteram[offs] & 0x01) if (spriteram[offs] & 0x01)
{ {
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[2], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2],
spriteram[offs+1] + ((spriteram[offs] & 0xf0) << 4), spriteram[offs + 1] + ((spriteram[offs] & 0xf0) << 4),
(spriteram[offs] & 0x08) >> 3, (spriteram[offs] & 0x08) >> 3,
spriteram[offs] & 0x04,spriteram[offs] & 0x02, spriteram[offs] & 0x04, spriteram[offs] & 0x02,
239 - spriteram[offs+3],(240 - spriteram[offs+2]) & 0xff,0); 239 - spriteram[offs + 3],(240 - spriteram[offs + 2]) & 0xff,0);
} }
} }
/* draw the frontmost playfield. They are characters, but draw them as sprites */ /* draw the frontmost playfield. They are characters, but draw them as sprites */
for (offs = matmania_videoram2_size - 1;offs >= 0;offs--) for (offs = state->videoram2_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 31 - offs / 32;
int sy = offs % 32;
sx = 31 - offs / 32;
sy = offs % 32;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
matmania_videoram2[offs] + 256 * (matmania_colorram2[offs] & 0x07), state->videoram2[offs] + 256 * (state->colorram2[offs] & 0x07),
(matmania_colorram2[offs] & 0x30) >> 4, (state->colorram2[offs] & 0x30) >> 4,
0,0, 0,0,
8*sx,8*sy,0); 8*sx,8*sy,0);
} }
@ -225,38 +201,33 @@ VIDEO_UPDATE( matmania )
VIDEO_UPDATE( maniach ) VIDEO_UPDATE( maniach )
{ {
UINT8 *spriteram = screen->machine->generic.spriteram.u8; matmania_state *state = (matmania_state *)screen->machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
/* Update the tiles in the left tile ram bank */ /* Update the tiles in the left tile ram bank */
for (offs = matmania_videoram_size - 1;offs >= 0;offs--) for (offs = state->videoram_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 15 - offs / 32;
int sy = offs % 32;
drawgfx_opaque(state->tmpbitmap, 0, screen->machine->gfx[1],
sx = 15 - offs / 32; state->videoram[offs] + ((state->colorram[offs] & 0x03) << 8),
sy = offs % 32; (state->colorram[offs] & 0x30) >> 4,
drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
matmania_videoram[offs] + ((matmania_colorram[offs] & 0x03) << 8),
(matmania_colorram[offs] & 0x30) >> 4,
0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */ 0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */
16*sx,16*sy); 16*sx,16*sy);
} }
/* Update the tiles in the right tile ram bank */ /* Update the tiles in the right tile ram bank */
for (offs = matmania_videoram3_size - 1;offs >= 0;offs--) for (offs = state->videoram3_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 15 - offs / 32;
int sy = offs % 32;
drawgfx_opaque(state->tmpbitmap2, 0, screen->machine->gfx[1],
sx = 15 - offs / 32; state->videoram3[offs] + ((state->colorram3[offs] & 0x03) << 8),
sy = offs % 32; (state->colorram3[offs] & 0x30) >> 4,
drawgfx_opaque(tmpbitmap2,0,screen->machine->gfx[1],
matmania_videoram3[offs] + ((matmania_colorram3[offs] & 0x03) << 8),
(matmania_colorram3[offs] & 0x30) >> 4,
0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */ 0,sy >= 16, /* flip horizontally tiles on the right half of the bitmap */
16*sx,16*sy); 16*sx,16*sy);
} }
@ -264,20 +235,17 @@ VIDEO_UPDATE( maniach )
/* copy the temporary bitmap to the screen */ /* copy the temporary bitmap to the screen */
{ {
int scrolly; int scrolly = -*state->scroll;
if (state->pageselect[0] & 0x01) // this sets 0x20 sometimes, which must have a different meaning
scrolly = -*matmania_scroll; copyscrollbitmap(bitmap, state->tmpbitmap2, 0, 0, 1, &scrolly, cliprect);
if (matmania_pageselect[0]&0x01) // this sets 0x20 sometimes, which must have a different meaning
copyscrollbitmap(bitmap,tmpbitmap2,0,0,1,&scrolly,cliprect);
else else
copyscrollbitmap(bitmap,tmpbitmap,0,0,1,&scrolly,cliprect); copyscrollbitmap(bitmap, state->tmpbitmap, 0, 0, 1, &scrolly, cliprect);
} }
/* Draw the sprites */ /* Draw the sprites */
for (offs = 0;offs < screen->machine->generic.spriteram_size;offs += 4) for (offs = 0; offs < state->spriteram_size; offs += 4)
{ {
if (spriteram[offs] & 0x01) if (spriteram[offs] & 0x01)
{ {
@ -291,17 +259,14 @@ VIDEO_UPDATE( maniach )
/* draw the frontmost playfield. They are characters, but draw them as sprites */ /* draw the frontmost playfield. They are characters, but draw them as sprites */
for (offs = matmania_videoram2_size - 1;offs >= 0;offs--) for (offs = state->videoram2_size - 1; offs >= 0; offs--)
{ {
int sx,sy; int sx = 31 - offs / 32;
int sy = offs % 32;
sx = 31 - offs / 32;
sy = offs % 32;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
matmania_videoram2[offs] + 256 * (matmania_colorram2[offs] & 0x07), state->videoram2[offs] + 256 * (state->colorram2[offs] & 0x07),
(matmania_colorram2[offs] & 0x30) >> 4, (state->colorram2[offs] & 0x30) >> 4,
0,0, 0,0,
8*sx,8*sy,0); 8*sx,8*sy,0);
} }

View File

@ -19,40 +19,33 @@
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/metlclsh.h"
/* Local variables: */
static tilemap_t *bg_tilemap,*fg_tilemap;
static UINT8 metlclsh_write_mask, *metlclsh_otherram;
/* Variables that driver has access to: */
UINT8 *metlclsh_bgram, *metlclsh_fgram, *metlclsh_scrollx;
/* Functions that driver has access to: */
WRITE8_HANDLER( metlclsh_rambank_w ) WRITE8_HANDLER( metlclsh_rambank_w )
{ {
metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
if (data & 1) if (data & 1)
{ {
metlclsh_write_mask = 0; state->write_mask = 0;
memory_set_bankptr(space->machine, "bank1", metlclsh_bgram); memory_set_bankptr(space->machine, "bank1", state->bgram);
} }
else else
{ {
metlclsh_write_mask = 1 << (data >> 1); state->write_mask = 1 << (data >> 1);
memory_set_bankptr(space->machine, "bank1", metlclsh_otherram); memory_set_bankptr(space->machine, "bank1", state->otherram);
} }
} }
static UINT8 metlclsh_gfxbank;
WRITE8_HANDLER( metlclsh_gfxbank_w ) WRITE8_HANDLER( metlclsh_gfxbank_w )
{ {
if (!(data & 4) && (metlclsh_gfxbank != data)) metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
if (!(data & 4) && (state->gfxbank != data))
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
metlclsh_gfxbank = data & 3; state->gfxbank = data & 3;
} }
} }
@ -80,14 +73,17 @@ static TILEMAP_MAPPER( metlclsh_bgtilemap_scan )
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
SET_TILE_INFO(1, metlclsh_bgram[tile_index] + (metlclsh_gfxbank << 7),0,0); metlclsh_state *state = (metlclsh_state *)machine->driver_data;
SET_TILE_INFO(1, state->bgram[tile_index] + (state->gfxbank << 7), 0, 0);
} }
WRITE8_HANDLER( metlclsh_bgram_w ) WRITE8_HANDLER( metlclsh_bgram_w )
{ {
metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
/* This ram is banked: it's either the tilemap (e401 = 1) /* This ram is banked: it's either the tilemap (e401 = 1)
or bit n of another area (e401 = n << 1)? (that I don't understand) */ or bit n of another area (e401 = n << 1)? (that I don't understand) */
if (metlclsh_write_mask) if (state->write_mask)
{ {
/* unknown area - the following is almost surely wrong */ /* unknown area - the following is almost surely wrong */
// 405b (e401 = e c a 8 6 4 2 0) writes d400++ // 405b (e401 = e c a 8 6 4 2 0) writes d400++
@ -95,14 +91,14 @@ WRITE8_HANDLER( metlclsh_bgram_w )
// 4085 (e401 = e a 6 2) writes d000++ // 4085 (e401 = e a 6 2) writes d000++
// 405b (e401 = e a 6 2) writes d000++ // 405b (e401 = e a 6 2) writes d000++
// metlclsh_otherram[offset] |= (data & metlclsh_write_mask); // state->otherram[offset] |= (data & state->write_mask);
metlclsh_otherram[offset] = (metlclsh_otherram[offset] & ~metlclsh_write_mask) | (data & metlclsh_write_mask); state->otherram[offset] = (state->otherram[offset] & ~state->write_mask) | (data & state->write_mask);
} }
else else
{ {
/* tilemap */ /* tilemap */
metlclsh_bgram[offset] = data; state->bgram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x1ff); tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x1ff);
} }
} }
@ -121,16 +117,18 @@ WRITE8_HANDLER( metlclsh_bgram_w )
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
UINT8 code = metlclsh_fgram[tile_index + 0x000]; metlclsh_state *state = (metlclsh_state *)machine->driver_data;
UINT8 attr = metlclsh_fgram[tile_index + 0x400]; UINT8 code = state->fgram[tile_index + 0x000];
UINT8 attr = state->fgram[tile_index + 0x400];
SET_TILE_INFO(2, code + ((attr & 0x03) << 8), (attr >> 5) & 3, 0); SET_TILE_INFO(2, code + ((attr & 0x03) << 8), (attr >> 5) & 3, 0);
tileinfo->category = ((attr & 0x80) ? 1 : 2); tileinfo->category = ((attr & 0x80) ? 1 : 2);
} }
WRITE8_HANDLER( metlclsh_fgram_w ) WRITE8_HANDLER( metlclsh_fgram_w )
{ {
metlclsh_fgram[offset] = data; metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff); state->fgram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
} }
@ -142,13 +140,17 @@ WRITE8_HANDLER( metlclsh_fgram_w )
VIDEO_START( metlclsh ) VIDEO_START( metlclsh )
{ {
metlclsh_otherram = auto_alloc_array(machine, UINT8, 0x800); // banked ram metlclsh_state *state = (metlclsh_state *)machine->driver_data;
bg_tilemap = tilemap_create(machine, get_bg_tile_info,metlclsh_bgtilemap_scan,16,16,32,16); state->otherram = auto_alloc_array(machine, UINT8, 0x800); // banked ram
fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen( bg_tilemap, 0 ); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, metlclsh_bgtilemap_scan, 16, 16, 32, 16);
tilemap_set_transparent_pen( fg_tilemap, 0 ); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->bg_tilemap, 0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
state_save_register_global_pointer(machine, state->otherram, 0x800);
} }
@ -172,38 +174,42 @@ VIDEO_START( metlclsh )
***************************************************************************/ ***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
UINT8 *spriteram = machine->generic.spriteram.u8; metlclsh_state *state = (metlclsh_state *)machine->driver_data;
UINT8 *spriteram = state->spriteram;
gfx_element *gfx = machine->gfx[0]; gfx_element *gfx = machine->gfx[0];
int offs; int offs;
for (offs = 0;offs < machine->generic.spriteram_size; offs += 4) for (offs = 0; offs < state->spriteram_size; offs += 4)
{ {
int attr,code,color,sx,sy,flipx,flipy,wrapy,sizey; int attr, code, color, sx, sy, flipx, flipy, wrapy, sizey;
attr = spriteram[offs]; attr = spriteram[offs];
if (!(attr & 0x01)) continue; // enable if (!(attr & 0x01))
continue; // enable
flipy = (attr & 0x02); flipy = (attr & 0x02);
flipx = (attr & 0x04); flipx = (attr & 0x04);
color = (attr & 0x08) >> 3; color = (attr & 0x08) >> 3;
sizey = (attr & 0x10); // double height sizey = (attr & 0x10); // double height
code = ((attr & 0x60) << 3) + spriteram[offs+1]; code = ((attr & 0x60) << 3) + spriteram[offs + 1];
sx = 240 - spriteram[offs+3]; sx = 240 - spriteram[offs + 3];
if (sx < -7) sx += 256; if (sx < -7)
sy = 240 - spriteram[offs+2]; sx += 256;
sy = 240 - spriteram[offs + 2];
if (flip_screen_get(machine)) if (flip_screen_get(machine))
{ {
sx = 240 - sx; flipx = !flipx; sx = 240 - sx; flipx = !flipx;
sy = 240 - sy; flipy = !flipy; if (sizey) sy+=16; sy = 240 - sy; flipy = !flipy; if (sizey) sy += 16;
if (sy > 240) sy -= 256; if (sy > 240) sy -= 256;
} }
/* Draw twice, at sy and sy + 256 (wrap around) */ /* Draw twice, at sy and sy + 256 (wrap around) */
for ( wrapy = 0; wrapy <= 256; wrapy += 256 ) for (wrapy = 0; wrapy <= 256; wrapy += 256)
{ {
if (sizey) if (sizey)
{ {
@ -238,20 +244,23 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( metlclsh ) VIDEO_UPDATE( metlclsh )
{ {
bitmap_fill(bitmap,cliprect,0x10); metlclsh_state *state = (metlclsh_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,fg_tilemap,1,0); // low priority tiles of foreground bitmap_fill(bitmap, cliprect, 0x10);
if (metlclsh_scrollx[0] & 0x08) // background (if enabled)
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 1, 0); // low priority tiles of foreground
if (state->scrollx[0] & 0x08) // background (if enabled)
{ {
/* The background seems to be always flipped along x */ /* The background seems to be always flipped along x */
tilemap_set_flip(bg_tilemap, (flip_screen_get(screen->machine) ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0) ^ TILEMAP_FLIPX); tilemap_set_flip(state->bg_tilemap, (flip_screen_get(screen->machine) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0) ^ TILEMAP_FLIPX);
tilemap_set_scrollx(bg_tilemap, 0,metlclsh_scrollx[1] + ((metlclsh_scrollx[0]&0x02)<<7) ); tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx[1] + ((state->scrollx[0] & 0x02) << 7) );
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
} }
draw_sprites(screen->machine,bitmap,cliprect); // sprites draw_sprites(screen->machine, bitmap, cliprect); // sprites
tilemap_draw(bitmap,cliprect,fg_tilemap,2,0); // high priority tiles of foreground tilemap_draw(bitmap, cliprect, state->fg_tilemap, 2, 0); // high priority tiles of foreground
// popmessage("%02X",metlclsh_scrollx[0]); // popmessage("%02X", state->scrollx[0]);
return 0; return 0;
} }

View File

@ -1,58 +1,57 @@
#include "emu.h" #include "emu.h"
#include "includes/mexico86.h" #include "includes/mexico86.h"
UINT8 *mexico86_videoram,*mexico86_objectram;
size_t mexico86_objectram_size;
static int charbank;
WRITE8_HANDLER( mexico86_bankswitch_w ) WRITE8_HANDLER( mexico86_bankswitch_w )
{ {
UINT8 *RAM = memory_region(space->machine, "maincpu"); mexico86_state *state = (mexico86_state *)space->machine->driver_data;
if ((data & 7) > 5) if ((data & 7) > 5)
popmessage( "Switching to invalid bank!" ); popmessage("Switching to invalid bank!");
memory_set_bankptr(space->machine, "bank1", &RAM[0x10000 + 0x4000 * (data & 0x07)]); memory_set_bank(space->machine, "bank1", data & 0x07);
charbank = (data & 0x20) >> 5; state->charbank = BIT(data, 5);
} }
VIDEO_UPDATE( mexico86 ) VIDEO_UPDATE( mexico86 )
{ {
mexico86_state *state = (mexico86_state *)screen->machine->driver_data;
int offs; int offs;
int sx,sy,xc,yc; int sx, sy, xc, yc;
int gfx_num,gfx_attr,gfx_offs; int gfx_num, gfx_attr, gfx_offs;
/* Bubble Bobble doesn't have a real video RAM. All graphics (characters */ /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
/* and sprites) are stored in the same memory region, and information on */ /* and sprites) are stored in the same memory region, and information on */
/* the background character columns is stored inthe area dd00-dd3f */ /* the background character columns is stored inthe area dd00-dd3f */
bitmap_fill(bitmap, cliprect, 255);
bitmap_fill(bitmap,cliprect,255);
sx = 0; sx = 0;
/* the score display seems to be outside of the main objectram. */
for (offs = 0;offs < mexico86_objectram_size+0x200;offs += 4) /* the score display seems to be outside of the main objectram. */
for (offs = 0; offs < state->objectram_size + 0x200; offs += 4)
{ {
int height; int height;
if (offs >= mexico86_objectram_size && offs < mexico86_objectram_size+0x180) continue; if (offs >= state->objectram_size && offs < state->objectram_size + 0x180)
if (offs >= mexico86_objectram_size+0x1c0) continue; continue;
if (offs >= state->objectram_size + 0x1c0)
continue;
/* skip empty sprites */ /* skip empty sprites */
/* this is dword aligned so the UINT32 * cast shouldn't give problems */ /* this is dword aligned so the UINT32 * cast shouldn't give problems */
/* on any architecture */ /* on any architecture */
if (*(UINT32 *)(&mexico86_objectram[offs]) == 0) if (*(UINT32 *)(&state->objectram[offs]) == 0)
continue; continue;
gfx_num = mexico86_objectram[offs + 1]; gfx_num = state->objectram[offs + 1];
gfx_attr = mexico86_objectram[offs + 3]; gfx_attr = state->objectram[offs + 3];
if ((gfx_num & 0x80) == 0) /* 16x16 sprites */ if (!BIT(gfx_num, 7)) /* 16x16 sprites */
{ {
gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12; gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
height = 2; height = 2;
@ -67,24 +66,25 @@ if (offs >= mexico86_objectram_size+0x1c0) continue;
sx += 16; sx += 16;
else else
{ {
sx = mexico86_objectram[offs + 2]; sx = state->objectram[offs + 2];
// if (gfx_attr & 0x40) sx -= 256; //if (gfx_attr & 0x40) sx -= 256;
} }
sy = 256 - height*8 - (mexico86_objectram[offs + 0]); sy = 256 - height * 8 - (state->objectram[offs + 0]);
for (xc = 0;xc < 2;xc++) for (xc = 0; xc < 2; xc++)
{ {
for (yc = 0;yc < height;yc++) for (yc = 0; yc < height; yc++)
{ {
int goffs,code,color,flipx,flipy,x,y; int goffs, code, color, flipx, flipy, x, y;
goffs = gfx_offs + xc * 0x40 + yc * 0x02; goffs = gfx_offs + xc * 0x40 + yc * 0x02;
code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x07) << 8) code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x07) << 8)
+ ((mexico86_videoram[goffs + 1] & 0x80) << 4) + (charbank << 12); + ((state->videoram[goffs + 1] & 0x80) << 4) + (state->charbank << 12);
color = ((mexico86_videoram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2); color = ((state->videoram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2);
flipx = mexico86_videoram[goffs + 1] & 0x40; flipx = state->videoram[goffs + 1] & 0x40;
flipy = 0; flipy = 0;
// x = sx + xc * 8;
//x = sx + xc * 8;
x = (sx + xc * 8) & 0xff; x = (sx + xc * 8) & 0xff;
y = (sy + yc * 8) & 0xff; y = (sy + yc * 8) & 0xff;
@ -101,23 +101,25 @@ if (offs >= mexico86_objectram_size+0x1c0) continue;
VIDEO_UPDATE( kikikai ) VIDEO_UPDATE( kikikai )
{ {
mexico86_state *state = (mexico86_state *)screen->machine->driver_data;
int offs; int offs;
int sx,sy,yc; int sx, sy, yc;
int gfx_num,gfx_attr,gfx_offs; int gfx_num, gfx_attr, gfx_offs;
int height; int height;
int goffs,code,color,y; int goffs, code, color, y;
int tx, ty; int tx, ty;
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
sx = 0; sx = 0;
for (offs=0; offs<mexico86_objectram_size; offs+=4) for (offs = 0; offs < state->objectram_size; offs += 4)
{ {
if (*(UINT32*)(mexico86_objectram + offs) == 0) continue; if (*(UINT32*)(state->objectram + offs) == 0)
continue;
ty = mexico86_objectram[offs]; ty = state->objectram[offs];
gfx_num = mexico86_objectram[offs + 1]; gfx_num = state->objectram[offs + 1];
tx = mexico86_objectram[offs + 2]; tx = state->objectram[offs + 2];
gfx_attr = mexico86_objectram[offs + 3]; gfx_attr = state->objectram[offs + 3];
if (gfx_num & 0x80) if (gfx_num & 0x80)
{ {
@ -133,15 +135,16 @@ VIDEO_UPDATE( kikikai )
height = 2; height = 2;
sx = tx; sx = tx;
} }
sy = 256 - (height << 3) - ty; sy = 256 - (height << 3) - ty;
height <<= 1; height <<= 1;
for (yc=0; yc<height; yc+=2) for (yc = 0; yc < height; yc += 2)
{ {
y = (sy + (yc << 2)) & 0xff; y = (sy + (yc << 2)) & 0xff;
goffs = gfx_offs + yc; goffs = gfx_offs + yc;
code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x1f) << 8); code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x1f) << 8);
color = (mexico86_videoram[goffs + 1] & 0xe0) >> 5; color = (state->videoram[goffs + 1] & 0xe0) >> 5;
goffs += 0x40; goffs += 0x40;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
@ -150,8 +153,8 @@ VIDEO_UPDATE( kikikai )
0,0, 0,0,
sx&0xff,y,15); sx&0xff,y,15);
code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x1f) << 8); code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x1f) << 8);
color = (mexico86_videoram[goffs + 1] & 0xe0) >> 5; color = (state->videoram[goffs + 1] & 0xe0) >> 5;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
code, code,

View File

@ -7,14 +7,7 @@
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/mosaic.h"
UINT8 *mosaic_fgvideoram;
UINT8 *mosaic_bgvideoram;
static tilemap_t *bg_tilemap,*fg_tilemap;
/*************************************************************************** /***************************************************************************
@ -24,20 +17,22 @@ static tilemap_t *bg_tilemap,*fg_tilemap;
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
mosaic_state *state = (mosaic_state *)machine->driver_data;
tile_index *= 2; tile_index *= 2;
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
mosaic_fgvideoram[tile_index] + (mosaic_fgvideoram[tile_index+1] << 8), state->fgvideoram[tile_index] + (state->fgvideoram[tile_index+1] << 8),
0, 0,
0); 0);
} }
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
mosaic_state *state = (mosaic_state *)machine->driver_data;
tile_index *= 2; tile_index *= 2;
SET_TILE_INFO( SET_TILE_INFO(
1, 1,
mosaic_bgvideoram[tile_index] + (mosaic_bgvideoram[tile_index+1] << 8), state->bgvideoram[tile_index] + (state->bgvideoram[tile_index+1] << 8),
0, 0,
0); 0);
} }
@ -52,10 +47,12 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( mosaic ) VIDEO_START( mosaic )
{ {
fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,64,32); mosaic_state *state = (mosaic_state *)machine->driver_data;
bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8,8,64,32);
tilemap_set_transparent_pen(fg_tilemap,0xff); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_transparent_pen(state->fg_tilemap, 0xff);
} }
@ -67,21 +64,27 @@ VIDEO_START( mosaic )
WRITE8_HANDLER( mosaic_fgvideoram_w ) WRITE8_HANDLER( mosaic_fgvideoram_w )
{ {
mosaic_fgvideoram[offset] = data; mosaic_state *state = (mosaic_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset/2);
state->fgvideoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
} }
WRITE8_HANDLER( mosaic_bgvideoram_w ) WRITE8_HANDLER( mosaic_bgvideoram_w )
{ {
mosaic_bgvideoram[offset] = data; mosaic_state *state = (mosaic_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset/2);
state->bgvideoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
} }
VIDEO_UPDATE( mosaic ) VIDEO_UPDATE( mosaic )
{ {
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); mosaic_state *state = (mosaic_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0; return 0;
} }

View File

@ -14,31 +14,29 @@
*******************************************************************************/ *******************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/mouser.h"
UINT8 *mouser_videoram;
UINT8 *mouser_colorram;
PALETTE_INIT( mouser ) PALETTE_INIT( mouser )
{ {
int i; int i;
for (i = 0;i < machine->config->total_colors;i++) for (i = 0; i < machine->config->total_colors; i++)
{ {
int bit0,bit1,bit2,r,g,b; int bit0, bit1, bit2, r, g, b;
/* red component */ /* red component */
bit0 = BIT(*color_prom,0); bit0 = BIT(*color_prom, 0);
bit1 = BIT(*color_prom,1); bit1 = BIT(*color_prom, 1);
bit2 = BIT(*color_prom,2); bit2 = BIT(*color_prom, 2);
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */ /* green component */
bit0 = BIT(*color_prom,3); bit0 = BIT(*color_prom, 3);
bit1 = BIT(*color_prom,4); bit1 = BIT(*color_prom, 4);
bit2 = BIT(*color_prom,5); bit2 = BIT(*color_prom, 5);
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */ /* blue component */
bit0 = BIT(*color_prom,6); bit0 = BIT(*color_prom, 6);
bit1 = BIT(*color_prom,7); bit1 = BIT(*color_prom, 7);
b = 0x4f * bit0 + 0xa8 * bit1; b = 0x4f * bit0 + 0xa8 * bit1;
palette_set_color(machine,i,MAKE_RGB(r,g,b)); palette_set_color(machine,i,MAKE_RGB(r,g,b));
@ -58,10 +56,11 @@ WRITE8_HANDLER( mouser_flip_screen_y_w )
VIDEO_UPDATE( mouser ) VIDEO_UPDATE( mouser )
{ {
UINT8 *spriteram = screen->machine->generic.spriteram.u8; mouser_state *state = (mouser_state *)screen->machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
int sx,sy; int sx, sy;
int flipx,flipy; int flipx, flipy;
/* for every character in the Video RAM */ /* for every character in the Video RAM */
for (offs = 0x3ff; offs >= 0; offs--) for (offs = 0x3ff; offs >= 0; offs--)
@ -89,11 +88,11 @@ VIDEO_UPDATE( mouser )
/* Ideally we would merge these on a pixel-by-pixel basis, but it's ok to do this char-by-char, */ /* Ideally we would merge these on a pixel-by-pixel basis, but it's ok to do this char-by-char, */
/* Since it's only for the MOUSER logo and it looks fine */ /* Since it's only for the MOUSER logo and it looks fine */
/* Note: this is _not_ dependant on flipping */ /* Note: this is _not_ dependant on flipping */
color_offs = offs%32 + ((256 + 8*(offs/32) - spriteram[offs%32])%256)/8*32; color_offs = offs % 32 + ((256 + 8 * (offs / 32) - spriteram[offs % 32] )% 256) / 8 * 32;
drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0], drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],
mouser_videoram[offs] | (mouser_colorram[color_offs]>>5)*256 | ((mouser_colorram[color_offs]>>4)&1)*512, state->videoram[offs] | (state->colorram[color_offs] >> 5) * 256 | ((state->colorram[color_offs] >> 4) & 1) * 512,
mouser_colorram[color_offs]%16, state->colorram[color_offs]%16,
flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine), flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine),
8*sx,scrolled_y_position); 8*sx,scrolled_y_position);
} }
@ -103,11 +102,11 @@ VIDEO_UPDATE( mouser )
/* This is the first set of 7 sprites */ /* This is the first set of 7 sprites */
for(offs = 0x0084; offs < 0x00A0; offs += 4) for(offs = 0x0084; offs < 0x00A0; offs += 4)
{ {
sx = spriteram[offs+3]; sx = spriteram[offs + 3];
sy = 0xef-spriteram[offs+2]; sy = 0xef - spriteram[offs + 2];
flipx = (spriteram[offs]&0x40)>>6; flipx = BIT(spriteram[offs], 6);
flipy = (spriteram[offs]&0x80)>>7; flipy = BIT(spriteram[offs], 7);
if (flip_screen_x_get(screen->machine)) if (flip_screen_x_get(screen->machine))
{ {
@ -121,7 +120,7 @@ VIDEO_UPDATE( mouser )
sy = 238 - sy; sy = 238 - sy;
} }
if ((spriteram[offs+1]&0x10)>>4) if (BIT(spriteram[offs + 1], 4))
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)],
spriteram[offs]&0x3f, spriteram[offs]&0x3f,
spriteram[offs+1]%16, spriteram[offs+1]%16,
@ -130,13 +129,13 @@ VIDEO_UPDATE( mouser )
} }
/* This is the second set of 8 sprites */ /* This is the second set of 8 sprites */
for(offs = 0x00C4; offs < 0x00E4; offs += 4) for(offs = 0x00C4; offs < 0x00e4; offs += 4)
{ {
sx = spriteram[offs+3]; sx = spriteram[offs + 3];
sy = 0xef-spriteram[offs+2]; sy = 0xef - spriteram[offs + 2];
flipx = (spriteram[offs]&0x40)>>6; flipx = BIT(spriteram[offs], 6);
flipy = (spriteram[offs]&0x80)>>7; flipy = BIT(spriteram[offs], 7);
if (flip_screen_x_get(screen->machine)) if (flip_screen_x_get(screen->machine))
{ {
@ -150,7 +149,7 @@ VIDEO_UPDATE( mouser )
sy = 238 - sy; sy = 238 - sy;
} }
if ((spriteram[offs+1]&0x10)>>4) if (BIT(spriteram[offs + 1], 4))
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)],
spriteram[offs]&0x3f, spriteram[offs]&0x3f,
spriteram[offs+1]%16, spriteram[offs+1]%16,

View File

@ -7,12 +7,7 @@
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/mrdo.h"
UINT8 *mrdo_bgvideoram,*mrdo_fgvideoram;
static tilemap_t *bg_tilemap,*fg_tilemap;
static int flipscreen;
/*************************************************************************** /***************************************************************************
@ -46,6 +41,7 @@ static int flipscreen;
200 ohm pulldown on all three components 200 ohm pulldown on all three components
***************************************************************************/ ***************************************************************************/
PALETTE_INIT( mrdo ) PALETTE_INIT( mrdo )
{ {
int i; int i;
@ -138,20 +134,22 @@ PALETTE_INIT( mrdo )
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
UINT8 attr = mrdo_bgvideoram[tile_index]; mrdo_state *state = (mrdo_state *)machine->driver_data;
UINT8 attr = state->bgvideoram[tile_index];
SET_TILE_INFO( SET_TILE_INFO(
1, 1,
mrdo_bgvideoram[tile_index+0x400] + ((attr & 0x80) << 1), state->bgvideoram[tile_index + 0x400] + ((attr & 0x80) << 1),
attr & 0x3f, attr & 0x3f,
(attr & 0x40) ? TILE_FORCE_LAYER0 : 0); (attr & 0x40) ? TILE_FORCE_LAYER0 : 0);
} }
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
UINT8 attr = mrdo_fgvideoram[tile_index]; mrdo_state *state = (mrdo_state *)machine->driver_data;
UINT8 attr = state->fgvideoram[tile_index];
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
mrdo_fgvideoram[tile_index+0x400] + ((attr & 0x80) << 1), state->fgvideoram[tile_index+0x400] + ((attr & 0x80) << 1),
attr & 0x3f, attr & 0x3f,
(attr & 0x40) ? TILE_FORCE_LAYER0 : 0); (attr & 0x40) ? TILE_FORCE_LAYER0 : 0);
} }
@ -166,18 +164,22 @@ static TILE_GET_INFO( get_fg_tile_info )
VIDEO_START( mrdo ) VIDEO_START( mrdo )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32); mrdo_state *state = (mrdo_state *)machine->driver_data;
fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(bg_tilemap,0); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(fg_tilemap,0); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_scrolldx(bg_tilemap, 0, 56); tilemap_set_transparent_pen(state->bg_tilemap,0);
tilemap_set_scrolldx(fg_tilemap, 0, 56); tilemap_set_transparent_pen(state->fg_tilemap,0);
tilemap_set_scrolldy(bg_tilemap, 0, 6);
tilemap_set_scrolldy(fg_tilemap, 0, 6);
state_save_register_global(machine, flipscreen); tilemap_set_scrolldx(state->bg_tilemap, 0, 56);
tilemap_set_scrolldx(state->fg_tilemap, 0, 56);
tilemap_set_scrolldy(state->bg_tilemap, 0, 6);
tilemap_set_scrolldy(state->fg_tilemap, 0, 6);
state->flipscreen = 0;
state_save_register_global(machine, state->flipscreen);
} }
@ -190,38 +192,46 @@ VIDEO_START( mrdo )
WRITE8_HANDLER( mrdo_bgvideoram_w ) WRITE8_HANDLER( mrdo_bgvideoram_w )
{ {
mrdo_bgvideoram[offset] = data; mrdo_state *state = (mrdo_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff); state->bgvideoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0x3ff);
} }
WRITE8_HANDLER( mrdo_fgvideoram_w ) WRITE8_HANDLER( mrdo_fgvideoram_w )
{ {
mrdo_fgvideoram[offset] = data; mrdo_state *state = (mrdo_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff); state->fgvideoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
} }
WRITE8_HANDLER( mrdo_scrollx_w ) WRITE8_HANDLER( mrdo_scrollx_w )
{ {
tilemap_set_scrollx(bg_tilemap,0,data); mrdo_state *state = (mrdo_state *)space->machine->driver_data;
tilemap_set_scrollx(state->bg_tilemap, 0, data);
} }
WRITE8_HANDLER( mrdo_scrolly_w ) WRITE8_HANDLER( mrdo_scrolly_w )
{ {
/* This is NOT affected by flipscreen (so stop it happening) */ mrdo_state *state = (mrdo_state *)space->machine->driver_data;
if (flipscreen) tilemap_set_scrolly(bg_tilemap,0,((256-data) & 0xff)); /* This is NOT affected by flipscreen (so stop it happening) */
else tilemap_set_scrolly(bg_tilemap,0,data); if (state->flipscreen)
tilemap_set_scrolly(state->bg_tilemap, 0,((256 - data) & 0xff));
else
tilemap_set_scrolly(state->bg_tilemap, 0, data);
} }
WRITE8_HANDLER( mrdo_flipscreen_w ) WRITE8_HANDLER( mrdo_flipscreen_w )
{ {
mrdo_state *state = (mrdo_state *)space->machine->driver_data;
/* bits 1-3 control the playfield priority, but they are not used by */ /* bits 1-3 control the playfield priority, but they are not used by */
/* Mr. Do! so we don't emulate them */ /* Mr. Do! so we don't emulate them */
flipscreen = data & 0x01; state->flipscreen = data & 0x01;
tilemap_set_flip_all(space->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
} }
@ -232,29 +242,31 @@ WRITE8_HANDLER( mrdo_flipscreen_w )
***************************************************************************/ ***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
{ {
UINT8 *spriteram = machine->generic.spriteram.u8; mrdo_state *state = (mrdo_state *)machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
{ {
if (spriteram[offs + 1] != 0) if (spriteram[offs + 1] != 0)
{ {
drawgfx_transpen(bitmap,cliprect,machine->gfx[2], drawgfx_transpen(bitmap, cliprect, machine->gfx[2],
spriteram[offs],spriteram[offs + 2] & 0x0f, spriteram[offs], spriteram[offs + 2] & 0x0f,
spriteram[offs + 2] & 0x10,spriteram[offs + 2] & 0x20, spriteram[offs + 2] & 0x10, spriteram[offs + 2] & 0x20,
spriteram[offs + 3],256 - spriteram[offs + 1],0); spriteram[offs + 3], 256 - spriteram[offs + 1], 0);
} }
} }
} }
VIDEO_UPDATE( mrdo ) VIDEO_UPDATE( mrdo )
{ {
bitmap_fill(bitmap,cliprect,0); mrdo_state *state = (mrdo_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); bitmap_fill(bitmap, cliprect,0);
draw_sprites(screen->machine,bitmap,cliprect); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }

View File

@ -6,46 +6,59 @@ Mr. F. Lea
******************************************************************/ ******************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/mrflea.h"
static int mrflea_gfx_bank; WRITE8_HANDLER( mrflea_gfx_bank_w )
{
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
state->gfx_bank = data;
WRITE8_HANDLER( mrflea_gfx_bank_w ){ if (data & ~0x14)
mrflea_gfx_bank = data; logerror("unknown gfx bank: 0x%02x\n", data);
if( data & ~0x14 ){
logerror( "unknown gfx bank: 0x%02x\n", data );
}
} }
WRITE8_HANDLER( mrflea_videoram_w ){ WRITE8_HANDLER( mrflea_videoram_w )
int bank = offset/0x400; {
mrflea_state *state = (mrflea_state *)space->machine->driver_data;
int bank = offset / 0x400;
offset &= 0x3ff; offset &= 0x3ff;
space->machine->generic.videoram.u8[offset] = data; state->videoram[offset] = data;
space->machine->generic.videoram.u8[offset+0x400] = bank; state->videoram[offset + 0x400] = bank;
/* the address range that tile data is written to sets one bit of /* the address range that tile data is written to sets one bit of
** the bank select. The remaining bits are from a video register. the bank select. The remaining bits are from a video register. */
*/
} }
WRITE8_HANDLER( mrflea_spriteram_w ){ WRITE8_HANDLER( mrflea_spriteram_w )
if( offset&2 ){ /* tile_number */ {
space->machine->generic.spriteram.u8[offset|1] = offset&1; mrflea_state *state = (mrflea_state *)space->machine->driver_data;
if (offset & 2)
{
/* tile_number */
state->spriteram[offset | 1] = offset & 1;
offset &= ~1; offset &= ~1;
} }
space->machine->generic.spriteram.u8[offset] = data;
state->spriteram[offset] = data;
} }
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
mrflea_state *state = (mrflea_state *)machine->driver_data;
const gfx_element *gfx = machine->gfx[0]; const gfx_element *gfx = machine->gfx[0];
const UINT8 *source = machine->generic.spriteram.u8; const UINT8 *source = state->spriteram;
const UINT8 *finish = source+0x100; const UINT8 *finish = source + 0x100;
rectangle clip = *video_screen_get_visible_area(machine->primary_screen); rectangle clip = *video_screen_get_visible_area(machine->primary_screen);
clip.max_x -= 24; clip.max_x -= 24;
clip.min_x += 16; clip.min_x += 16;
while( source<finish ){
int xpos = source[1]-3; while (source < finish)
int ypos = source[0]-16+3; {
int tile_number = source[2]+source[3]*0x100; int xpos = source[1] - 3;
int ypos = source[0] - 16 + 3;
int tile_number = source[2] + source[3] * 0x100;
drawgfx_transpen( bitmap, &clip,gfx, drawgfx_transpen( bitmap, &clip,gfx,
tile_number, tile_number,
@ -57,21 +70,29 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
0, /* color */ 0, /* color */
0,0, /* no flip */ 0,0, /* no flip */
xpos,256+ypos,0 ); xpos,256+ypos,0 );
source+=4; source += 4;
} }
} }
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
const UINT8 *source = machine->generic.videoram.u8; mrflea_state *state = (mrflea_state *)machine->driver_data;
const UINT8 *source = state->videoram;
const gfx_element *gfx = machine->gfx[1]; const gfx_element *gfx = machine->gfx[1];
int sx,sy; int sx, sy;
int base = 0; int base = 0;
if( mrflea_gfx_bank&0x04 ) base |= 0x400;
if( mrflea_gfx_bank&0x10 ) base |= 0x200; if (BIT(state->gfx_bank, 2))
for( sy=0; sy<256; sy+=8 ){ base |= 0x400;
for( sx=0; sx<256; sx+=8 ){
int tile_number = base+source[0]+source[0x400]*0x100; if (BIT(state->gfx_bank, 4))
base |= 0x200;
for (sy = 0; sy < 256; sy += 8)
{
for (sx = 0; sx < 256; sx += 8)
{
int tile_number = base + source[0] + source[0x400] * 0x100;
source++; source++;
drawgfx_opaque( bitmap, cliprect, drawgfx_opaque( bitmap, cliprect,
gfx, gfx,
@ -83,9 +104,6 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
} }
} }
VIDEO_START( mrflea ){
}
VIDEO_UPDATE( mrflea ) VIDEO_UPDATE( mrflea )
{ {
draw_background(screen->machine, bitmap, cliprect); draw_background(screen->machine, bitmap, cliprect);

View File

@ -7,16 +7,15 @@
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/mrjong.h"
UINT8 *mrjong_videoram;
UINT8 *mrjong_colorram;
static tilemap_t *bg_tilemap;
/*************************************************************************** /***************************************************************************
Convert the color PROMs. (from video/pengo.c) Convert the color PROMs. (from video/pengo.c)
***************************************************************************/ ***************************************************************************/
PALETTE_INIT( mrjong ) PALETTE_INIT( mrjong )
{ {
int i; int i;
@ -31,21 +30,21 @@ PALETTE_INIT( mrjong )
int r, g, b; int r, g, b;
/* red component */ /* red component */
bit0 = (color_prom[i] >> 0) & 0x01; bit0 = BIT(color_prom[i], 0);
bit1 = (color_prom[i] >> 1) & 0x01; bit1 = BIT(color_prom[i], 1);
bit2 = (color_prom[i] >> 2) & 0x01; bit2 = BIT(color_prom[i], 2);
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */ /* green component */
bit0 = (color_prom[i] >> 3) & 0x01; bit0 = BIT(color_prom[i], 3);
bit1 = (color_prom[i] >> 4) & 0x01; bit1 = BIT(color_prom[i], 4);
bit2 = (color_prom[i] >> 5) & 0x01; bit2 = BIT(color_prom[i], 5);
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */ /* blue component */
bit0 = 0; bit0 = 0;
bit1 = (color_prom[i] >> 6) & 0x01; bit1 = BIT(color_prom[i], 6);
bit2 = (color_prom[i] >> 7) & 0x01; bit2 = BIT(color_prom[i], 7);
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
@ -68,46 +67,52 @@ PALETTE_INIT( mrjong )
Display control parameter. Display control parameter.
***************************************************************************/ ***************************************************************************/
WRITE8_HANDLER( mrjong_videoram_w ) WRITE8_HANDLER( mrjong_videoram_w )
{ {
mrjong_videoram[offset] = data; mrjong_state *state = (mrjong_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( mrjong_colorram_w ) WRITE8_HANDLER( mrjong_colorram_w )
{ {
mrjong_colorram[offset] = data; mrjong_state *state = (mrjong_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset); state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( mrjong_flipscreen_w ) WRITE8_HANDLER( mrjong_flipscreen_w )
{ {
if (flip_screen_get(space->machine) != (data & 0x01)) if (flip_screen_get(space->machine) != BIT(data, 2))
{ {
flip_screen_set(space->machine, data & 0x01); flip_screen_set(space->machine, BIT(data, 2));
tilemap_mark_all_tiles_dirty_all(space->machine); tilemap_mark_all_tiles_dirty_all(space->machine);
} }
} }
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int code = mrjong_videoram[tile_index] | ((mrjong_colorram[tile_index] & 0x20) << 3); mrjong_state *state = (mrjong_state *)machine->driver_data;
int color = mrjong_colorram[tile_index] & 0x1f; int code = state->videoram[tile_index] | ((state->colorram[tile_index] & 0x20) << 3);
int flags = ((mrjong_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((mrjong_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0); int color = state->colorram[tile_index] & 0x1f;
int flags = ((state->colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((state->colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
SET_TILE_INFO(0, code, color, flags); SET_TILE_INFO(0, code, color, flags);
} }
VIDEO_START( mrjong ) VIDEO_START( mrjong )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32); mrjong_state *state = (mrjong_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32);
} }
/* /*
Note: First 0x40 entries in the videoram are actually spriteram Note: First 0x40 entries in the videoram are actually spriteram
*/ */
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
mrjong_state *state = (mrjong_state *)machine->driver_data;
int offs; int offs;
for (offs = (0x40 - 4); offs >= 0; offs -= 4) for (offs = (0x40 - 4); offs >= 0; offs -= 4)
@ -117,13 +122,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int sx, sy; int sx, sy;
int flipx, flipy; int flipx, flipy;
sprt = (((mrjong_videoram[offs + 1] >> 2) & 0x3f) | ((mrjong_videoram[offs + 3] & 0x20) << 1)); sprt = (((state->videoram[offs + 1] >> 2) & 0x3f) | ((state->videoram[offs + 3] & 0x20) << 1));
flipx = (mrjong_videoram[offs + 1] & 0x01) >> 0; flipx = (state->videoram[offs + 1] & 0x01) >> 0;
flipy = (mrjong_videoram[offs + 1] & 0x02) >> 1; flipy = (state->videoram[offs + 1] & 0x02) >> 1;
color = (mrjong_videoram[offs + 3] & 0x1f); color = (state->videoram[offs + 3] & 0x1f);
sx = 224 - mrjong_videoram[offs + 2]; sx = 224 - state->videoram[offs + 2];
sy = mrjong_videoram[offs + 0]; sy = state->videoram[offs + 0];
if (flip_screen_get(machine)) if (flip_screen_get(machine))
{ {
sx = 208 - sx; sx = 208 - sx;
@ -142,7 +147,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( mrjong ) VIDEO_UPDATE( mrjong )
{ {
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); mrjong_state *state = (mrjong_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }

View File

@ -27,16 +27,16 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
mugsmash_state *state = (mugsmash_state *)machine->driver_data; mugsmash_state *state = (mugsmash_state *)machine->driver_data;
const UINT16 *source = state->spriteram; const UINT16 *source = state->spriteram;
const UINT16 *finish = source+0x2000; const UINT16 *finish = source + 0x2000;
const gfx_element *gfx = machine->gfx[0]; const gfx_element *gfx = machine->gfx[0];
while( source<finish ) while (source < finish)
{ {
int xpos = source[0] & 0x00ff; int xpos = source[0] & 0x00ff;
int ypos = source[4] & 0x00ff; int ypos = source[4] & 0x00ff;
int num = (source[3] & 0x00ff) | ((source[2] & 0x00ff) << 8); int num = (source[3] & 0x00ff) | ((source[2] & 0x00ff) << 8);
int attr = source[1]; int attr = source[1];
int flipx = (attr & 0x0080)>>7; int flipx = (attr & 0x0080) >> 7;
int colour = (attr & 0x000f); int colour = (attr & 0x000f);
xpos += ((attr & 0x0020) >> 5) * 0x100; xpos += ((attr & 0x0020) >> 5) * 0x100;
@ -71,13 +71,13 @@ static TILE_GET_INFO( get_mugsmash_tile_info1 )
*/ */
mugsmash_state *state = (mugsmash_state *)machine->driver_data; mugsmash_state *state = (mugsmash_state *)machine->driver_data;
int tileno,colour,fx; int tileno, colour, fx;
tileno = state->videoram1[tile_index *2 +1]; tileno = state->videoram1[tile_index * 2 + 1];
colour = state->videoram1[tile_index *2] & 0x000f; colour = state->videoram1[tile_index * 2] & 0x000f;
fx = (state->videoram1[tile_index *2] & 0xc0) >>6; fx = (state->videoram1[tile_index * 2] & 0xc0) >> 6;
SET_TILE_INFO(1,tileno,colour,TILE_FLIPYX(fx)); SET_TILE_INFO(1, tileno, colour, TILE_FLIPYX(fx));
} }
WRITE16_HANDLER( mugsmash_videoram1_w ) WRITE16_HANDLER( mugsmash_videoram1_w )
@ -85,7 +85,7 @@ WRITE16_HANDLER( mugsmash_videoram1_w )
mugsmash_state *state = (mugsmash_state *)space->machine->driver_data; mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
state->videoram1[offset] = data; state->videoram1[offset] = data;
tilemap_mark_tile_dirty(state->tilemap1,offset/2); tilemap_mark_tile_dirty(state->tilemap1, offset / 2);
} }
static TILE_GET_INFO( get_mugsmash_tile_info2 ) static TILE_GET_INFO( get_mugsmash_tile_info2 )
@ -100,13 +100,13 @@ static TILE_GET_INFO( get_mugsmash_tile_info2 )
*/ */
mugsmash_state *state = (mugsmash_state *)machine->driver_data; mugsmash_state *state = (mugsmash_state *)machine->driver_data;
int tileno,colour,fx; int tileno, colour, fx;
tileno = state->videoram2[tile_index *2 +1]; tileno = state->videoram2[tile_index * 2 + 1];
colour = state->videoram2[tile_index *2] & 0x000f; colour = state->videoram2[tile_index * 2] & 0x000f;
fx = (state->videoram2[tile_index *2] & 0xc0) >>6; fx = (state->videoram2[tile_index * 2] & 0xc0) >> 6;
SET_TILE_INFO(1,tileno,16+colour,TILE_FLIPYX(fx)); SET_TILE_INFO(1, tileno, 16 + colour, TILE_FLIPYX(fx));
} }
WRITE16_HANDLER( mugsmash_videoram2_w ) WRITE16_HANDLER( mugsmash_videoram2_w )
@ -114,7 +114,7 @@ WRITE16_HANDLER( mugsmash_videoram2_w )
mugsmash_state *state = (mugsmash_state *)space->machine->driver_data; mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
state->videoram2[offset] = data; state->videoram2[offset] = data;
tilemap_mark_tile_dirty(state->tilemap2,offset/2); tilemap_mark_tile_dirty(state->tilemap2, offset / 2);
} }
WRITE16_HANDLER (mugsmash_reg_w) WRITE16_HANDLER (mugsmash_reg_w)
@ -127,16 +127,16 @@ WRITE16_HANDLER (mugsmash_reg_w)
switch (offset) switch (offset)
{ {
case 0: case 0:
tilemap_set_scrollx(state->tilemap2,0, state->regs1[2]+7); tilemap_set_scrollx(state->tilemap2, 0, state->regs1[2] + 7);
break; break;
case 1: case 1:
tilemap_set_scrolly(state->tilemap2,0, state->regs1[3]+4); tilemap_set_scrolly(state->tilemap2, 0, state->regs1[3] + 4);
break; break;
case 2: case 2:
tilemap_set_scrollx(state->tilemap1,0, state->regs1[0]+3); tilemap_set_scrollx(state->tilemap1, 0, state->regs1[0] + 3);
break; break;
case 3: case 3:
tilemap_set_scrolly(state->tilemap1,0, state->regs1[1]+4); tilemap_set_scrolly(state->tilemap1, 0, state->regs1[1] + 4);
break; break;
} }
} }
@ -145,18 +145,18 @@ VIDEO_START( mugsmash )
{ {
mugsmash_state *state = (mugsmash_state *)machine->driver_data; mugsmash_state *state = (mugsmash_state *)machine->driver_data;
state->tilemap1 = tilemap_create(machine, get_mugsmash_tile_info1,tilemap_scan_rows, 16, 16,32,32); state->tilemap1 = tilemap_create(machine, get_mugsmash_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
tilemap_set_transparent_pen(state->tilemap1,0); tilemap_set_transparent_pen(state->tilemap1, 0);
state->tilemap2 = tilemap_create(machine, get_mugsmash_tile_info2,tilemap_scan_rows, 16, 16,32,32); state->tilemap2 = tilemap_create(machine, get_mugsmash_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
} }
VIDEO_UPDATE( mugsmash ) VIDEO_UPDATE( mugsmash )
{ {
mugsmash_state *state = (mugsmash_state *)screen->machine->driver_data; mugsmash_state *state = (mugsmash_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,state->tilemap2,0,0); tilemap_draw(bitmap, cliprect, state->tilemap2, 0, 0);
tilemap_draw(bitmap,cliprect,state->tilemap1,0,0); tilemap_draw(bitmap, cliprect, state->tilemap1, 0, 0);
draw_sprites(screen->machine,bitmap,cliprect); draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }

View File

@ -1,73 +1,70 @@
#include "emu.h" #include "emu.h"
#include "includes/munchmo.h"
UINT8 *mnchmobl_vreg;
UINT8 *mnchmobl_status_vram;
UINT8 *mnchmobl_sprite_xpos;
UINT8 *mnchmobl_sprite_attr;
UINT8 *mnchmobl_sprite_tile;
static int mnchmobl_palette_bank;
static int flipscreen;
PALETTE_INIT( mnchmobl ) PALETTE_INIT( mnchmobl )
{ {
int i; int i;
for (i = 0;i < machine->config->total_colors;i++) for (i = 0; i < machine->config->total_colors; i++)
{ {
int bit0,bit1,bit2,r,g,b; int bit0, bit1, bit2, r, g, b;
/* red component */ /* red component */
bit0 = (color_prom[i] >> 0) & 0x01; bit0 = BIT(color_prom[i], 0);
bit1 = (color_prom[i] >> 1) & 0x01; bit1 = BIT(color_prom[i], 1);
bit2 = (color_prom[i] >> 2) & 0x01; bit2 = BIT(color_prom[i], 2);
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */ /* green component */
bit0 = (color_prom[i] >> 3) & 0x01; bit0 = BIT(color_prom[i], 3);
bit1 = (color_prom[i] >> 4) & 0x01; bit1 = BIT(color_prom[i], 4);
bit2 = (color_prom[i] >> 5) & 0x01; bit2 = BIT(color_prom[i], 5);
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */ /* blue component */
bit0 = (color_prom[i] >> 6) & 0x01; bit0 = BIT(color_prom[i], 6);
bit1 = (color_prom[i] >> 7) & 0x01; bit1 = BIT(color_prom[i], 7);
b = 0x4f * bit0 + 0xa8 * bit1; b = 0x4f * bit0 + 0xa8 * bit1;
palette_set_color(machine,i,MAKE_RGB(r,g,b)); palette_set_color(machine, i, MAKE_RGB(r, g, b));
} }
} }
WRITE8_HANDLER( mnchmobl_palette_bank_w ) WRITE8_HANDLER( mnchmobl_palette_bank_w )
{ {
mnchmobl_palette_bank = data&0x3; munchmo_state *state = (munchmo_state *)space->machine->driver_data;
state->palette_bank = data & 0x3;
} }
WRITE8_HANDLER( mnchmobl_flipscreen_w ) WRITE8_HANDLER( mnchmobl_flipscreen_w )
{ {
flipscreen = data; munchmo_state *state = (munchmo_state *)space->machine->driver_data;
state->flipscreen = data;
} }
VIDEO_START( mnchmobl ) VIDEO_START( mnchmobl )
{ {
machine->generic.tmpbitmap = auto_bitmap_alloc(machine,512,512,video_screen_get_format(machine->primary_screen)); munchmo_state *state = (munchmo_state *)machine->driver_data;
state->tmpbitmap = auto_bitmap_alloc(machine, 512, 512, video_screen_get_format(machine->primary_screen));
} }
static void draw_status(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_status( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
munchmo_state *state = (munchmo_state *)machine->driver_data;
const gfx_element *gfx = machine->gfx[0]; const gfx_element *gfx = machine->gfx[0];
int row; int row;
for( row=0; row<4; row++ ) for (row = 0; row < 4; row++)
{ {
int sy,sx = (row&1)*8; int sy, sx = (row & 1) * 8;
const UINT8 *source = mnchmobl_status_vram + (~row&1)*32; const UINT8 *source = state->status_vram + (~row & 1) * 32;
if( row<=1 ) if (row <= 1)
{ {
source+=2*32; source += 2 * 32;
sx+=256+32+16; sx += 256 + 32 + 16;
} }
for( sy=0; sy<256; sy+=8 )
for (sy = 0; sy < 256; sy += 8)
{ {
drawgfx_opaque( bitmap, cliprect, drawgfx_opaque( bitmap, cliprect,
gfx, gfx,
@ -79,62 +76,64 @@ static void draw_status(running_machine *machine, bitmap_t *bitmap, const rectan
} }
} }
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
/* /*
ROM B1.2C contains 256 tilemaps defining 4x4 configurations of ROM B1.2C contains 256 tilemaps defining 4x4 configurations of
the tiles in ROM B2.2B the tiles in ROM B2.2B
*/ */
munchmo_state *state = (munchmo_state *)machine->driver_data;
UINT8 *rom = memory_region(machine, "gfx2"); UINT8 *rom = memory_region(machine, "gfx2");
const gfx_element *gfx = machine->gfx[1]; const gfx_element *gfx = machine->gfx[1];
int offs; int offs;
for( offs=0; offs<0x100; offs++ ) for (offs = 0; offs < 0x100; offs++)
{ {
int sy = (offs%16)*32; int sy = (offs % 16) * 32;
int sx = (offs/16)*32; int sx = (offs / 16) * 32;
int tile_number = machine->generic.videoram.u8[offs]; int tile_number = state->videoram[offs];
int row,col; int row, col;
for( row=0; row<4; row++ ) for (row = 0; row < 4; row++)
{ {
for( col=0; col<4; col++ ) for (col = 0; col < 4; col++)
{ {
drawgfx_opaque( machine->generic.tmpbitmap,0, gfx, drawgfx_opaque(state->tmpbitmap, 0, gfx,
rom[col+tile_number*4+row*0x400], rom[col + tile_number * 4 + row * 0x400],
mnchmobl_palette_bank, state->palette_bank,
0,0, /* flip */ 0,0, /* flip */
sx+col*8, sy+row*8 ); sx + col * 8, sy + row * 8 );
} }
} }
} }
{ {
int scrollx = -(mnchmobl_vreg[6]*2+(mnchmobl_vreg[7]>>7))-64-128-16; int scrollx = -(state->vreg[6] *2 + (state->vreg[7] >> 7)) - 64 - 128 - 16;
int scrolly = 0; int scrolly = 0;
copyscrollbitmap(bitmap,machine->generic.tmpbitmap, 1,&scrollx,1,&scrolly, cliprect); copyscrollbitmap(bitmap, state->tmpbitmap, 1, &scrollx, 1, &scrolly, cliprect);
} }
} }
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
int scroll = mnchmobl_vreg[6]; munchmo_state *state = (munchmo_state *)machine->driver_data;
int flags = mnchmobl_vreg[7]; /* XB?????? */ int scroll = state->vreg[6];
int flags = state->vreg[7]; /* XB?????? */
int xadjust = - 128 - 16 - ((flags & 0x80) ? 1 : 0); int xadjust = - 128 - 16 - ((flags & 0x80) ? 1 : 0);
int bank = (flags & 0x40) ? 1 : 0; int bank = (flags & 0x40) ? 1 : 0;
const gfx_element *gfx = machine->gfx[2 + bank]; const gfx_element *gfx = machine->gfx[2 + bank];
int color_base = mnchmobl_palette_bank * 4 + 3; int color_base = state->palette_bank * 4 + 3;
int i, j; int i, j;
int firstsprite = mnchmobl_vreg[4] & 0x3f; int firstsprite = state->vreg[4] & 0x3f;
for( i = firstsprite; i < firstsprite + 0x40; i++ ) for (i = firstsprite; i < firstsprite + 0x40; i++)
{ {
for( j = 0; j < 8; j++ ) for (j = 0; j < 8; j++)
{ {
int offs = (j << 6) | ( i & 0x3f ); int offs = (j << 6) | (i & 0x3f);
int tile_number = mnchmobl_sprite_tile[offs]; /* ETTTTTTT */ int tile_number = state->sprite_tile[offs]; /* ETTTTTTT */
int attributes = mnchmobl_sprite_attr[offs]; /* XYYYYYCC */ int attributes = state->sprite_attr[offs]; /* XYYYYYCC */
int sx = mnchmobl_sprite_xpos[offs]; /* XXXXXXX? */ int sx = state->sprite_xpos[offs]; /* XXXXXXX? */
int sy = (offs >> 6) << 5; /* Y YY------ */ int sy = (offs >> 6) << 5; /* Y YY------ */
sy += (attributes >> 2) & 0x1f; sy += (attributes >> 2) & 0x1f;
if( attributes & 0x80 ) if( attributes & 0x80 )