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

📄 mcr68.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************

	Xenophobe, (c) 1987 Bally Midway, Game No. 0E85
	Spy Hunter 2 (Not working yet)
	Blasted (Not working yet)
	Zwackery (Not working yet)

    The timer chip (see machine/mcr68.c) needs to be fully emulated before
    the other games will work.

	Emulation by Bryan McPhail, mish@tendril.force9.net

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

#include "driver.h"
#include "vidhrdw/generic.h"
#include "machine/6821pia.h"

void mcr68_videoram_w(int offset,int data);
void mcr68_paletteram_w(int offset,int data);

extern unsigned char *mcr68_spriteram;
int mcr68_videoram_r(int offset);
void mcr68_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
void xenophobe_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void mcr68_init_machine(void);
int mcr68_interrupt(void);

void mcr_soundstatus_w (int offset,int data);
int mcr_soundlatch_r (int offset);
void mcr_pia_1_w (int offset, int data);
int mcr_pia_1_r (int offset);

int mcr68_control_0(int offset);
int mcr68_control_1(int offset);
int mcr68_control_2(int offset);
int mcr68_6840_r(int offset);
void mcr68_6840_w(int offset,int data);
void mcr68_sg_w(int offset,int data);

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

  Memory maps

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

static struct MemoryReadAddress mcr68_readmem[] =
{
	{ 0x00000, 0x3ffff, MRA_ROM },
	{ 0x60000, 0x63fff, MRA_BANK1 }, /* Main RAM */
	{ 0x70000, 0x70fff, mcr68_videoram_r },
	{ 0x71000, 0x71fff, MRA_BANK2 },
	{ 0x80000, 0x80fff, MRA_BANK3 },
	{ 0x90000, 0x900ff, paletteram_word_r },
	{ 0xa0000, 0xa000f, mcr68_6840_r },
	{ 0xd0000, 0xd0001, mcr68_control_0 },
	{ 0xe0000, 0xe0001, mcr68_control_1 },
	{ 0xf0000, 0xf0001, mcr68_control_2 },
	{ -1 }  /* end of table */
};

static struct MemoryWriteAddress mcr68_writemem[] =
{
	{ 0x00000, 0x3ffff, MWA_ROM },
	{ 0x60000, 0x63fff, MWA_BANK1 }, /* Main RAM */
	{ 0x70000, 0x70fff, mcr68_videoram_w, &videoram, &videoram_size },
	{ 0x71000, 0x71fff, MWA_BANK2 },
	{ 0x80000, 0x80fff, MWA_BANK3, &mcr68_spriteram },
	{ 0x90000, 0x900ff, mcr68_paletteram_w, &paletteram },
	{ 0xa0000, 0xa000f, mcr68_6840_w },
	{ 0xb0000, 0xb0001, MWA_NOP }, /* Watchdog is 0xb0000 */
	{ 0xc0000, 0xc0001, mcr68_sg_w }, /* sound cpu */
	{ -1 }  /* end of table */
};

/* Not finished yet */
static struct MemoryReadAddress zwackery_readmem[] =
{
	{ 0x00000, 0x3ffff, MRA_ROM },
	{ 0x80000, 0x80fff, MRA_BANK1 }, /* Main RAM */

	{ 0x70000, 0x70fff, mcr68_videoram_r },
	{ 0x71000, 0x71fff, MRA_BANK2 },
	{ 0x90000, 0x900ff, paletteram_word_r },
	{ 0xa0000, 0xa000f, mcr68_6840_r },
	{ 0xd0000, 0xd0001, mcr68_control_0 },
	{ 0xe0000, 0xe0001, mcr68_control_1 },
	{ 0xf0000, 0xf0001, mcr68_control_2 },

	{ 0x104000, 0x14000f, MRA_NOP },

	{ 0xc00000, 0xc00fff, MRA_BANK2 },

	{ -1 }  /* end of table */
};

