mario.c

来自「这个是延伸mame的在wince平台下的游戏模拟器的代码」· C语言 代码 · 共 613 行 · 第 1/2 页

C
613
字号
{
	1,
	{ 100 }
};

static struct Samplesinterface samples_interface =
{
	3	/* 3 channels */
};

static struct AY8910interface ay8910_interface =
{
	1,      /* 1 chip */
	14318000/6,	/* ? */
	{ 255 },
	{ soundlatch_r },
	{ 0 },
	{ 0 },
	{ 0 }
};

static struct MemoryReadAddress masao_sound_readmem[] =
{
	{ 0x0000, 0x0fff, MRA_ROM },
	{ 0x2000, 0x23ff, MRA_RAM },
	{ 0x4000, 0x4000, AY8910_read_port_0_r },
	{ -1 }  /* end of table */
};

static struct MemoryWriteAddress masao_sound_writemem[] =
{
	{ 0x0000, 0x0fff, MWA_ROM },
	{ 0x2000, 0x23ff, MWA_RAM },
	{ 0x6000, 0x6000, AY8910_control_port_0_w },
	{ 0x4000, 0x4000, AY8910_write_port_0_w },
	{ -1 }  /* end of table */
};


static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			3072000,	/* 3.072 Mhz (?) */
			0,
			readmem,writemem,0,mario_writeport,
			nmi_interrupt,1
		},
		{
			CPU_I8039 | CPU_AUDIO_CPU,
                        730000,         /* 730 khz */
			3,
			readmem_sound,writemem_sound,readport_sound,writeport_sound,
			ignore_interrupt,1
		}
	},
	60, DEFAULT_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* 1 CPU slice per frame - interleaving is forced when a sound command is written */
	0,

	/* video hardware */
	32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
	gfxdecodeinfo,
	256,16*4+32*8,
	mario_vh_convert_color_prom,

	VIDEO_TYPE_RASTER,
	0,
	generic_vh_start,
	generic_vh_stop,
	mario_vh_screenrefresh,

	/* sound hardware */
	0,0,0,0,
	{
		{
			SOUND_DAC,
			&dac_interface
		},
		{
			SOUND_SAMPLES,
			&samples_interface
		}
	}
};

static struct MachineDriver masao_machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			4000000,        /* 4.000 Mhz (?) */
			0,
			readmem,masao_writemem,0,0,
			nmi_interrupt,1
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			24576000/16,	/* ???? */
			3,
			masao_sound_readmem,masao_sound_writemem,0,0,
			ignore_interrupt,1
		}

		},
	60, DEFAULT_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* 1 CPU slice per frame - interleaving is forced when a sound command is written */
	0,

	/* video hardware */
	32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
	gfxdecodeinfo,
	256,16*4+32*8,
	mario_vh_convert_color_prom,

	VIDEO_TYPE_RASTER,
	0,
	generic_vh_start,
	generic_vh_stop,
	mario_vh_screenrefresh,

	/* sound hardware */
	0,0,0,0,
	{
		{
			SOUND_AY8910,
			&ay8910_interface
		}
	}
};



/***************************************************************************

  Game driver(s)

***************************************************************************/

static const char *sample_names[] =
{
	/* 7f00 - 7f07 sounds */
	"death.sam",  /* 0x00 death */
	"ice.sam",    /* 0x02 ice appears (formerly effect0.sam) */
	"coin.sam",   /* 0x06 coin appears (formerly effect1.sam) */
	"skid.sam",   /* 0x07 skid */

	/* 7c00 */
	"run.sam",        /* 03, 02, 01 - 0x1b */

	/* 7c80 */
	"luigirun.sam",   /* 03, 02, 01 - 0x1c */

    0	/* end of array */
};



