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

📄 toki.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	4096,	/* 4096 characters */
	4,	/* 4 bits per pixel */
        { 4096*16*16*3,4096*16*16*2,4096*16*16*1,4096*16*16*0 },	/* planes */
	{ 0, 1, 2, 3, 4, 5, 6, 7,
	  0x8000*8+0, 0x8000*8+1, 0x8000*8+2, 0x8000*8+3, 0x8000*8+4,
	  0x8000*8+5, 0x8000*8+6, 0x8000*8+7 },				/* x bit */
	{
	  0,8,16,24,32,40,48,56,
	  0x10000*8+ 0, 0x10000*8+ 8, 0x10000*8+16, 0x10000*8+24, 0x10000*8+32,
	  0x10000*8+40, 0x10000*8+48, 0x10000*8+56 },			/* y bit */
	8*8
};

static struct GfxLayout spriteslayout =
{
	16,16,	/* 16 by 16 */
	8192,	/* 8192 sprites */
	4,	/* 4 bits per pixel */
        { 8192*16*16*3,8192*16*16*2,8192*16*16*1,8192*16*16*0 },	/* planes */
	{    0,     1,     2,     3,     4,     5,     6,     7,
	 128+0, 128+1, 128+2, 128+3, 128+4, 128+5, 128+6, 128+7 },	/* x bit */
	{ 0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120 },		/* y bit */
	16*16
};

static struct GfxDecodeInfo gfxdecodeinfo[] =
{
	{ 1, 0x000000, &charlayout,			16*16,  16 },
	{ 1, 0x020000, &spriteslayout,		 0*16,  16 },
	{ 1, 0x120000, &backgroundlayout,	32*16,  16 },
	{ 1, 0x1a0000, &backgroundlayout,	48*16,  16 },
	{ -1 } /* end of array */
};



static struct YM3526interface ym3812_interface =
{
	1,			/* 1 chip (no more supported) */
	3600000,	/* 3.600000 MHz ? (partially supported) */
	{ 255 }		/* (not supported) */
};

static struct MSM5205interface msm5205_interface =
{
	1,			/* 1 chips */
	4000,       /* 8000Hz playback? */
	toki_adpcm_int,	/* interrupt function */
	{ 255 }
};



static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_M68000,
			16000000,	/* the real speed should be 8MHz or less (68000-8 CPU), */
						/* but with less than 14MHz there are slowdowns and the */
						/* title screen doesn't wave correctly */
			0,
			readmem,writemem,
			0,0,
			toki_interrupt,1
		},
		{
			CPU_Z80,
			4000000,	/* 4 MHz ??? */
			2,
			sound_readmem,sound_writemem,
			0,0,
			ignore_interrupt,0	/* IRQs are caused by the main CPU?? */
								/* NMIs are caused by the ADPCM chip */
		},
	},
	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, 0*8, 32*8-1 },
	gfxdecodeinfo,
	4*256, 4*256,
	0,
	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	toki_vh_start,
	toki_vh_stop,
	toki_vh_screenrefresh,

	/* sound hardware; only samples because we still haven't YM 3812 */
	0,0,0,0,
	{
		{
			SOUND_YM3812,
			&ym3812_interface
		},
		{
			SOUND_MSM5205,
			&msm5205_interface
		}
	}
};



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

  Game driver(s)

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

