vigilant.c

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

C
527
字号
		0x00*8+0,0x00*8+1,0x00*8+2,0x00*8+3,
		0x10*8+0,0x10*8+1,0x10*8+2,0x10*8+3,
		0x20*8+0,0x20*8+1,0x20*8+2,0x20*8+3,
		0x30*8+0,0x30*8+1,0x30*8+2,0x30*8+3
	},
	{ /* y offsets */
		0x00*8, 0x01*8, 0x02*8, 0x03*8,
		0x04*8, 0x05*8, 0x06*8, 0x07*8,
		0x08*8, 0x09*8, 0x0A*8, 0x0B*8,
		0x0C*8, 0x0D*8, 0x0E*8, 0x0F*8
	},
	0x40*8
};

static struct GfxLayout back_layout =
{
	32,1, /* tile size */
	512*8, /* number of tiles */
	4, /* bits per pixel */
	{0,2,4,6}, /* plane offsets */
	{ 0*8+1, 0*8,  1*8+1, 1*8, 2*8+1, 2*8, 3*8+1, 3*8, 4*8+1, 4*8, 5*8+1, 5*8,
	6*8+1, 6*8, 7*8+1, 7*8, 8*8+1, 8*8, 9*8+1, 9*8, 10*8+1, 10*8, 11*8+1, 11*8,
	12*8+1, 12*8, 13*8+1, 13*8, 14*8+1, 14*8, 15*8+1, 15*8 }, /* x offsets */
	{ 0 }, /* y offsets */
	16*8
};

static struct GfxDecodeInfo gfxdecodeinfo[] =
{
	{ 1, 0x00000, &text_layout,   256, 16 },	/* colors 256-511 */
	{ 1, 0x20000, &sprite_layout,   0, 16 },	/* colors   0-255 */
	{ 1, 0xA0000, &back_layout,   512,  2 },	/* actually the background uses colors */
	{ 1, 0xB0000, &back_layout,   512,  2 },	/* 256-511, but giving it exclusive */
	{ 1, 0xC0000, &back_layout,   512,  2 },	/* pens we can handle it more easily. */
	{ -1 } /* end of array */
};



/* handler called by the 2151 emulator when the internal timers cause an IRQ */
static void vigilant_irq_handler(void)
{
	cpu_cause_interrupt(1,0x00ef);	/* RST 28h */
}

static struct YM2151interface ym2151_interface =
{
	1,			/* 1 chip */
	3579645,	/* 3.579645 MHz */
	{ 60 },
	{ vigilant_irq_handler }
};

static struct DACinterface dac_interface =
{
	1,
	{ 100 }
};



static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			3579645,		   /* 3.579645 MHz */
			0,
			readmem,writemem,readport,writeport,
			interrupt,1
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			3579645,		   /* 3.579645 MHz */
			2,
			sound_readmem,sound_writemem,sound_readport,sound_writeport,
			nmi_interrupt,128	/* clocked by V1 */
								/* RST 18h (RST 08h?) is caused by the main CPU */
								/* RST 28h is caused by the YM2151 */
		}
	},
	60, DEFAULT_REAL_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* no need for interleaving */
	0,

	/* video hardware */
	64*8, 32*8, { 16*8, 48*8-1, 0*8, 32*8-1 },
	gfxdecodeinfo,
	512+32,512+32,
	0, /* no color prom */

	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	vigilant_vh_start,
	vigilant_vh_stop,
	vigilant_vh_screenrefresh,

	/* sound hardware */
	SOUND_SUPPORTS_STEREO,0,0,0,
	{
		{
			SOUND_YM2151,
			&ym2151_interface
		},
		{
			SOUND_DAC,
			&dac_interface
		}
	}

};



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

  Game ROMs

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

ROM_START( vigilant_rom )
	ROM_REGION(0x20000) /* region#0: 64k for code + 64k for bankswitching */
	ROM_LOAD( "g07_c03.bin",  0x00000, 0x08000, 0x9dcca081 )
	ROM_LOAD( "j07_c04.bin",  0x10000, 0x10000, 0xe0159105 )

	ROM_REGION_DISPOSE(0xD0000) /* region #1: graphics (disposed after conversion) */
	ROM_LOAD( "h05_c09.bin",  0x00000, 0x10000, 0x4f5872f0 )
	ROM_LOAD( "f05_c08.bin",  0x10000, 0x10000, 0x01579d20 )
	ROM_LOAD( "t07_c16.bin",  0x20000, 0x10000, 0xf5425e42 )
	ROM_LOAD( "v07_c17.bin",  0x30000, 0x10000, 0x959ba3c7 )
	ROM_LOAD( "p07_c14.bin",  0x40000, 0x10000, 0xcb50a17c )
	ROM_LOAD( "s07_c15.bin",  0x50000, 0x10000, 0x7f2e91c5 )
	ROM_LOAD( "n07_c12.bin",  0x60000, 0x10000, 0x10af8eb2 )
	ROM_LOAD( "o07_c13.bin",  0x70000, 0x10000, 0xb1d9d4dc )
	ROM_LOAD( "k07_c10.bin",  0x80000, 0x10000, 0x9576f304 )
	ROM_LOAD( "l07_c11.bin",  0x90000, 0x10000, 0x4598be4a )
	ROM_LOAD( "d01_c05.bin",  0xA0000, 0x10000, 0x81b1ee5c )
	ROM_LOAD( "e01_c06.bin",  0xB0000, 0x10000, 0xd0d33673 )
	ROM_LOAD( "f01_c07.bin",  0xC0000, 0x10000, 0xaae81695 )

	ROM_REGION(0x10000) /* region#2: 64k for sound */
	ROM_LOAD( "g05_c02.bin",  0x00000, 0x10000, 0x10582b2d )

	ROM_REGION(0x10000) /* region#3: 64k for sample ROM */
	ROM_LOAD( "d04_c01.bin",  0x00000, 0x10000, 0x9b85101d )
ROM_END

ROM_START( vigilntj_rom )
	ROM_REGION(0x20000) /* region#0: 64k for code + 64k for bankswitching */
	ROM_LOAD( "vg_a-8h.rom",  0x00000, 0x08000, 0xba848713 )
	ROM_LOAD( "vg_a-8l.rom",  0x10000, 0x10000, 0x3b12b1d8 )

	ROM_REGION_DISPOSE(0xD0000) /* region #1: graphics (disposed after conversion) */
	ROM_LOAD( "h05_c09.bin",  0x00000, 0x10000, 0x4f5872f0 )
	ROM_LOAD( "f05_c08.bin",  0x10000, 0x10000, 0x01579d20 )
	ROM_LOAD( "t07_c16.bin",  0x20000, 0x10000, 0xf5425e42 )
	ROM_LOAD( "v07_c17.bin",  0x30000, 0x10000, 0x959ba3c7 )
	ROM_LOAD( "p07_c14.bin",  0x40000, 0x10000, 0xcb50a17c )
	ROM_LOAD( "s07_c15.bin",  0x50000, 0x10000, 0x7f2e91c5 )
	ROM_LOAD( "n07_c12.bin",  0x60000, 0x10000, 0x10af8eb2 )
	ROM_LOAD( "o07_c13.bin",  0x70000, 0x10000, 0xb1d9d4dc )
	ROM_LOAD( "k07_c10.bin",  0x80000, 0x10000, 0x9576f304 )
	ROM_LOAD( "l07_c11.bin",  0x90000, 0x10000, 0x4598be4a )
	ROM_LOAD( "d01_c05.bin",  0xA0000, 0x10000, 0x81b1ee5c )
	ROM_LOAD( "e01_c06.bin",  0xB0000, 0x10000, 0xd0d33673 )
	ROM_LOAD( "f01_c07.bin",  0xC0000, 0x10000, 0xaae81695 )

	ROM_REGION(0x10000) /* region#2: 64k for sound */
	ROM_LOAD( "g05_c02.bin",  0x00000, 0x10000, 0x10582b2d )

	ROM_REGION(0x10000) /* region#3: 64k for sample ROM */
	ROM_LOAD( "d04_c01.bin",  0x00000, 0x10000, 0x9b85101d )
ROM_END

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


	/* check if the hi score table has already been initialized */
        if (memcmp(&RAM[0xe04b],"\x00\x45\x11",3) == 0)
	{
		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
                        osd_fread(f,&RAM[0xe04b],60);
			osd_fclose(f);

			/* copy the high score to the work RAM as well */
                        RAM[0xe048] = RAM[0xe04b];
                        RAM[0xe049] = RAM[0xe04c];
                        RAM[0xe04a] = RAM[0xe04d];

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

static void vigilant_hisave(void)
{
	void *f;
	unsigned char *RAM = Machine->memory_region[0];

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


struct GameDriver vigilant_driver =
{
	__FILE__,
	0,
	"vigilant",
	"Vigilante (US)",
	"1988",
	"Irem",
	"Mike Balfour\nPhil Stroffolino\nNicola Salmoria",
	0,
	&machine_driver,
	0,

	vigilant_rom,
	0,0,
	0,
	0,	/* sound_prom */

	vigilant_input_ports,

	0, 0, 0,   /* colors, palette, colortable */
	ORIENTATION_DEFAULT,
        vigilant_hiload, vigilant_hisave
};

struct GameDriver vigilntj_driver =
{
	__FILE__,
	&vigilant_driver,
	"vigilntj",
	"Vigilante (Japan)",
	"1988",
	"Irem",
	"Mike Balfour\nPhil Stroffolino\nNicola Salmoria",
	0,
	&machine_driver,
	0,

	vigilntj_rom,
	0,0,
	0,
	0,	/* sound_prom */

	vigilant_input_ports,

	0, 0, 0,   /* colors, palette, colortable */
	ORIENTATION_DEFAULT,
        vigilant_hiload, vigilant_hisave
};

⌨️ 快捷键说明

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