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

📄 pengo.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	ROM_LOAD( "ic7.2",        0x1000, 0x1000, 0x72e7775d )
	ROM_LOAD( "ic15.2",       0x2000, 0x1000, 0x7410ef1e )
	ROM_LOAD( "ic14.2",       0x3000, 0x1000, 0x55b3f379 )
	ROM_LOAD( "ic21",         0x4000, 0x1000, 0xb72084ec )
	ROM_LOAD( "ic20.2",       0x5000, 0x1000, 0x770570cf )
	ROM_LOAD( "ic32",         0x6000, 0x1000, 0xaf7b12c4 )
	ROM_LOAD( "ic31.2",       0x7000, 0x1000, 0x669555c1 )

	ROM_REGION_DISPOSE(0x4000)	/* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "ic92",         0x0000, 0x2000, 0xd7eec6cd )
	ROM_LOAD( "ic105",        0x2000, 0x2000, 0x5bfd26e9 )

	ROM_REGION(0x0420)	/* color PROMs */
	ROM_LOAD( "pr1633.078",   0x0000, 0x0020, 0x3a5844ec )
	ROM_LOAD( "pr1634.088",   0x0020, 0x0400, 0x766b139b )

	ROM_REGION(0x0200)	/* sound PROMs */
	ROM_LOAD( "pr1635.051",   0x0000, 0x0100, 0xc29dea27 )
	ROM_LOAD( "pr1636.070",   0x0100, 0x0100, 0x77245b66 )	/* timing - not used */
ROM_END

ROM_START( pengo2u_rom )
	ROM_REGION(0x10000)	/* 64k for code */
	ROM_LOAD( "pengo.u8",     0x0000, 0x1000, 0x3dfeb20e )
	ROM_LOAD( "pengo.u7",     0x1000, 0x1000, 0x1db341bd )
	ROM_LOAD( "pengo.u15",    0x2000, 0x1000, 0x7c2842d5 )
	ROM_LOAD( "pengo.u14",    0x3000, 0x1000, 0x6e3c1f2f )
	ROM_LOAD( "pengo.u21",    0x4000, 0x1000, 0x95f354ff )
	ROM_LOAD( "pengo.u20",    0x5000, 0x1000, 0x0fdb04b8 )
	ROM_LOAD( "pengo.u32",    0x6000, 0x1000, 0xe5920728 )
	ROM_LOAD( "pengo.u31",    0x7000, 0x1000, 0x13de47ed )

	ROM_REGION_DISPOSE(0x4000)	/* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "ic92",         0x0000, 0x2000, 0xd7eec6cd )
	ROM_LOAD( "ic105",        0x2000, 0x2000, 0x5bfd26e9 )

	ROM_REGION(0x0420)	/* color PROMs */
	ROM_LOAD( "pr1633.078",   0x0000, 0x0020, 0x3a5844ec )
	ROM_LOAD( "pr1634.088",   0x0020, 0x0400, 0x766b139b )

	ROM_REGION(0x0200)	/* sound PROMs */
	ROM_LOAD( "pr1635.051",   0x0000, 0x0100, 0xc29dea27 )
	ROM_LOAD( "pr1636.070",   0x0100, 0x0100, 0x77245b66 )	/* timing - not used */
ROM_END

ROM_START( penta_rom )
	ROM_REGION(0x10000)     /* 64k for code */
	ROM_LOAD( "008_pn01.bin", 0x0000, 0x1000, 0x22f328df )
	ROM_LOAD( "007_pn05.bin", 0x1000, 0x1000, 0x15bbc7d3 )
	ROM_LOAD( "015_pn02.bin", 0x2000, 0x1000, 0xde82b74a )
	ROM_LOAD( "014_pn06.bin", 0x3000, 0x1000, 0x160f3836 )
	ROM_LOAD( "021_pn03.bin", 0x4000, 0x1000, 0x7824e3ef )
	ROM_LOAD( "020_pn07.bin", 0x5000, 0x1000, 0x377b9663 )
	ROM_LOAD( "032_pn04.bin", 0x6000, 0x1000, 0xbfde44c1 )
	ROM_LOAD( "031_pn08.bin", 0x7000, 0x1000, 0x64e8c30d )

	ROM_REGION_DISPOSE(0x4000)      /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "092_pn09.bin", 0x0000, 0x2000, 0x6afeba9d )
	ROM_LOAD( "ic105",        0x2000, 0x2000, 0x5bfd26e9 )

	ROM_REGION(0x0420)	/* color PROMs */
	ROM_LOAD( "pr1633.078",   0x0000, 0x0020, 0x3a5844ec )
	ROM_LOAD( "pr1634.088",   0x0020, 0x0400, 0x766b139b )

	ROM_REGION(0x0200)	/* sound PROMs */
	ROM_LOAD( "pr1635.051",   0x0000, 0x0100, 0xc29dea27 )
	ROM_LOAD( "pr1636.070",   0x0100, 0x0100, 0x77245b66 )	/* timing - not used */
ROM_END



static void penta_decode(void)
{
/*
	the values vary, but the translation mask is always laid out like this:

	  0 1 2 3 4 5 6 7 8 9 a b c d e f
	0 A A B B A A B B C C D D C C D D
	1 A A B B A A B B C C D D C C D D
	2 E E F F E E F F G G H H G G H H
	3 E E F F E E F F G G H H G G H H
	4 A A B B A A B B C C D D C C D D
	5 A A B B A A B B C C D D C C D D
	6 E E F F E E F F G G H H G G H H
	7 E E F F E E F F G G H H G G H H
	8 H H G G H H G G F F E E F F E E
	9 H H G G H H G G F F E E F F E E
	a D D C C D D C C B B A A B B A A
	b D D C C D D C C B B A A B B A A
	c H H G G H H G G F F E E F F E E
	d H H G G H H G G F F E E F F E E
	e D D C C D D C C B B A A B B A A
	f D D C C D D C C B B A A B B A A

	(e.g. 0xc0 is XORed with H)
	therefore in the following tables we only keep track of A, B, C, D, E, F, G and H.
*/
	static const unsigned char data_xortable[2][8] =
	{
		{ 0xa0,0x82,0x28,0x0a,0x82,0xa0,0x0a,0x28 },	/* ...............0 */
		{ 0x88,0x0a,0x82,0x00,0x88,0x0a,0x82,0x00 }		/* ...............1 */
	};
	static const unsigned char opcode_xortable[8][8] =
	{
		{ 0x02,0x08,0x2a,0x20,0x20,0x2a,0x08,0x02 },	/* ...0...0...0.... */
		{ 0x88,0x88,0x00,0x00,0x88,0x88,0x00,0x00 },	/* ...0...0...1.... */
		{ 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 },	/* ...0...1...0.... */
		{ 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 },	/* ...0...1...1.... */
		{ 0x2a,0x08,0x2a,0x08,0x8a,0xa8,0x8a,0xa8 },	/* ...1...0...0.... */
		{ 0x2a,0x08,0x2a,0x08,0x8a,0xa8,0x8a,0xa8 },	/* ...1...0...1.... */
		{ 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 },	/* ...1...1...0.... */
		{ 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 }		/* ...1...1...1.... */
	};
	int A;
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];


	for (A = 0x0000;A < 0x8000;A++)
	{
		int i,j;
		unsigned char src;


		src = RAM[A];

		/* pick the translation table from bit 0 of the address */
		i = A & 1;

		/* pick the offset in the table from bits 1, 3 and 5 of the source data */
		j = ((src >> 1) & 1) + (((src >> 3) & 1) << 1) + (((src >> 5) & 1) << 2);
		/* the bottom half of the translation table is the mirror image of the top */
		if (src & 0x80) j = 7 - j;

		/* decode the ROM data */
		RAM[A] = src ^ data_xortable[i][j];

		/* now decode the opcodes */
		/* pick the translation table from bits 4, 8 and 12 of the address */
		i = ((A >> 4) & 1) + (((A >> 8) & 1) << 1) + (((A >> 12) & 1) << 2);
		ROM[A] = src ^ opcode_xortable[i][j];
	}
}



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[0x8840],"\xd0\x07",2) == 0 &&
			memcmp(&RAM[0x8858],"\xd0\x07",2) == 0 &&
			memcmp(&RAM[0x880c],"\xd0\x07",2) == 0)	/* high score */
	{
		void *f;


		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread(f,&RAM[0x8840],6*5);
			RAM[0x880c] = RAM[0x8858];
			RAM[0x880d] = RAM[0x8859];
			osd_fclose(f);
		}

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

static int pengo2_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[0x8840],"\x00\x00\x01\x55\x55\x55",6) == 0 &&
			memcmp(&RAM[0x8858],"\x00\x00",2) == 0 &&
			memcmp(&RAM[0x880c],"\x00\x00",2) == 0)	/* hi-score */
	{
		void *f;


		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread(f,&RAM[0x8840],6*5);
			RAM[0x880c] = RAM[0x8858];
			RAM[0x880d] = RAM[0x8859];
			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[0x8840],6*5);
		osd_fclose(f);
	}
}



struct GameDriver pengo_driver =
{
	__FILE__,
	0,
	"pengo",
	"Pengo (set 1)",
	"1982",
	"Sega",
	"Allard van der Bas (original code)\nNicola Salmoria (MAME driver)\nSergio Munoz (color and sound info)",
	0,
	&machine_driver,
	0,

	pengo_rom,
	0, pengo_decode,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	hiload, hisave
};

struct GameDriver pengo2_driver =
{
	__FILE__,
	&pengo_driver,
	"pengo2",
	"Pengo (set 2)",
	"1982",
	"Sega",
	"Allard van der Bas (original code)\nNicola Salmoria (MAME driver)\nSergio Munoz (color and sound info)",
	0,
	&machine_driver,
	0,

	pengo2_rom,
	0, pengo_decode,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	pengo2_hiload, hisave
};

struct GameDriver pengo2u_driver =
{
	__FILE__,
	&pengo_driver,
	"pengo2u",
	"Pengo (set 2 not encrypted)",
	"1982",
	"Sega",
	"Allard van der Bas (original code)\nNicola Salmoria (MAME driver)\nSergio Munoz (color and sound info)",
	0,
	&machine_driver,
	0,

	pengo2u_rom,
	0, 0,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	pengo2_hiload, hisave
};

struct GameDriver penta_driver =
{
	__FILE__,
	&pengo_driver,
	"penta",
	"Penta",
	"1982",
	"bootleg",
	"Allard van der Bas (original code)\nNicola Salmoria (MAME driver)\nSergio Munoz (color and sound info)",
	0,
	&machine_driver,
	0,

	penta_rom,
	0, penta_decode,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	hiload, hisave
};

⌨️ 快捷键说明

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