Added driver data struct to ironhors.c

This commit is contained in:
Fabio Priuli 2009-12-09 00:46:57 +00:00
parent 0c3290533f
commit 970edeb987
4 changed files with 206 additions and 104 deletions

1
.gitattributes vendored
View File

@ -2507,6 +2507,7 @@ src/mame/includes/iqblock.h svneol=native#text/plain
src/mame/includes/iremipt.h svneol=native#text/plain src/mame/includes/iremipt.h svneol=native#text/plain
src/mame/includes/iremz80.h svneol=native#text/plain src/mame/includes/iremz80.h svneol=native#text/plain
src/mame/includes/irobot.h svneol=native#text/plain src/mame/includes/irobot.h svneol=native#text/plain
src/mame/includes/ironhors.h svneol=native#text/plain
src/mame/includes/itech32.h svneol=native#text/plain src/mame/includes/itech32.h svneol=native#text/plain
src/mame/includes/itech8.h svneol=native#text/plain src/mame/includes/itech8.h svneol=native#text/plain
src/mame/includes/jackal.h svneol=native#text/plain src/mame/includes/jackal.h svneol=native#text/plain

View File

@ -1,8 +1,8 @@
/*************************************************************************** /***************************************************************************
IronHorse IronHorse
driver by Mirko Buffoni driver by Mirko Buffoni
***************************************************************************/ ***************************************************************************/
@ -12,41 +12,36 @@ driver by Mirko Buffoni
#include "cpu/m6809/m6809.h" #include "cpu/m6809/m6809.h"
#include "sound/2203intf.h" #include "sound/2203intf.h"
#include "sound/discrete.h" #include "sound/discrete.h"
#include "konamipt.h" #include "includes/konamipt.h"
#include "includes/ironhors.h"
extern UINT8 *ironhors_scroll;
static UINT8 *ironhors_interrupt_enable;
extern WRITE8_HANDLER( ironhors_videoram_w );
extern WRITE8_HANDLER( ironhors_colorram_w );
extern WRITE8_HANDLER( ironhors_palettebank_w );
extern WRITE8_HANDLER( ironhors_charbank_w );
extern WRITE8_HANDLER( ironhors_flipscreen_w );
extern PALETTE_INIT( ironhors );
extern VIDEO_START( ironhors );
extern VIDEO_UPDATE( ironhors );
extern VIDEO_START( farwest );
extern VIDEO_UPDATE( farwest );
/*************************************
*
* Memory handlers
*
*************************************/
static INTERRUPT_GEN( ironhors_interrupt ) static INTERRUPT_GEN( ironhors_interrupt )
{ {
ironhors_state *state = (ironhors_state *)device->machine->driver_data;
if (cpu_getiloops(device) == 0) if (cpu_getiloops(device) == 0)
{ {
if (*ironhors_interrupt_enable & 4) if (*state->interrupt_enable & 4)
cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE); cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE);
} }
else if (cpu_getiloops(device) % 2) else if (cpu_getiloops(device) % 2)
{ {
if (*ironhors_interrupt_enable & 1) if (*state->interrupt_enable & 1)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
} }
} }
static WRITE8_HANDLER( ironhors_sh_irqtrigger_w ) static WRITE8_HANDLER( ironhors_sh_irqtrigger_w )
{ {
cputag_set_input_line_and_vector(space->machine, "soundcpu", 0, HOLD_LINE, 0xff); ironhors_state *state = (ironhors_state *)space->machine->driver_data;
cpu_set_input_line_and_vector(state->soundcpu, 0, HOLD_LINE, 0xff);
} }
static WRITE8_DEVICE_HANDLER( ironhors_filter_w ) static WRITE8_DEVICE_HANDLER( ironhors_filter_w )
@ -56,12 +51,18 @@ static WRITE8_DEVICE_HANDLER( ironhors_filter_w )
discrete_sound_w(device, NODE_13, (data & 0x01) >> 0); discrete_sound_w(device, NODE_13, (data & 0x01) >> 0);
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0002) AM_RAM AM_RANGE(0x0000, 0x0002) AM_RAM
AM_RANGE(0x0003, 0x0003) AM_RAM_WRITE(ironhors_charbank_w) AM_RANGE(0x0003, 0x0003) AM_RAM_WRITE(ironhors_charbank_w)
AM_RANGE(0x0004, 0x0004) AM_RAM AM_BASE(&ironhors_interrupt_enable) AM_RANGE(0x0004, 0x0004) AM_RAM AM_BASE_MEMBER(ironhors_state, interrupt_enable)
AM_RANGE(0x0005, 0x001f) AM_RAM AM_RANGE(0x0005, 0x001f) AM_RAM
AM_RANGE(0x0020, 0x003f) AM_RAM AM_BASE(&ironhors_scroll) AM_RANGE(0x0020, 0x003f) AM_RAM AM_BASE_MEMBER(ironhors_state, scroll)
AM_RANGE(0x0040, 0x005f) AM_RAM AM_RANGE(0x0040, 0x005f) AM_RAM
AM_RANGE(0x0060, 0x00df) AM_RAM AM_RANGE(0x0060, 0x00df) AM_RAM
AM_RANGE(0x0800, 0x0800) AM_WRITE(soundlatch_w) AM_RANGE(0x0800, 0x0800) AM_WRITE(soundlatch_w)
@ -74,12 +75,12 @@ static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1800, 0x1800) AM_WRITENOP // ??? AM_RANGE(0x1800, 0x1800) AM_WRITENOP // ???
AM_RANGE(0x1a00, 0x1a01) AM_WRITENOP // ??? AM_RANGE(0x1a00, 0x1a01) AM_WRITENOP // ???
AM_RANGE(0x1c00, 0x1dff) AM_WRITENOP // ??? AM_RANGE(0x1c00, 0x1dff) AM_WRITENOP // ???
AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(ironhors_colorram_w) AM_BASE_GENERIC(colorram) AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(ironhors_colorram_w) AM_BASE_MEMBER(ironhors_state, colorram)
AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(ironhors_videoram_w) AM_BASE_GENERIC(videoram) AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(ironhors_videoram_w) AM_BASE_MEMBER(ironhors_state, videoram)
AM_RANGE(0x2800, 0x2fff) AM_RAM AM_RANGE(0x2800, 0x2fff) AM_RAM
AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE_GENERIC(spriteram2) AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE_MEMBER(ironhors_state, spriteram2)
AM_RANGE(0x3100, 0x37ff) AM_RAM AM_RANGE(0x3100, 0x37ff) AM_RAM
AM_RANGE(0x3800, 0x38ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x3800, 0x38ff) AM_RAM AM_BASE_SIZE_MEMBER(ironhors_state, spriteram, spriteram_size)
AM_RANGE(0x3900, 0x3fff) AM_RAM AM_RANGE(0x3900, 0x3fff) AM_RAM
AM_RANGE(0x4000, 0xffff) AM_ROM AM_RANGE(0x4000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -100,7 +101,7 @@ static ADDRESS_MAP_START( farwest_master_map, ADDRESS_SPACE_PROGRAM, 8 )
//20=31db //20=31db
AM_RANGE(0x0005, 0x001f) AM_RAM AM_RANGE(0x0005, 0x001f) AM_RAM
AM_RANGE(0x31db, 0x31fa) AM_RAM AM_BASE(&ironhors_scroll) AM_RANGE(0x31db, 0x31fa) AM_RAM AM_BASE_MEMBER(ironhors_state, scroll)
AM_RANGE(0x0040, 0x005f) AM_RAM AM_RANGE(0x0040, 0x005f) AM_RAM
AM_RANGE(0x0060, 0x00ff) AM_RAM AM_RANGE(0x0060, 0x00ff) AM_RAM
AM_RANGE(0x0800, 0x0800) AM_WRITE(soundlatch_w) AM_RANGE(0x0800, 0x0800) AM_WRITE(soundlatch_w)
@ -114,17 +115,17 @@ static ADDRESS_MAP_START( farwest_master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1800, 0x1800) AM_WRITE(ironhors_sh_irqtrigger_w) AM_RANGE(0x1800, 0x1800) AM_WRITE(ironhors_sh_irqtrigger_w)
AM_RANGE(0x1a00, 0x1a00) AM_RAM AM_BASE(&ironhors_interrupt_enable) AM_RANGE(0x1a00, 0x1a00) AM_RAM AM_BASE_MEMBER(ironhors_state, interrupt_enable)
AM_RANGE(0x1a01, 0x1a01) AM_RAM_WRITE(ironhors_charbank_w) AM_RANGE(0x1a01, 0x1a01) AM_RAM_WRITE(ironhors_charbank_w)
AM_RANGE(0x1a02, 0x1a02) AM_WRITE(ironhors_palettebank_w) AM_RANGE(0x1a02, 0x1a02) AM_WRITE(ironhors_palettebank_w)
AM_RANGE(0x0000, 0x1bff) AM_ROM AM_RANGE(0x0000, 0x1bff) AM_ROM
// AM_RANGE(0x1c00, 0x1fff) AM_RAM // AM_RANGE(0x1c00, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(ironhors_colorram_w) AM_BASE_GENERIC(colorram) AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(ironhors_colorram_w) AM_BASE_MEMBER(ironhors_state, colorram)
AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(ironhors_videoram_w) AM_BASE_GENERIC(videoram) AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(ironhors_videoram_w) AM_BASE_MEMBER(ironhors_state, videoram)
AM_RANGE(0x2800, 0x2fff) AM_RAM AM_RANGE(0x2800, 0x2fff) AM_RAM
AM_RANGE(0x1c00, 0x1dff) AM_RAM AM_BASE_GENERIC(spriteram2) AM_RANGE(0x1c00, 0x1dff) AM_RAM AM_BASE_MEMBER(ironhors_state, spriteram2)
AM_RANGE(0x3000, 0x38ff) AM_RAM AM_RANGE(0x3000, 0x38ff) AM_RAM
AM_RANGE(0x1e00, 0x1eff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x1e00, 0x1eff) AM_RAM AM_BASE_SIZE_MEMBER(ironhors_state, spriteram, spriteram_size)
AM_RANGE(0x3900, 0x3fff) AM_RAM AM_RANGE(0x3900, 0x3fff) AM_RAM
AM_RANGE(0x4000, 0xffff) AM_ROM AM_RANGE(0x4000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -136,6 +137,11 @@ static ADDRESS_MAP_START( farwest_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( dairesya ) static INPUT_PORTS_START( dairesya )
PORT_START("SYSTEM") PORT_START("SYSTEM")
@ -200,6 +206,12 @@ INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout ironhors_charlayout = static const gfx_layout ironhors_charlayout =
{ {
8,8, 8,8,
@ -272,6 +284,13 @@ static GFXDECODE_START( farwest )
GFXDECODE_ENTRY( "gfx2", 0, farwest_spritelayout2,16*8*16, 16*8 ) /* to handle 8x8 sprites */ GFXDECODE_ENTRY( "gfx2", 0, farwest_spritelayout2,16*8*16, 16*8 ) /* to handle 8x8 sprites */
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Discrete sound
*
*************************************/
static const discrete_mixer_desc ironhors_mixer_desc = static const discrete_mixer_desc ironhors_mixer_desc =
{DISC_MIXER_IS_RESISTOR, {DISC_MIXER_IS_RESISTOR,
{RES_K(2.2), RES_K(2.2), RES_K(2.2)}, {RES_K(2.2), RES_K(2.2), RES_K(2.2)},
@ -317,6 +336,12 @@ static DISCRETE_SOUND_START( ironhors )
DISCRETE_SOUND_END DISCRETE_SOUND_END
/*************************************
*
* Machine driver
*
*************************************/
static const ym2203_interface ym2203_config = static const ym2203_interface ym2203_config =
{ {
{ {
@ -331,8 +356,31 @@ static const ym2203_interface ym2203_config =
}; };
static MACHINE_START( ironhors )
{
ironhors_state *state = (ironhors_state *)machine->driver_data;
state->soundcpu = devtag_get_device(machine, "soundcpu");
state_save_register_global(machine, state->palettebank);
state_save_register_global(machine, state->charbank);
state_save_register_global(machine, state->spriterambank);
}
static MACHINE_RESET( ironhors )
{
ironhors_state *state = (ironhors_state *)machine->driver_data;
state->palettebank = 0;
state->charbank = 0;
state->spriterambank = 0;
}
static MACHINE_DRIVER_START( ironhors ) static MACHINE_DRIVER_START( ironhors )
/* driver data */
MDRV_DRIVER_DATA(ironhors_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6809,18432000/6) /* 3.072 MHz??? mod by Shingo Suzuki 1999/10/15 */ MDRV_CPU_ADD("maincpu", M6809,18432000/6) /* 3.072 MHz??? mod by Shingo Suzuki 1999/10/15 */
MDRV_CPU_PROGRAM_MAP(master_map) MDRV_CPU_PROGRAM_MAP(master_map)
@ -342,6 +390,9 @@ static MACHINE_DRIVER_START( ironhors )
MDRV_CPU_PROGRAM_MAP(slave_map) MDRV_CPU_PROGRAM_MAP(slave_map)
MDRV_CPU_IO_MAP(slave_io_map) MDRV_CPU_IO_MAP(slave_io_map)
MDRV_MACHINE_START(ironhors)
MDRV_MACHINE_RESET(ironhors)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(30) MDRV_SCREEN_REFRESH_RATE(30)
@ -376,21 +427,25 @@ MACHINE_DRIVER_END
static INTERRUPT_GEN( farwest_interrupt ) static INTERRUPT_GEN( farwest_interrupt )
{ {
ironhors_state *state = (ironhors_state *)device->machine->driver_data;
if (cpu_getiloops(device) &1) if (cpu_getiloops(device) &1)
{ {
if (*ironhors_interrupt_enable & 4) if (*state->interrupt_enable & 4)
cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE); cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE);
} }
else //if (cpu_getiloops() % 2) else //if (cpu_getiloops() % 2)
{ {
if (*ironhors_interrupt_enable & 1) if (*state->interrupt_enable & 1)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
} }
} }
static READ8_DEVICE_HANDLER( farwest_soundlatch_r ) static READ8_DEVICE_HANDLER( farwest_soundlatch_r )
{ {
return soundlatch_r(cputag_get_address_space(device->machine, "soundcpu", ADDRESS_SPACE_PROGRAM),0); ironhors_state *state = (ironhors_state *)device->machine->driver_data;
return soundlatch_r(cpu_get_address_space(state->soundcpu, ADDRESS_SPACE_PROGRAM), 0);
} }
static const ym2203_interface farwest_ym2203_config = static const ym2203_interface farwest_ym2203_config =
@ -429,11 +484,11 @@ MACHINE_DRIVER_END
/*************************************************************************** /*************************************
*
Game driver(s) * ROM definition(s)
*
***************************************************************************/ *************************************/
ROM_START( ironhors ) ROM_START( ironhors )
ROM_REGION( 0x10000, "maincpu", 0 ) ROM_REGION( 0x10000, "maincpu", 0 )
@ -507,6 +562,11 @@ ROM_START( farwest )
ROM_END ROM_END
/*************************************
*
* Game driver(s)
*
*************************************/
GAME( 1986, ironhors, 0, ironhors, ironhors, 0, ROT0, "Konami", "Iron Horse", 0 ) GAME( 1986, ironhors, 0, ironhors, ironhors, 0, ROT0, "Konami", "Iron Horse", 0 )
GAME( 1986, dairesya, ironhors, ironhors, dairesya, 0, ROT0, "[Konami] (Kawakusu license)", "Dai Ressya Goutou (Japan)", 0 ) GAME( 1986, dairesya, ironhors, ironhors, dairesya, 0, ROT0, "[Konami] (Kawakusu license)", "Dai Ressya Goutou (Japan)", 0 )

View File

@ -0,0 +1,40 @@
/*************************************************************************
IronHorse
*************************************************************************/
typedef struct _ironhors_state ironhors_state;
struct _ironhors_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
UINT8 * spriteram2;
UINT8 * scroll;
UINT8 * interrupt_enable;
size_t spriteram_size;
/* video-related */
tilemap *bg_tilemap;
int palettebank, charbank, spriterambank;
/* devices */
const device_config *soundcpu;
};
/*----------- defined in video/ironhors.c -----------*/
WRITE8_HANDLER( ironhors_videoram_w );
WRITE8_HANDLER( ironhors_colorram_w );
WRITE8_HANDLER( ironhors_palettebank_w );
WRITE8_HANDLER( ironhors_charbank_w );
WRITE8_HANDLER( ironhors_flipscreen_w );
PALETTE_INIT( ironhors );
VIDEO_START( ironhors );
VIDEO_UPDATE( ironhors );
VIDEO_START( farwest );
VIDEO_UPDATE( farwest );

View File

@ -8,17 +8,14 @@
#include "driver.h" #include "driver.h"
#include "video/resnet.h" #include "video/resnet.h"
#include "includes/ironhors.h"
UINT8 *ironhors_scroll;
static int palettebank, charbank, spriterambank;
static tilemap *bg_tilemap;
/*************************************************************************** /***************************************************************************
Convert the color PROMs into a more useable format. Convert the color PROMs into a more useable format.
***************************************************************************/ ***************************************************************************/
PALETTE_INIT( ironhors ) PALETTE_INIT( ironhors )
{ {
static const int resistances[4] = { 2000, 1000, 470, 220 }; static const int resistances[4] = { 2000, 1000, 470, 220 };
@ -83,34 +80,38 @@ PALETTE_INIT( ironhors )
WRITE8_HANDLER( ironhors_videoram_w ) WRITE8_HANDLER( ironhors_videoram_w )
{ {
space->machine->generic.videoram.u8[offset] = data; ironhors_state *state = (ironhors_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( ironhors_colorram_w ) WRITE8_HANDLER( ironhors_colorram_w )
{ {
space->machine->generic.colorram.u8[offset] = data; ironhors_state *state = (ironhors_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset); state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( ironhors_charbank_w ) WRITE8_HANDLER( ironhors_charbank_w )
{ {
if (charbank != (data & 0x03)) ironhors_state *state = (ironhors_state *)space->machine->driver_data;
if (state->charbank != (data & 0x03))
{ {
charbank = data & 0x03; state->charbank = data & 0x03;
tilemap_mark_all_tiles_dirty_all(space->machine); tilemap_mark_all_tiles_dirty_all(space->machine);
} }
spriterambank = data & 0x08; state->spriterambank = data & 0x08;
/* other bits unknown */ /* other bits unknown */
} }
WRITE8_HANDLER( ironhors_palettebank_w ) WRITE8_HANDLER( ironhors_palettebank_w )
{ {
if (palettebank != (data & 0x07)) ironhors_state *state = (ironhors_state *)space->machine->driver_data;
if (state->palettebank != (data & 0x07))
{ {
palettebank = data & 0x07; state->palettebank = data & 0x07;
tilemap_mark_all_tiles_dirty_all(space->machine); tilemap_mark_all_tiles_dirty_all(space->machine);
} }
@ -119,7 +120,8 @@ WRITE8_HANDLER( ironhors_palettebank_w )
/* bit 6 unknown - set after game over */ /* bit 6 unknown - set after game over */
if (data & 0x88) popmessage("ironhors_palettebank_w %02x",data); if (data & 0x88)
popmessage("ironhors_palettebank_w %02x",data);
} }
WRITE8_HANDLER( ironhors_flipscreen_w ) WRITE8_HANDLER( ironhors_flipscreen_w )
@ -135,41 +137,43 @@ WRITE8_HANDLER( ironhors_flipscreen_w )
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x40) << 2) + ironhors_state *state = (ironhors_state *)machine->driver_data;
((machine->generic.colorram.u8[tile_index] & 0x20) << 4) + (charbank << 10); int code = state->videoram[tile_index] + ((state->colorram[tile_index] & 0x40) << 2) +
int color = (machine->generic.colorram.u8[tile_index] & 0x0f) + 16 * palettebank; ((state->colorram[tile_index] & 0x20) << 4) + (state->charbank << 10);
int flags = ((machine->generic.colorram.u8[tile_index] & 0x10) ? TILE_FLIPX : 0) | int color = (state->colorram[tile_index] & 0x0f) + 16 * state->palettebank;
((machine->generic.colorram.u8[tile_index] & 0x20) ? TILE_FLIPY : 0); int flags = ((state->colorram[tile_index] & 0x10) ? TILE_FLIPX : 0) |
((state->colorram[tile_index] & 0x20) ? TILE_FLIPY : 0);
SET_TILE_INFO(0, code, color, flags); SET_TILE_INFO(0, code, color, flags);
} }
VIDEO_START( ironhors ) VIDEO_START( ironhors )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, ironhors_state *state = (ironhors_state *)machine->driver_data;
8, 8, 32, 32); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_scroll_rows(bg_tilemap, 32); tilemap_set_scroll_rows(state->bg_tilemap, 32);
} }
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
ironhors_state *state = (ironhors_state *)machine->driver_data;
int offs; int offs;
UINT8 *sr; UINT8 *sr;
if (spriterambank != 0) if (state->spriterambank != 0)
sr = machine->generic.spriteram.u8; sr = state->spriteram;
else else
sr = machine->generic.spriteram2.u8; sr = state->spriteram2;
for (offs = 0;offs < machine->generic.spriteram_size;offs += 5) for (offs = 0; offs < state->spriteram_size; offs += 5)
{ {
int sx = sr[offs+3]; int sx = sr[offs + 3];
int sy = sr[offs+2]; int sy = sr[offs + 2];
int flipx = sr[offs+4] & 0x20; int flipx = sr[offs + 4] & 0x20;
int flipy = sr[offs+4] & 0x40; int flipy = sr[offs + 4] & 0x40;
int code = (sr[offs] << 2) + ((sr[offs+1] & 0x03) << 10) + ((sr[offs+1] & 0x0c) >> 2); int code = (sr[offs] << 2) + ((sr[offs + 1] & 0x03) << 10) + ((sr[offs + 1] & 0x0c) >> 2);
int color = ((sr[offs+1] & 0xf0)>>4) + 16 * palettebank; int color = ((sr[offs + 1] & 0xf0) >> 4) + 16 * state->palettebank;
// int mod = flip_screen_get(machine) ? -8 : 8; // int mod = flip_screen_get(machine) ? -8 : 8;
if (flip_screen_get(machine)) if (flip_screen_get(machine))
@ -180,7 +184,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
flipy = !flipy; flipy = !flipy;
} }
switch (sr[offs+4] & 0x0c) switch (sr[offs + 4] & 0x0c)
{ {
case 0x00: /* 16x16 */ case 0x00: /* 16x16 */
drawgfx_transpen(bitmap,cliprect,machine->gfx[1], drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
@ -237,55 +241,51 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( ironhors ) VIDEO_UPDATE( ironhors )
{ {
ironhors_state *state = (ironhors_state *)screen->machine->driver_data;
int row; int row;
for (row = 0; row < 32; row++) for (row = 0; row < 32; row++)
tilemap_set_scrollx(bg_tilemap, row, ironhors_scroll[row]); tilemap_set_scrollx(state->bg_tilemap, row, state->scroll[row]);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }
static TILE_GET_INFO( farwest_get_bg_tile_info ) static TILE_GET_INFO( farwest_get_bg_tile_info )
{ {
int code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x40) << 2) + ironhors_state *state = (ironhors_state *)machine->driver_data;
((machine->generic.colorram.u8[tile_index] & 0x20) << 4) + (charbank << 10); int code = state->videoram[tile_index] + ((state->colorram[tile_index] & 0x40) << 2) +
int color = (machine->generic.colorram.u8[tile_index] & 0x0f) + 16 * palettebank; ((state->colorram[tile_index] & 0x20) << 4) + (state->charbank << 10);
int flags = 0;//((machine->generic.colorram.u8[tile_index] & 0x10) ? TILE_FLIPX : 0) | ((machine->generic.colorram.u8[tile_index] & 0x20) ? TILE_FLIPY : 0); int color = (state->colorram[tile_index] & 0x0f) + 16 * state->palettebank;
int flags = 0;//((state->colorram[tile_index] & 0x10) ? TILE_FLIPX : 0) | ((state->colorram[tile_index] & 0x20) ? TILE_FLIPY : 0);
SET_TILE_INFO(0, code, color, flags); SET_TILE_INFO(0, code, color, flags);
} }
VIDEO_START( farwest ) VIDEO_START( farwest )
{ {
bg_tilemap = tilemap_create(machine, farwest_get_bg_tile_info, tilemap_scan_rows, ironhors_state *state = (ironhors_state *)machine->driver_data;
8, 8, 32, 32); state->bg_tilemap = tilemap_create(machine, farwest_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_scroll_rows(bg_tilemap, 32); tilemap_set_scroll_rows(state->bg_tilemap, 32);
} }
static void farwest_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void farwest_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
ironhors_state *state = (ironhors_state *)machine->driver_data;
int offs; int offs;
UINT8 *sr=machine->generic.spriteram2.u8; UINT8 *sr = state->spriteram2;
UINT8 *sr2=machine->generic.spriteram.u8; UINT8 *sr2 = state->spriteram;
// if (spriterambank != 0) for (offs = 0; offs < state->spriteram_size; offs += 4)
// sr = spriteram;
//else
//sr = ;
for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
{ {
int sx = sr[offs+2]; int sx = sr[offs + 2];
int sy = sr[offs+1]; int sy = sr[offs + 1];
int flipx = sr[offs+3] & 0x20; int flipx = sr[offs + 3] & 0x20;
int flipy = sr[offs+3] & 0x40; int flipy = sr[offs + 3] & 0x40;
int code = (sr[offs] << 2) + ((sr2[offs] & 0x03) << 10) + ((sr2[offs] & 0x0c) >> 2); int code = (sr[offs] << 2) + ((sr2[offs] & 0x03) << 10) + ((sr2[offs] & 0x0c) >> 2);
int color = ((sr2[offs] & 0xf0)>>4) + 16 * palettebank; int color = ((sr2[offs] & 0xf0) >> 4) + 16 * state->palettebank;
// int mod = flip_screen_get() ? -8 : 8; // int mod = flip_screen_get() ? -8 : 8;
@ -297,7 +297,7 @@ static void farwest_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
// flipy = !flipy; // flipy = !flipy;
} }
switch (sr[offs+3] & 0x0c) switch (sr[offs + 3] & 0x0c)
{ {
case 0x00: /* 16x16 */ case 0x00: /* 16x16 */
drawgfx_transpen(bitmap,cliprect,machine->gfx[1], drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
@ -354,12 +354,13 @@ static void farwest_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
VIDEO_UPDATE( farwest) VIDEO_UPDATE( farwest)
{ {
ironhors_state *state = (ironhors_state *)screen->machine->driver_data;
int row; int row;
for (row = 0; row < 32; row++) for (row = 0; row < 32; row++)
tilemap_set_scrollx(bg_tilemap, row, ironhors_scroll[row]); tilemap_set_scrollx(state->bg_tilemap, row, state->scroll[row]);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
farwest_draw_sprites(screen->machine, bitmap, cliprect); farwest_draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
} }