⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lwings.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	{ 0 }
};



static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			4000000,        /* 4 Mhz (?) */
			0,
			readmem,writemem,0,0,
			lwings_interrupt,1
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			3000000,        /* 3 Mhz (?) */
			2,      /* memory region #2 */
			sound_readmem,sound_writemem,0,0,
			interrupt,4
		}
	},
	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, 1*8, 31*8-1 },
	gfxdecodeinfo,
	1024, 1024,
	0,

	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	lwings_vh_start,
	lwings_vh_stop,
	lwings_vh_screenrefresh,

	/* sound hardware */
	0,0,0,0,
	{
		{
			SOUND_YM2203,
			&ym2203_interface
		}
	}
};


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

  Game driver(s)

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

ROM_START( lwings_rom )
	ROM_REGION(0x20000)     /* 64k for code + 3*16k for the banked ROMs images */
	ROM_LOAD( "6c_lw01.bin",  0x00000, 0x8000, 0xb55a7f60 )
	ROM_LOAD( "7c_lw02.bin",  0x10000, 0x8000, 0xa5efbb1b )
	ROM_LOAD( "9c_lw03.bin",  0x18000, 0x8000, 0xec5cc201 )

	ROM_REGION_DISPOSE(0x70000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "9h_lw05.bin",  0x00000, 0x4000, 0x091d923c )  /* characters */
	ROM_LOAD( "3e_lw14.bin",  0x10000, 0x8000, 0x5436392c )  /* tiles */
	ROM_LOAD( "1e_lw08.bin",  0x18000, 0x8000, 0xb491bbbb )
	ROM_LOAD( "3d_lw13.bin",  0x20000, 0x8000, 0xfdd1908a )
	ROM_LOAD( "1d_lw07.bin",  0x28000, 0x8000, 0x5c73d406 )
	ROM_LOAD( "3b_lw12.bin",  0x30000, 0x8000, 0x32e17b3c )
	ROM_LOAD( "1b_lw06.bin",  0x38000, 0x8000, 0x52e533c1 )
	ROM_LOAD( "3f_lw15.bin",  0x40000, 0x8000, 0x99e134ba )
	ROM_LOAD( "1f_lw09.bin",  0x48000, 0x8000, 0xc8f28777 )
	ROM_LOAD( "3j_lw17.bin",  0x50000, 0x8000, 0x5ed1bc9b )  /* sprites */
	ROM_LOAD( "1j_lw11.bin",  0x58000, 0x8000, 0x2a0790d6 )
	ROM_LOAD( "3h_lw16.bin",  0x60000, 0x8000, 0xe8834006 )
	ROM_LOAD( "1h_lw10.bin",  0x68000, 0x8000, 0xb693f5a5 )

	ROM_REGION(0x10000)     /* 64k for the audio CPU */
	ROM_LOAD( "11e_lw04.bin", 0x0000, 0x8000, 0xa20337a2 )
ROM_END