ROM_START( mario_rom )
	ROM_REGION(0x10000)	/* 64k for code */
	ROM_LOAD( "mario.7f",     0x0000, 0x2000, 0xc0c6e014 )
	ROM_LOAD( "mario.7e",     0x2000, 0x2000, 0x116b3856 )
	ROM_LOAD( "mario.7d",     0x4000, 0x2000, 0xdcceb6c1 )
	ROM_LOAD( "mario.7c",     0xf000, 0x1000, 0x4a63d96b )

	ROM_REGION_DISPOSE(0x8000)	/* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "mario.3f",     0x0000, 0x1000, 0x28b0c42c )
	ROM_LOAD( "mario.3j",     0x1000, 0x1000, 0x0c8cc04d )
	ROM_LOAD( "mario.7m",     0x2000, 0x1000, 0x22b7372e )
	ROM_LOAD( "mario.7n",     0x3000, 0x1000, 0x4f3a1f47 )
	ROM_LOAD( "mario.7p",     0x4000, 0x1000, 0x56be6ccd )
	ROM_LOAD( "mario.7s",     0x5000, 0x1000, 0x56f1d613 )
	ROM_LOAD( "mario.7t",     0x6000, 0x1000, 0x641f0008 )
	ROM_LOAD( "mario.7u",     0x7000, 0x1000, 0x7baf5309 )

	ROM_REGION(0x0200)	/* color prom */
	ROM_LOAD( "mario.4p",     0x0000, 0x0200, 0xafc9bd41 )

	ROM_REGION(0x1000)	/* sound */
	ROM_LOAD( "mario.6k",     0x0000, 0x1000, 0x06b9ff85 )
ROM_END

ROM_START( masao_rom )
	ROM_REGION(0x10000) /* 64k for code */
	ROM_LOAD( "masao-4.rom",  0x0000, 0x2000, 0x07a75745 )
	ROM_LOAD( "masao-3.rom",  0x2000, 0x2000, 0x55c629b6 )
	ROM_LOAD( "masao-2.rom",  0x4000, 0x2000, 0x42e85240 )
	ROM_LOAD( "masao-1.rom",  0xf000, 0x1000, 0xb2817af9 )

	ROM_REGION_DISPOSE(0x8000)	/* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "masao-6.rom",  0x0000, 0x1000, 0x1c9e0be2 )
	ROM_LOAD( "masao-7.rom",  0x1000, 0x1000, 0x747c1349 )
	ROM_LOAD( "masao-8.rom",  0x2000, 0x1000, 0x186762f8 )
	ROM_LOAD( "masao-9.rom",  0x3000, 0x1000, 0x50be3918 )
	ROM_LOAD( "masao-10.rom", 0x4000, 0x1000, 0x56be6ccd )
	ROM_LOAD( "masao-11.rom", 0x5000, 0x1000, 0x912ba80a )
	ROM_LOAD( "masao-12.rom", 0x6000, 0x1000, 0x5cbb92a5 )
	ROM_LOAD( "masao-13.rom", 0x7000, 0x1000, 0x13afb9ed )

	ROM_REGION(0x0200)	/* color prom */
	ROM_LOAD( "mario.4p",     0x0000, 0x0200, 0xafc9bd41 )

	ROM_REGION(0x10000) /* 64k for sound */
	ROM_LOAD( "masao-5.rom",  0x0000, 0x1000, 0xbd437198 )
ROM_END

static int hiload(void)
{
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


	/* check if the hi score table has already been initialized */
	if (memcmp(&RAM[0x6b1d],"\x00\x20\x01",3) == 0 &&
	    memcmp(&RAM[0x6ba5],"\x00\x32\x00",3) == 0)
	{
		void *f;


		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread(f,&RAM[0x6b00],34*5);	/* hi scores */
			RAM[0x6823] = RAM[0x6b1f];
			RAM[0x6824] = RAM[0x6b1e];
			RAM[0x6825] = RAM[0x6b1d];
			osd_fread(f,&RAM[0x6c00],0x3c);	/* distributions */
			osd_fclose(f);
		}

		return 1;
	}
	else return 0;	/* we can't load the hi scores yet */
}



static void hisave(void)
{
	void *f;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


	if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0)
	{
		osd_fwrite(f,&RAM[0x6b00],34*5);	/* hi scores */
		osd_fwrite(f,&RAM[0x6c00],0x3c);	/* distributions */
		osd_fclose(f);
	}
}



struct GameDriver mario_driver =
{
	__FILE__,
	0,
	"mario",
	"Mario Bros.",
	"1983",
	"Nintendo of America",
	"Mirko Buffoni (MAME driver)\nNicola Salmoria (MAME driver)\nTim Lindquist (color info)\nDan Boris (8039 info)\nRon Fries (Audio Info)\nMarco Cassili",
	0,
	&machine_driver,
	0,

	mario_rom,
	0, 0,
	sample_names,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_180,

	hiload, hisave
};

struct GameDriver masao_driver =
{
	__FILE__,
	&mario_driver,
	"masao",
	"Masao",
	"1983",
	"bootleg",
	"Hugh McLenaghan (MAME driver)\nMirko Buffoni (sound info)",
	0,
	&masao_machine_driver,
	0,

	masao_rom,
	0, 0,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_180,

	hiload, hisave
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?