psychic5.c

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

C
669
字号
		psychic5_bank_latch = data;
		bankaddress = 0x10000 + ((data & 3) * 0x4000);
		cpu_setbank(1,&RAM[bankaddress]);	 /* Select 4 banks of 16k */
	}
}

int psychic5_interrupt(void)
{
	if (cpu_getiloops() == 0)
	   return 0xd7;		/* RST 10h */
	else
   	   return 0xcf;		/* RST 08h */
}


static struct MemoryReadAddress readmem[] =
{
	{ 0x0000, 0x7fff, MRA_ROM },
	{ 0x8000, 0xbfff, MRA_BANK1 },
	{ 0xc000, 0xdfff, psychic5_paged_ram_r },
	{ 0xe000, 0xefff, MRA_RAM },
	{ 0xf000, 0xf000, MRA_RAM },
	{ 0xf001, 0xf001, MRA_RAM },			
	{ 0xf002, 0xf002, psychic5_bankselect_r },
	{ 0xf003, 0xf003, psychic5_vram_page_select_r },
	{ 0xf004, 0xf004, MRA_RAM },			
	{ 0xf005, 0xf005, MRA_RAM },			
	{ 0xf006, 0xf1ff, MRA_NOP },
	{ 0xf200, 0xf7ff, MRA_RAM },
	{ 0xf800, 0xffff, MRA_RAM },
	{ -1 }	/* end of table */
};

static struct MemoryWriteAddress writemem[] =
{
	{ 0x0000, 0x7fff, MWA_ROM },
	{ 0x8000, 0xbfff, MWA_BANK1 },
	{ 0xc000, 0xdfff, psychic5_paged_ram_w },
	{ 0xe000, 0xefff, MWA_RAM },
	{ 0xf000, 0xf000, soundlatch_w },
	{ 0xf001, 0xf001, MWA_RAM },			
	{ 0xf002, 0xf002, psychic5_bankselect_w },
	{ 0xf003, 0xf003, psychic5_vram_page_select_w },
	{ 0xf004, 0xf004, MWA_RAM },			
	{ 0xf005, 0xf005, MWA_RAM },			
	{ 0xf006, 0xf1ff, MWA_NOP },
	{ 0xf200, 0xf7ff, MWA_RAM, &spriteram, &spriteram_size },
	{ 0xf800, 0xffff, MWA_RAM },
	{ -1 }	/* end of table */
};

static struct MemoryReadAddress sound_readmem[] =
{
	{ 0x0000, 0x7fff, MRA_ROM },
	{ 0xc000, 0xc7ff, MRA_RAM },
	{ 0xe000, 0xe000, soundlatch_r },
	{ -1 }
};

static struct MemoryWriteAddress sound_writemem[] =
{
	{ 0x0000, 0x7fff, MWA_ROM },
	{ 0xc000, 0xc7ff, MWA_RAM },
	{ -1 }
};

static struct IOWritePort sound_writeport[] =
{
	{ 0x0000, 0x0000, YM2203_control_port_0_w },
	{ 0x0001, 0x0001, YM2203_write_port_0_w },
	{ 0x0080, 0x0080, YM2203_control_port_1_w },
	{ 0x0081, 0x0081, YM2203_write_port_1_w },
        { -1 }
};

