Added save states to bionicc.c

Out of whatsnew: this driver also has 99% of driver data stored in the struct. 
it still misses paletteram16, which currently uses a generic handler(and hence does not fit the struct approach), but I wanted save states so much for this game that I commit it anyway :-)
This commit is contained in:
Fabio Priuli 2009-11-19 23:22:24 +00:00
parent aa2e1eb445
commit cba7af8e5b
4 changed files with 270 additions and 161 deletions

1
.gitattributes vendored
View File

@ -2334,6 +2334,7 @@ src/mame/includes/battlex.h svneol=native#text/plain
src/mame/includes/beathead.h svneol=native#text/plain src/mame/includes/beathead.h svneol=native#text/plain
src/mame/includes/beezer.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/bigevglf.h svneol=native#text/plain
src/mame/includes/bionicc.h svneol=native#text/plain
src/mame/includes/blockade.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/blstroid.h svneol=native#text/plain
src/mame/includes/blueprnt.h svneol=native#text/plain src/mame/includes/blueprnt.h svneol=native#text/plain

View File

@ -1,129 +1,126 @@
/******************************************************************** /******************************************************************************************
Bionic Commando Bionic Commando
PCB is a 3 board stack: PCB is a 3 board stack:
Main CPU board: 86612-A-2 Main CPU board: 86612-A-2
Graphics ROM board: 86612-B-2 Graphics ROM board: 86612-B-2
Program ROM board: 86612-C-2 Program ROM board: 86612-C-2
Main CPU: 68000CP10 Main CPU: 68000CP10
Sound CPU: Z80A Sound CPU: Z80A
MCU: Intel C8751H-88 MCU: Intel C8751H-88
Sound Chip: YM2151 & YM3012 Sound Chip: YM2151 & YM3012
OSC: 24.000 MHz (on the 86612-B-2 PCB) OSC: 24.000 MHz (on the 86612-B-2 PCB)
Custom: CAPCOM DL-010D-103 (on the 86612-B-2 PCB) Custom: CAPCOM DL-010D-103 (on the 86612-B-2 PCB)
Note: Euro rom labels (IE: "TSE") had a blue stripe, while those labeled Note: Euro rom labels (IE: "TSE") had a blue stripe, while those labeled
as USA (TSU) had an red stripe on the sticker. The intermixing as USA (TSU) had an red stripe on the sticker. The intermixing
of TSE and TSU roms in the parent set is correct and verified. of TSE and TSU roms in the parent set is correct and verified.
Note: Euro set simply states the game cannot be operated in Japan.... Note: Euro set simply states the game cannot be operated in Japan....
Note: These issues have been verified on a real PCB and are not emulation bugs: Note: These issues have been verified on a real PCB and are not emulation bugs:
- misplaced sprites ( see beginning of level 1 or 2 for example ) - misplaced sprites ( see beginning of level 1 or 2 for example )
- sprite / sprite priority ( see level 2 the reflectors ) - sprite / sprite priority ( see level 2 the reflectors )
- sprite / background priority ( see level 1: birds walk through - sprite / background priority ( see level 1: birds walk through
branches of different trees ) branches of different trees )
- see the beginning of level 3: background screwed - see the beginning of level 3: background screwed
- gray tiles around the title in Top Secret - gray tiles around the title in Top Secret
ToDo: ToDo:
- get rid of input port hack - get rid of input port hack
Controls appear to be mapped at 0xFE4000, alongside dip switches, but there Controls appear to be mapped at 0xFE4000, alongside dip switches, but there
is something strange going on that I can't (yet) figure out. is something strange going on that I can't (yet) figure out.
Player controls and coin inputs are supposed to magically appear at Player controls and coin inputs are supposed to magically appear at
0xFFFFFB (coin/start) 0xFFFFFB (coin/start)
0xFFFFFD (player 2) 0xFFFFFD (player 2)
0xFFFFFF (player 1) 0xFFFFFF (player 1)
This is probably done by the Intel C8751H MCU on the board (whose interal ROM This is probably done by the Intel C8751H MCU on the board (whose interal ROM
is not yet available). is not yet available).
The MCU also takes care of the commands for the sound CPU, which are stored The MCU also takes care of the commands for the sound CPU, which are stored
at FFFFF9. at FFFFF9.
IRQ4 seems to be control related. IRQ4 seems to be control related.
On each interrupt, it reads 0xFE4000 (coin/start), shift the bits around On each interrupt, it reads 0xFE4000 (coin/start), shift the bits around
and move the resulting byte into a dword RAM location. The dword RAM location and move the resulting byte into a dword RAM location. The dword RAM location
is rotated by 8 bits each time this happens. is rotated by 8 bits each time this happens.
This is probably done to be pedantic about coin insertions (might be protection This is probably done to be pedantic about coin insertions (might be protection
related). In fact, currently coin insertions are not consistently recognized. related). In fact, currently coin insertions are not consistently recognized.
********************************************************************/ ******************************************************************************************/
#include "driver.h" #include "driver.h"
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "deprecat.h" #include "deprecat.h"
#include "sound/2151intf.h" #include "sound/2151intf.h"
#include "bionicc.h"
#define MASTER_CLOCK XTAL_24MHz #define MASTER_CLOCK XTAL_24MHz
#define EXO3_F0_CLK XTAL_14_31818MHz #define EXO3_F0_CLK XTAL_14_31818MHz
WRITE16_HANDLER( bionicc_fgvideoram_w );
WRITE16_HANDLER( bionicc_bgvideoram_w );
WRITE16_HANDLER( bionicc_txvideoram_w );
WRITE16_HANDLER( bionicc_paletteram_w );
WRITE16_HANDLER( bionicc_scroll_w );
WRITE16_HANDLER( bionicc_gfxctrl_w );
extern UINT16 *bionicc_bgvideoram;
extern UINT16 *bionicc_fgvideoram;
extern UINT16 *bionicc_txvideoram;
VIDEO_START( bionicc );
VIDEO_UPDATE( bionicc );
VIDEO_EOF( bionicc );
/*************************************
static UINT16 bionicc_inp[3]; *
* Memory handlers
*
*************************************/
static WRITE16_HANDLER( hacked_controls_w ) static WRITE16_HANDLER( hacked_controls_w )
{ {
logerror("%06x: hacked_controls_w %04x %02x\n",cpu_get_pc(space->cpu),offset,data); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
COMBINE_DATA(&bionicc_inp[offset]);
logerror("%06x: hacked_controls_w %04x %02x\n", cpu_get_pc(space->cpu), offset, data);
COMBINE_DATA(&state->inp[offset]);
} }
static READ16_HANDLER( hacked_controls_r ) static READ16_HANDLER( hacked_controls_r )
{ {
logerror("%06x: hacked_controls_r %04x %04x\n",cpu_get_pc(space->cpu),offset,bionicc_inp[offset]); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
return bionicc_inp[offset];
logerror("%06x: hacked_controls_r %04x %04x\n", cpu_get_pc(space->cpu), offset, state->inp[offset]);
return state->inp[offset];
} }
static WRITE16_HANDLER( bionicc_mpu_trigger_w ) static WRITE16_HANDLER( bionicc_mpu_trigger_w )
{ {
bionicc_state *state = (bionicc_state *)space->machine->driver_data;
data = input_port_read(space->machine, "SYSTEM") >> 12; data = input_port_read(space->machine, "SYSTEM") >> 12;
bionicc_inp[0] = data ^ 0x0f; state->inp[0] = data ^ 0x0f;
data = input_port_read(space->machine, "P2"); data = input_port_read(space->machine, "P2");
bionicc_inp[1] = data ^ 0xff; state->inp[1] = data ^ 0xff;
data = input_port_read(space->machine, "P1"); data = input_port_read(space->machine, "P1");
bionicc_inp[2] = data ^ 0xff; state->inp[2] = data ^ 0xff;
} }
static UINT16 soundcommand;
static WRITE16_HANDLER( hacked_soundcommand_w ) static WRITE16_HANDLER( hacked_soundcommand_w )
{ {
COMBINE_DATA(&soundcommand); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
soundlatch_w(space,0,soundcommand & 0xff);
COMBINE_DATA(&state->soundcommand);
soundlatch_w(space, 0, state->soundcommand & 0xff);
} }
static READ16_HANDLER( hacked_soundcommand_r ) static READ16_HANDLER( hacked_soundcommand_r )
{ {
return soundcommand; bionicc_state *state = (bionicc_state *)space->machine->driver_data;
return state->soundcommand;
} }
/******************************************************************** /********************************************************************
INTERRUPT Interrupt
The game runs on 2 interrupts. The game runs on 2 interrupts.
@ -143,6 +140,12 @@ static INTERRUPT_GEN( bionicc_interrupt )
cpu_set_input_line(device, 4, HOLD_LINE); cpu_set_input_line(device, 4, HOLD_LINE);
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x000000, 0x03ffff) AM_ROM
AM_RANGE(0xfe0000, 0xfe07ff) AM_RAM /* RAM? */ AM_RANGE(0xfe0000, 0xfe07ff) AM_RAM /* RAM? */
@ -153,10 +156,10 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xfe4002, 0xfe4003) AM_READ_PORT("DSW") AM_RANGE(0xfe4002, 0xfe4003) AM_READ_PORT("DSW")
AM_RANGE(0xfe8010, 0xfe8017) AM_WRITE(bionicc_scroll_w) AM_RANGE(0xfe8010, 0xfe8017) AM_WRITE(bionicc_scroll_w)
AM_RANGE(0xfe801a, 0xfe801b) AM_WRITE(bionicc_mpu_trigger_w) /* ??? not sure, but looks like it */ AM_RANGE(0xfe801a, 0xfe801b) AM_WRITE(bionicc_mpu_trigger_w) /* ??? not sure, but looks like it */
AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(bionicc_txvideoram_w) AM_BASE(&bionicc_txvideoram) AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(bionicc_txvideoram_w) AM_BASE_MEMBER(bionicc_state, txvideoram)
AM_RANGE(0xff0000, 0xff3fff) AM_RAM_WRITE(bionicc_fgvideoram_w) AM_BASE(&bionicc_fgvideoram) AM_RANGE(0xff0000, 0xff3fff) AM_RAM_WRITE(bionicc_fgvideoram_w) AM_BASE_MEMBER(bionicc_state, fgvideoram)
AM_RANGE(0xff4000, 0xff7fff) AM_RAM_WRITE(bionicc_bgvideoram_w) AM_BASE(&bionicc_bgvideoram) AM_RANGE(0xff4000, 0xff7fff) AM_RAM_WRITE(bionicc_bgvideoram_w) AM_BASE_MEMBER(bionicc_state, bgvideoram)
AM_RANGE(0xff8000, 0xff87ff) AM_RAM_WRITE(bionicc_paletteram_w) AM_BASE(&paletteram16) AM_RANGE(0xff8000, 0xff87ff) AM_RAM_WRITE(bionicc_paletteram_w) AM_BASE_MEMBER(bionicc_state, paletteram16)
AM_RANGE(0xffc000, 0xfffff7) AM_RAM /* working RAM */ AM_RANGE(0xffc000, 0xfffff7) AM_RAM /* working RAM */
AM_RANGE(0xfffff8, 0xfffff9) AM_READWRITE(hacked_soundcommand_r, hacked_soundcommand_w) /* hack */ AM_RANGE(0xfffff8, 0xfffff9) AM_READWRITE(hacked_soundcommand_r, hacked_soundcommand_w) /* hack */
AM_RANGE(0xfffffa, 0xffffff) AM_READWRITE(hacked_controls_r, hacked_controls_w) /* hack */ AM_RANGE(0xfffffa, 0xffffff) AM_READWRITE(hacked_controls_r, hacked_controls_w) /* hack */
@ -171,6 +174,11 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( bionicc ) static INPUT_PORTS_START( bionicc )
PORT_START("SYSTEM") PORT_START("SYSTEM")
@ -247,13 +255,11 @@ static INPUT_PORTS_START( bionicc )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
/******************************************************************** *
* Graphics definitions
GRAPHICS *
*************************************/
********************************************************************/
static const gfx_layout spritelayout_bionicc= static const gfx_layout spritelayout_bionicc=
{ {
@ -321,8 +327,40 @@ static GFXDECODE_START( bionicc )
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( bionicc )
{
bionicc_state *state = (bionicc_state *)machine->driver_data;
state_save_register_global(machine, state->soundcommand);
state_save_register_global_array(machine, state->inp);
state_save_register_global_array(machine, state->scroll);
}
static MACHINE_RESET( bionicc )
{
bionicc_state *state = (bionicc_state *)machine->driver_data;
state->inp[0] = 0;
state->inp[1] = 0;
state->inp[2] = 0;
state->scroll[0] = 0;
state->scroll[1] = 0;
state->scroll[2] = 0;
state->scroll[3] = 0;
state->soundcommand = 0;
}
static MACHINE_DRIVER_START( bionicc ) static MACHINE_DRIVER_START( bionicc )
/* driver data */
MDRV_DRIVER_DATA(bionicc_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK / 2) /* 12 MHz - verified in schematics */ MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK / 2) /* 12 MHz - verified in schematics */
MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_PROGRAM_MAP(main_map)
@ -336,6 +374,9 @@ static MACHINE_DRIVER_START( bionicc )
*/ */
MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,4) MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,4)
MDRV_MACHINE_START(bionicc)
MDRV_MACHINE_RESET(bionicc)
/* video hardware */ /* video hardware */
MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
@ -361,6 +402,12 @@ MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( bionicc ) /* "Not for use in Japan" */ ROM_START( bionicc ) /* "Not for use in Japan" */
ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */ ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */
ROM_LOAD16_BYTE( "tse_02.1a", 0x00000, 0x10000, CRC(e4aeefaa) SHA1(77b6a2d4337bf350239abb50013d030d7c5c8640) ) /* 68000 code */ ROM_LOAD16_BYTE( "tse_02.1a", 0x00000, 0x10000, CRC(e4aeefaa) SHA1(77b6a2d4337bf350239abb50013d030d7c5c8640) ) /* 68000 code */
@ -538,8 +585,13 @@ ROM_START( topsecrt ) /* "Not for use in any other country but Japan" */
ROM_END ROM_END
/*************************************
*
* Game driver(s)
*
*************************************/
GAME( 1987, bionicc, 0, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (Euro)", 0 ) GAME( 1987, bionicc, 0, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (Euro)", GAME_SUPPORTS_SAVE )
GAME( 1987, bionicc1, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (US set 1)", 0 ) GAME( 1987, bionicc1, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (US set 1)", GAME_SUPPORTS_SAVE )
GAME( 1987, bionicc2, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (US set 2)", 0 ) GAME( 1987, bionicc2, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Bionic Commando (US set 2)", GAME_SUPPORTS_SAVE )
GAME( 1987, topsecrt, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Top Secret (Japan)", 0 ) GAME( 1987, topsecrt, bionicc, bionicc, bionicc, 0, ROT0, "Capcom", "Top Secret (Japan)", GAME_SUPPORTS_SAVE )

View File

@ -0,0 +1,37 @@
/***************************************************************************
Bionic Commando
***************************************************************************/
typedef struct _bionicc_state bionicc_state;
struct _bionicc_state
{
/* memory pointers */
UINT16 * bgvideoram;
UINT16 * fgvideoram;
UINT16 * txvideoram;
UINT16 * paletteram16;
// UINT16 * spriteram16; // needed for EOF, but currently handled through buffer_spriteram16
/* video-related */
tilemap *tx_tilemap, *bg_tilemap, *fg_tilemap;
UINT16 scroll[4];
UINT16 inp[3];
UINT16 soundcommand;
};
/*----------- defined in video/bionicc.c -----------*/
WRITE16_HANDLER( bionicc_fgvideoram_w );
WRITE16_HANDLER( bionicc_bgvideoram_w );
WRITE16_HANDLER( bionicc_txvideoram_w );
WRITE16_HANDLER( bionicc_paletteram_w );
WRITE16_HANDLER( bionicc_scroll_w );
WRITE16_HANDLER( bionicc_gfxctrl_w );
VIDEO_START( bionicc );
VIDEO_UPDATE( bionicc );
VIDEO_EOF( bionicc );

View File

@ -1,35 +1,30 @@
/*************************************************************************** /***************************************************************************
Bionic Commando Video Hardware Bionic Commando Video Hardware
This board handles tile/tile and tile/sprite priority with a PROM. Its This board handles tile/tile and tile/sprite priority with a PROM. Its
working is complicated and hardcoded in the driver. working is complicated and hardcoded in the driver.
The PROM is a 256x4 chip, with address inputs wired as follows: The PROM is a 256x4 chip, with address inputs wired as follows:
A0 bg opaque A0 bg opaque
A1 \ A1 \
A2 | fg pen A2 | fg pen
A3 | A3 |
A4 / A4 /
A5 fg has priority over sprites (bit 5 of tile attribute) A5 fg has priority over sprites (bit 5 of tile attribute)
A6 fg has not priority over bg (bits 6 & 7 of tile attribute both set) A6 fg has not priority over bg (bits 6 & 7 of tile attribute both set)
A7 sprite opaque A7 sprite opaque
The output selects the active layer, it can be: The output selects the active layer, it can be:
0 bg 0 bg
1 fg 1 fg
2 sprite 2 sprite
***************************************************************************/ ***************************************************************************/
#include "driver.h" #include "driver.h"
#include "bionicc.h"
UINT16 *bionicc_fgvideoram;
UINT16 *bionicc_bgvideoram;
UINT16 *bionicc_txvideoram;
static tilemap *tx_tilemap, *bg_tilemap, *fg_tilemap;
/*************************************************************************** /***************************************************************************
@ -40,17 +35,21 @@ static tilemap *tx_tilemap, *bg_tilemap, *fg_tilemap;
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int attr = bionicc_bgvideoram[2*tile_index+1]; bionicc_state *state = (bionicc_state *)machine->driver_data;
int attr = state->bgvideoram[2 * tile_index + 1];
SET_TILE_INFO( SET_TILE_INFO(
1, 1,
(bionicc_bgvideoram[2*tile_index] & 0xff) + ((attr & 0x07) << 8), (state->bgvideoram[2 * tile_index] & 0xff) + ((attr & 0x07) << 8),
(attr & 0x18) >> 3, (attr & 0x18) >> 3,
TILE_FLIPXY((attr & 0xc0) >> 6)); TILE_FLIPXY((attr & 0xc0) >> 6));
} }
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
int attr = bionicc_fgvideoram[2*tile_index+1]; bionicc_state *state = (bionicc_state *)machine->driver_data;
int attr = state->fgvideoram[2 * tile_index + 1];
int flags; int flags;
if ((attr & 0xc0) == 0xc0) if ((attr & 0xc0) == 0xc0)
@ -68,17 +67,19 @@ static TILE_GET_INFO( get_fg_tile_info )
SET_TILE_INFO( SET_TILE_INFO(
2, 2,
(bionicc_fgvideoram[2*tile_index] & 0xff) + ((attr & 0x07) << 8), (state->fgvideoram[2 * tile_index] & 0xff) + ((attr & 0x07) << 8),
(attr & 0x18) >> 3, (attr & 0x18) >> 3,
flags); flags);
} }
static TILE_GET_INFO( get_tx_tile_info ) static TILE_GET_INFO( get_tx_tile_info )
{ {
int attr = bionicc_txvideoram[tile_index + 0x400]; bionicc_state *state = (bionicc_state *)machine->driver_data;
int attr = state->txvideoram[tile_index + 0x400];
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
(bionicc_txvideoram[tile_index] & 0xff) + ((attr & 0x00c0) << 2), (state->txvideoram[tile_index] & 0xff) + ((attr & 0x00c0) << 2),
attr & 0x3f, attr & 0x3f,
0); 0);
} }
@ -93,14 +94,16 @@ static TILE_GET_INFO( get_tx_tile_info )
VIDEO_START( bionicc ) VIDEO_START( bionicc )
{ {
tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows, 8, 8,32,32); bionicc_state *state = (bionicc_state *)machine->driver_data;
fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,16,16,64,64);
bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8, 8,64,64);
tilemap_set_transparent_pen(tx_tilemap,3); state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transmask(fg_tilemap,0,0xffff,0x8000); /* split type 0 is completely transparent in front half */ state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
tilemap_set_transmask(fg_tilemap,1,0xffc1,0x803e); /* split type 1 has pens 1-5 opaque in front half */ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
tilemap_set_transparent_pen(bg_tilemap,15);
tilemap_set_transparent_pen(state->tx_tilemap, 3);
tilemap_set_transmask(state->fg_tilemap, 0, 0xffff, 0x8000); /* split type 0 is completely transparent in front half */
tilemap_set_transmask(state->fg_tilemap, 1, 0xffc1, 0x803e); /* split type 1 has pens 1-5 opaque in front half */
tilemap_set_transparent_pen(state->bg_tilemap, 15);
} }
@ -113,32 +116,39 @@ VIDEO_START( bionicc )
WRITE16_HANDLER( bionicc_bgvideoram_w ) WRITE16_HANDLER( bionicc_bgvideoram_w )
{ {
COMBINE_DATA(&bionicc_bgvideoram[offset]); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset/2);
COMBINE_DATA(&state->bgvideoram[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
} }
WRITE16_HANDLER( bionicc_fgvideoram_w ) WRITE16_HANDLER( bionicc_fgvideoram_w )
{ {
COMBINE_DATA(&bionicc_fgvideoram[offset]); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(fg_tilemap,offset/2);
COMBINE_DATA(&state->fgvideoram[offset]);
tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
} }
WRITE16_HANDLER( bionicc_txvideoram_w ) WRITE16_HANDLER( bionicc_txvideoram_w )
{ {
COMBINE_DATA(&bionicc_txvideoram[offset]); bionicc_state *state = (bionicc_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(tx_tilemap,offset&0x3ff);
COMBINE_DATA(&state->txvideoram[offset]);
tilemap_mark_tile_dirty(state->tx_tilemap, offset & 0x3ff);
} }
WRITE16_HANDLER( bionicc_paletteram_w ) WRITE16_HANDLER( bionicc_paletteram_w )
{ {
bionicc_state *state = (bionicc_state *)space->machine->driver_data;
int r, g, b, bright; int r, g, b, bright;
data = COMBINE_DATA(&paletteram16[offset]); data = COMBINE_DATA(&state->paletteram16[offset]);
bright = (data&0x0f); bright = (data & 0x0f);
r = ((data>>12)&0x0f) * 0x11; r = ((data >> 12) & 0x0f) * 0x11;
g = ((data>>8 )&0x0f) * 0x11; g = ((data >> 8 ) & 0x0f) * 0x11;
b = ((data>>4 )&0x0f) * 0x11; b = ((data >> 4 ) & 0x0f) * 0x11;
if ((bright & 0x08) == 0) if ((bright & 0x08) == 0)
{ {
@ -152,38 +162,40 @@ WRITE16_HANDLER( bionicc_paletteram_w )
WRITE16_HANDLER( bionicc_scroll_w ) WRITE16_HANDLER( bionicc_scroll_w )
{ {
static UINT16 scroll[4]; bionicc_state *state = (bionicc_state *)space->machine->driver_data;
data = COMBINE_DATA(&scroll[offset]); data = COMBINE_DATA(&state->scroll[offset]);
switch (offset) switch (offset)
{ {
case 0: case 0:
tilemap_set_scrollx(fg_tilemap,0,data); tilemap_set_scrollx(state->fg_tilemap, 0, data);
break; break;
case 1: case 1:
tilemap_set_scrolly(fg_tilemap,0,data); tilemap_set_scrolly(state->fg_tilemap, 0, data);
break; break;
case 2: case 2:
tilemap_set_scrollx(bg_tilemap,0,data); tilemap_set_scrollx(state->bg_tilemap, 0, data);
break; break;
case 3: case 3:
tilemap_set_scrolly(bg_tilemap,0,data); tilemap_set_scrolly(state->bg_tilemap, 0, data);
break; break;
} }
} }
WRITE16_HANDLER( bionicc_gfxctrl_w ) WRITE16_HANDLER( bionicc_gfxctrl_w )
{ {
bionicc_state *state = (bionicc_state *)space->machine->driver_data;
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
{ {
flip_screen_set(space->machine, data & 0x0100); flip_screen_set(space->machine, data & 0x0100);
tilemap_set_enable(bg_tilemap,data & 0x2000); /* guess */ tilemap_set_enable(state->bg_tilemap, data & 0x2000); /* guess */
tilemap_set_enable(fg_tilemap,data & 0x1000); /* guess */ tilemap_set_enable(state->fg_tilemap, data & 0x1000); /* guess */
coin_counter_w(0,data & 0x8000); coin_counter_w(0, data & 0x8000);
coin_counter_w(1,data & 0x4000); coin_counter_w(1, data & 0x4000);
} }
} }
@ -195,22 +207,27 @@ WRITE16_HANDLER( bionicc_gfxctrl_w )
***************************************************************************/ ***************************************************************************/
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 )
{ {
// bionicc_state *state = (bionicc_state *)machine->driver_data;
int offs; int offs;
const gfx_element *gfx = machine->gfx[3]; const gfx_element *gfx = machine->gfx[3];
for (offs = (spriteram_size-8)/2;offs >= 0;offs -= 4) for (offs = (spriteram_size - 8) / 2; offs >= 0; offs -= 4)
{ {
int tile_number = buffered_spriteram16[offs] & 0x7ff; int tile_number = buffered_spriteram16[offs] & 0x7ff;
if( tile_number!=0x7FF ){ if( tile_number != 0x7ff )
int attr = buffered_spriteram16[offs+1]; {
int color = (attr&0x3C)>>2; int attr = buffered_spriteram16[offs + 1];
int flipx = attr&0x02; int color = (attr & 0x3c) >> 2;
int flipx = attr & 0x02;
int flipy = 0; int flipy = 0;
int sx = (INT16)buffered_spriteram16[offs+3]; /* signed */ int sx = (INT16)buffered_spriteram16[offs + 3]; /* signed */
int sy = (INT16)buffered_spriteram16[offs+2]; /* signed */ int sy = (INT16)buffered_spriteram16[offs + 2]; /* signed */
if(sy>512-16) sy-=512;
if (sy > 512 - 16)
sy -= 512;
if (flip_screen_get(machine)) if (flip_screen_get(machine))
{ {
sx = 240 - sx; sx = 240 - sx;
@ -230,13 +247,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( bionicc ) VIDEO_UPDATE( bionicc )
{ {
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); bionicc_state *state = (bionicc_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,fg_tilemap,1|TILEMAP_DRAW_LAYER1,0); /* nothing in FRONT */
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
tilemap_draw(bitmap,cliprect,fg_tilemap,0|TILEMAP_DRAW_LAYER1,0); tilemap_draw(bitmap, cliprect, state->fg_tilemap, 1 | TILEMAP_DRAW_LAYER1, 0); /* nothing in FRONT */
draw_sprites(screen->machine,bitmap,cliprect); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap,cliprect,fg_tilemap,0|TILEMAP_DRAW_LAYER0,0); tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0 | TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0 | TILEMAP_DRAW_LAYER0, 0);
tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0);
return 0; return 0;
} }