From 1ededa80eed77c4179cb496ed93d36902c23eb56 Mon Sep 17 00:00:00 2001 From: Couriersud Date: Tue, 1 Jan 2008 19:20:50 +0000 Subject: [PATCH] Rewrote mario.c: - fixed mario0110u1gre - rewrote driver, separate MACHINE_DRIVER(mario_audio) - palette from schematics - video timing from schematics - driver configuration switch Nintendo/Std Monitor - got rid of COLORTABLE - clocks as defines in .h - use XTAL_* --- .gitattributes | 1 + src/mame/audio/mario.c | 226 ++++++++++++++++++++++++++++++++++ src/mame/drivers/mario.c | 252 +++++++++----------------------------- src/mame/includes/mario.h | 78 ++++++++++++ src/mame/video/mario.c | 108 ++++++++-------- 5 files changed, 423 insertions(+), 242 deletions(-) create mode 100644 src/mame/includes/mario.h diff --git a/.gitattributes b/.gitattributes index 4d10f2afebe..12862e2b3d6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2207,6 +2207,7 @@ src/mame/includes/lwings.h svneol=native#text/plain src/mame/includes/m107.h svneol=native#text/plain src/mame/includes/m72.h svneol=native#text/plain src/mame/includes/m92.h svneol=native#text/plain +src/mame/includes/mario.h svneol=native#text/plain src/mame/includes/mcr.h svneol=native#text/plain src/mame/includes/meadows.h svneol=native#text/plain src/mame/includes/megasys1.h svneol=native#text/plain diff --git a/src/mame/audio/mario.c b/src/mame/audio/mario.c index 00177a457d1..614f535268b 100644 --- a/src/mame/audio/mario.c +++ b/src/mame/audio/mario.c @@ -1,8 +1,132 @@ #include "driver.h" #include "cpu/i8039/i8039.h" +#include "sound/dac.h" +#include "sound/ay8910.h" #include "sound/samples.h" +#include "includes/mario.h" +/**************************************************************** + * + * Defines and Macros + * + ****************************************************************/ + +#define ACTIVELOW_PORT_BIT(P,A,D) ((P & (~(1 << A))) | ((D ^ 1) << A)) +#define ACTIVEHIGH_PORT_BIT(P,A,D) ((P & (~(1 << A))) | (D << A)) + +/************************************* + * + * statics + * + *************************************/ + +static UINT8 p[8] = { 0,0xf0,0,0,0,0,0,0 }; +static UINT8 t[2] = { 0,0 }; + +static UINT8 last; + +/**************************************************************** + * + * Initialization + * + ****************************************************************/ + +static SOUND_START( mario ) +{ + p[1] = 0xf0; + state_save_register_global_array(p); + state_save_register_global_array(t); + state_save_register_global(last); +} + +/**************************************************************** + * + * I/O Handlers - static + * + ****************************************************************/ + +static READ8_HANDLER( mario_sh_p1_r ) +{ + return p[1]; +} + +static READ8_HANDLER( mario_sh_p2_r ) +{ + return p[2]; +} + +static READ8_HANDLER( mario_sh_t0_r ) +{ + return t[0]; +} + +static READ8_HANDLER( mario_sh_t1_r ) +{ + return t[1]; +} + +static READ8_HANDLER( mario_sh_tune_r ) +{ + return soundlatch_r(offset); +} + +static WRITE8_HANDLER( mario_sh_sound_w ) +{ + DAC_data_w(0,data); +} + +static WRITE8_HANDLER( mario_sh_p1_w ) +{ + p[1] = data; +} + +static WRITE8_HANDLER( mario_sh_p2_w ) +{ + p[2] = data; +} + +/**************************************************************** + * + * I/O Handlers - global + * + ****************************************************************/ + +WRITE8_HANDLER( mario_sh_getcoin_w ) +{ + t[0] = data; +} + +WRITE8_HANDLER( mario_sh_crab_w ) +{ + p[1] = ACTIVEHIGH_PORT_BIT(p[1],0,data); +} + +WRITE8_HANDLER( mario_sh_turtle_w ) +{ + p[1] = ACTIVEHIGH_PORT_BIT(p[1],1,data); +} + +WRITE8_HANDLER( mario_sh_fly_w ) +{ + p[1] = ACTIVEHIGH_PORT_BIT(p[1],2,data); +} + +WRITE8_HANDLER( masao_sh_irqtrigger_w ) +{ + if (last == 1 && data == 0) + { + /* setting bit 0 high then low triggers IRQ on the sound CPU */ + cpunum_set_input_line_and_vector(1,0,HOLD_LINE,0xff); + } + + last = data; +} + +WRITE8_HANDLER( mario_sh_tuneselect_w ) +{ + soundlatch_w(offset,data); +} WRITE8_HANDLER( mario_sh_w ) { @@ -62,3 +186,105 @@ WRITE8_HANDLER( mario_sh3_w ) } } } + +/************************************* + * + * Sound CPU memory handlers + * + *************************************/ + +static ADDRESS_MAP_START( mario_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x0fff) AM_ROM +ADDRESS_MAP_END + +static ADDRESS_MAP_START( mario_sound_io_map, ADDRESS_SPACE_IO, 8 ) + AM_RANGE(0x00, 0xff) AM_READWRITE(mario_sh_tune_r, mario_sh_sound_w) + AM_RANGE(I8039_p1, I8039_p1) AM_READWRITE(mario_sh_p1_r, mario_sh_p1_w) + AM_RANGE(I8039_p2, I8039_p2) AM_READWRITE(mario_sh_p2_r, mario_sh_p2_w) + AM_RANGE(I8039_t0, I8039_t0) AM_READ(mario_sh_t0_r) + AM_RANGE(I8039_t1, I8039_t1) AM_READ(mario_sh_t1_r) +ADDRESS_MAP_END + +static ADDRESS_MAP_START( masao_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x0fff) AM_ROM + AM_RANGE(0x2000, 0x23ff) AM_RAM + AM_RANGE(0x4000, 0x4000) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w) + AM_RANGE(0x6000, 0x6000) AM_WRITE(AY8910_control_port_0_w) +ADDRESS_MAP_END + +/************************************* + * + * Sound Interfaces + * + *************************************/ + +static const char *const mario_sample_names[] = +{ + "*mario", + + /* 7f01 - 7f07 sounds */ + "ice.wav", /* 0x02 ice appears (formerly effect0.wav) */ + "coin.wav", /* 0x06 coin appears (formerly effect1.wav) */ + "skid.wav", /* 0x07 skid */ + + /* 7c00 */ + "run.wav", /* 03, 02, 01 - 0x1b */ + + /* 7c80 */ + "luigirun.wav", /* 03, 02, 01 - 0x1c */ + + 0 /* end of array */ +}; + +static const struct Samplesinterface samples_interface = +{ + 3, /* 3 channels */ + mario_sample_names +}; + +static const struct AY8910interface ay8910_interface = +{ + soundlatch_r +}; + + +/************************************* + * + * Machine driver + * + *************************************/ + +MACHINE_DRIVER_START( mario_audio ) + + MDRV_CPU_ADD(I8039, I8035_CLOCK) /* audio CPU */ /* 730 kHz */ + MDRV_CPU_PROGRAM_MAP(mario_sound_map, 0) + MDRV_CPU_IO_MAP(mario_sound_io_map, 0) + + MDRV_SOUND_START(mario) + + MDRV_SPEAKER_STANDARD_MONO("mono") + + MDRV_SOUND_ADD(DAC, 0) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MDRV_SOUND_ADD(SAMPLES, 0) + MDRV_SOUND_CONFIG(samples_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) + +MACHINE_DRIVER_END + +MACHINE_DRIVER_START( masao_audio ) + + MDRV_CPU_ADD(Z80,24576000/16) /* audio CPU */ /* ???? */ + MDRV_CPU_PROGRAM_MAP(masao_sound_map,0) + + MDRV_SOUND_START(mario) + + MDRV_SPEAKER_STANDARD_MONO("mono") + + MDRV_SOUND_ADD(AY8910, 14318000/6) + MDRV_SOUND_CONFIG(ay8910_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + +MACHINE_DRIVER_END + diff --git a/src/mame/drivers/mario.c b/src/mame/drivers/mario.c index 02bc9bbceae..d64ad6290f6 100644 --- a/src/mame/drivers/mario.c +++ b/src/mame/drivers/mario.c @@ -1,5 +1,20 @@ /*************************************************************************** +TODO: + - combine memory maps + - discrete sound + - combine sh_* writes into one routine + +Done: + - fixed mario0110u1gre + - rewrote driver, separate MACHINE_DRIVER(mario_audio) + - palette from schematics + - video timing from schematics + - driver configuration switch Nintendo/Std Monitor + - got rid of COLORTABLE + - clocks as defines in .h + - use XTAL_* + Mario Bros memory map (preliminary): driver by Mirko Buffoni @@ -69,81 +84,14 @@ write: ***************************************************************************/ #include "driver.h" -#include "cpu/i8039/i8039.h" -#include "sound/dac.h" -#include "sound/ay8910.h" -#include "sound/samples.h" -static UINT8 p[8] = { 0,0xf0,0,0,0,0,0,0 }; -static UINT8 t[2] = { 0,0 }; +#include "mario.h" -static UINT8 last; - - -extern WRITE8_HANDLER( mario_videoram_w ); -extern WRITE8_HANDLER( mario_gfxbank_w ); -extern WRITE8_HANDLER( mario_palettebank_w ); -extern WRITE8_HANDLER( mario_scroll_w ); - -extern PALETTE_INIT( mario ); -extern VIDEO_START( mario ); -extern VIDEO_UPDATE( mario ); - -/* - * from audio/mario.c - */ -extern WRITE8_HANDLER( mario_sh_w ); -extern WRITE8_HANDLER( mario_sh1_w ); -extern WRITE8_HANDLER( mario_sh2_w ); -extern WRITE8_HANDLER( mario_sh3_w ); - - -static MACHINE_START( mario ) -{ - state_save_register_global_array(p); - state_save_register_global_array(t); - state_save_register_global(last); -} - - -#define ACTIVELOW_PORT_BIT(P,A,D) ((P & (~(1 << A))) | ((D ^ 1) << A)) -#define ACTIVEHIGH_PORT_BIT(P,A,D) ((P & (~(1 << A))) | (D << A)) - - -static WRITE8_HANDLER( mario_sh_getcoin_w ) { t[0] = data; } -static WRITE8_HANDLER( mario_sh_crab_w ) { p[1] = ACTIVEHIGH_PORT_BIT(p[1],0,data); } -static WRITE8_HANDLER( mario_sh_turtle_w ) { p[1] = ACTIVEHIGH_PORT_BIT(p[1],1,data); } -static WRITE8_HANDLER( mario_sh_fly_w ) { p[1] = ACTIVEHIGH_PORT_BIT(p[1],2,data); } -static WRITE8_HANDLER( mario_sh_tuneselect_w ) { soundlatch_w(offset,data); } - -static READ8_HANDLER( mario_sh_p1_r ) { return p[1]; } -static READ8_HANDLER( mario_sh_p2_r ) { return p[2]; } -static READ8_HANDLER( mario_sh_t0_r ) { return t[0]; } -static READ8_HANDLER( mario_sh_t1_r ) { return t[1]; } -static READ8_HANDLER( mario_sh_tune_r ) { return soundlatch_r(offset); } - -static WRITE8_HANDLER( mario_sh_sound_w ) -{ - DAC_data_w(0,data); -} -static WRITE8_HANDLER( mario_sh_p1_w ) -{ - p[1] = data; -} -static WRITE8_HANDLER( mario_sh_p2_w ) -{ - p[2] = data; -} -static WRITE8_HANDLER( masao_sh_irqtrigger_w ) -{ - if (last == 1 && data == 0) - { - /* setting bit 0 high then low triggers IRQ on the sound CPU */ - cpunum_set_input_line_and_vector(1,0,HOLD_LINE,0xff); - } - - last = data; -} +/************************************* + * + * Main CPU memory handlers + * + *************************************/ static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM) @@ -198,33 +146,14 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( mario_writeport, ADDRESS_SPACE_IO, 8 ) ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) - AM_RANGE(0x00, 0x00) AM_WRITE(MWA8_NOP) /* unknown... is this a trigger? */ + AM_RANGE(0x00, 0x00) AM_WRITE(MWA8_NOP) /*Z80 DMA Ctrl port */ ADDRESS_MAP_END - -static ADDRESS_MAP_START( readmem_sound, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_ROM) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( writemem_sound, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_WRITE(MWA8_ROM) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( readport_sound, ADDRESS_SPACE_IO, 8 ) - AM_RANGE(0x00, 0xff) AM_READ(mario_sh_tune_r) - AM_RANGE(I8039_p1, I8039_p1) AM_READ(mario_sh_p1_r) - AM_RANGE(I8039_p2, I8039_p2) AM_READ(mario_sh_p2_r) - AM_RANGE(I8039_t0, I8039_t0) AM_READ(mario_sh_t0_r) - AM_RANGE(I8039_t1, I8039_t1) AM_READ(mario_sh_t1_r) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( writeport_sound, ADDRESS_SPACE_IO, 8 ) - AM_RANGE(0x00, 0xff) AM_WRITE(mario_sh_sound_w) - AM_RANGE(I8039_p1, I8039_p1) AM_WRITE(mario_sh_p1_w) - AM_RANGE(I8039_p2, I8039_p2) AM_WRITE(mario_sh_p2_w) -ADDRESS_MAP_END - - +/************************************* + * + * Port definitions + * + *************************************/ static INPUT_PORTS_START( mario ) PORT_START_TAG("IN0") @@ -268,6 +197,12 @@ static INPUT_PORTS_START( mario ) PORT_DIPSETTING( 0x80, DEF_STR( Medium ) ) PORT_DIPSETTING( 0x40, DEF_STR( Hard ) ) PORT_DIPSETTING( 0xc0, DEF_STR( Hardest ) ) + + PORT_START_TAG("MONITOR") + PORT_CONFNAME( 0x01, 0x00, "Monitor" ) + PORT_CONFSETTING( 0x00, "Nintendo" ) + PORT_CONFSETTING( 0x01, "Std 15.72Khz" ) + INPUT_PORTS_END static INPUT_PORTS_START( marioo ) @@ -318,6 +253,11 @@ static INPUT_PORTS_START( masao ) INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ static const gfx_layout charlayout = { @@ -344,97 +284,39 @@ static const gfx_layout spritelayout = 16*8 /* every sprite takes 16 consecutive bytes */ }; - - static GFXDECODE_START( mario ) GFXDECODE_ENTRY( REGION_GFX1, 0, charlayout, 0, 16 ) - GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 16*4, 32 ) + GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 0, 32 ) GFXDECODE_END - -static const char *const mario_sample_names[] = -{ - "*mario", - - /* 7f01 - 7f07 sounds */ - "ice.wav", /* 0x02 ice appears (formerly effect0.wav) */ - "coin.wav", /* 0x06 coin appears (formerly effect1.wav) */ - "skid.wav", /* 0x07 skid */ - - /* 7c00 */ - "run.wav", /* 03, 02, 01 - 0x1b */ - - /* 7c80 */ - "luigirun.wav", /* 03, 02, 01 - 0x1c */ - - 0 /* end of array */ -}; - -static const struct Samplesinterface samples_interface = -{ - 3, /* 3 channels */ - mario_sample_names -}; - -static const struct AY8910interface ay8910_interface = -{ - soundlatch_r -}; - -static ADDRESS_MAP_START( masao_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_ROM) - AM_RANGE(0x2000, 0x23ff) AM_READ(MRA8_RAM) - AM_RANGE(0x4000, 0x4000) AM_READ(AY8910_read_port_0_r) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( masao_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_WRITE(MWA8_ROM) - AM_RANGE(0x2000, 0x23ff) AM_WRITE(MWA8_RAM) - AM_RANGE(0x6000, 0x6000) AM_WRITE(AY8910_control_port_0_w) - AM_RANGE(0x4000, 0x4000) AM_WRITE(AY8910_write_port_0_w) -ADDRESS_MAP_END - +/************************************* + * + * Machine driver + * + *************************************/ static MACHINE_DRIVER_START( mario ) /* basic machine hardware */ - MDRV_CPU_ADD(Z80, 8000000/2) /* verified on pcb */ + MDRV_CPU_ADD(Z80, Z80_CLOCK) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(readmem,writemem) MDRV_CPU_IO_MAP(0,mario_writeport) MDRV_CPU_VBLANK_INT(nmi_line_pulse,1) - MDRV_CPU_ADD(I8039, 730000) - /* audio CPU */ /* verified on pcb */ - MDRV_CPU_PROGRAM_MAP(readmem_sound,writemem_sound) - MDRV_CPU_IO_MAP(readport_sound,writeport_sound) - - MDRV_MACHINE_START(mario) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(32*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART) MDRV_GFXDECODE(mario) - MDRV_PALETTE_LENGTH(256) - MDRV_COLORTABLE_LENGTH(16*4+32*8) + MDRV_PALETTE_LENGTH(512) MDRV_PALETTE_INIT(mario) MDRV_VIDEO_START(mario) MDRV_VIDEO_UPDATE(mario) /* sound hardware */ - MDRV_SPEAKER_STANDARD_MONO("mono") - - MDRV_SOUND_ADD(DAC, 0) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MDRV_SOUND_ADD(SAMPLES, 0) - MDRV_SOUND_CONFIG(samples_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) + MDRV_IMPORT_FROM(mario_audio) MACHINE_DRIVER_END @@ -445,43 +327,27 @@ static MACHINE_DRIVER_START( masao ) MDRV_CPU_PROGRAM_MAP(readmem,masao_writemem) MDRV_CPU_VBLANK_INT(nmi_line_pulse,1) - MDRV_CPU_ADD(Z80,24576000/16) - /* audio CPU */ /* ???? */ - MDRV_CPU_PROGRAM_MAP(masao_sound_readmem,masao_sound_writemem) - - MDRV_MACHINE_START(mario) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(32*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART) MDRV_GFXDECODE(mario) - MDRV_PALETTE_LENGTH(256) - MDRV_COLORTABLE_LENGTH(16*4+32*8) + MDRV_PALETTE_LENGTH(512) MDRV_PALETTE_INIT(mario) MDRV_VIDEO_START(mario) MDRV_VIDEO_UPDATE(mario) /* sound hardware */ - MDRV_SPEAKER_STANDARD_MONO("mono") - - MDRV_SOUND_ADD(AY8910, 14318000/6) - MDRV_SOUND_CONFIG(ay8910_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + MDRV_IMPORT_FROM(masao_audio) MACHINE_DRIVER_END - - -/*************************************************************************** - - Game driver(s) - -***************************************************************************/ +/************************************* + * + * ROM definitions + * + *************************************/ ROM_START( mario ) ROM_REGION( 0x10000, REGION_CPU1, 0 ) @@ -587,7 +453,11 @@ ROM_START( masao ) ROM_LOAD( "mario.4p", 0x0000, 0x0200, CRC(afc9bd41) SHA1(90b739c4c7f24a88b6ac5ca29b06c032906a2801) ) ROM_END - +/************************************* + * + * Game drivers + * + *************************************/ GAME( 1983, mario, 0, mario, mario, 0, ROT180, "Nintendo of America", "Mario Bros. (US, set 1)", GAME_SUPPORTS_SAVE ) GAME( 1983, marioo, mario, mario, marioo, 0, ROT180, "Nintendo of America", "Mario Bros. (US, set 2)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/mario.h b/src/mame/includes/mario.h new file mode 100644 index 00000000000..691e4a5808d --- /dev/null +++ b/src/mame/includes/mario.h @@ -0,0 +1,78 @@ +#ifndef MARIO_H_ +#define MARIO_H_ + +/* + * From the schematics: + * + * Video generation like dkong/dkongjr. However, clock is 24MHZ + * 7C -> 100 => 256 - 124 = 132 ==> 264 Scanlines + */ + +#define MASTER_CLOCK XTAL_24MHz +#define PIXEL_CLOCK (MASTER_CLOCK / 4) +#define CLOCK_1H (MASTER_CLOCK / 8) +#define CLOCK_16H (CLOCK_1H / 16) +#define CLOCK_1VF ((CLOCK_16H) / 12 / 2) +#define CLOCK_2VF ((CLOCK_1VF) / 2) + +#define HTOTAL (384) +#define HBSTART (256) +#define HBEND (0) +#define VTOTAL (264) +#define VBSTART (240) +#define VBEND (16) + +#define Z80_MASTER_CLOCK XTAL_8MHz +#define Z80_CLOCK (Z80_MASTER_CLOCK / 2) /* verified on pcb */ + +#define I8035_MASTER_CLOCK XTAL_11MHz /* verified on pcb: 730Khz */ +#define I8035_DIVIDER (15) +#define I8035_CLOCK (I8035_MASTER_CLOCK/I8035_DIVIDER) + +#define MARIO_PALETTE_LENGTH (256) + +typedef struct _mario_state mario_state; +struct _mario_state +{ + /* memory pointers */ + + /* machine states */ + + /* sound state */ + + /* video state */ + + /* Save state relevant */ + +}; + +/*----------- defined in video/mario.c -----------*/ + +WRITE8_HANDLER( mario_videoram_w ); +WRITE8_HANDLER( mario_gfxbank_w ); +WRITE8_HANDLER( mario_palettebank_w ); +WRITE8_HANDLER( mario_scroll_w ); + +PALETTE_INIT( mario ); +VIDEO_START( mario ); +VIDEO_UPDATE( mario ); + + +/*----------- defined in audio/mario.c -----------*/ + +WRITE8_HANDLER( mario_sh_w ); +WRITE8_HANDLER( mario_sh1_w ); +WRITE8_HANDLER( mario_sh2_w ); +WRITE8_HANDLER( mario_sh3_w ); + +WRITE8_HANDLER( mario_sh_getcoin_w ); +WRITE8_HANDLER( mario_sh_crab_w ); +WRITE8_HANDLER( mario_sh_turtle_w ); +WRITE8_HANDLER( mario_sh_fly_w ); +WRITE8_HANDLER( mario_sh_tuneselect_w ); +WRITE8_HANDLER( masao_sh_irqtrigger_w ); + +MACHINE_DRIVER_EXTERN( mario_audio ); +MACHINE_DRIVER_EXTERN( masao_audio ); + +#endif /*MARIO_H_*/ diff --git a/src/mame/video/mario.c b/src/mame/video/mario.c index ac9ac5bbb3a..2470e3970e2 100644 --- a/src/mame/video/mario.c +++ b/src/mame/video/mario.c @@ -7,11 +7,46 @@ ***************************************************************************/ #include "driver.h" +#include "video/resnet.h" + +#include "includes/mario.h" static UINT8 gfx_bank, palette_bank; +static int monitor; static tilemap *bg_tilemap; +static const res_net_decode_info mario_decode_info = +{ + 1, // there may be two proms needed to construct color + 0, // start at 0 + 255, // end at 255 + // R, G, B + { 0, 0, 0}, // offsets + { 5, 2, 0}, // shifts + {0x07,0x07,0x03} // masks +}; + +static const res_net_info mario_net_info = +{ + RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_MB7052 | RES_NET_MONITOR_SANYO_EZV20, + { + { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_EMITTER, 680, 0, 2, { 470, 220, 0 } } // dkong + } +}; + +static const res_net_info mario_net_info_std = +{ + RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_MB7052, + { + { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } }, + { RES_NET_AMP_EMITTER, 680, 0, 2, { 470, 220, 0 } } // dkong + } +}; + /*************************************************************************** Convert the color PROMs into a more useable format. @@ -34,55 +69,17 @@ static tilemap *bg_tilemap; ***************************************************************************/ PALETTE_INIT( mario ) { - int i; - #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity) - #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs]) + rgb_t *rgb; - - for (i = 0;i < machine->drv->total_colors;i++) - { - int bit0,bit1,bit2,r,g,b; - - - /* red component */ - bit0 = (*color_prom >> 5) & 1; - bit1 = (*color_prom >> 6) & 1; - bit2 = (*color_prom >> 7) & 1; - r = 255 - (0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2); - /* green component */ - bit0 = (*color_prom >> 2) & 1; - bit1 = (*color_prom >> 3) & 1; - bit2 = (*color_prom >> 4) & 1; - g = 255 - (0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2); - /* blue component */ - bit0 = (*color_prom >> 0) & 1; - bit1 = (*color_prom >> 1) & 1; - b = 255 - (0x55 * bit0 + 0xaa * bit1); - - palette_set_color(machine,i,MAKE_RGB(r,g,b)); - color_prom++; - } - - /* characters use the same palette as sprites, however characters */ - /* use only colors 64-127 and 192-255. */ - for (i = 0;i < 8;i++) - { - COLOR(0,4*i) = 8*i + 64; - COLOR(0,4*i+1) = 8*i+1 + 64; - COLOR(0,4*i+2) = 8*i+2 + 64; - COLOR(0,4*i+3) = 8*i+3 + 64; - } - for (i = 0;i < 8;i++) - { - COLOR(0,4*i+8*4) = 8*i + 192; - COLOR(0,4*i+8*4+1) = 8*i+1 + 192; - COLOR(0,4*i+8*4+2) = 8*i+2 + 192; - COLOR(0,4*i+8*4+3) = 8*i+3 + 192; - } - - /* sprites */ - for (i = 0;i < TOTAL_COLORS(1);i++) - COLOR(1,i) = i; + rgb = compute_res_net_all(color_prom, &mario_decode_info, &mario_net_info); + palette_set_colors(machine, 0, rgb, 256); + free(rgb); + rgb = compute_res_net_all(color_prom+256, &mario_decode_info, &mario_net_info_std); + palette_set_colors(machine, 256, rgb, 256); + free(rgb); + + palette_normalize_range(machine->palette, 0, 255, 0, 255); + palette_normalize_range(machine->palette, 256, 511, 0, 255); } WRITE8_HANDLER( mario_videoram_w ) @@ -117,8 +114,10 @@ WRITE8_HANDLER( mario_scroll_w ) static TILE_GET_INFO( get_bg_tile_info ) { int code = videoram[tile_index] + 256 * gfx_bank; - int color = (videoram[tile_index] >> 5) + 8 * palette_bank; + int color; + color = ((videoram[tile_index] >> 2) & 0x38) | 0x40 | (palette_bank<<7) | (monitor<<8); + color = color >> 2; SET_TILE_INFO(0, code, color, 0); } @@ -141,9 +140,9 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re { drawgfx(bitmap,machine->gfx[1], spriteram[offs + 2], - (spriteram[offs + 1] & 0x0f) + 16 * palette_bank, + (spriteram[offs + 1] & 0x0f) + 16 * palette_bank+32 * monitor, spriteram[offs + 1] & 0x80,spriteram[offs + 1] & 0x40, - spriteram[offs + 3] - 8,240 - spriteram[offs] + 8, + spriteram[offs + 3] - 8,(VBSTART - 1) - spriteram[offs] + 8, cliprect,TRANSPARENCY_PEN,0); } } @@ -151,6 +150,13 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re VIDEO_UPDATE( mario ) { + int t; + t = readinputportbytag("MONITOR"); + if (t != monitor) + { + monitor = t; + tilemap_mark_all_tiles_dirty(ALL_TILEMAPS); + } tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); draw_sprites(machine, bitmap, cliprect); return 0;