INPUT_PORTS_START( input_ports )
    PORT_START
    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )

    PORT_START		/* player 1 controls */
    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

    PORT_START		/* player 2 controls */
    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_COCKTAIL )
    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_COCKTAIL )
    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_COCKTAIL )
    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_COCKTAIL )
    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )

    PORT_START  /* dsw0 */
    PORT_DIPNAME( 0x01, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x01, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0x02, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x02, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0x04, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x04, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0x08, 0x08, "Difficulty", IP_KEY_NONE )
    PORT_DIPSETTING(    0x08, "Normal" )
    PORT_DIPSETTING(    0x00, "Difficult" )
    PORT_DIPNAME( 0x10, 0x00, "Cabinet", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Upright" )
    PORT_DIPSETTING(    0x10, "Cocktail" )
    PORT_DIPNAME( 0x20, 0x20, "Demo Sounds", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x20, "On" )
    PORT_DIPNAME( 0xC0, 0xC0, "Lives", IP_KEY_NONE )
    PORT_DIPSETTING(    0x80, "2" )
    PORT_DIPSETTING(    0xC0, "3" )
    PORT_DIPSETTING(    0x40, "4" )
    PORT_DIPSETTING(    0x00, "5" )

    PORT_START  /* dsw1 */
    PORT_BITX(    0x01, 0x01, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE, 0 )
    PORT_DIPSETTING(    0x01, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0x02, 0x02, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x02, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0xe0, 0xe0, "Coin A", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "5 Coins/1 Credit" )
    PORT_DIPSETTING(    0x20, "4 Coins/1 Credit" )
    PORT_DIPSETTING(    0x40, "3 Coins/1 Credit" )
    PORT_DIPSETTING(    0x60, "2 Coins/1 Credit" )
    PORT_DIPSETTING(    0xe0, "1 Coin/1 Credit" )
    PORT_DIPSETTING(    0xc0, "1 Coin/2 Credits" )
    PORT_DIPSETTING(    0xa0, "1 Coin/3 Credits" )
    PORT_DIPSETTING(    0x80, "1 Coin/4 Credits" )
    PORT_DIPNAME( 0x1c, 0x1c, "Coin B", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "5 Coins/1 Credit" )
    PORT_DIPSETTING(    0x04, "4 Coins/1 Credit" )
    PORT_DIPSETTING(    0x08, "3 Coins/1 Credit" )
    PORT_DIPSETTING(    0x0c, "2 Coins/1 Credit" )
    PORT_DIPSETTING(    0x1c, "1 Coin/1 Credit" )
    PORT_DIPSETTING(    0x18, "1 Coin/2 Credits" )
    PORT_DIPSETTING(    0x14, "1 Coin/3 Credits" )
    PORT_DIPSETTING(    0x10, "1 Coin/4 Credits" )
INPUT_PORTS_END

static struct GfxLayout charlayout =
{
        8,8,    /* 8x8 characters */
        2048,	/* 2048 characters */
        4,      /* 4 bits per pixel */
        { 0, 1, 2, 3 }, /* the four bitplanes for pixel are packed into one nibble */
        { 0, 4, 8, 12, 16, 20, 24, 28 },
	{ 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
        32*8   	/* every char takes 32 consecutive bytes */
};

static struct GfxLayout spritelayout =
{
        16,16,  /* 16x16 characters */
        1024,	/* 1024 characters */
        4,      /* 4 bits per pixel */
        { 0, 1, 2, 3 },	/* the four bitplanes for pixel are packed into one nibble */
        { 0, 4, 8, 12, 16, 20, 24, 28, 64*8, 64*8+4, 64*8+8, 64*8+12, 64*8+16, 64*8+20, 64*8+24, 64*8+28 },
	{ 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8, 32*8, 36*8, 40*8, 44*8, 48*8, 52*8, 56*8, 60*8 },
        128*8	/* every char takes 128 consecutive bytes */
};

static struct GfxDecodeInfo gfxdecodeinfo[] =
{
        /* character set */
        { 1, 0x00000, &spritelayout,  0*16, 16 },
        { 1, 0x20000, &spritelayout, 16*16, 16 },
        { 1, 0x40000, &charlayout,   32*16, 16 },
	{ -1 } /* end of array */
};

static struct YM2203interface ym2203_interface =
{
	2,		/* 2 chips   */
	1500000,    /* 6000000/4 */
	{ YM2203_VOL(255,127), YM2203_VOL(255,127) },
	{ 0 },
	{ 0 },
	{ 0 },
	{ 0 }
};

static struct MachineDriver machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			6000000,
			0,
			readmem,writemem,0,0,
			psychic5_interrupt,2
		},
		{
			CPU_Z80 | CPU_AUDIO_CPU,
			4250000,	/* hand tuned to fix the tempo */
			2,
			sound_readmem,sound_writemem,0,sound_writeport,
			interrupt,3
		}
	},
	60, DEFAULT_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	10,                                     /* Allow time for 2nd cpu to interleave*/
	0,
	/* video hardware */
	32*8, 32*8,
	{ 0*8, 32*8-1, 2*8, 30*8-1 },
	gfxdecodeinfo,
	48*16,48*16,
	0,
	VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
	0,
	psychic5_vh_start,
	psychic5_vh_stop,
	psychic5_vh_screenrefresh,

	/* sound hardware */
	0,0,0,0,
	{
		{
			SOUND_YM2203,
			&ym2203_interface
		}
	}

};


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

  Game driver(s)

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

ROM_START( psychic5_rom )
	ROM_REGION( 0x20000 ) 				/* 2*64K for main CPU, Z80 */
	ROM_LOAD( "p5d",          0x00000, 0x08000, 0x90259249 )
	ROM_LOAD( "p5e",          0x10000, 0x10000, 0x72298f34 )

	ROM_REGION_DISPOSE( 0x48000 )   			/* graphics (disposed after conversion) */
	ROM_LOAD( "p5b",          0x00000, 0x10000, 0x7e3f87d4 )	/* sprite tiles */
	ROM_LOAD( "p5c",          0x10000, 0x10000, 0x8710fedb )
	ROM_LOAD( "p5g",          0x20000, 0x10000, 0xf9262f32 )	/* background tiles */
	ROM_LOAD( "p5h",          0x30000, 0x10000, 0xc411171a )
	ROM_LOAD( "p5f",          0x40000, 0x08000, 0x04d7e21c ) /* foreground tiles */

	ROM_REGION( 0x10000 ) 				/*64K for 2nd z80 CPU*/
	ROM_LOAD( "p5a",          0x00000, 0x08000, 0x50060ecd )
ROM_END


static int hiload(void)
{
	/* get RAM pointer (this game is multiCPU, we can't assume the global */
	/* RAM pointer is pointing to the right place) */
	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];

	if (memcmp(&RAM[0xfc84],"\x00\x07\x53",3) == 0)
	{
		void *f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,0);
		if (f)
		{
			osd_fread(f,&RAM[0xfd00],49);
			osd_fclose(f);

			/* Copy the high score to the work ram as well */

			RAM[0xfc84] = RAM[0xfd00];
			RAM[0xfc85] = RAM[0xfd01];
			RAM[0xfc86] = RAM[0xfd02];
		}
		return 1;
	}
	return 0;  /* we can't load the hi scores yet */
}

static void hisave(void)
{
	/* get RAM pointer (this game is multiCPU, we can't assume the global */
	/* RAM pointer is pointing to the right place) */

	unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
	void *f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1);

	if (f)
	{
		osd_fwrite(f,&RAM[0xfd00],49);
		osd_fclose(f);
	}
}

struct GameDriver psychic5_driver =
{
	__FILE__,
	0,
	"psychic5",
	"Psychic 5",
	"1987",
	"Jaleco",
	"Jarek Parchanski\nRoberto Ventura",
	0,
	&machine_driver,
	0,

	psychic5_rom,
	0, 0,
	0,
	0,	/* sound_prom */

	input_ports,

	0, 0, 0,
	ORIENTATION_ROTATE_270,
	hiload, hisave
};

⌨️ 快捷键说明

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