ROM_START( lwings2_rom )
	ROM_REGION(0x20000)     /* 64k for code + 3*16k for the banked ROMs images */
	ROM_LOAD( "u13-l",        0x00000, 0x8000, 0x3069c01c )
	ROM_LOAD( "u14-k",        0x10000, 0x8000, 0x5d91c828 )
	ROM_LOAD( "9c_lw03.bin",  0x18000, 0x8000, 0xec5cc201 )

	ROM_REGION_DISPOSE(0x70000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "9h_lw05.bin",  0x00000, 0x4000, 0x091d923c )  /* characters */
	ROM_LOAD( "b_03e.rom",    0x10000, 0x8000, 0x176e3027 )  /* tiles */
	ROM_LOAD( "b_01e.rom",    0x18000, 0x8000, 0xf5d25623 )
	ROM_LOAD( "b_03d.rom",    0x20000, 0x8000, 0x001caa35 )
	ROM_LOAD( "b_01d.rom",    0x28000, 0x8000, 0x0ba008c3 )
	ROM_LOAD( "b_03b.rom",    0x30000, 0x8000, 0x4f8182e9 )
	ROM_LOAD( "b_01b.rom",    0x38000, 0x8000, 0xf1617374 )
	ROM_LOAD( "b_03f.rom",    0x40000, 0x8000, 0x9b374dcc )
	ROM_LOAD( "b_01f.rom",    0x48000, 0x8000, 0x23654e0a )
	ROM_LOAD( "b_03j.rom",    0x50000, 0x8000, 0x8f3c763a )  /* sprites */
	ROM_LOAD( "b_01j.rom",    0x58000, 0x8000, 0x7cc90a1d )
	ROM_LOAD( "b_03h.rom",    0x60000, 0x8000, 0x7d58f532 )
	ROM_LOAD( "b_01h.rom",    0x68000, 0x8000, 0x3e396eda )

	ROM_REGION(0x10000)     /* 64k for the audio CPU */
	ROM_LOAD( "11e_lw04.bin", 0x0000, 0x8000, 0xa20337a2 )
ROM_END

ROM_START( lwingsjp_rom )
	ROM_REGION(0x20000)     /* 64k for code + 3*16k for the banked ROMs images */
	ROM_LOAD( "a_06c.rom",    0x00000, 0x8000, 0x2068a738 )
	ROM_LOAD( "a_07c.rom",    0x10000, 0x8000, 0xd6a2edc4 )
	ROM_LOAD( "9c_lw03.bin",  0x18000, 0x8000, 0xec5cc201 )

	ROM_REGION_DISPOSE(0x70000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "9h_lw05.bin",  0x00000, 0x4000, 0x091d923c )  /* characters */
	ROM_LOAD( "b_03e.rom",    0x10000, 0x8000, 0x176e3027 )  /* tiles */
	ROM_LOAD( "b_01e.rom",    0x18000, 0x8000, 0xf5d25623 )
	ROM_LOAD( "b_03d.rom",    0x20000, 0x8000, 0x001caa35 )
	ROM_LOAD( "b_01d.rom",    0x28000, 0x8000, 0x0ba008c3 )
	ROM_LOAD( "b_03b.rom",    0x30000, 0x8000, 0x4f8182e9 )
	ROM_LOAD( "b_01b.rom",    0x38000, 0x8000, 0xf1617374 )
	ROM_LOAD( "b_03f.rom",    0x40000, 0x8000, 0x9b374dcc )
	ROM_LOAD( "b_01f.rom",    0x48000, 0x8000, 0x23654e0a )
	ROM_LOAD( "b_03j.rom",    0x50000, 0x8000, 0x8f3c763a )  /* sprites */
	ROM_LOAD( "b_01j.rom",    0x58000, 0x8000, 0x7cc90a1d )
	ROM_LOAD( "b_03h.rom",    0x60000, 0x8000, 0x7d58f532 )
	ROM_LOAD( "b_01h.rom",    0x68000, 0x8000, 0x3e396eda )

	ROM_REGION(0x10000)     /* 64k for the audio CPU */
	ROM_LOAD( "11e_lw04.bin", 0x0000, 0x8000, 0xa20337a2 )
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[0xce00],"\x00\x30\x00",3) == 0 &&
			memcmp(&RAM[0xce4e],"\x00\x08\x00",3) == 0)
	{
		void *f;


		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread(f,&RAM[0xce00],13*7);
			RAM[0xce97] = RAM[0xce00];
			RAM[0xce98] = RAM[0xce01];
			RAM[0xce99] = RAM[0xce02];
			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[0xce00],13*7);
		osd_fclose(f);
	}
}



struct GameDriver lwings_driver =
{
	__FILE__,
	0,
	"lwings",
	"Legendary Wings (US set 1)",
	"1986",
	"Capcom",
	"Paul Leaman\nMarco Cassili (dip switches)",
	0,
	&machine_driver,
	0,

