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

📄 exerion.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	ROM_LOAD( "exerion.06",   0x0e000, 0x2000, 0x435a85a4 )	/* fg chars */
	ROM_LOAD( "exerion.03",   0x10000, 0x2000, 0x790595b8 )	/* bg chars */
	ROM_LOAD( "exerion.04",   0x12000, 0x2000, 0xd7abd0b9 )
	ROM_LOAD( "exerion.01",   0x14000, 0x2000, 0x5bb755cb )
	ROM_LOAD( "exerion.02",   0x16000, 0x2000, 0xa7ecbb70 )
	ROM_LOAD( "exerion.11",   0x18000, 0x2000, 0xf0633a09 )	/* sprites */
	ROM_LOAD( "exerion.10",   0x1a000, 0x2000, 0x80312de0 )

	ROM_REGION(0x420)       /* color/lookup proms */
	ROM_LOAD( "exerion.e1",   0x0000, 0x020, 0x2befcc20 ) /* palette */
	ROM_LOAD( "exerion.i8",   0x0020, 0x100, 0x31db0e08 ) /* fg char lookup table */
	ROM_LOAD( "exerion.h10",  0x0120, 0x100, 0xcdd23f3e ) /* sprite lookup table */
	ROM_LOAD( "exerion.i3",   0x0220, 0x100, 0xfe72ab79 ) /* bg char lookup table */
	ROM_LOAD( "exerion.k4",   0x0320, 0x100, 0xffc2ba43 ) /* bg char mixer */

	ROM_REGION(0x10000)     /* 64k for the second CPU */
	ROM_LOAD( "exerion.05",   0x0000, 0x2000, 0x32f6bff5 )
ROM_END

ROM_START( exeriont_rom )
	ROM_REGION(0x10000)     /* 64k for code */
	ROM_LOAD( "prom5.4p",     0x0000, 0x4000, 0x58b4dc1b )
	ROM_LOAD( "prom6.4s",     0x4000, 0x2000, 0xfca18c2d )

	ROM_REGION_DISPOSE(0x1c000)     /* temporary space for graphics (disposed after conversion) */
	/* Set aside 0xe000 for the unscrambled graphics */
	ROM_LOAD( "exerion.06",   0x0e000, 0x2000, 0x435a85a4 )	/* fg chars */
	ROM_LOAD( "exerion.03",   0x10000, 0x2000, 0x790595b8 )	/* bg chars */
	ROM_LOAD( "exerion.04",   0x12000, 0x2000, 0xd7abd0b9 )
	ROM_LOAD( "exerion.01",   0x14000, 0x2000, 0x5bb755cb )
	ROM_LOAD( "exerion.02",   0x16000, 0x2000, 0xa7ecbb70 )
	ROM_LOAD( "exerion.11",   0x18000, 0x2000, 0xf0633a09 )	/* sprites */
	ROM_LOAD( "exerion.10",   0x1a000, 0x2000, 0x80312de0 )

	ROM_REGION(0x420)       /* color/lookup proms */
	ROM_LOAD( "exerion.e1",   0x0000, 0x020, 0x2befcc20 ) /* palette */
	ROM_LOAD( "exerion.i8",   0x0020, 0x100, 0x31db0e08 ) /* fg char lookup table */
	ROM_LOAD( "exerion.h10",  0x0120, 0x100, 0xcdd23f3e ) /* sprite lookup table */
	ROM_LOAD( "exerion.i3",   0x0220, 0x100, 0xfe72ab79 ) /* bg char lookup table */
	ROM_LOAD( "exerion.k4",   0x0320, 0x100, 0xffc2ba43 ) /* bg char mixer */

	ROM_REGION(0x10000)     /* 64k for the second CPU */
	ROM_LOAD( "exerion.05",   0x0000, 0x2000, 0x32f6bff5 )
ROM_END

ROM_START( exerionb_rom )
	ROM_REGION(0x10000)     /* 64k for code */
	ROM_LOAD( "eb5.bin",      0x0000, 0x4000, 0xda175855 )
	ROM_LOAD( "eb6.bin",      0x4000, 0x2000, 0x0dbe2eff )

	ROM_REGION_DISPOSE(0x1c000)     /* temporary space for graphics (disposed after conversion) */
	/* Set aside 0xe000 for the unscrambled graphics */
	ROM_LOAD( "exerion.06",   0x0e000, 0x2000, 0x435a85a4 )	/* fg chars */
	ROM_LOAD( "exerion.03",   0x10000, 0x2000, 0x790595b8 )	/* bg chars */
	ROM_LOAD( "exerion.04",   0x12000, 0x2000, 0xd7abd0b9 )
	ROM_LOAD( "exerion.01",   0x14000, 0x2000, 0x5bb755cb )
	ROM_LOAD( "exerion.02",   0x16000, 0x2000, 0xa7ecbb70 )
	ROM_LOAD( "exerion.11",   0x18000, 0x2000, 0xf0633a09 )	/* sprites */
	ROM_LOAD( "exerion.10",   0x1a000, 0x2000, 0x80312de0 )

	ROM_REGION(0x420)       /* color/lookup proms */
	ROM_LOAD( "exerion.e1",   0x0000, 0x020, 0x2befcc20 ) /* palette */
	ROM_LOAD( "exerion.i8",   0x0020, 0x100, 0x31db0e08 ) /* fg char lookup table */
	ROM_LOAD( "exerion.h10",  0x0120, 0x100, 0xcdd23f3e ) /* sprite lookup table */
	ROM_LOAD( "exerion.i3",   0x0220, 0x100, 0xfe72ab79 ) /* bg char lookup table */
	ROM_LOAD( "exerion.k4",   0x0320, 0x100, 0xffc2ba43 ) /* bg char mixer */

	ROM_REGION(0x10000)     /* 64k for the second CPU */
	ROM_LOAD( "exerion.05",   0x0000, 0x2000, 0x32f6bff5 )
ROM_END



static void exerion_decode(void)
{
	int i, x, offs;
	unsigned char *RAM;
	unsigned char *src;

	/*
		The gfx ROMs are stored in a half-assed fashion that makes using them with
		MAME challenging. We shuffle the bytes around to make it easier.

		They have been loaded at 0xe000, we write them at 0x0000.
	*/

	RAM = Machine->memory_region[1];
	src = RAM + 0xe000;

	for(i = 0;i < 512*7;i++)
	{
		offs = (i/16)*2048 + (i%16)*16;

		for (x=0; x<8; x++)
		{
			int d, s;

			d = i*16 + x*2;
			s = (offs + 256*x) / 8;

			RAM[d] = src[s];
			RAM[d+1] = src[s+1];
		}
	}

	/* reorganize bg chars */
	for(i = 0;i < 0x8000;i++)
	{
		int s;

		s = (i & 0x6000) | ((i & 0x1fe0) >> 2) | ((i & 0x0018) << 8) | (i & 0x0007);

		RAM[0x2000+s] = src[0x2000+i];
	}

	/* now reorganize the characters that form the sprites, and the sprites */

	/* get a fresh copy to work with */
	memcpy (&RAM[0x18000], &RAM[0xa000], 0x4000);

	/* for each of the 256 sprites, make the 4 characters contiguous */
	for (i=0; i<(128*2); i++)
	{
		int d, s;

		/* this assumes that sprite 1 is offset by 32 characters (32*16 bytes) from sprite 0 */
		offs = 16 * ((i/32)*2 + (i%32)*32);     

		d = 0xa000 + i*64;
		s = 0x18000 + offs;

		memcpy (&RAM[d], &RAM[s], 32);  
		memcpy (&RAM[d+32], &RAM[s+256], 32); 
	}
}

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


	/* the program ROMs have data lines D1 and D2 swapped. Decode them. */
	for (A = 0;A < 0x6000;A++)
		RAM[A] = (RAM[A] & 0xf9) | ((RAM[A] & 2) << 1) | ((RAM[A] & 4) >> 1);

	/* also convert the gfx as in Exerion */
	exerion_decode();
}



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


	/* check if the hi score table has already been initialized */
	/* the high score table is intialized to all 0, so first of all */
	/* we dirty it, then we wait for it to be cleared again */
	if (firsttime == 0)
	{
		memset(&RAM[0x6600],0xff,10);	/* high score */
		memset(&RAM[0x6700],0xff,40);
		firsttime = 1;
	}



	/* check if the hi score table has already been initialized */
	if (memcmp(&RAM[0x6600],"\x00\x00\x00",3) == 0 &&
		memcmp(&RAM[0x6700],"\x00\x00\x00",3) == 0 &&
		memcmp(&RAM[0x6725],"\x00\x00\x00",3) == 0)
	{
		void *f;
		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			int writing = 0;


			osd_fread(f,&RAM[0x6600],10);
			osd_fread(f,&RAM[0x6700],40);
			osd_fclose(f);

			/* this is a little gross, but necessary to get the high score on-screen */
			if (!writing) writing = (RAM[0x6600] >> 4);
			videoram_w (0x48d, writing ? (RAM[0x6600] >> 4) | 0x30 : ' ');
			if (!writing) writing = (RAM[0x6600] & 0x0f);
			videoram_w (0x44d, writing ? (RAM[0x6600] & 0x0f) | 0x30 : ' ');
			if (!writing) writing = (RAM[0x6601] >> 4);
			videoram_w (0x40d, writing ? (RAM[0x6601] >> 4) | 0x30 : ' ');
			if (!writing) writing = (RAM[0x6601] & 0x0f);
			videoram_w (0x3cd, writing ? (RAM[0x6601] & 0x0f) | 0x30 : ' ');
		}
		firsttime = 0;
		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[0x6600],10);
		osd_fwrite(f,&RAM[0x6700],40);
		osd_fclose(f);
	}
}


struct GameDriver exerion_driver =
{
	__FILE__,
	0,
	"exerion",
	"Exerion",
	"1983",
	"Jaleco",
	"Brad Oliver\nJohn Butler\nGerald Vanderick (color info)",
	GAME_WRONG_COLORS,
	&machine_driver,
	0,

	exerion_rom,
	exerion_decode, 0,
	0,
	0,      /* sound_prom */

	exerion_input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	hiload, hisave
};

struct GameDriver exeriont_driver =
{
	__FILE__,
	&exerion_driver,
	"exeriont",
	"Exerion (Taito)",
	"1983",
	"Jaleco (Taito America license)",
	"Brad Oliver\nJohn Butler\nGerald Vanderick (color info)",
	GAME_WRONG_COLORS,
	&machine_driver,
	0,

	exeriont_rom,
	exerion_decode, 0,
	0,
	0,      /* sound_prom */

	exerion_input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	hiload, hisave
};

struct GameDriver exerionb_driver =
{
	__FILE__,
	&exerion_driver,
	"exerionb",
	"Exerion (bootleg)",
	"1983",
	"Jaleco",
	"Brad Oliver\nJohn Butler\nGerald Vanderick (color info)",
	GAME_WRONG_COLORS,
	&machine_driver,
	0,

	exerionb_rom,
	exerionb_decode, 0,
	0,
	0,      /* sound_prom */

	exerion_input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_ROTATE_90,

	hiload, hisave
};

⌨️ 快捷键说明

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