ROM_START( toki_rom )
	ROM_REGION(0x60000)	/* 6*64k for 68000 code */
	ROM_LOAD_EVEN( "toki.e3",      0x00000, 0x20000, 0xae9b3da4 )
	ROM_LOAD_ODD ( "toki.e5",      0x00000, 0x20000, 0x66a5a1d6 )
	ROM_LOAD_EVEN( "toki.e2",      0x40000, 0x10000, 0xd6a82808 )
	ROM_LOAD_ODD ( "toki.e4",      0x40000, 0x10000, 0xa01a5b10 )

	ROM_REGION_DISPOSE(0x220000)	/* 2*64k for foreground tiles */
	ROM_LOAD( "toki.e21",     0x000000, 0x08000, 0xbb8cacbd )
	ROM_LOAD( "toki.e13",     0x008000, 0x08000, 0x052ad275 )
	ROM_LOAD( "toki.e22",     0x010000, 0x08000, 0x04dcdc21 )
	ROM_LOAD( "toki.e7",      0x018000, 0x08000, 0x70729106 )
							/* 16*64k for sprites */
	ROM_LOAD( "toki.e26",     0x020000, 0x20000, 0xa8ba71fc )
	ROM_LOAD( "toki.e28",     0x040000, 0x20000, 0x29784948 )
	ROM_LOAD( "toki.e34",     0x060000, 0x20000, 0xe5f6e19b )
	ROM_LOAD( "toki.e36",     0x080000, 0x20000, 0x96e8db8b )
	ROM_LOAD( "toki.e30",     0x0a0000, 0x20000, 0x770d2b1b )
	ROM_LOAD( "toki.e32",     0x0c0000, 0x20000, 0xc289d246 )
	ROM_LOAD( "toki.e38",     0x0e0000, 0x20000, 0x87f4e7fb )
	ROM_LOAD( "toki.e40",     0x100000, 0x20000, 0x96e87350 )
							/* 8*64k for background #1 tiles */
	ROM_LOAD( "toki.e23",     0x120000, 0x10000, 0xfeb13d35 )
	ROM_LOAD( "toki.e24",     0x130000, 0x10000, 0x5b365637 )
	ROM_LOAD( "toki.e15",     0x140000, 0x10000, 0x617c32e6 )
	ROM_LOAD( "toki.e16",     0x150000, 0x10000, 0x2a11c0f0 )
	ROM_LOAD( "toki.e17",     0x160000, 0x10000, 0xfbc3d456 )
	ROM_LOAD( "toki.e18",     0x170000, 0x10000, 0x4c2a72e1 )
	ROM_LOAD( "toki.e8",      0x180000, 0x10000, 0x46a1b821 )
	ROM_LOAD( "toki.e9",      0x190000, 0x10000, 0x82ce27f6 )
							/* 8*64k for background #2 tiles */
	ROM_LOAD( "toki.e25",     0x1a0000, 0x10000, 0x63026cad )
	ROM_LOAD( "toki.e20",     0x1b0000, 0x10000, 0xa7f2ce26 )
	ROM_LOAD( "toki.e11",     0x1c0000, 0x10000, 0x48989aa0 )
	ROM_LOAD( "toki.e12",     0x1d0000, 0x10000, 0xc2ad9342 )
	ROM_LOAD( "toki.e19",     0x1e0000, 0x10000, 0x6cd22b18 )
	ROM_LOAD( "toki.e14",     0x1f0000, 0x10000, 0x859e313a )
	ROM_LOAD( "toki.e10",     0x200000, 0x10000, 0xe15c1d0f )
	ROM_LOAD( "toki.e6",      0x210000, 0x10000, 0x6f4b878a )

	ROM_REGION(0x18000)	/* 64k for code + 32k for banked data */
	ROM_LOAD( "toki.e1",      0x00000, 0x8000, 0x2832ef75 )
	ROM_CONTINUE(        0x10000, 0x8000 )	/* banked at 8000-bfff */
ROM_END



static int hiload(void)
{
	void *f;

	/* check if the hi score table has already been initialized */

	if (memcmp(&ram[0x6BB6],"D TA",4) == 0)
	{
		if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
		{
			osd_fread(f,&ram[0x6B66],180);
			osd_fclose(f);
		}
		return 1;
	}
	else return 0;	/* we can't load the hi scores yet */
}


static void hisave(void)
{
	void *f;

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


void toki_rom_decode (void)
{
	unsigned char *temp = malloc (65536 * 2);
	int i, offs;

	/* invert the sprite data in the ROMs */
	for (i = 0x020000; i < 0x120000; i++)
		Machine->memory_region[1][i] ^= 0xff;

	/* merge background tile graphics together */
	if (temp)
	{
		for (offs = 0x120000; offs < 0x220000; offs += 0x20000)
		{
			unsigned char *base = &Machine->memory_region[1][offs];
			memcpy (temp, base, 65536 * 2);
			for (i = 0; i < 16; i++)
			{
				memcpy (&base[0x00000 + i * 0x800], &temp[0x0000 + i * 0x2000], 0x800);
				memcpy (&base[0x10000 + i * 0x800], &temp[0x0800 + i * 0x2000], 0x800);
				memcpy (&base[0x08000 + i * 0x800], &temp[0x1000 + i * 0x2000], 0x800);
				memcpy (&base[0x18000 + i * 0x800], &temp[0x1800 + i * 0x2000], 0x800);
			}
		}

		free (temp);
	}
}



struct GameDriver toki_driver =
{
	__FILE__,
	0,
	"toki",
	"Toki (bootleg)",
	"1990",
	"Datsu",
	"Jarek Parchanski (MAME driver)\nRichard Bush (hardware info)", 
	0,
	&machine_driver,
	0,

	toki_rom,
	toki_rom_decode, 0,
	0,
	0,			/* sound_prom */
	input_ports,
	0, 0, 0, 	  	/* colors, palette, colortable */
	ORIENTATION_DEFAULT,
	hiload, hisave
};

⌨️ 快捷键说明

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