	lwings_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	lwings_input_ports,

	NULL, 0, 0,
	ORIENTATION_ROTATE_270,
	hiload, hisave
};

struct GameDriver lwings2_driver =
{
	__FILE__,
	&lwings_driver,
	"lwings2",
	"Legendary Wings (US set 2)",
	"1986",
	"Capcom",
	"Paul Leaman\nMarco Cassili (dip switches)",
	0,
	&machine_driver,
	0,

	lwings2_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	lwings_input_ports,

	NULL, 0, 0,
	ORIENTATION_ROTATE_270,
	hiload, hisave
};

struct GameDriver lwingsjp_driver =
{
	__FILE__,
	&lwings_driver,
	"lwingsjp",
	"Legendary Wings (Japan)",
	"1986",
	"Capcom",
	"Paul Leaman\nMarco Cassili (dip switches)",
	0,
	&machine_driver,
	0,

	lwingsjp_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	lwings_input_ports,

	NULL, 0, 0,
	ORIENTATION_ROTATE_270,
	hiload, hisave
};



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

 Section Z
 =========

   Exactly the same hardware as legendary wings, apart from the
   graphics orientation.

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


ROM_START( sectionz_rom )
	ROM_REGION(0x20000)     /* 64k for code + 3*16k for the banked ROMs images */
	ROM_LOAD( "6c_sz01.bin",  0x00000, 0x8000, 0x69585125 )
	ROM_LOAD( "7c_sz02.bin",  0x10000, 0x8000, 0x22f161b8 )
	ROM_LOAD( "9c_sz03.bin",  0x18000, 0x8000, 0x4c7111ed )

	ROM_REGION_DISPOSE(0x70000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "9h_sz05.bin",  0x00000, 0x4000, 0x3173ba2e )  /* characters */
	ROM_LOAD( "3e_sz14.bin",  0x10000, 0x8000, 0x63782e30 )  /* tiles */
	ROM_LOAD( "1e_sz08.bin",  0x18000, 0x8000, 0xd57d9f13 )
	ROM_LOAD( "3d_sz13.bin",  0x20000, 0x8000, 0x1b3d4d7f )
	ROM_LOAD( "1d_sz07.bin",  0x28000, 0x8000, 0xf5b3a29f )
	ROM_LOAD( "3b_sz12.bin",  0x30000, 0x8000, 0x11d47dfd )
	ROM_LOAD( "1b_sz06.bin",  0x38000, 0x8000, 0xdf703b68 )
	ROM_LOAD( "3f_sz15.bin",  0x40000, 0x8000, 0x36bb9bf7 )
	ROM_LOAD( "1f_sz09.bin",  0x48000, 0x8000, 0xda8f06c9 )
	ROM_LOAD( "3j_sz17.bin",  0x50000, 0x8000, 0x8df7b24a )  /* sprites */
	ROM_LOAD( "1j_sz11.bin",  0x58000, 0x8000, 0x685d4c54 )
	ROM_LOAD( "3h_sz16.bin",  0x60000, 0x8000, 0x500ff2bb )
	ROM_LOAD( "1h_sz10.bin",  0x68000, 0x8000, 0x00b3d244 )

	ROM_REGION(0x10000)     /* 64k for the audio CPU */
	ROM_LOAD( "11e_sz04.bin", 0x0000, 0x8000, 0xa6073566 )
ROM_END

struct GameDriver sectionz_driver =
{
	__FILE__,
	0,
	"sectionz",
	"Section Z",
	"1985",
	"Capcom",
	"Paul Leaman\nMarco Cassili (dip switches)",
	0,
	&machine_driver,
	0,

	sectionz_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	sectionz_input_ports,