static struct MemoryWriteAddress zwackery_writemem[] =
{
	{ 0x00000, 0x3ffff, MWA_ROM },
	{ 0x80000, 0x80fff, MWA_BANK1 }, /* Main RAM */

	{ 0x70000, 0x70fff, mcr68_videoram_w, &videoram, &videoram_size },
	{ 0x71000, 0x71fff, MWA_BANK2 },

	{ 0x90000, 0x900ff, mcr68_paletteram_w, &paletteram },
	{ 0xa0000, 0xa000f, mcr68_6840_w },
	{ 0xb0000, 0xb0001, MWA_NOP }, /* Watchdog is 0xb0000 */
	{ 0xc0000, 0xc0001, mcr68_sg_w }, /* sound cpu */

	{ 0x104000, 0x14000f, MWA_NOP },

	{ 0xc00000, 0xc00fff, MWA_BANK2 },


	{ -1 }  /* end of table */
};

/* Xenophobe Sounds Good board */
static struct MemoryReadAddress sg_readmem[] =
{
	{ 0x000000, 0x03ffff, MRA_ROM },
	{ 0x060000, 0x060007, mcr_pia_1_r },
	{ 0x070000, 0x070fff, MRA_BANK8 },
	{ -1 }	/* end of table */
};

static struct MemoryWriteAddress sg_writemem[] =
{
	{ 0x000000, 0x03ffff, MWA_ROM },
	{ 0x060000, 0x060007, mcr_pia_1_w },
	{ 0x070000, 0x070fff, MWA_BANK8 },
	{ -1 }	/* end of table */
};

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

  Input port definitions

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

INPUT_PORTS_START( xenophobe_input_ports )
	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* actually tilt? */
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT )  /* actually service..? */
	PORT_BITX(    0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
	PORT_DIPSETTING(    0x80, "Off" )
	PORT_DIPSETTING(    0x00, "On" )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )

	PORT_START
	PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNUSED )
	PORT_DIPNAME( 0x04, 0x04, "Free Play", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "On" )
	PORT_DIPSETTING(    0x04, "Off" )
	PORT_DIPNAME( 0x08, 0x08, "Coins per Life Unit", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "2" )
	PORT_DIPSETTING(    0x08, "1" )
	PORT_DIPNAME( 0x10, 0x10, "Life Unit", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "2000" )
	PORT_DIPSETTING(    0x10, "1000" )
	PORT_DIPNAME( 0x20, 0x20, "Attract Music", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "Off" )
	PORT_DIPSETTING(    0x20, "On" )
	PORT_DIPNAME( 0xC0, 0xC0, "Difficulty", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "Medium" )
	PORT_DIPSETTING(    0x40, "Easy" )
	PORT_DIPSETTING(    0x80, "Hard" )
	PORT_DIPSETTING(    0xC0, "Medium" )
INPUT_PORTS_END

