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

📄 naughtyb.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			CPU_Z80,
			1500000,	/* 3 Mhz ? */
			0,
			readmem,writemem,0,0,
			naughtyb_interrupt,1
		}
	},
	60, DEFAULT_REAL_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* single CPU, no need for interleaving */
	0,

	/* video hardware */
	28*8, 36*8, { 0*8, 28*8-1, 0*8, 36*8-1 },
	gfxdecodeinfo,
	256,32*4+32*4,
	naughtyb_vh_convert_color_prom,

	VIDEO_TYPE_RASTER,
	0,
	naughtyb_vh_start,
	naughtyb_vh_stop,
	naughtyb_vh_screenrefresh,

	/* sound hardware */
	0,
	pleiads_sh_start,
	0,
	pleiads_sh_update
};

/* Exactly the same but for the writemem handler */
static struct MachineDriver popflame_machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			1500000,	/* 3 Mhz ? */
			0,
			readmem,popflame_writemem,0,0,
			naughtyb_interrupt,1
		}
	},
	60, DEFAULT_REAL_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* single CPU, no need for interleaving */
	0,

	/* video hardware */
	28*8, 36*8, { 0*8, 28*8-1, 0*8, 36*8-1 },
	gfxdecodeinfo,
	256,32*4+32*4,
	naughtyb_vh_convert_color_prom,

	VIDEO_TYPE_RASTER,
	0,
	naughtyb_vh_start,
	naughtyb_vh_stop,
	naughtyb_vh_screenrefresh,

	/* sound hardware */
	0,
	pleiads_sh_start,
	0,
	pleiads_sh_update
};



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

  Game driver(s)

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

ROM_START( naughtyb_rom )
	ROM_REGION(0x10000)      /* 64k for code */
	ROM_LOAD( "nb1ic30",      0x0000, 0x0800, 0x3f482fa3 )
	ROM_LOAD( "nb2ic29",      0x0800, 0x0800, 0x7ddea141 )
	ROM_LOAD( "nb3ic28",      0x1000, 0x0800, 0x8c72a069 )
	ROM_LOAD( "nb4ic27",      0x1800, 0x0800, 0x30feae51 )
	ROM_LOAD( "nb5ic26",      0x2000, 0x0800, 0x05242fd0 )
	ROM_LOAD( "nb6ic25",      0x2800, 0x0800, 0x7a12ffea )
	ROM_LOAD( "nb7ic24",      0x3000, 0x0800, 0x9cc287df )
	ROM_LOAD( "nb8ic23",      0x3800, 0x0800, 0x4d84ff2c )

	ROM_REGION_DISPOSE(0x4000)      /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "nb15ic44",     0x0000, 0x0800, 0xd692f9c7 )
	ROM_LOAD( "nb16ic43",     0x0800, 0x0800, 0xd3ba8b27 )
	ROM_LOAD( "nb13ic46",     0x1000, 0x0800, 0xc1669cd5 )
	ROM_LOAD( "nb14ic45",     0x1800, 0x0800, 0xeef2c8e5 )
	ROM_LOAD( "nb11ic48",     0x2000, 0x0800, 0x23271a13 )
	ROM_LOAD( "nb12ic47",     0x2800, 0x0800, 0xef0706c3 )
	ROM_LOAD( "nb9ic50",      0x3000, 0x0800, 0xd6949c27 )
	ROM_LOAD( "nb10ic49",     0x3800, 0x0800, 0xc97c97b9 )

	ROM_REGION(0x0200)      /* color proms */
	ROM_LOAD( "naughtyb.633", 0x0000, 0x0100, 0x7838b973 ) /* palette low bits */
	ROM_LOAD( "naughtyb.h4",  0x0100, 0x0100, 0x70043706 ) /* palette high bits */
ROM_END

ROM_START( popflame_rom )
	ROM_REGION(0x10000)	/* 64k for code */
	ROM_LOAD( "ic86.pop",     0x0000, 0x1000, 0x5e32bbdf )
	ROM_LOAD( "ic80.pop",     0x1000, 0x1000, 0xb77abf3d )
	ROM_LOAD( "ic94.pop",     0x2000, 0x1000, 0x945a3c0f )
	ROM_LOAD( "ic100.pop",    0x3000, 0x1000, 0xf9f2343b )

	ROM_REGION_DISPOSE(0x4000)	/* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "ic13.pop",     0x0000, 0x1000, 0x2367131e )
	ROM_LOAD( "ic3.pop",      0x1000, 0x1000, 0xdeed0a8b )
	ROM_LOAD( "ic29.pop",     0x2000, 0x1000, 0x7b54f60f )
	ROM_LOAD( "ic38.pop",     0x3000, 0x1000, 0xdd2d9601 )

	ROM_REGION(0x0200)      /* color proms */
	ROM_LOAD( "ic53",         0x0000, 0x0100, 0x6e66057f ) /* palette low bits */
	ROM_LOAD( "ic54",         0x0100, 0x0100, 0x236bc771 ) /* palette high bits */
ROM_END



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


	/* check if the hi score has already been written to screen */
	if((RAM[0x874a] == 8) && (RAM[0x8746] == 9) && (RAM[0x8742] == 7) && (RAM[0x873e] == 8) &&  /* HIGH */
	   (RAM[0x8743] == 0x20) && (RAM[0x873f] == 0x20) && (RAM[0x873b] == 0x20) && (RAM[0x8737] == 0x20))
	{
		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			char buf[10];
			int hi;

			osd_fread(f,&RAM[0x4003],4);

			/* also copy the high score to the screen, otherwise it won't be */
			/* updated */
			hi = (RAM[0x4006] & 0x0f) +
			     (RAM[0x4006] >> 4) * 10 +
			     (RAM[0x4005] & 0x0f) * 100 +
			     (RAM[0x4005] >> 4) * 1000 +
			     (RAM[0x4004] & 0x0f) * 10000 +
			     (RAM[0x4004] >> 4) * 100000 +
			     (RAM[0x4003] & 0x0f) * 1000000 +
			     (RAM[0x4003] >> 4) * 10000000;
			if (hi)
			{
				sprintf(buf,"%8d",hi);
				if (buf[2] != ' ') videoram_w(0x0743,buf[2]-'0'+0x20);
				if (buf[3] != ' ') videoram_w(0x073f,buf[3]-'0'+0x20);
				if (buf[4] != ' ') videoram_w(0x073b,buf[4]-'0'+0x20);
				if (buf[5] != ' ') videoram_w(0x0737,buf[5]-'0'+0x20);
				if (buf[6] != ' ') videoram_w(0x0733,buf[6]-'0'+0x20);
				if (buf[7] != ' ') videoram_w(0x072f,buf[7]-'0'+0x20);
			}
			osd_fclose(f);
		}

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

static unsigned long get_score(unsigned char *score)
{
   return (score[3])+(154*score[2])+((unsigned long)(39322)*score[1])+((unsigned long)(39322)*154*score[0]);
}

static void naughtyb_hisave(void)
{
	unsigned long score1,score2,hiscore;
	void *f;

	unsigned char *RAM = Machine->memory_region[0];

	score1 = get_score(&RAM[0x4020]);
	score2 = get_score(&RAM[0x4030]);
	hiscore = get_score(&RAM[0x4003]);

	if (score1 > hiscore) RAM += 0x4020;
	else if (score2 > hiscore) RAM += 0x4030;
	else RAM += 0x4003;

	if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0)
	{
		osd_fwrite(f,&RAM[0],4);
		osd_fclose(f);
	}
}



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


	/* check if the hi score has already been written to screen */
	if ((RAM[0x874a] == 8) && (RAM[0x8746] == 9) && (RAM[0x8742] == 7) &&
	    (RAM[0x873e] == 8) &&  /* HIGH */
	    (RAM[0x8743] == 0x20) && (RAM[0x873f] == 0x20) && (RAM[0x873b] == 0x20) &&
	    (RAM[0x8737] == 0x20)) /* 0000 */
	{
		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread (f,&RAM[0x4004],3);
			osd_fclose (f);

			videoram_w (0x743, (RAM[0x4004] >> 4) | 0x20);
			videoram_w (0x73f, (RAM[0x4004] & 0x0f) | 0x20);
			videoram_w (0x73b, (RAM[0x4005] >> 4) | 0x20);
			videoram_w (0x737, (RAM[0x4005] & 0x0f) | 0x20);
			videoram_w (0x733, (RAM[0x4006] >> 4) | 0x20);
			videoram_w (0x72f, (RAM[0x4006] & 0x0f) | 0x20);
		}

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

static void popflame_hisave (void)
{
	unsigned long score1,score2,hiscore;
	void *f;

	unsigned char *RAM = Machine->memory_region[0];

	score1 = get_score (&RAM[0x4021]);
	score2 = get_score (&RAM[0x4031]);
	hiscore = get_score (&RAM[0x4004]);

	if (score1 > hiscore) RAM += 0x4021;
	else if (score2 > hiscore) RAM += 0x4031;
	else RAM += 0x4004;

	if ((f = osd_fopen (Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0)
	{
		osd_fwrite (f,&RAM[0],3);
		osd_fclose (f);
	}
}



struct GameDriver naughtyb_driver =
{
	__FILE__,
	0,
	"naughtyb",
	"Naughty Boy",
	"1982",
	"Jaleco (Cinematronics license)",
	"Sal and John Bugliarisi (MAME driver)\nMirko Buffoni (additional code)\nNicola Salmoria (additional code)\nAlan J. McCormick (color info)",
	0,
	&machine_driver,
	0,

	naughtyb_rom,
	0, 0,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_DEFAULT,

	naughtyb_hiload, naughtyb_hisave
};

struct GameDriver popflame_driver =
{
	__FILE__,
	0,
	"popflame",
	"Pop Flamer",
	"1982",
	"Jaleco",
	"Brad Oliver (MAME driver)\nSal and John Bugliarisi (Naughty Boy driver)\nMirko Buffoni (additional code)\nNicola Salmoria (additional code)\nTim Lindquist (color info)",
	0,
	&popflame_machine_driver,
	0,

	popflame_rom,
	0, 0,
	0,
	0,	/* sound_prom */

	input_ports,

	PROM_MEMORY_REGION(2), 0, 0,
	ORIENTATION_DEFAULT,

	popflame_hiload, popflame_hisave
};

⌨️ 快捷键说明

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