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

📄 starforc.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 },
	32*8	/* every character takes 32 consecutive bytes */
};
static struct GfxLayout spritelayout1 =
{
	16,16,	/* 16*16 sprites */
	256,	/* 256 sprites */
	3,	/* 3 bits per pixel */
	{ 2*512*16*16, 512*16*16, 0 },	/* the bitplanes are separated */
	{ 23*8, 22*8, 21*8, 20*8, 19*8, 18*8, 17*8, 16*8,
			7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
	{ 0, 1, 2, 3, 4, 5, 6, 7,	/* pretty straightforward layout */
			8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 },
	32*8	/* every sprite takes 32 consecutive bytes */
};
static struct GfxLayout spritelayout2 =
{
	32,32,	/* 32*32 sprites */
	64,	/* 64 sprites */
	3,	/* 3 bits per pixel */
	{ 2*128*32*32, 128*32*32, 0 },	/* the bitplanes are separated */
	{ 87*8, 86*8, 85*8, 84*8, 83*8, 82*8, 81*8, 80*8,
			71*8, 70*8, 69*8, 68*8, 67*8, 66*8, 65*8, 64*8,
			23*8, 22*8, 21*8, 20*8, 19*8, 18*8, 17*8, 16*8,
			7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 },
	{ 0, 1, 2, 3, 4, 5, 6, 7,	/* pretty straightforward layout */
			8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7,
			32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7,
			40*8+0, 40*8+1, 40*8+2, 40*8+3, 40*8+4, 40*8+5, 40*8+6, 40*8+7 },
	128*8	/* every sprite takes 128 consecutive bytes */
};



static struct GfxDecodeInfo gfxdecodeinfo[] =
{
	{ 1, 0x00000, &charlayout1,     0, 8 },	/*   0- 63 characters */
	{ 1, 0x03000, &charlayout2,   128, 8 },	/* 128-191 background #1 */
	{ 1, 0x09000, &charlayout2,    64, 8 },	/*  64-127 background #2 */
	{ 1, 0x0f000, &charlayout3,   192, 8 },	/* 192-255 star background */
	{ 1, 0x12000, &spritelayout1, 320, 8 },	/* 320-383 normal sprites */
	{ 1, 0x14000, &spritelayout2, 320, 8 },	/* 320-383 large sprites */
	{ -1 } /* end of array */
};



static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			4000000,	/* 4 Mhz */
			0,
			readmem,writemem,0,0,
			interrupt,1
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			2000000,        /* 2 Mhz */
			2,
			sound_readmem,sound_writemem,
			sound_readport,sound_writeport,
			0,0 /* interrupts are made by z80 daisy chain system */
		}
	},
	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, { 2*8, 30*8-1, 0, 32*8-1 },
	gfxdecodeinfo,
	384, 384,
	0,

	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	starforc_vh_start,
	starforc_vh_stop,
	starforc_vh_screenrefresh,

	/* sound hardware */
	0,
	starforc_sh_start,
	starforc_sh_stop,
	starforc_sh_update,
};



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

  Game driver(s)

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

ROM_START( starforc_rom )
	ROM_REGION(0x10000)     /* 64k for code */
	ROM_LOAD( "starforc.3",   0x0000, 0x4000, 0x8ba27691 )
	ROM_LOAD( "starforc.2",   0x4000, 0x4000, 0x0fc4d2d6 )

	ROM_REGION_DISPOSE(0x1e000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "starforc.7",   0x00000, 0x1000, 0xf4803339 )
	ROM_LOAD( "starforc.8",   0x01000, 0x1000, 0x96979684 )
	ROM_LOAD( "starforc.9",   0x02000, 0x1000, 0xeead1d5c )
	ROM_LOAD( "starforc.10",  0x03000, 0x2000, 0xc62a19c1 )
	ROM_LOAD( "starforc.11",  0x05000, 0x2000, 0x668aea14 )
	ROM_LOAD( "starforc.12",  0x07000, 0x2000, 0xfdd9e38b )
	ROM_LOAD( "starforc.13",  0x09000, 0x2000, 0x84603285 )
	ROM_LOAD( "starforc.14",  0x0b000, 0x2000, 0x9e9384fe )
	ROM_LOAD( "starforc.15",  0x0d000, 0x2000, 0xc3bda12f )
	ROM_LOAD( "starforc.16",  0x0f000, 0x1000, 0xce20b469 )
	ROM_LOAD( "starforc.17",  0x10000, 0x1000, 0x68c60d0f )
	ROM_LOAD( "starforc.18",  0x11000, 0x1000, 0x6455c3ad )
	ROM_LOAD( "starforc.4",   0x12000, 0x4000, 0xdd9d68a4 )
	ROM_LOAD( "starforc.5",   0x16000, 0x4000, 0xf71717f8 )
	ROM_LOAD( "starforc.6",   0x1a000, 0x4000, 0x5468a21d )

	ROM_REGION(0x10000)     /* 64k for sound board */
	ROM_LOAD( "starforc.1",   0x0000, 0x2000, 0x2735bb22 )
ROM_END