INPUT_PORTS_START( spyhunt2_input_ports )
	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_TILT )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )  
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE )
	PORT_BITX(    0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
	PORT_DIPSETTING(    0x80, "Off" )
	PORT_DIPSETTING(    0x00, "On" )

	PORT_START
 	PORT_ANALOGX( 0xff, 0x74, IPT_AD_STICK_X | IPF_CENTER, 100, 0, 0x20, 0xff, OSD_KEY_LEFT, OSD_KEY_RIGHT, IPT_JOYSTICK_LEFT, IPT_JOYSTICK_RIGHT, 2 )

	PORT_START
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) /* Left Trigger */
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) /* Left Button */
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 ) /* Right Trigger */
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 ) /* Right Button */
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )

	PORT_START 
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER3 )
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 )


	PORT_START	/* IN3 -- dipswitches */

		PORT_DIPNAME( 0x01, 0x01, "Unknown 1", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x01, "A2" )
	PORT_DIPNAME( 0x02, 0x02, "Unknown 2", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x02, "A2" )
	PORT_DIPNAME( 0x04, 0x04, "Unknown 3 (FREE PLAY)", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x04, "A2" )
	PORT_DIPNAME( 0x08, 0x08, "Unknown 4", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x08, "A2" )
	PORT_DIPNAME( 0x10, 0x10, "Unknown 5", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x10, "A2" )
	PORT_DIPNAME( 0x20, 0x20, "Unknown 6", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x20, "A2" )
	PORT_DIPNAME( 0x40, 0x40, "Unknown 7", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x40, "A2" )
	PORT_DIPNAME( 0x80, 0x80, "Unknown 8", IP_KEY_NONE )
		PORT_DIPSETTING(    0x00, "a1" )
		PORT_DIPSETTING(    0x80, "A2" )



	/* Free play in Spy 2 *
	PORT_DIPNAME( 0x04, 0x04, "Score Option", IP_KEY_NONE )
	PORT_DIPSETTING(    0x04, "Keep score when continuing" )
	PORT_DIPSETTING(    0x00, "Lose score when continuing" )



	PORT_DIPNAME( 0x08, 0x08, "Coin A", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "2 Coins/1 Credit" )
	PORT_DIPSETTING(    0x08, "1 Coin/1 Credit" )
	PORT_DIPNAME( 0x70, 0x70, "Coin B", IP_KEY_NONE )
	PORT_DIPSETTING(    0x00, "3 Coins/1 Credit" )
	PORT_DIPSETTING(    0x10, "2 Coins/1 Credit" )
	PORT_DIPSETTING(    0x70, "1 Coin/1 Credit" )
	PORT_DIPSETTING(    0x60, "1 Coin/2 Credits" )
	PORT_DIPSETTING(    0x50, "1 Coin/3 Credits" )
	PORT_DIPSETTING(    0x40, "1 Coin/4 Credits" )
	PORT_DIPSETTING(    0x30, "1 Coin/5 Credits" )
	PORT_DIPSETTING(    0x20, "1 Coin/6 Credits" )
	PORT_BITX( 0x80,    0x80, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Advance", OSD_KEY_F1, IP_JOY_NONE, 0 )
	PORT_DIPSETTING(    0x80, "Off" )
	PORT_DIPSETTING(    0x00, "On" )

*/

INPUT_PORTS_END

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

/* note that characters are half the resolution of sprites in each direction, so we generate
   them at double size */

static struct GfxLayout mcr68_charlayout_2048 =
{
	16,16,
	2048,
	4,
	{ 0,1,2048*16*8,2048*16*8+1 },
	{ 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14 },
	{ 0, 0, 2*8, 2*8, 4*8, 4*8, 6*8, 6*8, 8*8, 8*8, 10*8, 10*8, 12*8, 12*8, 14*8, 14*8 },
	16*8
};


/* 512 sprites; used by Rampage, Xenophobe */
#define X (512*128*8)
#define Y (2*X)
#define Z (3*X)
static struct GfxLayout mcr3_spritelayout_512 =
{
   32,32,
   512,
   4,
   { 0, 1, 2, 3 },
   {  Z+0, Z+4, Y+0, Y+4, X+0, X+4, 0, 4, Z+8, Z+12, Y+8, Y+12, X+8, X+12, 8, 12,
      Z+16, Z+20, Y+16, Y+20, X+16, X+20, 16, 20, Z+24, Z+28, Y+24, Y+28,
      X+24, X+28, 24, 28 },
	 {  0, 32, 32*2, 32*3, 32*4, 32*5, 32*6, 32*7, 32*8, 32*9, 32*10, 32*11,
      32*12, 32*13, 32*14, 32*15, 32*16, 32*17, 32*18, 32*19, 32*20, 32*21,
      32*22, 32*23, 32*24, 32*25, 32*26, 32*27, 32*28, 32*29, 32*30, 32*31 },
   128*8

⌨️ 快捷键说明

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