📄 rastan.c
字号:
/***************************************************************************
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
unsigned char *rastan_ram;
extern unsigned char *rastan_videoram1,*rastan_videoram3;
extern int rastan_videoram_size;
extern unsigned char *rastan_spriteram;
extern unsigned char *rastan_scrollx;
extern unsigned char *rastan_scrolly;
void rastan_spriteram_w(int offset,int data);
int rastan_spriteram_r(int offset);
void rastan_videoram1_w(int offset,int data);
int rastan_videoram1_r(int offset);
void rastan_videoram3_w(int offset,int data);
int rastan_videoram3_r(int offset);
void rastan_scrollY_w(int offset,int data);
void rastan_scrollX_w(int offset,int data);
void rastan_videocontrol_w(int offset,int data);
int rastan_interrupt(void);
int rastan_s_interrupt(void);
void rastan_background_w(int offset,int data);
void rastan_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
int rastan_vh_start(void);
void rastan_vh_stop(void);
void rastan_sound_w(int offset,int data);
int rastan_sound_r(int offset);
int r_rd_a001(int offset);
void r_wr_a000(int offset,int data);
void r_wr_a001(int offset,int data);
void r_wr_c000(int offset,int data);
void r_wr_d000(int offset,int data);
void rastan_irq_handler(void);
int rastan_interrupt(void)
{
return 5; /*Interrupt vector 5*/
}
int rastan_input_r (int offset)
{
switch (offset)
{
case 0:
return input_port_0_r (offset);
case 2:
return input_port_1_r (offset);
case 6:
return input_port_2_r (offset);
case 8:
return input_port_3_r (offset);
case 10:
return input_port_4_r (offset);
default:
return 0;
}
}
static int rastan_cycle_r(int offset)
{
if (cpu_getpc()==0x3b088) cpu_spinuntil_int();
return READ_WORD(&rastan_ram[0x1c10]);
}
static int rastan_sound_spin(int offset)
{
if ( (cpu_getpc()==0x1c5) && !(Machine->memory_region[2][ 0x8f27 ] & 0x01) )
cpu_spin();
return Machine->memory_region[2][ 0x8f27 ];
}
static struct MemoryReadAddress rastan_readmem[] =
{
{ 0x000000, 0x05ffff, MRA_ROM },
{ 0x10dc10, 0x10dc11, rastan_cycle_r },
{ 0x10c000, 0x10ffff, MRA_BANK1 }, /* RAM */
{ 0x200000, 0x20ffff, paletteram_word_r },
{ 0x3e0000, 0x3e0003, rastan_sound_r },
{ 0x390000, 0x39000f, rastan_input_r },
{ 0xc00000, 0xc03fff, rastan_videoram1_r },
{ 0xc04000, 0xc07fff, MRA_BANK2 },
{ 0xc08000, 0xc0bfff, rastan_videoram3_r },
{ 0xc0c000, 0xc0ffff, MRA_BANK3 },
{ 0xd00000, 0xd0ffff, MRA_BANK4 },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress rastan_writemem[] =
{
{ 0x000000, 0x05ffff, MWA_ROM },
{ 0x10c000, 0x10ffff, MWA_BANK1, &rastan_ram },
{ 0x200000, 0x20ffff, paletteram_xBBBBBGGGGGRRRRR_word_w, &paletteram },
{ 0x350008, 0x35000b, MWA_NOP }, /* 0 only (often) ? */
{ 0x380000, 0x380003, rastan_videocontrol_w }, /* sprite palette bank, coin counters, other unknowns */
{ 0x3c0000, 0x3c0003, MWA_NOP }, /*0000,0020,0063,0992,1753 (very often) watchdog? */
{ 0x3e0000, 0x3e0003, rastan_sound_w },
{ 0xc00000, 0xc03fff, rastan_videoram1_w, &rastan_videoram1, &rastan_videoram_size },
{ 0xc04000, 0xc07fff, MWA_BANK2 },
{ 0xc08000, 0xc0bfff, rastan_videoram3_w, &rastan_videoram3 },
{ 0xc0c000, 0xc0ffff, MWA_BANK3 },
{ 0xc20000, 0xc20003, rastan_scrollY_w, &rastan_scrolly }, /* scroll Y 1st.w plane1 2nd.w plane2 */
{ 0xc40000, 0xc40003, rastan_scrollX_w, &rastan_scrollx }, /* scroll X 1st.w plane1 2nd.w plane2 */
{ 0xd00000, 0xd0ffff, MWA_BANK4, &rastan_spriteram },
{ -1 } /* end of table */
};
static void rastan_bankswitch_w(int offset, int data)
{
int bankaddress;
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bankaddress = 0x10000 + ((data^1) & 0x01) * 0x4000;
cpu_setbank(5,&RAM[bankaddress]);
}
static struct MemoryReadAddress rastan_s_readmem[] =
{
{ 0x0000, 0x3fff, MRA_ROM },
{ 0x4000, 0x7fff, MRA_BANK5 },
{ 0x8f27, 0x8f27, rastan_sound_spin },
{ 0x8000, 0x8fff, MRA_RAM },
{ 0x9001, 0x9001, YM2151_status_port_0_r },
{ 0x9002, 0x9100, MRA_RAM },
{ 0xa001, 0xa001, r_rd_a001 },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress rastan_s_writemem[] =
{
{ 0x0000, 0x7fff, MWA_ROM },
{ 0x8000, 0x8fff, MWA_RAM },
{ 0x9000, 0x9000, YM2151_register_port_0_w },
{ 0x9001, 0x9001, YM2151_data_port_0_w },
{ 0xa000, 0xa000, r_wr_a000 },
{ 0xa001, 0xa001, r_wr_a001 },
{ 0xb000, 0xb000, ADPCM_trigger },
{ 0xc000, 0xc000, r_wr_c000 },
{ 0xd000, 0xd000, r_wr_d000 },
{ -1 } /* end of table */
};
INPUT_PORTS_START( rastan_input_ports )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | 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 /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x01, 0x00, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x01, "Cocktail" )
PORT_DIPNAME( 0x02, 0x02, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_BITX( 0x04, 0x04, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x04, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x08, 0x08, "Unknown 1", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x30, 0x30, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0x10, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x30, "1 Coin/1 Credit" )
PORT_DIPNAME( 0xc0, 0xc0, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0xc0, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x80, "1 Coin/3 Credits" )
PORT_DIPSETTING( 0x40, "1 Coin/4 Credits" )
PORT_DIPSETTING( 0x00, "1 Coin/6 Credits" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x03, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "Easy" )
PORT_DIPSETTING( 0x03, "Medium" )
PORT_DIPSETTING( 0x01, "Hard" )
PORT_DIPSETTING( 0x00, "Hardest" )
PORT_DIPNAME( 0x0c, 0x0c, "Bonus Life", IP_KEY_NONE )
PORT_DIPSETTING( 0x0c, "100000" )
PORT_DIPSETTING( 0x08, "150000" )
PORT_DIPSETTING( 0x04, "200000" )
PORT_DIPSETTING( 0x00, "250000" )
PORT_DIPNAME( 0x30, 0x30, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x30, "3" )
PORT_DIPSETTING( 0x20, "4" )
PORT_DIPSETTING( 0x10, "5" )
PORT_DIPSETTING( 0x00, "6" )
PORT_DIPNAME( 0x40, 0x40, "Allow Continue", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "No" )
PORT_DIPSETTING( 0x40, "Yes" )
PORT_DIPNAME( 0x80, 0x80, "Unknown 2", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
INPUT_PORTS_END
/* same as rastan, coinage is different */
INPUT_PORTS_START( rastsaga_input_ports )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | 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 /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x01, 0x00, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x01, "Cocktail" )
PORT_DIPNAME( 0x02, 0x02, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_BITX( 0x04, 0x04, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x04, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x08, 0x08, "Unknown 1", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x30, 0x30, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x10, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x30, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x00, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x20, "1 Coin/2 Credits" )
PORT_DIPNAME( 0xc0, 0xc0, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0x40, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0xc0, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x00, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x80, "1 Coin/2 Credits" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x03, "Difficulty", IP_KEY_NONE )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -