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

📄 gameplan.c

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

GAME PLAN driver, used for games like MegaTack, Killer Comet, Kaos, Challenger

Modifications by Santeri Saarimaa:

3/6/1998: - CPU #2 is only for audio in all four games, added | CPU_AUDIO_CPU
          - A little louder sounds
          - Fixed MegaTack dip switches & input ports
          - Fixed Killer Comet dip switches & input ports
          - Fixed Challenger dip switches & input ports + coin slots
          - Added hi-score saving/loading for Challenger
          - Added hi-score saving/loading for MegaTack
          - Added hi-score saving/loading for Killer Comet

TO-DO: - Fix the input ports/dip switches of Kaos?
       - Graphics are still somewhat scrambled sometimes (just look at
         the tests with f2/f1)

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

#include "driver.h"
#include "vidhrdw/generic.h"

int gameplan_vh_start(void);
void gameplan_vh_stop(void);
int gameplan_video_r(int offset);
void gameplan_video_w(int offset, int data);
int gameplan_sound_r(int offset);
void gameplan_sound_w(int offset, int data);
int gameplan_via5_r(int offset);
void gameplan_via5_w(int offset, int data);
void gameplan_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void gameplan_select_port(int offset, int data);
int gameplan_read_port(int offset);

static int gameplan_current_port;

void gameplan_select_port(int offset, int data)
{

	switch (offset)
	{
		case 0x00:
			switch(data)
			{
				case 0x01: gameplan_current_port = 0; break;
				case 0x02: gameplan_current_port = 1; break;
				case 0x04: gameplan_current_port = 2; break;
				case 0x08: gameplan_current_port = 3; break;
				case 0x80: gameplan_current_port = 4; break;
				case 0x40: gameplan_current_port = 5; break;

				default:
					return;
			}

			break;

		case 0x02:
			break;

		case 0x03:
			break;

		case 0x0c:
			break;

		default:
			break;
	}
}

int gameplan_read_port(int offset)
{
	return readinputport(gameplan_current_port);
}

static struct MemoryReadAddress readmem[] =
{
    { 0x0000, 0x03ff, MRA_RAM },
    { 0x032d, 0x03d8, MRA_RAM }, /* note: 300-32c and 3d9-3ff is
								  * written but never read?
								  * (write by code at e1df and e1e9,
								  * 32d is read by e258)*/
    { 0x2000, 0x200f, gameplan_video_r },
    { 0x2801, 0x2801, gameplan_read_port },
	{ 0x3000, 0x300f, gameplan_sound_r },
    { 0x9000, 0xffff, MRA_ROM },

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

static struct MemoryWriteAddress writemem[] =
{
    { 0x0000, 0x03ff, MWA_RAM },
    { 0x2000, 0x200f, gameplan_video_w },		/* VIA 1 */
    { 0x2800, 0x280f, gameplan_select_port },	/* VIA 2 */
    { 0x3000, 0x300f, gameplan_sound_w },       /* VIA 3 */
    { 0x9000, 0xffff, MWA_ROM },

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

static struct MemoryReadAddress readmem_snd[] =
{
	{ 0x0000, 0x0026, MRA_RAM },
	{ 0x01f6, 0x01ff, MRA_RAM },
	{ 0x0800, 0x080f, gameplan_via5_r },

#if 0
    { 0xa001, 0xa001, gameplan_ay_3_8910_1_r }, /* AY-3-8910 */
#else
    { 0xa001, 0xa001, soundlatch_r }, /* AY-3-8910 */
#endif

    { 0xf800, 0xffff, MRA_ROM },
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress writemem_snd[] =
{
	{ 0x0000, 0x0026, MWA_RAM },
	{ 0x01f6, 0x01ff, MWA_RAM },
	{ 0x0800, 0x080f, gameplan_via5_w },

#if 0
    { 0xa000, 0xa000, gameplan_ay_3_8910_0_w }, /* AY-3-8910 */
    { 0xa002, 0xa002, gameplan_ay_3_8910_2_w }, /* AY-3-8910 */
#else
    { 0xa000, 0xa000, AY8910_control_port_0_w }, /* AY-3-8910 */
    { 0xa002, 0xa002, AY8910_write_port_0_w }, /* AY-3-8910 */
#endif

	{ 0xf800, 0xffff, MWA_ROM },

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

int gameplan_interrupt(void)
{
	return 1;
}

INPUT_PORTS_START( kaos_input_ports )
	PORT_START      /* IN0 - from "TEST NO.7 - status locator - coin-door" */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_TILT,
			  "Slam", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x08, IP_ACTIVE_LOW, 0,
			  "Do Tests", OSD_KEY_F1, IP_JOY_NONE, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_SERVICE,
			  "Select Test", OSD_KEY_F2, IP_JOY_NONE, 0)
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN3 )	 /* coin sw. no.3 */
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )	 /* coin sw. no.2 */
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )	 /* coin sw. no.1 */

	PORT_START      /* IN1 - from "TEST NO.7 - status locator - start sws." */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )  /* 2 player start */
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )  /* 1 player start */

	PORT_START      /* IN2 - from "TEST NO.8 - status locator - player no.1" */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1,
			  "P1 Jump", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1,
			  "P1 Move Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1,
			  "P1 Move Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1,
			  "P1 Fire Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1,
			  "P1 Fire Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */

	PORT_START      /* IN3 - from "TEST NO.8 - status locator - player no.2" */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2,
			  "P2 Fire Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2,
			  "P2 Fire Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2,
			  "P2 Fire Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2,
			  "P2 Move Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2,
			  "P2 Move Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */

	PORT_START      /* IN4 - from "TEST NO.6 - dip switch A" */

	PORT_DIPNAME(0x0f, 0x0f, "Coinage", IP_KEY_NONE ) /* -> 039F */
	PORT_DIPSETTING(   0x0f, " 1 Coin / 1 Credit" )
	PORT_DIPSETTING(   0x0e, " 1 Coin / 1 Credit" )
	PORT_DIPSETTING(   0x0d, " 1 Coin / 2 Credits" )
	PORT_DIPSETTING(   0x0c, " 1 Coin / 3 Credits" )
	PORT_DIPSETTING(   0x0b, " 1 Coin / 4 Credits" )
	PORT_DIPSETTING(   0x0a, " 1 Coin / 5 Credits" )
	PORT_DIPSETTING(   0x09, " 1 Coin / 6 Credits" )
	PORT_DIPSETTING(   0x08, " 1 Coin / 7 Credits" )
	PORT_DIPSETTING(   0x07, " 1 Coin / 8 Credits" )
	PORT_DIPSETTING(   0x06, " 1 Coin / 9 Credits" )
	PORT_DIPSETTING(   0x05, " 1 Coin / 10 Credits" )
	PORT_DIPSETTING(   0x04, " 1 Coin / 11 Credits" )
	PORT_DIPSETTING(   0x03, " 1 Coin / 12 Credits" )
	PORT_DIPSETTING(   0x02, " 1 Coin / 13 Credits" )
	PORT_DIPSETTING(   0x01, " 1 Coin / 14 Credits" )
	PORT_DIPSETTING(   0x00, "2 Coins / 1 Credit" )

	PORT_DIPNAME(0x10, 0x10, "A4", IP_KEY_NONE ) /* -> 039A */
	PORT_DIPSETTING(   0x10, "10" )
	PORT_DIPSETTING(   0x00, "00" )

	PORT_DIPNAME(0x60, 0x20, "A5", IP_KEY_NONE ) /* -> 039C */
	PORT_DIPSETTING(   0x60, "10" )
	PORT_DIPSETTING(   0x40, "20" )
	PORT_DIPSETTING(   0x20, "30" )
	PORT_DIPSETTING(   0x00, "40" )

	PORT_DIPNAME(0x80, 0x80, "A7", IP_KEY_NONE ) /* -> 039D */
	PORT_DIPSETTING(   0x80, "Insert Coin To Play" )
	PORT_DIPSETTING(   0x00, "Free Play" )

	PORT_START      /* IN5 - from "TEST NO.6 - dip switch B" */

	PORT_DIPNAME(0x01, 0x01, "Lives", IP_KEY_NONE )
	PORT_DIPSETTING(   0x01, "3" )
	PORT_DIPSETTING(   0x00, "4" )

	PORT_DIPNAME(0x02, 0x00, "$0397 (?)", IP_KEY_NONE )
	PORT_DIPSETTING(   0x00, "2" )
	PORT_DIPSETTING(   0x02, "1" )

	PORT_DIPNAME(0x0c, 0x00, "$03a4 (?)", IP_KEY_NONE )
	PORT_DIPSETTING(   0x00, "3" )
	PORT_DIPSETTING(   0x04, "2" )
	PORT_DIPSETTING(   0x08, "1" )
	PORT_DIPSETTING(   0x0c, "0" )

	PORT_DIPNAME(0x10, 0x00, "$03be (?)", IP_KEY_NONE )
	PORT_DIPSETTING(   0x00, "c" )
	PORT_DIPSETTING(   0x10, "8" )

	PORT_DIPNAME(0x20, 0x00, "$03a5 (?)", IP_KEY_NONE )
	PORT_DIPSETTING(   0x00, "1" )
	PORT_DIPSETTING(   0x20, "0" )

	PORT_DIPNAME(0x40, 0x00, "$0398 (?)", IP_KEY_NONE )
	PORT_DIPSETTING(   0x00, "40" )
	PORT_DIPSETTING(   0x40, "0" )

	PORT_DIPNAME(0x80, 0x80, "Cabinet", IP_KEY_NONE )
	PORT_DIPSETTING(   0x80, "Upright" )
	PORT_DIPSETTING(   0x00, "Cocktail" )
INPUT_PORTS_END


INPUT_PORTS_START( killcom_input_ports )
	PORT_START      /* IN0 - from "TEST NO.7 - status locator - coin-door" */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_TILT,
			  "Slam", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x08, IP_ACTIVE_LOW, 0,
			  "Do Tests", OSD_KEY_F1, IP_JOY_NONE, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_SERVICE,
			  "Select Test", OSD_KEY_F2, IP_JOY_NONE, 0)
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN3 )	 /* coin sw. no.3 */
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )	 /* coin sw. no.2 */
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )	 /* coin sw. no.1 */

	PORT_START      /* IN1 - from "TEST NO.7 - status locator - start sws." */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )  /* unused */
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )  /* 2 player start */
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused */
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )  /* 1 player start */

	PORT_START      /* IN2 - from "TEST NO.8 - status locator - player no.1" */
	PORT_BITX(0x01, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1,
			  "P1 Hyperspace", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1,
			  "P1 Fire Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1,
			  "P1 Fire Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1,
			  "P1 Fire Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1,
			  "P1 Move Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1,
			  "P1 Move Down", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1,
			  "P1 Move Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1,
			  "P1 Move Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)

	PORT_START      /* IN3 - from "TEST NO.8 - status locator - player no.2" */
	PORT_BITX(0x01, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2,
			  "P2 Hyperspace", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2,
			  "P2 Fire Up", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2,
			  "P2 Fire Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
    PORT_BITX(0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2,
			  "P2 Fire Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2,
			  "P2 Move Left", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2,
			  "P2 Move Down", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2,
			  "P2 Move Right", IP_KEY_DEFAULT, IP_JOY_DEFAULT, 0)
	PORT_BITX(0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2,

⌨️ 快捷键说明

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