ROM_START( megaforc_rom )
	ROM_REGION(0x10000)     /* 64k for code */
	ROM_LOAD( "mf3.bin",      0x0000, 0x4000, 0xd3ea82ec )
	ROM_LOAD( "mf2.bin",      0x4000, 0x4000, 0xaa320718 )

	ROM_REGION_DISPOSE(0x1e000)     /* temporary space for graphics (disposed after conversion) */
	ROM_LOAD( "mf7.bin",      0x00000, 0x1000, 0x43ef8d20 )
	ROM_LOAD( "mf8.bin",      0x01000, 0x1000, 0xc36fb746 )
	ROM_LOAD( "mf9.bin",      0x02000, 0x1000, 0x62e7c9ec )
	ROM_LOAD( "starforc.10",  0x03000, 0x2000, 0xc62a19c1 )
	ROM_LOAD( "starforc.11",  0x05000, 0x2000, 0x668aea14 )
	ROM_LOAD( "starforc.12",  0x07000, 0x2000, 0xfdd9e38b )
	ROM_LOAD( "starforc.13",  0x09000, 0x2000, 0x84603285 )
	ROM_LOAD( "starforc.14",  0x0b000, 0x2000, 0x9e9384fe )
	ROM_LOAD( "starforc.15",  0x0d000, 0x2000, 0xc3bda12f )
	ROM_LOAD( "starforc.16",  0x0f000, 0x1000, 0xce20b469 )
	ROM_LOAD( "starforc.17",  0x10000, 0x1000, 0x68c60d0f )
	ROM_LOAD( "starforc.18",  0x11000, 0x1000, 0x6455c3ad )
	ROM_LOAD( "starforc.4",   0x12000, 0x4000, 0xdd9d68a4 )
	ROM_LOAD( "starforc.5",   0x16000, 0x4000, 0xf71717f8 )
	ROM_LOAD( "starforc.6",   0x1a000, 0x4000, 0x5468a21d )

	ROM_REGION(0x10000)     /* 64k for sound board */
	ROM_LOAD( "starforc.1",   0x0000, 0x2000, 0x2735bb22 )
ROM_END



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


        if (memcmp(&RAM[0x8348],"\x00\x08\x05\x00",4) == 0 &&
        memcmp(&RAM[0x9181],"\x18",1) == 0 &&
        memcmp(&RAM[0x91a1],"\x18",1) == 0 &&
        memcmp(&RAM[0x91c1],"\x21",1) == 0 &&
        memcmp(&RAM[0x91e1],"\x18",1) == 0 &&
        memcmp(&RAM[0x9201],"\x1d",1) == 0)

        {
                void *f;

                if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0)) != 0)
                {
                        int p,temp;

                        osd_fread(f,&RAM[0x8038],112);
                        RAM[0x8348] = RAM[0x803d];
                        RAM[0x8349] = RAM[0x803c];
                        RAM[0x834a] = RAM[0x803b];
                        RAM[0x834b] = RAM[0x803a];

                        for (p=0;p<4;p++)
                           {
                            temp=0x18+(RAM[0x8348+p]%16);
                            if (temp>=0x20) temp++;
                            RAM[0x9181+(p*0x40)]=temp;
                            temp=0x18+(RAM[0x8348+p]/16);
                            if (temp>=0x20) temp++;
                            RAM[0x91A1+(p*0x40)]=temp;
                            }

                        for (p=0;p<8;p++ )
                        {
                                if (RAM[0x9261-(p*0x20)]==0x18) RAM[0x9261-(p*0x20)]=0x23;
                                else break;
                        }

                        osd_fclose(f);
                }

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

}



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


        /* Bug to solve the problem about resetting in the hi-score screen */
        for (i = 0x8039; i < 0x80a0; i+=0x0b)
                        if (RAM[i] == 0x02) RAM[i] = 0x01;

        if ((RAM[0x8038] != 0) &&
            ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0))


        {
                osd_fwrite(f,&RAM[0x8038],112);

                osd_fclose(f);
        }
}



struct GameDriver starforc_driver =
{
	__FILE__,
	0,
	"starforc",
	"Star Force",
	"1984",
	"Tehkan",
	"Mirko Buffoni\nNicola Salmoria\nTatsuyuki Satoh\nJuan Carlos Lorente\nMarco Cassili",
	0,
	&machine_driver,
	0,

	starforc_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	input_ports,

	0, 0, 0,
	ORIENTATION_DEFAULT,

	hiload, hisave
};

struct GameDriver megaforc_driver =
{
	__FILE__,
	&starforc_driver,
	"megaforc",
	"Mega Force",
	"1985",
	"Tehkan (Video Ware license)",
	"Mirko Buffoni\nNicola Salmoria\nTatsuyuki Satoh\nJuan Carlos Lorente\nMarco Cassili",
	0,
	&machine_driver,
	0,

	megaforc_rom,
	0, 0,
	0,
	0,      /* sound_prom */

	input_ports,

	0, 0, 0,
	ORIENTATION_DEFAULT,

	hiload, hisave
};

⌨️ 快捷键说明

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