	NULL, 0, 0,
	ORIENTATION_DEFAULT,
	hiload, hisave
};


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

 Trojan
 ======

   Similar to Legendary Wings apart from:
   1) More sprites
   2) 3rd Z80 (ADPCM)
   3) Different palette layout
   4) Third Background tile layer

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


static struct GfxLayout spritelayout_trojan = /* LWings, with more sprites */
{
	16,16,  /* 16*16 sprites */
	2048,   /* 2048 sprites */
	4,      /* 4 bits per pixel */
	{ 0x20000*8+4, 0x20000*8+0, 4, 0 },
	{ 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3,
			32*8+0, 32*8+1, 32*8+2, 32*8+3, 33*8+0, 33*8+1, 33*8+2, 33*8+3 },
	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
			8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
	64*8    /* every sprite takes 64 consecutive bytes */
};

static struct GfxLayout bktilelayout_trojan =
{
	16,16,  /* 16*16 sprites */
	512,   /* 512 sprites */
	4,      /* 4 bits per pixel */
	{ 0x08000*8+0, 0x08000*8+4, 0, 4 },
	{ 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3,
			32*8+0, 32*8+1, 32*8+2, 32*8+3, 33*8+0, 33*8+1, 33*8+2, 33*8+3 },
	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
			8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
	64*8    /* every sprite takes 64 consecutive bytes */
};


static struct GfxDecodeInfo gfxdecodeinfo_trojan[] =
{
	{ 1, 0x00000, &charlayout,          768, 16 },  /* colors 768-831 */
	{ 1, 0x10000, &tilelayout,          256,  8 },  /* colors 256-383 */
	{ 1, 0x50000, &spritelayout_trojan, 640,  8 },  /* colors 640-767 */
	{ 1, 0x90000, &bktilelayout_trojan,   0,  8 },  /* colors   0-127 */
	{ -1 } /* end of array */
};


/*
ADPCM is driven by Z80 continuously outputting to a port. The following
table is lifted from the code.

Sample 5 doesn't play properly.
*/

ADPCM_SAMPLES_START(trojan_samples)
	ADPCM_SAMPLE(0x00, 0x00a7, (0x0aa9-0x00a7)*2 )
	ADPCM_SAMPLE(0x01, 0x0aa9, (0x12ab-0x0aa9)*2 )
	ADPCM_SAMPLE(0x02, 0x12ab, (0x17ad-0x12ab)*2 )
	ADPCM_SAMPLE(0x03, 0x17ad, (0x22af-0x17ad)*2 )
	ADPCM_SAMPLE(0x04, 0x22af, (0x2db1-0x22af)*2 )
	ADPCM_SAMPLE(0x05, 0x2db1, (0x310a-0x2db1)*2 )
	ADPCM_SAMPLE(0x06, 0x310a, (0x3cb3-0x310a)*2 )
ADPCM_SAMPLES_END

static struct ADPCMinterface adpcm_interface =
{
	1,                      /* 1 channel */
	4000,                   /* 4000Hz playback */
	3,                      /* memory region 3 */
	0,                      /* init function */
	{ 255 }
};



static struct MachineDriver trojan_machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			4000000,        /* 4 Mhz (?) */
			0,
			readmem,trojan_writemem,0,0,
			lwings_interrupt,1
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			3000000,        /* 3 Mhz (?) */
			2,      /* memory region #2 */
			sound_readmem,sound_writemem,0,0,
			interrupt,4
		}
	},
	60, 2500,       /* frames per second, vblank duration */
				/* hand tuned to get rid of sprite lag */
	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, 1*8, 31*8-1 },
	gfxdecodeinfo_trojan,
	1024, 1024,
	0,

	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	trojan_vh_start,
	trojan_vh_stop,
	trojan_vh_screenrefresh,

	/* sound hardware */
	0,0,0,0,
	{
		{
			SOUND_YM2203,
			&ym2203_interface,
		},
		{
			SOUND_ADPCM,
			&adpcm_interface
		}
	}

⌨️ 快捷键说明

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