Added driver data struct to beaminv.c

Added driver data struct and save states to blmbycar.c
This commit is contained in:
Fabio Priuli 2009-11-20 09:58:37 +00:00
parent f0cdba5b11
commit 737b583448
5 changed files with 216 additions and 126 deletions

1
.gitattributes vendored
View File

@ -2335,6 +2335,7 @@ src/mame/includes/beathead.h svneol=native#text/plain
src/mame/includes/beezer.h svneol=native#text/plain
src/mame/includes/bigevglf.h svneol=native#text/plain
src/mame/includes/bionicc.h svneol=native#text/plain
src/mame/includes/blmbycar.h svneol=native#text/plain
src/mame/includes/blockade.h svneol=native#text/plain
src/mame/includes/blstroid.h svneol=native#text/plain
src/mame/includes/blueprnt.h svneol=native#text/plain

View File

@ -55,9 +55,19 @@ Stephh's notes (based on the games Z80 code and some tests) :
#include "cpu/z80/z80.h"
static UINT8 *beaminv_videoram;
static size_t beaminv_videoram_size;
static UINT8 controller_select;
typedef struct _beaminv_state beaminv_state;
struct _beaminv_state
{
/* memory pointers */
UINT8 * videoram;
size_t videoram_size;
/* misc */
emu_timer *interrupt_timer;
/* input-related */
UINT8 controller_select;
};
@ -73,11 +83,10 @@ static UINT8 controller_select;
static const int interrupt_lines[INTERRUPTS_PER_FRAME] = { 0x00, 0x80 };
static emu_timer *interrupt_timer;
static TIMER_CALLBACK( interrupt_callback )
{
beaminv_state *state = (beaminv_state *)machine->driver_data;
int interrupt_number = param;
int next_interrupt_number;
int next_vpos;
@ -88,20 +97,22 @@ static TIMER_CALLBACK( interrupt_callback )
next_interrupt_number = (interrupt_number + 1) % INTERRUPTS_PER_FRAME;
next_vpos = interrupt_lines[next_interrupt_number];
timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), next_interrupt_number);
timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), next_interrupt_number);
}
static void create_interrupt_timer(running_machine *machine)
static void create_interrupt_timer( running_machine *machine )
{
interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
beaminv_state *state = (beaminv_state *)machine->driver_data;
state->interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
}
static void start_interrupt_timer(running_machine *machine)
static void start_interrupt_timer( running_machine *machine )
{
beaminv_state *state = (beaminv_state *)machine->driver_data;
int vpos = interrupt_lines[0];
timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0);
timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0);
}
@ -114,10 +125,11 @@ static void start_interrupt_timer(running_machine *machine)
static MACHINE_START( beaminv )
{
beaminv_state *state = (beaminv_state *)machine->driver_data;
create_interrupt_timer(machine);
/* setup for save states */
state_save_register_global(machine, controller_select);
state_save_register_global(machine, state->controller_select);
}
@ -130,7 +142,10 @@ static MACHINE_START( beaminv )
static MACHINE_RESET( beaminv )
{
beaminv_state *state = (beaminv_state *)machine->driver_data;
start_interrupt_timer(machine);
state->controller_select = 0;
}
@ -143,15 +158,16 @@ static MACHINE_RESET( beaminv )
static VIDEO_UPDATE( beaminv )
{
beaminv_state *state = (beaminv_state *)screen->machine->driver_data;
offs_t offs;
for (offs = 0; offs < beaminv_videoram_size; offs++)
for (offs = 0; offs < state->videoram_size; offs++)
{
int i;
UINT8 y = offs;
UINT8 x = offs >> 8 << 3;
UINT8 data = beaminv_videoram[offs];
UINT8 data = state->videoram[offs];
for (i = 0; i < 8; i++)
{
@ -186,14 +202,16 @@ static READ8_HANDLER( v128_r )
static WRITE8_HANDLER( controller_select_w )
{
beaminv_state *state = (beaminv_state *)space->machine->driver_data;
/* 0x01 (player 1) or 0x02 (player 2) */
controller_select = data;
state->controller_select = data;
}
static READ8_HANDLER( controller_r )
{
return input_port_read(space->machine, (controller_select == 1) ? P1_CONTROL_PORT_TAG : P2_CONTROL_PORT_TAG);
beaminv_state *state = (beaminv_state *)space->machine->driver_data;
return input_port_read(space->machine, (state->controller_select == 1) ? P1_CONTROL_PORT_TAG : P2_CONTROL_PORT_TAG);
}
@ -211,7 +229,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x2800, 0x2800) AM_MIRROR(0x03ff) AM_READ_PORT("INPUTS")
AM_RANGE(0x3400, 0x3400) AM_MIRROR(0x03ff) AM_READ(controller_r)
AM_RANGE(0x3800, 0x3800) AM_MIRROR(0x03ff) AM_READ(v128_r)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&beaminv_videoram) AM_SIZE(&beaminv_videoram_size)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(beaminv_state, videoram) AM_SIZE_MEMBER(beaminv_state, videoram_size)
ADDRESS_MAP_END
@ -303,6 +321,9 @@ INPUT_PORTS_END
static MACHINE_DRIVER_START( beaminv )
/* driver data */
MDRV_DRIVER_DATA(beaminv_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 2000000) /* 2 MHz ? */
MDRV_CPU_PROGRAM_MAP(main_map)
@ -359,5 +380,5 @@ ROM_END
*
*************************************/
GAME( 1979, beaminv, 0, beaminv, beaminv, 0, ROT270, "Tekunon Kougyou", "Beam Invader (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE)
GAME( 1979, beaminva, beaminv, beaminv, beaminva, 0, ROT270, "Tekunon Kougyou", "Beam Invader (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE) // what's the real title ?
GAME( 1979, beaminv, 0, beaminv, beaminv, 0, ROT270, "Tekunon Kougyou", "Beam Invader (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
GAME( 1979, beaminva, beaminv, beaminv, beaminva, 0, ROT270, "Tekunon Kougyou", "Beam Invader (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) // what's the real title ?

View File

@ -26,21 +26,7 @@ Check game speed, it depends on a bit we toggle..
#include "driver.h"
#include "cpu/m68000/m68000.h"
#include "sound/okim6295.h"
/* Variables defined in video: */
extern UINT16 *blmbycar_vram_0, *blmbycar_scroll_0;
extern UINT16 *blmbycar_vram_1, *blmbycar_scroll_1;
/* Functions defined in video: */
WRITE16_HANDLER( blmbycar_palette_w );
WRITE16_HANDLER( blmbycar_vram_0_w );
WRITE16_HANDLER( blmbycar_vram_1_w );
VIDEO_START( blmbycar );
VIDEO_UPDATE( blmbycar );
#include "blmbycar.h"
/***************************************************************************
@ -58,7 +44,7 @@ static WRITE16_HANDLER( blmbycar_okibank_w )
if (ACCESSING_BITS_0_7)
{
UINT8 *RAM = memory_region(space->machine, "oki");
memcpy(&RAM[0x30000],&RAM[0x40000 + 0x10000*(data & 0xf)],0x10000);
memcpy(&RAM[0x30000], &RAM[0x40000 + 0x10000 * (data & 0xf)], 0x10000);
}
}
@ -72,29 +58,30 @@ static WRITE16_HANDLER( blmbycar_okibank_w )
/* Preliminary potentiometric wheel support */
static UINT8 pot_wheel = 0;
static WRITE16_HANDLER( blmbycar_pot_wheel_reset_w )
{
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
pot_wheel = ~input_port_read(space->machine, "WHEEL") & 0xff;
state->pot_wheel = ~input_port_read(space->machine, "WHEEL") & 0xff;
}
static WRITE16_HANDLER( blmbycar_pot_wheel_shift_w )
{
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
static int old;
if ( ((old & 0xff) == 0xff) && ((data & 0xff) == 0) )
pot_wheel <<= 1;
old = data;
if ( ((state->old_val & 0xff) == 0xff) && ((data & 0xff) == 0) )
state->pot_wheel <<= 1;
state->old_val = data;
}
}
static READ16_HANDLER( blmbycar_pot_wheel_r )
{
return ((pot_wheel & 0x80) ? 0x04 : 0) |
(mame_rand(space->machine) & 0x08);
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
return ((state->pot_wheel & 0x80) ? 0x04 : 0) | (mame_rand(space->machine) & 0x08);
}
@ -102,7 +89,7 @@ static READ16_HANDLER( blmbycar_pot_wheel_r )
static READ16_HANDLER( blmbycar_opt_wheel_r )
{
return (~input_port_read(space->machine, "WHEEL") & 0xff) << 8;
return (~input_port_read(space->machine, "WHEEL") & 0xff) << 8;
}
@ -118,17 +105,17 @@ static ADDRESS_MAP_START( blmbycar_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0xfec000, 0xfeffff) AM_RAM
AM_RANGE(0x100000, 0x103fff) AM_WRITEONLY // ???
AM_RANGE(0x104000, 0x105fff) AM_RAM_WRITE(blmbycar_vram_1_w) AM_BASE(&blmbycar_vram_1) // Layer 1
AM_RANGE(0x106000, 0x107fff) AM_RAM_WRITE(blmbycar_vram_0_w) AM_BASE(&blmbycar_vram_0) // Layer 0
AM_RANGE(0x104000, 0x105fff) AM_RAM_WRITE(blmbycar_vram_1_w) AM_BASE_MEMBER(blmbycar_state, vram_1) // Layer 1
AM_RANGE(0x106000, 0x107fff) AM_RAM_WRITE(blmbycar_vram_0_w) AM_BASE_MEMBER(blmbycar_state, vram_0) // Layer 0
AM_RANGE(0x108000, 0x10bfff) AM_WRITEONLY // ???
AM_RANGE(0x10c000, 0x10c003) AM_WRITEONLY AM_BASE(&blmbycar_scroll_1) // Scroll 1
AM_RANGE(0x10c004, 0x10c007) AM_WRITEONLY AM_BASE(&blmbycar_scroll_0) // Scroll 0
AM_RANGE(0x10c000, 0x10c003) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, scroll_1) // Scroll 1
AM_RANGE(0x10c004, 0x10c007) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, scroll_0) // Scroll 0
AM_RANGE(0x200000, 0x2005ff) AM_RAM_WRITE(blmbycar_palette_w) // Palette
AM_RANGE(0x200600, 0x203fff) AM_RAM
AM_RANGE(0x204000, 0x2045ff) AM_RAM_WRITE(blmbycar_palette_w) AM_BASE(&paletteram16) // Palette
AM_RANGE(0x204000, 0x2045ff) AM_RAM_WRITE(blmbycar_palette_w) AM_BASE_MEMBER(blmbycar_state, paletteram16) // Palette
AM_RANGE(0x204600, 0x207fff) AM_RAM
AM_RANGE(0x440000, 0x441fff) AM_RAM
AM_RANGE(0x444000, 0x445fff) AM_WRITEONLY AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)// Sprites (size?)
AM_RANGE(0x444000, 0x445fff) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, spriteram16) AM_SIZE(&spriteram_size)// Sprites (size?)
AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW")
AM_RANGE(0x700002, 0x700003) AM_READ_PORT("P1_P2")
AM_RANGE(0x700004, 0x700005) AM_READ(blmbycar_opt_wheel_r) // Wheel (optical)
@ -143,28 +130,27 @@ ADDRESS_MAP_END
static READ16_HANDLER( waterball_unk_r )
{
static int retvalue = 0;
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
retvalue ^= 0x0008; // must toggle.. but not vblank?
return retvalue;
state->retvalue ^= 0x0008; // must toggle.. but not vblank?
return state->retvalue;
}
static ADDRESS_MAP_START( watrball_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0xfec000, 0xfeffff) AM_RAM
AM_RANGE(0x100000, 0x103fff) AM_WRITEONLY // ???
AM_RANGE(0x104000, 0x105fff) AM_RAM_WRITE(blmbycar_vram_1_w) AM_BASE(&blmbycar_vram_1) // Layer 1
AM_RANGE(0x106000, 0x107fff) AM_RAM_WRITE(blmbycar_vram_0_w) AM_BASE(&blmbycar_vram_0) // Layer 0
AM_RANGE(0x104000, 0x105fff) AM_RAM_WRITE(blmbycar_vram_1_w) AM_BASE_MEMBER(blmbycar_state, vram_1) // Layer 1
AM_RANGE(0x106000, 0x107fff) AM_RAM_WRITE(blmbycar_vram_0_w) AM_BASE_MEMBER(blmbycar_state, vram_0) // Layer 0
AM_RANGE(0x108000, 0x10bfff) AM_WRITEONLY // ???
AM_RANGE(0x10c000, 0x10c003) AM_WRITEONLY AM_BASE(&blmbycar_scroll_1) // Scroll 1
AM_RANGE(0x10c004, 0x10c007) AM_WRITEONLY AM_BASE(&blmbycar_scroll_0) // Scroll 0
AM_RANGE(0x10c000, 0x10c003) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, scroll_1) // Scroll 1
AM_RANGE(0x10c004, 0x10c007) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, scroll_0) // Scroll 0
AM_RANGE(0x200000, 0x2005ff) AM_RAM_WRITE(blmbycar_palette_w) // Palette
AM_RANGE(0x200600, 0x203fff) AM_RAM
AM_RANGE(0x204000, 0x2045ff) AM_RAM_WRITE(blmbycar_palette_w) AM_BASE(&paletteram16) // Palette
AM_RANGE(0x204000, 0x2045ff) AM_RAM_WRITE(blmbycar_palette_w) AM_BASE_MEMBER(blmbycar_state, paletteram16) // Palette
AM_RANGE(0x204600, 0x207fff) AM_RAM
AM_RANGE(0x440000, 0x441fff) AM_RAM
AM_RANGE(0x444000, 0x445fff) AM_WRITEONLY AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)// Sprites (size?)
AM_RANGE(0x444000, 0x445fff) AM_WRITEONLY AM_BASE_MEMBER(blmbycar_state, spriteram16) AM_SIZE(&spriteram_size)// Sprites (size?)
AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW")
AM_RANGE(0x700002, 0x700003) AM_READ_PORT("P1_P2")
AM_RANGE(0x700006, 0x700007) AM_READNOP // read
@ -184,7 +170,7 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( blmbycar )
PORT_START("DSW") // IN0 - $700000.w
PORT_START("DSW") /* $700000.w */
PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:8,7")
PORT_DIPSETTING( 0x0002, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x0003, DEF_STR( Normal ) )
@ -231,7 +217,7 @@ static INPUT_PORTS_START( blmbycar )
PORT_DIPSETTING( 0x8000, DEF_STR( Off ) )
PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
PORT_START("P1_P2") // IN1 - $700002.w
PORT_START("P1_P2") /* $700002.w */
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
@ -250,17 +236,17 @@ static INPUT_PORTS_START( blmbycar )
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
PORT_START("WHEEL") // IN2 - $700004.w
PORT_START("WHEEL") /* $700004.w */
PORT_BIT ( 0x00ff, 0x0080, IPT_AD_STICK_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(1)
PORT_START("UNK") // IN3 - $700006.w
PORT_START("UNK") /* $700006.w */
PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END
static INPUT_PORTS_START( watrball )
PORT_START("DSW") /* dips */
PORT_START("DSW")
PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:8,7") /* Affects timer */
PORT_DIPSETTING( 0x0002, DEF_STR( Easy ) ) /* 180 Seconds */
PORT_DIPSETTING( 0x0003, DEF_STR( Normal ) ) /* 150 Seconds */
@ -298,7 +284,7 @@ static INPUT_PORTS_START( watrball )
PORT_DIPUNUSED_DIPLOC( 0x4000, 0x4000, "SW2:2" )
PORT_DIPUNUSED_DIPLOC( 0x8000, 0x8000, "SW2:1" )
PORT_START("P1_P2") /* 16bit */
PORT_START("P1_P2")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
@ -353,13 +339,36 @@ GFXDECODE_END
***************************************************************************/
static MACHINE_START( blmbycar )
{
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
state_save_register_global(machine, state->pot_wheel);
state_save_register_global(machine, state->old_val);
}
static MACHINE_RESET( blmbycar )
{
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
state->pot_wheel = 0;
state->old_val = 0;
}
static MACHINE_DRIVER_START( blmbycar )
/* driver data */
MDRV_DRIVER_DATA(blmbycar_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 10000000) /* ? */
MDRV_CPU_PROGRAM_MAP(blmbycar_map)
MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
MDRV_MACHINE_START(blmbycar)
MDRV_MACHINE_RESET(blmbycar)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -383,13 +392,34 @@ static MACHINE_DRIVER_START( blmbycar )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
MACHINE_DRIVER_END
static MACHINE_START( watrball )
{
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
state_save_register_global(machine, state->retvalue);
}
static MACHINE_RESET( watrball )
{
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
state->retvalue = 0;
}
static MACHINE_DRIVER_START( watrball )
/* driver data */
MDRV_DRIVER_DATA(blmbycar_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 10000000) /* ? */
MDRV_CPU_PROGRAM_MAP(watrball_map)
MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
MDRV_MACHINE_START(watrball)
MDRV_MACHINE_RESET(watrball)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -506,7 +536,7 @@ ROM_END
static DRIVER_INIT( blmbycar )
{
UINT16 *RAM = (UINT16 *) memory_region(machine, "maincpu");
size_t size = memory_region_length(machine, "maincpu") / 2;
size_t size = memory_region_length(machine, "maincpu") / 2;
int i;
for (i = 0; i < size; i++)
@ -525,6 +555,6 @@ static DRIVER_INIT( blmbycar )
***************************************************************************/
GAME( 1994, blmbycar, 0, blmbycar, blmbycar, blmbycar, ROT0, "ABM & Gecas", "Blomby Car", 0 )
GAME( 1994, blmbycaru,blmbycar, blmbycar, blmbycar, 0, ROT0, "ABM & Gecas", "Blomby Car (not encrypted)", 0 )
GAME( 1996, watrball, 0, watrball, watrball, 0, ROT0, "ABM", "Water Balls", 0 )
GAME( 1994, blmbycar, 0, blmbycar, blmbycar, blmbycar, ROT0, "ABM & Gecas", "Blomby Car", GAME_SUPPORTS_SAVE )
GAME( 1994, blmbycaru,blmbycar, blmbycar, blmbycar, 0, ROT0, "ABM & Gecas", "Blomby Car (not encrypted)", GAME_SUPPORTS_SAVE )
GAME( 1996, watrball, 0, watrball, watrball, 0, ROT0, "ABM", "Water Balls", GAME_SUPPORTS_SAVE )

View File

@ -0,0 +1,36 @@
/***************************************************************************
Blomby Car
***************************************************************************/
typedef struct _blmbycar_state blmbycar_state;
struct _blmbycar_state
{
/* memory pointers */
UINT16 * vram_0;
UINT16 * scroll_0;
UINT16 * vram_1;
UINT16 * scroll_1;
UINT16 * spriteram16;
UINT16 * paletteram16;
/* video-related */
tilemap *tilemap_0, *tilemap_1;
/* input-related */
UINT8 pot_wheel; // blmbycar
int old_val; // blmbycar
int retvalue; // waterball
};
/*----------- defined in video/blmbycar.c -----------*/
WRITE16_HANDLER( blmbycar_palette_w );
WRITE16_HANDLER( blmbycar_vram_0_w );
WRITE16_HANDLER( blmbycar_vram_1_w );
VIDEO_START( blmbycar );
VIDEO_UPDATE( blmbycar );

View File

@ -29,11 +29,7 @@ Note: if MAME_DEBUG is defined, pressing Z with:
***************************************************************************/
#include "driver.h"
/* Variables needed by driver: */
UINT16 *blmbycar_vram_0, *blmbycar_scroll_0;
UINT16 *blmbycar_vram_1, *blmbycar_scroll_1;
#include "blmbycar.h"
/***************************************************************************
@ -48,7 +44,9 @@ UINT16 *blmbycar_vram_1, *blmbycar_scroll_1;
WRITE16_HANDLER( blmbycar_palette_w )
{
data = COMBINE_DATA(&paletteram16[offset]);
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
data = COMBINE_DATA(&state->paletteram16[offset]);
palette_set_color_rgb( space->machine, offset, pal4bit(data >> 4), pal4bit(data >> 0), pal4bit(data >> 8));
}
@ -70,15 +68,14 @@ WRITE16_HANDLER( blmbycar_palette_w )
***************************************************************************/
static tilemap *tilemap_0, *tilemap_1;
#define DIM_NX (0x40)
#define DIM_NY (0x20)
static TILE_GET_INFO( get_tile_info_0 )
{
UINT16 code = blmbycar_vram_0[ tile_index * 2 + 0 ];
UINT16 attr = blmbycar_vram_0[ tile_index * 2 + 1 ];
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
UINT16 code = state->vram_0[tile_index * 2 + 0];
UINT16 attr = state->vram_0[tile_index * 2 + 1];
SET_TILE_INFO(
0,
code,
@ -90,8 +87,9 @@ static TILE_GET_INFO( get_tile_info_0 )
static TILE_GET_INFO( get_tile_info_1 )
{
UINT16 code = blmbycar_vram_1[ tile_index * 2 + 0 ];
UINT16 attr = blmbycar_vram_1[ tile_index * 2 + 1 ];
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
UINT16 code = state->vram_1[tile_index * 2 + 0];
UINT16 attr = state->vram_1[tile_index * 2 + 1];
SET_TILE_INFO(
0,
code,
@ -104,14 +102,16 @@ static TILE_GET_INFO( get_tile_info_1 )
WRITE16_HANDLER( blmbycar_vram_0_w )
{
COMBINE_DATA(&blmbycar_vram_0[offset]);
tilemap_mark_tile_dirty(tilemap_0, offset/2);
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
COMBINE_DATA(&state->vram_0[offset]);
tilemap_mark_tile_dirty(state->tilemap_0, offset / 2);
}
WRITE16_HANDLER( blmbycar_vram_1_w )
{
COMBINE_DATA(&blmbycar_vram_1[offset]);
tilemap_mark_tile_dirty(tilemap_1, offset/2);
blmbycar_state *state = (blmbycar_state *)space->machine->driver_data;
COMBINE_DATA(&state->vram_1[offset]);
tilemap_mark_tile_dirty(state->tilemap_1, offset / 2);
}
@ -125,18 +125,17 @@ WRITE16_HANDLER( blmbycar_vram_1_w )
VIDEO_START( blmbycar )
{
tilemap_0 = tilemap_create( machine, get_tile_info_0, tilemap_scan_rows,
16,16, DIM_NX, DIM_NY );
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
tilemap_1 = tilemap_create( machine, get_tile_info_1, tilemap_scan_rows,
16,16, DIM_NX, DIM_NY );
state->tilemap_0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, DIM_NX, DIM_NY );
state->tilemap_1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, DIM_NX, DIM_NY );
tilemap_set_scroll_rows(tilemap_0,1);
tilemap_set_scroll_cols(tilemap_0,1);
tilemap_set_scroll_rows(state->tilemap_0, 1);
tilemap_set_scroll_cols(state->tilemap_0, 1);
tilemap_set_scroll_rows(tilemap_1,1);
tilemap_set_scroll_cols(tilemap_1,1);
tilemap_set_transparent_pen(tilemap_1,0);
tilemap_set_scroll_rows(state->tilemap_1, 1);
tilemap_set_scroll_cols(state->tilemap_1, 1);
tilemap_set_transparent_pen(state->tilemap_1, 0);
}
@ -166,47 +165,48 @@ VIDEO_START( blmbycar )
***************************************************************************/
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 )
{
blmbycar_state *state = (blmbycar_state *)machine->driver_data;
UINT16 *source, *finish;
source = spriteram16 + 0x6/2; // !
finish = spriteram16 + spriteram_size/2 - 8/2;
source = state->spriteram16 + 0x6 / 2; // !
finish = state->spriteram16 + spriteram_size / 2 - 8 / 2;
/* Find "the end of sprites" marker */
for ( ; source < finish; source += 8/2 )
for ( ; source < finish; source += 8 / 2 )
if (source[0] & 0x8000) break;
/* Draw sprites in reverse order for pdrawfgfx */
source -= 8/2;
finish = spriteram16;
source -= 8 / 2;
finish = state->spriteram16;
for ( ; source >= finish; source -= 8/2 )
for ( ; source >= finish; source -= 8 / 2 )
{
int y = source[0];
int code = source[1];
int attr = source[2];
int x = source[3];
int y = source[0];
int code = source[1];
int attr = source[2];
int x = source[3];
int flipx = attr & 0x4000;
int flipy = attr & 0x8000;
int pri = (~attr >> 3) & 0x1; // Priority (1 = Low)
int pri_mask = ~((1 << (pri+1)) - 1); // Above the first "pri" levels
int flipx = attr & 0x4000;
int flipy = attr & 0x8000;
int pri = (~attr >> 3) & 0x1; // Priority (1 = Low)
int pri_mask = ~((1 << (pri+1)) - 1); // Above the first "pri" levels
if (x & 0x4000) continue; // ? To get rid of the "shadow" blocks
x = (x & 0x1ff) - 0x10;
y = 0xf0 - ((y & 0xff) - (y & 0x100));
x = (x & 0x1ff) - 0x10;
y = 0xf0 - ((y & 0xff) - (y & 0x100));
pdrawgfx_transpen( bitmap, cliprect, machine->gfx[0],
pdrawgfx_transpen(bitmap, cliprect, machine->gfx[0],
code,
0x20 + (attr & 0xf),
flipx, flipy,
x, y,
machine->priority_bitmap,
pri_mask,0 );
pri_mask,0);
}
}
@ -221,13 +221,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( blmbycar )
{
int i,layers_ctrl = -1;
blmbycar_state *state = (blmbycar_state *)screen->machine->driver_data;
int i, layers_ctrl = -1;
tilemap_set_scrolly( tilemap_0, 0, blmbycar_scroll_0[ 0 ]);
tilemap_set_scrollx( tilemap_0, 0, blmbycar_scroll_0[ 1 ]);
tilemap_set_scrolly(state->tilemap_0, 0, state->scroll_0[0]);
tilemap_set_scrollx(state->tilemap_0, 0, state->scroll_0[1]);
tilemap_set_scrolly( tilemap_1, 0, blmbycar_scroll_1[ 0 ]+1);
tilemap_set_scrollx( tilemap_1, 0, blmbycar_scroll_1[ 1 ]+5);
tilemap_set_scrolly(state->tilemap_1, 0, state->scroll_1[0] + 1);
tilemap_set_scrollx(state->tilemap_1, 0, state->scroll_1[1] + 5);
#ifdef MAME_DEBUG
if (input_code_pressed(screen->machine, KEYCODE_Z))
@ -242,19 +243,20 @@ if (input_code_pressed(screen->machine, KEYCODE_Z))
}
#endif
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
if (layers_ctrl&1)
if (layers_ctrl & 1)
for (i = 0; i <= 1; i++)
tilemap_draw(bitmap, cliprect, tilemap_0, i, i);
tilemap_draw(bitmap, cliprect, state->tilemap_0, i, i);
else
bitmap_fill(bitmap,cliprect,0);
bitmap_fill(bitmap, cliprect, 0);
if (layers_ctrl&2)
if (layers_ctrl & 2)
for (i = 0; i <= 1; i++)
tilemap_draw(bitmap, cliprect, tilemap_1, i, i);
tilemap_draw(bitmap, cliprect, state->tilemap_1, i, i);
if (layers_ctrl&8)
if (layers_ctrl & 8)
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}