📄 ironhors.c
字号:
/***************************************************************************
IronHorse memory map (preliminary)
0000-00ff Work area
2000-23ff ColorRAM
2400-27ff VideoRAM
2800-2fff RAM
3000-30ff First sprite bank?
3800-38ff Second sprite bank?
3f00-3fff Stack AREA
4000-ffff ROM
Read:
0b01: Player 2 controls
0b02: Player 1 controls
0b03: Coin + selftest
0a00: DSW1
0b00: DSW2
0900: DSW3
Write:
0003: Bit 1 selects the 1024 char bank, bit 3 the sprite RAM bank, other bits unknown
0004: Bit 0 controls NMI, bit 3 controls FIRQ, other bits unknown
0020-003f: Scroll registers
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
#include "M6809/M6809.h"
extern unsigned char *ironhors_scroll;
static unsigned char *ironhors_interrupt_enable;
void ironhors_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
void ironhors_palettebank_w(int offset,int data);
void ironhors_charbank_w(int offset,int data);
void ironhors_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void ironhors_init_machine(void)
{
/* Set optimization flags for M6809 */
m6809_Flags = M6809_FAST_S | M6809_FAST_U;
}
int ironhors_interrupt(void)
{
if (cpu_getiloops() == 0)
{
if (*ironhors_interrupt_enable & 4) return M6809_INT_FIRQ;
}
else if (cpu_getiloops() % 2)
{
if (*ironhors_interrupt_enable & 1) return nmi_interrupt();
}
return ignore_interrupt();
}
int ironhors_sh_timer_r(int offset)
{
int clock;
#define TIMER_RATE 128
clock = cpu_gettotalcycles() / TIMER_RATE;
return clock;
}
void ironhors_sh_irqtrigger_w(int offset,int data)
{
cpu_cause_interrupt(1,0xff);
}
static struct MemoryReadAddress ironhors_readmem[] =
{
{ 0x0020, 0x003f, MRA_RAM },
{ 0x0b03, 0x0b03, input_port_0_r }, /* coins + selftest */
{ 0x0b02, 0x0b02, input_port_1_r }, /* player 1 controls */
{ 0x0b01, 0x0b01, input_port_2_r }, /* player 2 controls */
{ 0x0a00, 0x0a00, input_port_3_r }, /* Dipswitch settings 0 */
{ 0x0b00, 0x0b00, input_port_4_r }, /* Dipswitch settings 1 */
{ 0x0900, 0x0900, input_port_5_r }, /* Dipswitch settings 2 */
{ 0x2000, 0x2fff, MRA_RAM },
{ 0x3000, 0x3fff, MRA_RAM },
{ 0x4000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress ironhors_writemem[] =
{
{ 0x0003, 0x0003, ironhors_charbank_w },
{ 0x0004, 0x0004, MWA_RAM, &ironhors_interrupt_enable },
{ 0x0020, 0x003f, MWA_RAM, &ironhors_scroll },
{ 0x0800, 0x0800, soundlatch_w },
{ 0x0900, 0x0900, ironhors_sh_irqtrigger_w }, /* cause interrupt on audio CPU */
{ 0x0a00, 0x0a00, ironhors_palettebank_w },
{ 0x0b00, 0x0b00, watchdog_reset_w },
{ 0x2000, 0x23ff, colorram_w, &colorram },
{ 0x2400, 0x27ff, videoram_w, &videoram, &videoram_size },
{ 0x2800, 0x2fff, MWA_RAM },
{ 0x3000, 0x30ff, MWA_RAM, &spriteram_2 },
{ 0x3100, 0x37ff, MWA_RAM },
{ 0x3800, 0x38ff, MWA_RAM, &spriteram, &spriteram_size },
{ 0x3900, 0x3fff, MWA_RAM },
{ 0x4000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress ironhors_sound_readmem[] =
{
{ 0x0000, 0x3fff, MRA_ROM },
{ 0x4000, 0x43ff, MRA_RAM },
{ 0x8000, 0x8000, soundlatch_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress ironhors_sound_writemem[] =
{
{ 0x0000, 0x3fff, MWA_ROM },
{ 0x4000, 0x43ff, MWA_RAM },
{ -1 } /* end of table */
};
static struct IOReadPort ironhors_sound_readport[] =
{
{ 0x00, 0x00, ironhors_sh_timer_r },
{ -1 } /* end of table */
};
static struct IOWritePort ironhors_sound_writeport[] =
{
{ 0x00, 0x00, YM2203_control_port_0_w },
{ 0x01, 0x01, YM2203_write_port_0_w },
{ -1 } /* end of table */
};
static struct MemoryReadAddress farwest_sound_readmem[] =
{
{ 0x0000, 0x3fff, MRA_ROM },
{ 0x4000, 0x43ff, MRA_RAM },
{ 0x8000, 0x8000, soundlatch_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress farwest_sound_writemem[] =
{
{ 0x0000, 0x3fff, MWA_ROM },
{ 0x4000, 0x43ff, MWA_RAM },
{ 0x8000, 0x8000, YM2203_control_port_0_w },
{ 0x8001, 0x8001, YM2203_write_port_0_w },
{ -1 } /* end of table */
};
INPUT_PORTS_START( ironhors_input_ports )
PORT_START /* IN0 */
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_START1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN1 */
/* note that button 3 for player 1 and 2 are exchanged */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_COCKTAIL )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x03, 0x02, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x03, "2" )
PORT_DIPSETTING( 0x02, "3" )
PORT_DIPSETTING( 0x01, "5" )
PORT_DIPSETTING( 0x00, "7" )
PORT_DIPNAME( 0x04, 0x00, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x04, "Cocktail" )
PORT_DIPNAME( 0x18, 0x18, "Bonus Life", IP_KEY_NONE )
PORT_DIPSETTING( 0x18, "30000 70000" )
PORT_DIPSETTING( 0x10, "40000 80000" )
PORT_DIPSETTING( 0x08, "40000" )
PORT_DIPSETTING( 0x00, "50000" )
PORT_DIPNAME( 0x60, 0x60, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x60, "Easy" )
PORT_DIPSETTING( 0x40, "Normal" )
PORT_DIPSETTING( 0x20, "Hard" )
PORT_DIPSETTING( 0x00, "Hardest" )
PORT_DIPNAME( 0x80, 0x80, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x0f, 0x0f, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0x05, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x08, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x04, "3 Coins/2 Credits" )
PORT_DIPSETTING( 0x01, "4 Coins/3 Credits" )
PORT_DIPSETTING( 0x0f, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x03, "3 Coins/4 Credits" )
PORT_DIPSETTING( 0x07, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x0e, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x06, "2 Coins/5 Credits" )
PORT_DIPSETTING( 0x0d, "1 Coin/3 Credits" )
PORT_DIPSETTING( 0x0c, "1 Coin/4 Credits" )
PORT_DIPSETTING( 0x0b, "1 Coin/5 Credits" )
PORT_DIPSETTING( 0x0a, "1 Coin/6 Credits" )
PORT_DIPSETTING( 0x09, "1 Coin/7 Credits" )
PORT_DIPSETTING( 0x00, "Free Play" )
PORT_DIPNAME( 0xf0, 0xf0, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0x50, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x80, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x40, "3 Coins/2 Credits" )
PORT_DIPSETTING( 0x10, "4 Coins/3 Credits" )
PORT_DIPSETTING( 0xf0, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x30, "3 Coins/4 Credits" )
PORT_DIPSETTING( 0x70, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0xe0, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x60, "2 Coins/5 Credits" )
PORT_DIPSETTING( 0xd0, "1 Coin/3 Credits" )
PORT_DIPSETTING( 0xc0, "1 Coin/4 Credits" )
PORT_DIPSETTING( 0xb0, "1 Coin/5 Credits" )
PORT_DIPSETTING( 0xa0, "1 Coin/6 Credits" )
PORT_DIPSETTING( 0x90, "1 Coin/7 Credits" )
/* PORT_DIPSETTING( 0x00, "Invalid" ) */
PORT_START
PORT_DIPNAME( 0x01, 0x00, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x01, "On" )
PORT_DIPNAME( 0x02, 0x02, "Controls", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "Single" )
PORT_DIPSETTING( 0x00, "Dual" )
PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNKNOWN )
INPUT_PORTS_END
static struct GfxLayout ironhors_charlayout =
{
8,8, /* 8*8 characters */
2048, /* 2048 characters */
4, /* 4 bits per pixel */
{ 0, 1, 2, 3 }, /* the four bitplanes are packed in one nibble */
{ 0*4, 1*4, 0x8000*8+0*4, 0x8000*8+1*4, 2*4, 3*4, 0x8000*8+2*4, 0x8000*8+3*4 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
16*8 /* every char takes 16 consecutive bytes */
};
static struct GfxLayout ironhors_spritelayout =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -