📄 vigilant.c
字号:
/***************************************************************************
Vigilante
If you have any questions about how this driver works, don't hesitate to
ask. - Mike Balfour (mab22@po.cwru.edu)
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
/* vidhrdw/vigilant.c */
extern int vigilant_vh_start(void);
extern void vigilant_vh_stop(void);
extern void vigilant_vh_convert_color_prom (unsigned char *palette, unsigned char *colortable, const unsigned char *color_prom);
extern void vigilant_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
extern void vigilant_paletteram_w(int offset, int data);
extern void vigilant_sprite_paletteram_w(int offset, int data);
extern void vigilant_horiz_scroll_w(int offset, int data);
extern void vigilant_rear_horiz_scroll_w(int offset, int data);
extern void vigilant_rear_color_w(int offset, int data);
void vigilant_bank_select_w (int offset,int data)
{
int bankaddress;
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
bankaddress = 0x10000 + (data & 0x07) * 0x4000;
cpu_setbank(1,&RAM[bankaddress]);
}
/***************************************************************************
vigilant_out2_w
**************************************************************************/
void vigilant_out2_w(int offset,int data)
{
/* D0 = FILP = Flip screen? */
/* D1 = COA1 = Coin Counter A? */
/* D2 = COB1 = Coin Counter B? */
}
static int sample_rom_offset;
void vigilant_sample_offset_low_w(int offset,int data)
{
sample_rom_offset = (sample_rom_offset & 0xFF00) | (data & 0x00FF);
}
void vigilant_sample_offset_high_w(int offset,int data)
{
sample_rom_offset = (sample_rom_offset & 0x00FF) | ((data & 0x00FF) << 8);
}
int vigilant_sample_rom_r(int offset)
{
unsigned char *dac_ROM = Machine->memory_region[3];
return dac_ROM[sample_rom_offset];
}
void vigilant_count_up_w(int offset,int data)
{
unsigned char *dac_ROM = Machine->memory_region[3];
sample_rom_offset++;
DAC_data_w(0,dac_ROM[sample_rom_offset]);
}
void vigilant_soundcmd_w(int offset,int data)
{
soundlatch_w(offset,data);
cpu_cause_interrupt(1,0x00df); /* RST 18h (could be RST 08h instead) */
}
static struct MemoryReadAddress readmem[] =
{
{ 0x0000, 0x7fff, MRA_ROM },
{ 0x8000, 0xbfff, MRA_BANK1 },
{ 0xc020, 0xc0df, MRA_RAM },
{ 0xc800, 0xcbff, MRA_RAM },
{ 0xcc00, 0xcfff, MRA_RAM },
{ 0xd000, 0xdfff, videoram_r },
{ 0xe000, 0xefff, MRA_RAM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress writemem[] =
{
{ 0x0000, 0xbfff, MWA_ROM },
{ 0xc020, 0xc0df, MWA_RAM, &spriteram, &spriteram_size },
{ 0xc800, 0xcfff, vigilant_paletteram_w, &paletteram },
{ 0xd000, 0xdfff, videoram_w, &videoram, &videoram_size },
{ 0xe000, 0xefff, MWA_RAM },
{ -1 } /* end of table */
};
static struct IOReadPort readport[] =
{
{ 0x00, 0x00, input_port_0_r },
{ 0x01, 0x01, input_port_1_r },
{ 0x02, 0x02, input_port_2_r },
{ 0x03, 0x03, input_port_3_r },
{ 0x04, 0x04, input_port_4_r },
{ -1 } /* end of table */
};
static struct IOWritePort writeport[] =
{
{ 0x00, 0x00, vigilant_soundcmd_w }, /* SD */
{ 0x01, 0x01, vigilant_out2_w }, /* OUT2 */
{ 0x04, 0x04, vigilant_bank_select_w }, /* PBANK */
{ 0x80, 0x81, vigilant_horiz_scroll_w }, /* HSPL, HSPH */
{ 0x82, 0x83, vigilant_rear_horiz_scroll_w }, /* RHSPL, RHSPH */
{ 0x84, 0x84, vigilant_rear_color_w }, /* RCOD */
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0xbfff, MRA_ROM },
{ 0xf000, 0xffff, MRA_RAM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0xbfff, MWA_ROM },
{ 0xf000, 0xffff, MWA_RAM },
{ -1 } /* end of table */
};
static struct IOReadPort sound_readport[] =
{
{ 0x01, 0x01, YM2151_status_port_0_r },
{ 0x80, 0x80, soundlatch_r }, /* SDRE */
{ 0x84, 0x84, vigilant_sample_rom_r }, /* S ROM C */
{ -1 } /* end of table */
};
static struct IOWritePort sound_writeport[] =
{
{ 0x00, 0x00, YM2151_register_port_0_w },
{ 0x01, 0x01, YM2151_data_port_0_w },
{ 0x80, 0x80, vigilant_sample_offset_low_w }, /* STL */
{ 0x81, 0x81, vigilant_sample_offset_high_w }, /* STH */
{ 0x82, 0x82, vigilant_count_up_w }, /* COUNT UP */
/* { 0x83, 0x83, interrupt acknowledge? */
{ -1 } /* end of table */
};
INPUT_PORTS_START( vigilant_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_COIN3 )
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT(0xF0, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START
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_UNKNOWN )
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_START
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_COIN2 )
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_START
PORT_DIPNAME( 0x03, 0x03, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "2" )
PORT_DIPSETTING( 0x03, "3" )
PORT_DIPSETTING( 0x01, "4" )
PORT_DIPSETTING( 0x00, "5" )
PORT_DIPNAME( 0x04, 0x04, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x04, "Normal" )
PORT_DIPSETTING( 0x00, "Hard" )
PORT_DIPNAME( 0x08, 0x08, "Decrease of Energy", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "Slow" )
PORT_DIPSETTING( 0x00, "Fast" )
/* TODO: support the different settings which happen in Coin Mode 2 */
PORT_DIPNAME( 0xF0, 0xF0, "Coinage", IP_KEY_NONE )
PORT_DIPSETTING( 0xA0, "6 Coins/1 Credit" )
PORT_DIPSETTING( 0xB0, "5 Coins/1 Credit" )
PORT_DIPSETTING( 0xC0, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0xD0, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x10, "8 Coins/3 Credits" )
PORT_DIPSETTING( 0xE0, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x20, "5 Coins/3 Credits" )
PORT_DIPSETTING( 0x30, "3 Coins/2 Credits" )
PORT_DIPSETTING( 0xF0, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x40, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x90, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x80, "1 Coin/3 Credits" )
PORT_DIPSETTING( 0x70, "1 Coin/4 Credits" )
PORT_DIPSETTING( 0x60, "1 Coin/5 Credits" )
PORT_DIPSETTING( 0x50, "1 Coin/6 Credits" )
PORT_DIPSETTING( 0x00, "Free Play" )
PORT_START
PORT_DIPNAME( 0x01, 0x01, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x01, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x02, 0x00, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x02, "Cocktail" )
/* This activates a different coin mode. Look at the dip switch setting schematic */
PORT_DIPNAME( 0x04, 0x04, "Coin Mode", IP_KEY_NONE )
PORT_DIPSETTING( 0x04, "Mode 1" )
PORT_DIPSETTING( 0x00, "Mode 2" )
PORT_DIPNAME( 0x08, 0x08, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x08, "On" )
PORT_DIPNAME( 0x10, 0x10, "Allow Continue", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "No" )
PORT_DIPSETTING( 0x10, "Yes" )
/* In stop mode, press 2 to stop and 1 to restart */
PORT_BITX ( 0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Stop Mode", IP_KEY_NONE, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x20, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_BITX( 0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x40, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x80, 0x80, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
INPUT_PORTS_END
static struct GfxLayout text_layout =
{
8,8, /* tile size */
4096, /* number of tiles */
4, /* bits per pixel */
{0,4,64*1024*8,64*1024*8+4}, /* plane offsets */
{ 0,1,2,3, 64+0,64+1,64+2,64+3 }, /* x offsets */
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, /* y offsets */
128
};
static struct GfxLayout sprite_layout =
{
16,16, /* tile size */
4096, /* number of sprites ($1000) */
4, /* bits per pixel */
{0,4,0x40000*8,0x40000*8+4}, /* plane offsets */
{ /* x offsets */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -