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

📄 turbo.c

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

     Memory Map:  ( * not complete * )

     Address Range:     R/W:     Function:
     --------------------------------------------------------------------------
     0000 - 5fff        R        Program ROM
	 a000 - a0ff        W        Sprite RAM
     a800 - a803        W        Lamps / Coin Meters
	 b000 - b1ff        R/W      Collision RAM
     e000 - e7ff        R/W      character RAM
     f000 - f7ff        R/W      RAM
     f202                        coinage 2
     f205                        coinage 1
     f800 - f803        R/W      road drawing
     f900 - f903        R/W      road drawing
     fa00 - fa03        R/W      sound
     fb00 - fb03        R/W      x,DS2,x,x
     fc00 - fc01        R        DS1,x
     fc00 - fc01        W        score
     fd00               R        Coin Inputs, etc.
     fe00               R        DS3,x

 Switch settings:
 Notes:
        1) Facing the CPU board, with the two large IDC connectors at
           the top of the board, and the large and small IDC
           connectors at the bottom, DIP switch #1 is upper right DIP
           switch, DIP switch #2 is the DIP switch to the right of it.

        2) Facing the Sound board, with the IDC connector at the
           bottom of the board, DIP switch #3 (4 bank) can be seen.
 ----------------------------------------------------------------------------

 Option    (DIP Swtich #1) | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | SW7 | SW8 |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 1 Car On Extended Play    | ON  | ON  |     |     |     |     |     |     |
 2 Car On Extended Play    | OFF | ON  |     |     |     |     |     |     |
 3 Car On Extended Play    | ON  | OFF |     |     |     |     |     |     |
 4 Car On Extended Play    | OFF | OFF |     |     |     |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Game Time Adjustable      |     |     | ON  |     |     |     |     |     |
 Game Time Fixed (55 Sec.) |     |     | OFF |     |     |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Hard Game Difficulty      |     |     |     | ON  |     |     |     |     |
 Easy Game Difficulty      |     |     |     | OFF |     |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Normal Game Mode          |     |     |     |     | ON  |     |     |     |
 No Collisions (cheat)     |     |     |     |     | OFF |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Initial Entry Off (?)     |     |     |     |     |     | ON  |     |     |
 Initial Entry On  (?)     |     |     |     |     |     | OFF |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Not Used                  |     |     |     |     |     |     |  X  |  X  |
 ---------------------------------------------------------------------------

 Option    (DIP Swtich #2) | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | SW7 | SW8 |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 60 Seconds Game Time      | ON  | ON  |     |     |     |     |     |     |
 70 Seconds Game Time      | OFF | ON  |     |     |     |     |     |     |
 80 Seconds Game Time      | ON  | OFF |     |     |     |     |     |     |
 90 Seconds Game Time      | OFF | OFF |     |     |     |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Slot 1  1 Coin  1 Credit  |     |     | ON  | ON  | ON  |     |     |     |
 Slot 1  1 Coin  2 Credits |     |     | OFF | ON  | ON  |     |     |     |
 Slot 1  1 Coin  3 Credits |     |     | ON  | OFF | ON  |     |     |     |
 Slot 1  1 Coin  6 Credits |     |     | OFF | OFF | ON  |     |     |     |
 Slot 1  2 Coins 1 Credit  |     |     | ON  | ON  | OFF |     |     |     |
 Slot 1  3 Coins 1 Credit  |     |     | OFF | ON  | OFF |     |     |     |
 Slot 1  4 Coins 1 Credit  |     |     | ON  | OFF | OFF |     |     |     |
 Slot 1  1 Coin  1 Credit  |     |     | OFF | OFF | OFF |     |     |     |
 --------------------------|-----|-----|-----|-----|-----|-----|-----|-----|
 Slot 2  1 Coin  1 Credit  |     |     |     |     |     | ON  | ON  | ON  |
 Slot 2  1 Coin  2 Credits |     |     |     |     |     | OFF | ON  | ON  |
 Slot 2  1 Coin  3 Credits |     |     |     |     |     | ON  | OFF | ON  |
 Slot 2  1 Coin  6 Credits |     |     |     |     |     | OFF | OFF | ON  |
 Slot 2  2 Coins 1 Credit  |     |     |     |     |     | ON  | ON  | OFF |
 Slot 2  3 Coins 1 Credit  |     |     |     |     |     | OFF | ON  | OFF |
 Slot 2  4 Coins 1 Credit  |     |     |     |     |     | ON  | OFF | OFF |
 Slot 2  1 Coins 1 Credit  |     |     |     |     |     | OFF | OFF | OFF |
 ---------------------------------------------------------------------------

 Option    (DIP Swtich #3) | SW1 | SW2 | SW3 | SW4 |
 --------------------------|-----|-----|-----|-----|
 Not Used                  |  X  |  X  |     |     |
 --------------------------|-----|-----|-----|-----|
 Digital (LED) Tachometer  |     |     | ON  |     |
 Analog (Meter) Tachometer |     |     | OFF |     |
 --------------------------|-----|-----|-----|-----|
 Cockpit Sound System      |     |     |     | ON  |
 Upright Sound System      |     |     |     | OFF |
---------------------------------------------------

Here is a complete list of the ROMs:
 Turbo ROMLIST - Frank Palazzolo
 Name    Loc             Function
 -----------------------------------------------------------------------------
 Images Acquired:
 EPR1262,3,4     IC76, IC89, IC103
 EPR1363,4,5
 EPR15xx                 Program ROMS
 EPR1244                 Character Data 1
 EPR1245                 Character Data 2
 EPR-1125                Road ROMS
 EPR-1126
 EPR-1127
 EPR-1238
 EPR-1239
 EPR-1240
 EPR-1241
 EPR-1242
 EPR-1243
 EPR1246-1258            Sprite ROMS
 EPR1288-1300

 PR-1114         IC13    Color 1 (road, etc.)
 PR-1115         IC18    Road gfx
 PR-1116         IC20    Crash (collision detection?)
 PR-1117         IC21    Color 2 (road, etc.)
 PR-1118         IC99    256x4 Character Color PROM
 PR-1119         IC50    512x8 Vertical Timing PROM
 PR-1120         IC62    Horizontal Timing PROM
 PR-1121         IC29    Color PROM
 PR-1122         IC11    Pattern 1
 PR-1123         IC21    Pattern 2

 PA-06R          IC22    Mathbox Timing PAL              (may be needed?)
 PA-06L          IC90    Address Decode PAL


 Issues:

     - it doesn't work!
	 - sprite position and scaling
	 - collision detection
	 - character colors  (mising a PROM I think)
	 - background colors -- this is most likely a bug
	 - speed

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

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

/* ******************************** */
/* Functions in src/vidhrdw/turbo.c */

int turbo_vh_start(void);
void turbo_vh_convert_color_prom(unsigned char *palette,
								 unsigned short *colortable,
								 const unsigned char *color_prom);
void turbo_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);

extern unsigned char 	*turbo_sprites_collisionram;
extern int turbo_sprites_collisionram_size;


/* ******************************** */
/* Functions in src/machine/turbo.c */

void turbo_init_machine(void);
int turbo_interrupt(void);
int turbo_fa00_r(int offset);
int turbo_fb00_r(int offset);
int turbo_fc00_r(int offset);
int turbo_fd00_r(int offset);
int turbo_fe00_r(int offset);
void turbo_b800_w(int offset, int data);
void turbo_f800_w(int offset, int data);
void turbo_f900_w(int offset, int data);
void turbo_fa00_w(int offset, int data);
void turbo_fb00_w(int offset, int data);
void turbo_fc00_w(int offset, int data);


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

static struct Samplesinterface samples_interface =
{
        8       /* eight channels */
};

const char *turbo_sample_names[]=
{
	"*turbo",
	"01.sam", /* Trig1 */
	"02.sam", /* Trig2 */
	"03.sam", /* Trig3 */
	"04.sam", /* Trig4 */
	"10.sam", /* Ambulance */
	0 /*array end*/
};

static struct MemoryReadAddress turbo_readmem[] =
{
	{ 0x0000, 0x5fff, MRA_ROM }, 
	{ 0xb000, 0xb1ff, MRA_RAM }, 
	{ 0xe000, 0xe7ff, videoram_r }, 
	{ 0xf000, 0xf7ff, MRA_RAM }, 
	{ 0xfa00, 0xfa03, turbo_fa00_r }, 
	{ 0xfb00, 0xfbff, turbo_fb00_r },
	{ 0xfc00, 0xfcff, turbo_fc00_r },
	{ 0xfd00, 0xfdff, turbo_fd00_r },
	{ 0xfe00, 0xfeff, turbo_fe00_r },
	{ -1 }	/* end of table */
};

static struct MemoryWriteAddress turbo_writemem[] =
{
	{ 0x0000, 0x5fff, MWA_ROM }, 
	{ 0xa000, 0xa0ff, MWA_RAM, &spriteram, &spriteram_size }, 
	{ 0xa800, 0xa803, MWA_RAM }, 
	{ 0xb000, 0xb1ff, MWA_RAM, &turbo_sprites_collisionram, &turbo_sprites_collisionram_size }, 
	{ 0xb800, 0xb800, turbo_b800_w }, 
	{ 0xe000, 0xe7ff, videoram_w, &videoram, &videoram_size }, 
	{ 0xe800, 0xe800, MWA_NOP }, 
	{ 0xf000, 0xf7ff, MWA_RAM }, 
	{ 0xf800, 0xf803, turbo_f800_w }, 
	{ 0xf900, 0xf903, turbo_f900_w }, 
	{ 0xfa00, 0xfa03, turbo_fa00_w }, 
	{ 0xfb00, 0xfbff, turbo_fb00_w },
	{ 0xfc00, 0xfcff, turbo_fc00_w }, 
	{ -1 }	/* end of table */
};

INPUT_PORTS_START( turbo_input_ports )
	PORT_START      /* IN0 */
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) 
	PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_SERVICE, "Test Mode", OSD_KEY_F2, IP_JOY_NONE, 0)
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_TOGGLE ) 
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) 
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) 

	PORT_START  /* DSW 1 */
	PORT_DIPNAME( 0x03, 0x00, "Car On Extended Play", IP_KEY_NONE)
	PORT_DIPSETTING(    0x00, "1")
	PORT_DIPSETTING(    0x01, "2")
	PORT_DIPSETTING(    0x02, "3")
	PORT_DIPSETTING(    0x03, "4")
	PORT_DIPNAME( 0x04, 0x00, "Game Time", IP_KEY_NONE)
	PORT_DIPSETTING(    0x04, "Fixed (55 sec)")
	PORT_DIPSETTING(    0x00, "Adjustable")
	PORT_DIPNAME( 0x08, 0x00, "Difficulty", IP_KEY_NONE)
	PORT_DIPSETTING(    0x08, "Easy")
	PORT_DIPSETTING(    0x00, "Hard")
	PORT_DIPNAME( 0x10, 0x00, "Game Mode", IP_KEY_NONE)
	PORT_DIPSETTING(    0x10, "No Collisions (cheat)")
	PORT_DIPSETTING(    0x00, "Normal")
	PORT_DIPNAME( 0x20, 0x20, "Initial Entry", IP_KEY_NONE)
	PORT_DIPSETTING(    0x20, "On")
	PORT_DIPSETTING(    0x00, "Off")
	PORT_DIPNAME( 0x40, 0x40, "Unknown", IP_KEY_NONE) 
	PORT_DIPSETTING(    0x40, "Off")
	PORT_DIPSETTING(    0x00, "On")
	PORT_DIPNAME( 0x80, 0x80, "Unknown", IP_KEY_NONE) 
	PORT_DIPSETTING(    0x80, "Off")
	PORT_DIPSETTING(    0x00, "On")

	PORT_START  /* DSW 2 */
	PORT_DIPNAME( 0x03, 0x03, "Game Time", IP_KEY_NONE)
	PORT_DIPSETTING(    0x01, "70 seconds")
	PORT_DIPSETTING(    0x00, "60 seconds")
	PORT_DIPSETTING(    0x02, "80 seconds")
	PORT_DIPSETTING(    0x03, "90 seconds")
	PORT_DIPNAME( 0xe0, 0xe0, "Coinage 1", IP_KEY_NONE)
	PORT_DIPSETTING(    0x00, "1 coin/1 credits")
	PORT_DIPSETTING(    0x20, "1 coin/2 credits")
	PORT_DIPSETTING(    0x40, "1 coin/3 credits")
	PORT_DIPSETTING(    0x60, "1 coin/6 credits")
	PORT_DIPSETTING(    0x80, "2 coin/1 credits")
	PORT_DIPSETTING(    0xa0, "3 coin/1 credits")
	PORT_DIPSETTING(    0xc0, "4 coin/1 credits")
	PORT_DIPSETTING(    0xe0, "1 coin/1 credits")
	PORT_DIPNAME( 0x1c, 0x1c, "Coinage 2", IP_KEY_NONE)
	PORT_DIPSETTING(    0x00, "1 coin/1 credits")
	PORT_DIPSETTING(    0x04, "1 coin/2 credits")
	PORT_DIPSETTING(    0x08, "1 coin/3 credits")
	PORT_DIPSETTING(    0x0c, "1 coin/6 credits")
	PORT_DIPSETTING(    0x10, "2 coin/1 credits")
	PORT_DIPSETTING(    0x14, "3 coin/1 credits")
	PORT_DIPSETTING(    0x18, "4 coin/1 credits")
	PORT_DIPSETTING(    0x1c, "1 coin/1 credits")

	PORT_START  /* DSW 3 */
	PORT_DIPNAME( 0x10, 0x10, "Unknown", IP_KEY_NONE) 
	PORT_DIPSETTING(    0x10, "Off")
	PORT_DIPSETTING(    0x00, "On")
	PORT_DIPNAME( 0x20, 0x20, "Unknown", IP_KEY_NONE) 
	PORT_DIPSETTING(    0x20, "Off")
	PORT_DIPSETTING(    0x00, "On")
	PORT_DIPNAME( 0x40, 0x40, "Tachometer", IP_KEY_NONE)
	PORT_DIPSETTING(    0x40, "Analog (Meter)")
	PORT_DIPSETTING(    0x00, "Digital (led)")
	PORT_DIPNAME( 0x80, 0x80, "Sound System", IP_KEY_NONE)
	PORT_DIPSETTING(    0x80, "upright")
	PORT_DIPSETTING(    0x00, "cockpit")
	PORT_DIPNAME( 0x0f, 0x00, "Unused", IP_KEY_NONE)
	PORT_DIPSETTING(    0x00, "Unused")

	PORT_START      /* IN0 */
	PORT_ANALOGX( 0xff, 0, IPT_DIAL | IPF_CENTER, 1, 0, 0, 0,
				OSD_KEY_LEFT, OSD_KEY_RIGHT, OSD_JOY_LEFT, OSD_JOY_RIGHT, 16)

INPUT_PORTS_END


static struct GfxLayout turbo_charlayout =
{
	8,8,	/* 8*8 sprites */
	256,	/* 256 characters */
	2,	/* 2 bits per pixel */

	{ 256*8*8, 0 },	/* bitplane offsets */
	{ 0, 1, 2, 3, 4, 5, 6, 7},		/* x bit */
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8	/* every chares 8 consecutive bytes */
};

static struct GfxLayout turbo_numlayout =
{
	10,8,	/* 8*8 sprites */
	16,	/* 16 characters */
	1,	/* 1 bit per pixel */

	{ 0 },	/* bitplane offsets */
	{ 9*8, 8*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},		/* x bit */
	10*8	/* every chares 10 consecutive bytes */
};


static struct GfxDecodeInfo turbo_gfxdecodeinfo[] =
{
	{ 1, 0x0000, &turbo_charlayout,     0, 256 },
	{ 1, 0x0000, &turbo_numlayout,  4*256,   1 }, /* replaced in vh_start */
	{ -1 } /* end of array */
};


static struct MachineDriver turbo_machine_driver =
{
	/* basic machine hardware */
	{
		{
			CPU_Z80,
			5000000,
			0,
			turbo_readmem,turbo_writemem,0,0,
			turbo_interrupt,1
		}
	},
	30, DEFAULT_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
	1,	/* single CPU, no need for interleaving */
	turbo_init_machine,

	/* video hardware */
  	32*8, 36*8, { 0*8, 32*8-1, 0*8, 36*8-1 },
	turbo_gfxdecodeinfo,
	512+2,4*256+2,
	turbo_vh_convert_color_prom,

⌨️ 快捷键说明

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