summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/witch.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2011-03-10 07:26:48 +0000
committer Aaron Giles <aaron@aarongiles.com>2011-03-10 07:26:48 +0000
commit4977af6a7da6015c9940d04fc9f7a6f5e5effb41 (patch)
treefbcc4b370a8596c6c7f088f4b5a10e9e5e97136b /src/mame/drivers/witch.c
parent46550a475b3efb3dacd58e3df8635f41dfa9b0c4 (diff)
Converted namco/thepit/toaplan/unico/upl/valadon/veltmjr/venture/vsystem/
zaccaria to driver_device. Also simplified unico and disentangled gridlee from balsente. [Atari Ace]
Diffstat (limited to 'src/mame/drivers/witch.c')
-rw-r--r--src/mame/drivers/witch.c165
1 files changed, 95 insertions, 70 deletions
diff --git a/src/mame/drivers/witch.c b/src/mame/drivers/witch.c
index 8c622dad3cc..adf9eb643bc 100644
--- a/src/mame/drivers/witch.c
+++ b/src/mame/drivers/witch.c
@@ -195,30 +195,36 @@ TODO :
#include "sound/2203intf.h"
#include "machine/nvram.h"
-#define UNBANKED_SIZE 0x800
-
-static tilemap_t *gfx0a_tilemap;
-static tilemap_t *gfx0b_tilemap;
-static tilemap_t *gfx1_tilemap;
-
-static UINT8 *gfx0_cram;
-static UINT8 *gfx0_vram;
-static UINT8 *gfx1_cram;
-static UINT8 *gfx1_vram;
+class witch_state : public driver_device
+{
+public:
+ witch_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ tilemap_t *gfx0a_tilemap;
+ tilemap_t *gfx0b_tilemap;
+ tilemap_t *gfx1_tilemap;
+ UINT8 *gfx0_cram;
+ UINT8 *gfx0_vram;
+ UINT8 *gfx1_cram;
+ UINT8 *gfx1_vram;
+ UINT8 *sprite_ram;
+ int scrollx;
+ int scrolly;
+ UINT8 reg_a002;
+ int bank;
+};
-static UINT8 *sprite_ram;
-static int scrollx=0;
-static int scrolly=0;
+#define UNBANKED_SIZE 0x800
-static UINT8 reg_a002=0;
-static int bank;
static TILE_GET_INFO( get_gfx0b_tile_info )
{
- int code = gfx0_vram[tile_index];
- int color = gfx0_cram[tile_index];
+ witch_state *state = machine->driver_data<witch_state>();
+ int code = state->gfx0_vram[tile_index];
+ int color = state->gfx0_cram[tile_index];
code=code | ((color & 0xe0) << 3);
@@ -236,8 +242,9 @@ static TILE_GET_INFO( get_gfx0b_tile_info )
static TILE_GET_INFO( get_gfx0a_tile_info )
{
- int code = gfx0_vram[tile_index];
- int color = gfx0_cram[tile_index];
+ witch_state *state = machine->driver_data<witch_state>();
+ int code = state->gfx0_vram[tile_index];
+ int color = state->gfx0_cram[tile_index];
code=code | ((color & 0xe0) << 3);
@@ -255,8 +262,9 @@ static TILE_GET_INFO( get_gfx0a_tile_info )
static TILE_GET_INFO( get_gfx1_tile_info )
{
- int code = gfx1_vram[tile_index];
- int color = gfx1_cram[tile_index];
+ witch_state *state = machine->driver_data<witch_state>();
+ int code = state->gfx1_vram[tile_index];
+ int color = state->gfx1_cram[tile_index];
SET_TILE_INFO(
0,
@@ -267,59 +275,69 @@ static TILE_GET_INFO( get_gfx1_tile_info )
static WRITE8_HANDLER( gfx0_vram_w )
{
- gfx0_vram[offset] = data;
- tilemap_mark_tile_dirty(gfx0a_tilemap,offset);
- tilemap_mark_tile_dirty(gfx0b_tilemap,offset);
+ witch_state *state = space->machine->driver_data<witch_state>();
+ state->gfx0_vram[offset] = data;
+ tilemap_mark_tile_dirty(state->gfx0a_tilemap,offset);
+ tilemap_mark_tile_dirty(state->gfx0b_tilemap,offset);
}
static WRITE8_HANDLER( gfx0_cram_w )
{
- gfx0_cram[offset] = data;
- tilemap_mark_tile_dirty(gfx0a_tilemap,offset);
- tilemap_mark_tile_dirty(gfx0b_tilemap,offset);
+ witch_state *state = space->machine->driver_data<witch_state>();
+ state->gfx0_cram[offset] = data;
+ tilemap_mark_tile_dirty(state->gfx0a_tilemap,offset);
+ tilemap_mark_tile_dirty(state->gfx0b_tilemap,offset);
}
static READ8_HANDLER( gfx0_vram_r )
{
- return gfx0_vram[offset];
+ witch_state *state = space->machine->driver_data<witch_state>();
+ return state->gfx0_vram[offset];
}
static READ8_HANDLER( gfx0_cram_r )
{
- return gfx0_cram[offset];
+ witch_state *state = space->machine->driver_data<witch_state>();
+ return state->gfx0_cram[offset];
}
-#define FIX_OFFSET() do { offset=(((offset + ((scrolly & 0xf8) << 2) ) & 0x3e0)+((offset + (scrollx >> 3) ) & 0x1f)+32)&0x3ff; } while(0)
+#define FIX_OFFSET() do { \
+ offset=(((offset + ((state->scrolly & 0xf8) << 2) ) & 0x3e0)+((offset + (state->scrollx >> 3) ) & 0x1f)+32)&0x3ff; } while(0)
static WRITE8_HANDLER( gfx1_vram_w )
{
+ witch_state *state = space->machine->driver_data<witch_state>();
FIX_OFFSET();
- gfx1_vram[offset] = data;
- tilemap_mark_tile_dirty(gfx1_tilemap,offset);
+ state->gfx1_vram[offset] = data;
+ tilemap_mark_tile_dirty(state->gfx1_tilemap,offset);
}
static WRITE8_HANDLER( gfx1_cram_w )
{
+ witch_state *state = space->machine->driver_data<witch_state>();
FIX_OFFSET();
- gfx1_cram[offset] = data;
- tilemap_mark_tile_dirty(gfx1_tilemap,offset);
+ state->gfx1_cram[offset] = data;
+ tilemap_mark_tile_dirty(state->gfx1_tilemap,offset);
}
static READ8_HANDLER( gfx1_vram_r )
{
+ witch_state *state = space->machine->driver_data<witch_state>();
FIX_OFFSET();
- return gfx1_vram[offset];
+ return state->gfx1_vram[offset];
}
static READ8_HANDLER( gfx1_cram_r )
{
+ witch_state *state = space->machine->driver_data<witch_state>();
FIX_OFFSET();
- return gfx1_cram[offset];
+ return state->gfx1_cram[offset];
}
static READ8_HANDLER(read_a00x)
{
+ witch_state *state = space->machine->driver_data<witch_state>();
switch(offset)
{
- case 0x02: return reg_a002;
+ case 0x02: return state->reg_a002;
case 0x04: return input_port_read(space->machine, "A004");
case 0x05: return input_port_read(space->machine, "A005");
case 0x0c: return input_port_read(space->machine, "SERVICE"); // stats / reset
@@ -328,7 +346,7 @@ static READ8_HANDLER(read_a00x)
if(offset == 0x00) //muxed with A002?
{
- switch(reg_a002 & 0x3f)
+ switch(state->reg_a002 & 0x3f)
{
case 0x3b:
return input_port_read(space->machine, "UNK"); //bet10 / pay out
@@ -337,7 +355,7 @@ static READ8_HANDLER(read_a00x)
case 0x3d:
return input_port_read(space->machine, "A005");
default:
- logerror("A000 read with mux=0x%02x\n", reg_a002 & 0x3f);
+ logerror("A000 read with mux=0x%02x\n", state->reg_a002 & 0x3f);
}
}
return 0xff;
@@ -345,18 +363,19 @@ static READ8_HANDLER(read_a00x)
static WRITE8_HANDLER(write_a00x)
{
+ witch_state *state = space->machine->driver_data<witch_state>();
switch(offset)
{
- case 0x02: //A002 bit 7&6 = bank ????
+ case 0x02: //A002 bit 7&6 = state->bank ????
{
int newbank;
- reg_a002 = data;
+ state->reg_a002 = data;
newbank = (data>>6)&3;
- if(newbank != bank)
+ if(newbank != state->bank)
{
UINT8 *ROM = space->machine->region("maincpu")->base();
- bank = newbank;
+ state->bank = newbank;
ROM = &ROM[0x10000+0x8000 * newbank + UNBANKED_SIZE];
memory_set_bankptr(space->machine, "bank1",ROM);
}
@@ -405,11 +424,13 @@ static READ8_DEVICE_HANDLER(read_8010) { return 0x00; }
static WRITE8_DEVICE_HANDLER(xscroll_w)
{
- scrollx=data;
+ witch_state *state = device->machine->driver_data<witch_state>();
+ state->scrollx=data;
}
static WRITE8_DEVICE_HANDLER(yscroll_w)
{
- scrolly=data;
+ witch_state *state = device->machine->driver_data<witch_state>();
+ state->scrolly=data;
}
static const ym2203_interface ym2203_interface_0 =
@@ -444,11 +465,11 @@ static ADDRESS_MAP_START( map_main, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x8001) AM_DEVREADWRITE("ym1", ym2203_r, ym2203_w)
AM_RANGE(0x8008, 0x8009) AM_DEVREADWRITE("ym2", ym2203_r, ym2203_w)
AM_RANGE(0xa000, 0xa00f) AM_READWRITE(read_a00x, write_a00x)
- AM_RANGE(0xc000, 0xc3ff) AM_READWRITE(gfx0_vram_r, gfx0_vram_w) AM_BASE(&gfx0_vram)
- AM_RANGE(0xc400, 0xc7ff) AM_READWRITE(gfx0_cram_r, gfx0_cram_w) AM_BASE(&gfx0_cram)
- AM_RANGE(0xc800, 0xcbff) AM_READWRITE(gfx1_vram_r, gfx1_vram_w) AM_BASE(&gfx1_vram)
- AM_RANGE(0xcc00, 0xcfff) AM_READWRITE(gfx1_cram_r, gfx1_cram_w) AM_BASE(&gfx1_cram)
- AM_RANGE(0xd000, 0xdfff) AM_RAM AM_BASE(&sprite_ram)
+ AM_RANGE(0xc000, 0xc3ff) AM_READWRITE(gfx0_vram_r, gfx0_vram_w) AM_BASE_MEMBER(witch_state, gfx0_vram)
+ AM_RANGE(0xc400, 0xc7ff) AM_READWRITE(gfx0_cram_r, gfx0_cram_w) AM_BASE_MEMBER(witch_state, gfx0_cram)
+ AM_RANGE(0xc800, 0xcbff) AM_READWRITE(gfx1_vram_r, gfx1_vram_w) AM_BASE_MEMBER(witch_state, gfx1_vram)
+ AM_RANGE(0xcc00, 0xcfff) AM_READWRITE(gfx1_cram_r, gfx1_cram_w) AM_BASE_MEMBER(witch_state, gfx1_cram)
+ AM_RANGE(0xd000, 0xdfff) AM_RAM AM_BASE_MEMBER(witch_state, sprite_ram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_split1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_split2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_SHARE("share1")
@@ -675,19 +696,21 @@ GFXDECODE_END
static VIDEO_START(witch)
{
- gfx0a_tilemap = tilemap_create(machine, get_gfx0a_tile_info,tilemap_scan_rows,8,8,32,32);
- gfx0b_tilemap = tilemap_create(machine, get_gfx0b_tile_info,tilemap_scan_rows,8,8,32,32);
- gfx1_tilemap = tilemap_create(machine, get_gfx1_tile_info,tilemap_scan_rows,8,8,32,32);
-
- tilemap_set_transparent_pen(gfx0a_tilemap,0);
- tilemap_set_transparent_pen(gfx0b_tilemap,0);
- tilemap_set_palette_offset(gfx0a_tilemap,0x100);
- tilemap_set_palette_offset(gfx0b_tilemap,0x100);
- tilemap_set_palette_offset(gfx1_tilemap,0x200);
+ witch_state *state = machine->driver_data<witch_state>();
+ state->gfx0a_tilemap = tilemap_create(machine, get_gfx0a_tile_info,tilemap_scan_rows,8,8,32,32);
+ state->gfx0b_tilemap = tilemap_create(machine, get_gfx0b_tile_info,tilemap_scan_rows,8,8,32,32);
+ state->gfx1_tilemap = tilemap_create(machine, get_gfx1_tile_info,tilemap_scan_rows,8,8,32,32);
+
+ tilemap_set_transparent_pen(state->gfx0a_tilemap,0);
+ tilemap_set_transparent_pen(state->gfx0b_tilemap,0);
+ tilemap_set_palette_offset(state->gfx0a_tilemap,0x100);
+ tilemap_set_palette_offset(state->gfx0b_tilemap,0x100);
+ tilemap_set_palette_offset(state->gfx1_tilemap,0x200);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
+ witch_state *state = machine->driver_data<witch_state>();
int i,sx,sy,tileno,flags,color;
int flipx=0;
int flipy=0;
@@ -695,12 +718,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
for(i=0;i<0x800;i+=0x20) {
- sx = sprite_ram[i+1];
+ sx = state->sprite_ram[i+1];
if(sx!=0xF8) {
- tileno = (sprite_ram[i]<<2) | (( sprite_ram[i+0x800] & 0x07 ) << 10 );
+ tileno = (state->sprite_ram[i]<<2) | (( state->sprite_ram[i+0x800] & 0x07 ) << 10 );
- sy = sprite_ram[i+2];
- flags = sprite_ram[i+3];
+ sy = state->sprite_ram[i+2];
+ flags = state->sprite_ram[i+3];
flipx = (flags & 0x10 ) ? 1 : 0;
flipy = (flags & 0x20 ) ? 1 : 0;
@@ -735,15 +758,16 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static SCREEN_UPDATE(witch)
{
- tilemap_set_scrollx( gfx1_tilemap, 0, scrollx-7 ); //offset to have it aligned with the sprites
- tilemap_set_scrolly( gfx1_tilemap, 0, scrolly+8 );
+ witch_state *state = screen->machine->driver_data<witch_state>();
+ tilemap_set_scrollx( state->gfx1_tilemap, 0, state->scrollx-7 ); //offset to have it aligned with the sprites
+ tilemap_set_scrolly( state->gfx1_tilemap, 0, state->scrolly+8 );
- tilemap_draw(bitmap,cliprect,gfx1_tilemap,0,0);
- tilemap_draw(bitmap,cliprect,gfx0a_tilemap,0,0);
+ tilemap_draw(bitmap,cliprect,state->gfx1_tilemap,0,0);
+ tilemap_draw(bitmap,cliprect,state->gfx0a_tilemap,0,0);
draw_sprites(screen->machine, bitmap, cliprect);
- tilemap_draw(bitmap,cliprect,gfx0b_tilemap,0,0);
+ tilemap_draw(bitmap,cliprect,state->gfx0b_tilemap,0,0);
return 0;
}
@@ -757,7 +781,7 @@ static INTERRUPT_GEN( witch_sub_interrupt )
cpu_set_input_line(device,0,ASSERT_LINE);
}
-static MACHINE_CONFIG_START( witch, driver_device )
+static MACHINE_CONFIG_START( witch, witch_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,8000000) /* ? MHz */
MCFG_CPU_PROGRAM_MAP(map_main)
@@ -840,11 +864,12 @@ ROM_END
static DRIVER_INIT(witch)
{
+ witch_state *state = machine->driver_data<witch_state>();
UINT8 *ROM = (UINT8 *)machine->region("maincpu")->base();
memory_set_bankptr(machine, "bank1", &ROM[0x10000+UNBANKED_SIZE]);
memory_install_read8_handler(cputag_get_address_space(machine, "sub", ADDRESS_SPACE_PROGRAM), 0x7000, 0x700f, 0, 0, prot_read_700x);
- bank = -1;
+ state->bank = -1;
}
GAME( 1992, witch, 0, witch, witch, witch, ROT0, "Sega / Vic Tokai", "Witch", 0 )