Converted namco/thepit/toaplan/unico/upl/valadon/veltmjr/venture/vsystem/

zaccaria to driver_device. Also simplified unico and disentangled gridlee
from balsente. [Atari Ace]
This commit is contained in:
Aaron Giles 2011-03-10 07:26:48 +00:00
parent 46550a475b
commit 4977af6a7d
89 changed files with 2884 additions and 2304 deletions

View File

@ -36,7 +36,6 @@ static void turbo_update_samples(turbo_state *state, device_t *samples)
#if (DISCRETE_TEST)
static int last_sound_a;
static TIMER_CALLBACK( update_sound_a )
{
@ -110,12 +109,12 @@ WRITE8_DEVICE_HANDLER( turbo_sound_a_w )
#else
if (((data ^ last_sound_a) & 0x1e) && (last_sound_a & 0x1e) != 0x1e)
if (((data ^ state->last_sound_a) & 0x1e) && (state->last_sound_a & 0x1e) != 0x1e)
space->machine->scheduler().timer_set(attotime::from_hz(20000), FUNC(update_sound_a), data);
else
update_sound_a(data);
last_sound_a = data;
state->last_sound_a = data;
#endif
}

View File

@ -66,35 +66,32 @@ DIP locations verified for:
#include "sound/tms5110.h"
#include "includes/bagman.h"
//static int speech_rom_address = 0;
static UINT8 ls259_buf[8] = {0,0,0,0,0,0,0,0};
static WRITE8_DEVICE_HANDLER( bagman_ls259_w )
{
bagman_state *state = device->machine->driver_data<bagman_state>();
address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
bagman_pal16r6_w(space, offset,data); /*this is just a simulation*/
if (ls259_buf[offset] != (data&1) )
if (state->ls259_buf[offset] != (data&1) )
{
ls259_buf[offset] = data&1;
state->ls259_buf[offset] = data&1;
switch (offset)
{
case 0:
case 1:
case 2:
tmsprom_bit_w(device, 0, 7 - ((ls259_buf[0]<<2) | (ls259_buf[1]<<1) | (ls259_buf[2]<<0)));
tmsprom_bit_w(device, 0, 7 - ((state->ls259_buf[0]<<2) | (state->ls259_buf[1]<<1) | (state->ls259_buf[2]<<0)));
break;
case 3:
tmsprom_enable_w(device, ls259_buf[offset]);
tmsprom_enable_w(device, state->ls259_buf[offset]);
break;
case 4:
tmsprom_rom_csq_w(device, 0, ls259_buf[offset]);
tmsprom_rom_csq_w(device, 0, state->ls259_buf[offset]);
break;
case 5:
tmsprom_rom_csq_w(device, 1, ls259_buf[offset]);
tmsprom_rom_csq_w(device, 1, state->ls259_buf[offset]);
break;
}
}
@ -116,14 +113,14 @@ static WRITE8_DEVICE_HANDLER( bagman_interrupt_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x67ff) AM_RAM
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE(&bagman_videoram)
AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE(&bagman_colorram)
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE_MEMBER(bagman_state, videoram)
AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE_MEMBER(bagman_state, colorram)
AM_RANGE(0x9c00, 0x9fff) AM_WRITENOP /* written to, but unused */
AM_RANGE(0xa000, 0xa000) AM_READ(bagman_pal16r6_r)
//AM_RANGE(0xa800, 0xa805) AM_READ(bagman_ls259_r) /*just for debugging purposes*/
AM_RANGE(0xa000, 0xa000) AM_DEVWRITE("maincpu", bagman_interrupt_w)
AM_RANGE(0xa001, 0xa002) AM_WRITE(bagman_flipscreen_w)
AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE(&bagman_video_enable)
AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE_MEMBER(bagman_state, video_enable)
AM_RANGE(0xc000, 0xffff) AM_ROM /* Super Bagman only */
AM_RANGE(0x9800, 0x981f) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) /* hidden portion of color RAM */
/* here only to initialize the pointer, */
@ -145,15 +142,15 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( pickin_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x7000, 0x77ff) AM_RAM
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE(&bagman_videoram)
AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE(&bagman_colorram)
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE_MEMBER(bagman_state, videoram)
AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE_MEMBER(bagman_state, colorram)
AM_RANGE(0x9800, 0x981f) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) /* hidden portion of color RAM */
/* here only to initialize the pointer, */
/* writes are handled by bagman_colorram_w */
AM_RANGE(0x9c00, 0x9fff) AM_WRITENOP /* written to, but unused */
AM_RANGE(0xa000, 0xa000) AM_WRITE(interrupt_enable_w)
AM_RANGE(0xa001, 0xa002) AM_WRITE(bagman_flipscreen_w)
AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE(&bagman_video_enable)
AM_RANGE(0xa003, 0xa003) AM_WRITEONLY AM_BASE_MEMBER(bagman_state, video_enable)
AM_RANGE(0xa004, 0xa004) AM_WRITE(bagman_coin_counter_w)
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("DSW")
@ -381,42 +378,44 @@ static const ay8910_interface ay8910_config =
I don't know if the following is correct, there can possbily be multiple solutions for the same problem. */
static READ8_DEVICE_HANDLER( dial_input_p1_r )
{
static UINT8 res,dial_val,old_val;
bagman_state *state = device->machine->driver_data<bagman_state>();
UINT8 dial_val;
dial_val = input_port_read(device->machine, "DIAL_P1");
if(res != 0x60)
res = 0x60;
else if(dial_val > old_val)
res = 0x40;
else if(dial_val < old_val)
res = 0x20;
if(state->p1_res != 0x60)
state->p1_res = 0x60;
else if(dial_val > state->p1_old_val)
state->p1_res = 0x40;
else if(dial_val < state->p1_old_val)
state->p1_res = 0x20;
else
res = 0x60;
state->p1_res = 0x60;
old_val = dial_val;
state->p1_old_val = dial_val;
return (input_port_read(device->machine, "P1") & 0x9f) | (res);
return (input_port_read(device->machine, "P1") & 0x9f) | (state->p1_res);
}
static READ8_DEVICE_HANDLER( dial_input_p2_r )
{
static UINT8 res,dial_val,old_val;
bagman_state *state = device->machine->driver_data<bagman_state>();
UINT8 dial_val;
dial_val = input_port_read(device->machine, "DIAL_P2");
if(res != 0x60)
res = 0x60;
else if(dial_val > old_val)
res = 0x40;
else if(dial_val < old_val)
res = 0x20;
if(state->p2_res != 0x60)
state->p2_res = 0x60;
else if(dial_val > state->p2_old_val)
state->p2_res = 0x40;
else if(dial_val < state->p2_old_val)
state->p2_res = 0x20;
else
res = 0x60;
state->p2_res = 0x60;
old_val = dial_val;
state->p2_old_val = dial_val;
return (input_port_read(device->machine, "P2") & 0x9f) | (res);
return (input_port_read(device->machine, "P2") & 0x9f) | (state->p2_res);
}
static const ay8910_interface ay8910_dial_config =
@ -468,7 +467,7 @@ static const tms5110_interface bagman_tms5110_interface =
DEVCB_NULL /* rom clock - Only used to drive the data lines */
};
static MACHINE_CONFIG_START( bagman, driver_device )
static MACHINE_CONFIG_START( bagman, bagman_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, BAGMAN_H0)
@ -505,7 +504,7 @@ static MACHINE_CONFIG_START( bagman, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( pickin, driver_device )
static MACHINE_CONFIG_START( pickin, bagman_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, BAGMAN_H0)
@ -558,7 +557,7 @@ z80
*/
static MACHINE_CONFIG_START( botanic, driver_device )
static MACHINE_CONFIG_START( botanic, bagman_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, BAGMAN_H0)
@ -931,8 +930,9 @@ ROM_END
static DRIVER_INIT( bagnarda )
{
bagman_state *state = machine->driver_data<bagman_state>();
/* initialize video enable because it's not done in the code */
*bagman_video_enable = 1;
*state->video_enable = 1;
}
GAME( 1982, bagman, 0, bagman, bagman, 0, ROT270, "Valadon Automation", "Bagman", 0 )

View File

@ -22,19 +22,31 @@
#include "cardline.lh"
static int cardline_video;
static UINT8 *videoram;
static UINT8 *colorram;
class cardline_state : public driver_device
{
public:
cardline_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
int video;
UINT8 *videoram;
UINT8 *colorram;
int var;
};
#define DRAW_TILE(machine, offset, transparency) drawgfx_transpen(bitmap, cliprect, machine->gfx[0],\
(videoram[index+offset] | (colorram[index+offset]<<8))&0x3fff,\
(colorram[index+offset]&0x80)>>7,\
(state->videoram[index+offset] | (state->colorram[index+offset]<<8))&0x3fff,\
(state->colorram[index+offset]&0x80)>>7,\
0,0,\
x<<3, y<<3,\
transparency?transparency:(UINT32)-1);
static SCREEN_UPDATE( cardline )
{
cardline_state *state = screen->machine->driver_data<cardline_state>();
int x,y;
bitmap_fill(bitmap,cliprect,0);
for(y=0;y<32;y++)
@ -42,13 +54,13 @@ static SCREEN_UPDATE( cardline )
for(x=0;x<64;x++)
{
int index=y*64+x;
if(cardline_video&1)
if(state->video&1)
{
DRAW_TILE(screen->machine,0,0);
DRAW_TILE(screen->machine,0x800,1);
}
if(cardline_video&2)
if(state->video&2)
{
DRAW_TILE(screen->machine,0x1000,0);
DRAW_TILE(screen->machine,0x1800,1);
@ -60,27 +72,30 @@ static SCREEN_UPDATE( cardline )
static WRITE8_HANDLER(vram_w)
{
offset+=0x1000*((cardline_video&2)>>1);
videoram[offset]=data;
cardline_state *state = space->machine->driver_data<cardline_state>();
offset+=0x1000*((state->video&2)>>1);
state->videoram[offset]=data;
}
static WRITE8_HANDLER(attr_w)
{
offset+=0x1000*((cardline_video&2)>>1);
colorram[offset]=data;
cardline_state *state = space->machine->driver_data<cardline_state>();
offset+=0x1000*((state->video&2)>>1);
state->colorram[offset]=data;
}
static WRITE8_HANDLER(video_w)
{
cardline_video=data;
cardline_state *state = space->machine->driver_data<cardline_state>();
state->video=data;
}
static READ8_HANDLER(unk_r)
{
static int var=0;
var^=0x10;
//printf("var %d\n",var);
return var;
cardline_state *state = space->machine->driver_data<cardline_state>();
state->var^=0x10;
//printf("var %d\n",state->var);
return state->var;
}
static WRITE8_HANDLER(lamps_w)
@ -113,8 +128,8 @@ static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x2840, 0x2840) AM_NOP
AM_RANGE(0x2880, 0x2880) AM_NOP
AM_RANGE(0x3003, 0x3003) AM_NOP
AM_RANGE(0xc000, 0xdfff) AM_WRITE(vram_w) AM_BASE(&videoram)
AM_RANGE(0xe000, 0xffff) AM_WRITE(attr_w) AM_BASE(&colorram)
AM_RANGE(0xc000, 0xdfff) AM_WRITE(vram_w) AM_BASE_MEMBER(cardline_state, videoram)
AM_RANGE(0xe000, 0xffff) AM_WRITE(attr_w) AM_BASE_MEMBER(cardline_state, colorram)
/* Ports */
AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(unk_r, video_w)
ADDRESS_MAP_END
@ -192,7 +207,7 @@ static PALETTE_INIT(cardline)
}
}
static MACHINE_CONFIG_START( cardline, driver_device )
static MACHINE_CONFIG_START( cardline, cardline_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", I80C32,12000000)

View File

@ -435,7 +435,7 @@ static READ8_DEVICE_HANDLER( dunhuang_dsw_r )
if (!(state->input & 0x04)) return input_port_read(device->machine, "DSW3");
if (!(state->input & 0x08)) return input_port_read(device->machine, "DSW4");
if (!(state->input & 0x10)) return input_port_read(device->machine, "DSW5");
logerror("%s: warning, unknown dsw bits read, state->input = %02x\n", device->machine->describe_context(), state->input);
logerror("%s: warning, unknown dsw bits read, input = %02x\n", device->machine->describe_context(), state->input);
return 0xff;
}
static READ8_HANDLER( dunhuang_input_r )
@ -446,7 +446,7 @@ static READ8_HANDLER( dunhuang_input_r )
if (!(state->input & 0x04)) return input_port_read(space->machine, "IN2");
if (!(state->input & 0x08)) return input_port_read(space->machine, "IN3");
if (!(state->input & 0x10)) return input_port_read(space->machine, "IN4");
logerror("%s: warning, unknown input bits read, state->input = %02x\n", space->machine->describe_context(), state->input);
logerror("%s: warning, unknown input bits read, input = %02x\n", space->machine->describe_context(), state->input);
return 0xff;
}

View File

@ -28,9 +28,8 @@ Notes:
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "machine/nvram.h"
#include "includes/naughtyb.h"
/* it uses the same palette layout as in naughtyb */
PALETTE_INIT( naughtyb );
static int palreg = 0;
static int gfx_bank = 0;

View File

@ -628,8 +628,8 @@ static void GCU_w(running_machine *machine, int chip, UINT32 offset, UINT32 data
if (reg != 0x70 && chip == 0)
{
//printf("%s:state->gcu%d_w: %08X, %08X, %08X at %08X\n", machine->describe_context(), chip, data, offset, mem_mask);
//logerror("%s:state->gcu%d_w: %08X, %08X, %08X at %08X\n", cmachine->describe_context(), hip, data, offset, mem_mask);
//printf("%s:gcu%d_w: %08X, %08X, %08X at %08X\n", machine->describe_context(), chip, data, offset, mem_mask);
//logerror("%s:gcu%d_w: %08X, %08X, %08X at %08X\n", cmachine->describe_context(), hip, data, offset, mem_mask);
}
switch(reg)

View File

@ -142,17 +142,12 @@ static UINT16 *rsoSharedRAM;
static UINT32 led_mst; //Diagnostic LEDs
static UINT32 led_slv;
static int objcode2tile( int code )
{ /* callback for sprite drawing code in namcoic.c */
return code;
} /* objcode2tile */
static VIDEO_START(gal3)
{
namco_obj_init(machine,
0, /* gfx bank */
0xf, /* reverse palette mapping */
objcode2tile );
NULL );
}

View File

@ -28,11 +28,22 @@ TS 2008.08.12:
#include "sound/s2636.h"
#include "cpu/s2650/s2650.h"
static UINT8 *galaxia_video;
static UINT8 *galaxia_color;
class galaxia_state : public driver_device
{
public:
galaxia_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *video;
UINT8 *color;
};
static SCREEN_UPDATE( galaxia )
{
galaxia_state *state = screen->machine->driver_data<galaxia_state>();
int x,y, count;
bitmap_t *s2636_0_bitmap;
@ -49,7 +60,7 @@ static SCREEN_UPDATE( galaxia )
{
for (x=0;x<256/8;x++)
{
int tile = galaxia_video[count];
int tile = state->video[count];
drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,0,0,0,x*8,y*8);
count++;
}
@ -89,19 +100,21 @@ static SCREEN_UPDATE( galaxia )
static WRITE8_HANDLER(galaxia_video_w)
{
galaxia_state *state = space->machine->driver_data<galaxia_state>();
if (cpu_get_reg(space->cpu, S2650_FO))
{
galaxia_video[offset]=data;
state->video[offset]=data;
}
else
{
galaxia_color[offset]=data;
state->color[offset]=data;
}
}
static READ8_HANDLER(galaxia_video_r)
{
return galaxia_video[offset];
galaxia_state *state = space->machine->driver_data<galaxia_state>();
return state->video[offset];
}
static ADDRESS_MAP_START( mem_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -110,7 +123,7 @@ static ADDRESS_MAP_START( mem_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(galaxia_video_r, galaxia_video_w) AM_BASE(&galaxia_video)
AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(galaxia_video_r, galaxia_video_w) AM_BASE_MEMBER(galaxia_state, video)
AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
AM_RANGE(0x2000, 0x33ff) AM_ROM
AM_RANGE(0x7214, 0x7214) AM_READ_PORT("IN0")
@ -133,7 +146,7 @@ static ADDRESS_MAP_START( astrowar_mem, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_work_ram_r, s2636_work_ram_w)
AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(galaxia_video_r, galaxia_video_w) AM_BASE(&galaxia_video)
AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(galaxia_video_r, galaxia_video_w) AM_BASE_MEMBER(galaxia_state, video)
AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
AM_RANGE(0x2000, 0x33ff) AM_ROM
ADDRESS_MAP_END
@ -256,7 +269,7 @@ static const s2636_interface s2636_2_config =
"s2636snd_2"
};
static MACHINE_CONFIG_START( galaxia, driver_device )
static MACHINE_CONFIG_START( galaxia, galaxia_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", S2650,2000000) /* ? MHz */
MCFG_CPU_PROGRAM_MAP(mem_map)
@ -344,7 +357,8 @@ ROM_END
static DRIVER_INIT(galaxia)
{
galaxia_color=auto_alloc_array(machine, UINT8, 0x400);
galaxia_state *state = machine->driver_data<galaxia_state>();
state->color=auto_alloc_array(machine, UINT8, 0x400);
}
GAME( 1979, galaxia, 0, galaxia, galaxia, galaxia, ROT90, "Zaccaria", "Galaxia", GAME_NOT_WORKING )

View File

@ -79,10 +79,9 @@
#include "emu.h"
#include "cpu/m6809/m6809.h"
#include "includes/gridlee.h"
#include "includes/balsente.h"
#include "sound/samples.h"
#include "machine/nvram.h"
#include "includes/gridlee.h"
/* constants */
@ -117,7 +116,7 @@ static TIMER_CALLBACK( irq_timer_tick )
cputag_set_input_line(machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE);
/* it will turn off on the next HBLANK */
state->irq_off->adjust(machine->primary_screen->time_until_pos(param, BALSENTE_HBSTART));
state->irq_off->adjust(machine->primary_screen->time_until_pos(param, GRIDLEE_HBSTART));
}
@ -137,7 +136,7 @@ static TIMER_CALLBACK( firq_timer_tick )
cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
/* it will turn off on the next HBLANK */
state->firq_off->adjust(machine->primary_screen->time_until_pos(FIRQ_SCANLINE, BALSENTE_HBSTART));
state->firq_off->adjust(machine->primary_screen->time_until_pos(FIRQ_SCANLINE, GRIDLEE_HBSTART));
}
static MACHINE_START( gridlee )
@ -429,7 +428,7 @@ static const samples_interface gridlee_samples_interface =
static MACHINE_CONFIG_START( gridlee, gridlee_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6809, BALSENTE_CPU_CLOCK)
MCFG_CPU_ADD("maincpu", M6809, GRIDLEE_CPU_CLOCK)
MCFG_CPU_PROGRAM_MAP(cpu1_map)
MCFG_MACHINE_START(gridlee)
@ -439,7 +438,7 @@ static MACHINE_CONFIG_START( gridlee, gridlee_state )
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
MCFG_SCREEN_RAW_PARAMS(BALSENTE_PIXEL_CLOCK, BALSENTE_HTOTAL, BALSENTE_HBEND, BALSENTE_HBSTART, BALSENTE_VTOTAL, BALSENTE_VBEND, BALSENTE_VBSTART)
MCFG_SCREEN_RAW_PARAMS(GRIDLEE_PIXEL_CLOCK, GRIDLEE_HTOTAL, GRIDLEE_HBEND, GRIDLEE_HBSTART, GRIDLEE_VTOTAL, GRIDLEE_VBEND, GRIDLEE_VBSTART)
MCFG_SCREEN_UPDATE(gridlee)
MCFG_PALETTE_LENGTH(2048)

View File

@ -178,28 +178,24 @@ Frequencies: 68k is XTAL_32MHZ/2
******************************************************************************/
//UINT16 *gs_videoram3;
//UINT16 *gs_mixer_regs;
static UINT16 dmmy_8f_ret;
/*** MISC READ / WRITE HANDLERS **********************************************/
static READ16_HANDLER(dmmy_8f)
{
dmmy_8f_ret = ~dmmy_8f_ret;
return dmmy_8f_ret;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
state->dmmy_8f_ret = ~state->dmmy_8f_ret;
return state->dmmy_8f_ret;
}
/*** SOUND RELATED ***********************************************************/
static int pending_command;
static WRITE16_HANDLER( sound_command_w )
{
gstriker_state *state = space->machine->driver_data<gstriker_state>();
if (ACCESSING_BITS_0_7)
{
pending_command = 1;
state->pending_command = 1;
soundlatch_w(space, offset, data & 0xff);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
}
@ -208,13 +204,15 @@ static WRITE16_HANDLER( sound_command_w )
#if 0
static READ16_HANDLER( pending_command_r )
{
return pending_command;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
return state->pending_command;
}
#endif
static WRITE8_HANDLER( gs_sh_pending_command_clear_w )
{
pending_command = 0;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
state->pending_command = 0;
}
static WRITE8_HANDLER( gs_sh_bankswitch_w )
@ -280,15 +278,14 @@ static const ym2610_interface ym2610_config =
/*** MEMORY LAYOUTS **********************************************************/
static UINT16 *work_ram;
static ADDRESS_MAP_START( gstriker_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(MB60553_0_vram_w) AM_BASE(&MB60553_0_vram)
AM_RANGE(0x140000, 0x141fff) AM_RAM AM_BASE(&CG10103_0_vram)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(VS920A_0_vram_w) AM_BASE(&VS920A_0_vram)
AM_RANGE(0x181000, 0x181fff) AM_RAM AM_BASE(&gstriker_lineram)
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(MB60553_0_vram_w) AM_BASE_MEMBER(gstriker_state, MB60553[0].vram)
AM_RANGE(0x140000, 0x141fff) AM_RAM AM_BASE_MEMBER(gstriker_state, CG10103[0].vram)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(VS920A_0_vram_w) AM_BASE_MEMBER(gstriker_state, VS920A[0].vram)
AM_RANGE(0x181000, 0x181fff) AM_RAM AM_BASE_MEMBER(gstriker_state, lineram)
AM_RANGE(0x1c0000, 0x1c0fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x200000, 0x20000f) AM_RAM_WRITE(MB60553_0_regs_w)
@ -302,7 +299,7 @@ static ADDRESS_MAP_START( gstriker_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x20008e, 0x20008f) AM_READ(dmmy_8f)
AM_RANGE(0x2000a0, 0x2000a1) AM_WRITE(sound_command_w)
AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE(&work_ram)
AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE_MEMBER(gstriker_state, work_ram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -322,10 +319,10 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( vgoal_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(MB60553_0_vram_w) AM_BASE(&MB60553_0_vram)
AM_RANGE(0x140000, 0x141fff) AM_RAM AM_BASE(&CG10103_0_vram)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(VS920A_0_vram_w) AM_BASE(&VS920A_0_vram)
AM_RANGE(0x181000, 0x181fff) AM_RAM AM_BASE(&gstriker_lineram)
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(MB60553_0_vram_w) AM_BASE_MEMBER(gstriker_state, MB60553[0].vram)
AM_RANGE(0x140000, 0x141fff) AM_RAM AM_BASE_MEMBER(gstriker_state, CG10103[0].vram)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(VS920A_0_vram_w) AM_BASE_MEMBER(gstriker_state, VS920A[0].vram)
AM_RANGE(0x181000, 0x181fff) AM_RAM AM_BASE_MEMBER(gstriker_state, lineram)
AM_RANGE(0x1c0000, 0x1c4fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x200000, 0x20000f) AM_RAM_WRITE(MB60553_0_regs_w)
AM_RANGE(0x200040, 0x20005f) AM_RAM //AM_BASE(&gs_mixer_regs)
@ -338,7 +335,7 @@ static ADDRESS_MAP_START( vgoal_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x20008e, 0x20008f) AM_READ(dmmy_8f)
AM_RANGE(0x2000a0, 0x2000a1) AM_WRITE(sound_command_w)
AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE(&work_ram)
AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE_MEMBER(gstriker_state, work_ram)
ADDRESS_MAP_END
/*** INPUT PORTS *************************************************************/
@ -546,7 +543,7 @@ INPUT_PORTS_END
/*** MACHINE DRIVER **********************************************************/
static MACHINE_CONFIG_START( gstriker, driver_device )
static MACHINE_CONFIG_START( gstriker, gstriker_state )
MCFG_CPU_ADD("maincpu", M68000, 10000000)
MCFG_CPU_PROGRAM_MAP(gstriker_map)
MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)
@ -585,7 +582,7 @@ static MACHINE_CONFIG_DERIVED( twrldc94, gstriker )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( vgoal, driver_device )
static MACHINE_CONFIG_START( vgoal, gstriker_state )
MCFG_CPU_ADD("maincpu", M68000, 16000000)
MCFG_CPU_PROGRAM_MAP(vgoal_map)
MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)
@ -830,34 +827,34 @@ the zooming.To use it,you should use Player 2 Start button to show the test scre
or to advance into the tests.
******************************************************************************************/
#define PC(_num_)\
work_ram[0x000/2] = (_num_ & 0xffff0000) >> 16;\
work_ram[0x002/2] = (_num_ & 0x0000ffff) >> 0;
state->work_ram[0x000/2] = (_num_ & 0xffff0000) >> 16;\
state->work_ram[0x002/2] = (_num_ & 0x0000ffff) >> 0;
static int gametype = 0;
static UINT16 mcu_data = 0;
static WRITE16_HANDLER( twrldc94_mcu_w )
{
mcu_data = data;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
state->mcu_data = data;
}
static READ16_HANDLER( twrldc94_mcu_r )
{
return mcu_data;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
return state->mcu_data;
}
static UINT16 prot_reg[2] = {0,0}; // current,last
static WRITE16_HANDLER( twrldc94_prot_reg_w )
{
prot_reg[1] = prot_reg[0];
prot_reg[0] = data;
gstriker_state *state = space->machine->driver_data<gstriker_state>();
state->prot_reg[1] = state->prot_reg[0];
state->prot_reg[0] = data;
if( ((prot_reg[1] & 2) == 2) && ((prot_reg[0] & 2) == 0) )
if( ((state->prot_reg[1] & 2) == 2) && ((state->prot_reg[0] & 2) == 0) )
{
switch( gametype )
switch( state->gametype )
{
case 1:
switch(mcu_data)
switch(state->mcu_data)
{
#define NULL_SUB 0x0000828E
case 0x53: PC(0x0000a4c); break; // boot -> main loop
@ -917,19 +914,19 @@ static WRITE16_HANDLER( twrldc94_prot_reg_w )
case 0x6f: PC(NULL_SUB); break;
default:
popmessage("Unknown MCU CMD %04x",mcu_data);
popmessage("Unknown MCU CMD %04x",state->mcu_data);
PC(NULL_SUB);
break;
}
break;
case 2:
switch(mcu_data)
switch(state->mcu_data)
{
case 0x53: PC(0x00000a5c); break; // POST
default:
popmessage("Unknown MCU CMD %04x",mcu_data);
popmessage("Unknown MCU CMD %04x",state->mcu_data);
PC(NULL_SUB);
break;
}
@ -937,7 +934,7 @@ static WRITE16_HANDLER( twrldc94_prot_reg_w )
case 3:
switch(mcu_data)
switch(state->mcu_data)
{
case 0x33: PC(0x00063416); break; // *after game over, is this right?
case 0x3d: PC(0x0006275C); break; // after sprite ram init, team select
@ -950,7 +947,7 @@ static WRITE16_HANDLER( twrldc94_prot_reg_w )
case 0x79: PC(0x0006072E); break; // after select, start match
default:
popmessage("Unknown MCU CMD %04x",mcu_data);
popmessage("Unknown MCU CMD %04x",state->mcu_data);
PC(0x00000586); // rts
break;
}
@ -961,11 +958,12 @@ static WRITE16_HANDLER( twrldc94_prot_reg_w )
static READ16_HANDLER( twrldc94_prot_reg_r )
{
gstriker_state *state = space->machine->driver_data<gstriker_state>();
// bit 0 is for debugging vgoalsoc?
// Setting it results in a hang with a digit displayed on screen
// For twrldc94, it just disables sound.
return prot_reg[0];
return state->prot_reg[0];
}
/*
@ -979,15 +977,15 @@ static READ16_HANDLER( twrldc94_prot_reg_r )
The tick count is usually set to 0x3c => it's driven off vblank?
*/
//work_ram[ (0xffe900 - 0xffc00) ]
#define COUNTER1_ENABLE work_ram[0x2900/2] >> 8
#define COUNTER2_ENABLE (work_ram[0x2900/2] & 0xff)
#define TICK_1 work_ram[0x2908/2]
#define TICKCOUNT_1 work_ram[0x290a/2]
#define TICK_2 work_ram[0x290c/2]
#define TICKCOUNT_3 work_ram[0x290e/2]
#define COUNTER_1 work_ram[0x2928/2]
#define COUNTER_2 work_ram[0x292a/2]
//state->work_ram[ (0xffe900 - 0xffc00) ]
#define COUNTER1_ENABLE state->work_ram[0x2900/2] >> 8
#define COUNTER2_ENABLE (state->work_ram[0x2900/2] & 0xff)
#define TICK_1 state->work_ram[0x2908/2]
#define TICKCOUNT_1 state->work_ram[0x290a/2]
#define TICK_2 state->work_ram[0x290c/2]
#define TICKCOUNT_3 state->work_ram[0x290e/2]
#define COUNTER_1 state->work_ram[0x2928/2]
#define COUNTER_2 state->work_ram[0x292a/2]
static READ16_HANDLER( vbl_toggle_r )
{
return 0xff;
@ -995,6 +993,7 @@ static READ16_HANDLER( vbl_toggle_r )
static WRITE16_HANDLER( vbl_toggle_w )
{
gstriker_state *state = space->machine->driver_data<gstriker_state>();
if( COUNTER1_ENABLE == 1 )
{
TICK_1 = (TICK_1 - 1) & 0xff; // 8bit
@ -1018,9 +1017,10 @@ static WRITE16_HANDLER( vbl_toggle_w )
static void mcu_init( running_machine *machine )
{
dmmy_8f_ret = 0xFFFF;
pending_command = 0;
mcu_data = 0;
gstriker_state *state = machine->driver_data<gstriker_state>();
state->dmmy_8f_ret = 0xFFFF;
state->pending_command = 0;
state->mcu_data = 0;
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20008a, 0x20008b, 0, 0, twrldc94_mcu_w);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20008a, 0x20008b, 0, 0, twrldc94_mcu_r);
@ -1031,19 +1031,22 @@ static void mcu_init( running_machine *machine )
static DRIVER_INIT( twrldc94 )
{
gametype = 1;
gstriker_state *state = machine->driver_data<gstriker_state>();
state->gametype = 1;
mcu_init( machine );
}
static DRIVER_INIT( twrldc94a )
{
gametype = 2;
gstriker_state *state = machine->driver_data<gstriker_state>();
state->gametype = 2;
mcu_init( machine );
}
static DRIVER_INIT( vgoalsoc )
{
gametype = 3;
gstriker_state *state = machine->driver_data<gstriker_state>();
state->gametype = 3;
mcu_init( machine );
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200090, 0x200091, 0, 0, vbl_toggle_w); // vblank toggle

View File

@ -87,7 +87,6 @@ L056-6 9A " " VLI-8-4 7A "
#define VBEND (16)
#define VBSTART (224+16)
static UINT8 *cop_io;
/*************************************
*
@ -105,12 +104,15 @@ public:
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
UINT8 * cop_io;
/* tilemaps */
tilemap_t * bg_tilemap;
/* sound state */
UINT8 sound[8];
int last;
};
@ -402,10 +404,10 @@ static WRITE8_DEVICE_HANDLER( speech_enable_w )
static WRITE8_HANDLER( ballon_enable_w )
{
static int last;
if (last != data)
looping_state *state = space->machine->driver_data<looping_state>();
if (state->last != data)
mame_printf_debug("ballon_enable_w = %d\n", data);
last = data;
state->last = data;
}
@ -438,18 +440,21 @@ static WRITE8_HANDLER( plr2_w )
static READ8_HANDLER( cop_io_r )
{
//looping_state *state = space->machine->driver_data<looping_state>();
// if (offset == 1) return space->machine->rand() & 0x01;
return 1; // cop_io[offset];
return 1; // state->cop_io[offset];
}
static WRITE8_HANDLER( cop_io_w )
{
cop_io[offset] = data;
looping_state *state = space->machine->driver_data<looping_state>();
state->cop_io[offset] = data;
if (offset == 0) logerror("%02x ",data);
}
static READ8_HANDLER( protection_r )
{
looping_state *state = space->machine->driver_data<looping_state>();
// The code reads ($7002) ($7004) alternately
// The result must change at least once every 10 reads
// A read from ($34b0 + result) must == $01
@ -468,7 +473,7 @@ static READ8_HANDLER( protection_r )
// cop write randomly fc (unfortunatly) but 61,67,b7,bf,db,e1,f3,fd,ff too and only these values
// missing something
if(cop_io[0] != 0xfc) return cop_io[0];
if(state->cop_io[0] != 0xfc) return state->cop_io[0];
return 0xff;
}
@ -882,11 +887,12 @@ ROM_END
static DRIVER_INIT( looping )
{
looping_state *state = machine->driver_data<looping_state>();
int length = machine->region("maincpu")->bytes();
UINT8 *rom = machine->region("maincpu")->base();
int i;
cop_io = auto_alloc_array(machine, UINT8, 0x08);
state->cop_io = auto_alloc_array(machine, UINT8, 0x08);
/* bitswap the TMS9995 ROMs */
for (i = 0; i < length; i++)

View File

@ -1470,7 +1470,7 @@ static READ64_HANDLER( model3_sys_r )
else logerror("m3_sys: Unk sys_r @ 0x10: mask = %x\n", (UINT32)mem_mask);
break;
case 0x18/8:
// printf("read state->irq_state %x (PC %x)\n", state->irq_state, cpu_get_pc(space->cpu));
// printf("read irq_state %x (PC %x)\n", state->irq_state, cpu_get_pc(space->cpu));
return (UINT64)state->irq_state<<56 | 0xff000000;
break;
}

View File

@ -1562,7 +1562,7 @@ static WRITE8_DEVICE_HANDLER( pia_ic8_portb_w )
static WRITE_LINE_DEVICE_HANDLER( pia_ic8_ca2_w )
{
mpu4_state *drvstate = device->machine->driver_data<mpu4_state>();
LOG_IC8(("%s: IC8 PIA write CA2 (drvstate->input_strobe bit 2 / LED C) %02X\n", device->machine->describe_context(), state & 0xFF));
LOG_IC8(("%s: IC8 PIA write CA2 (input_strobe bit 2 / LED C) %02X\n", device->machine->describe_context(), state & 0xFF));
drvstate->IC23GC = state;
ic23_update(drvstate);

View File

@ -171,19 +171,15 @@ Super Strong Warriors
#include "machine/ms32crpt.h"
#include "includes/ms32.h"
static UINT8 *ms32_nvram_8;
static UINT32 *ms32_mahjong_input_select;
static UINT32 to_main;
/********** READ INPUTS **********/
static CUSTOM_INPUT( mahjong_ctrl_r )
{
ms32_state *state = field->port->machine->driver_data<ms32_state>();
UINT32 mj_input;
switch (ms32_mahjong_input_select[0])
switch (state->mahjong_input_select[0])
{
case 0x01:
mj_input = input_port_read(field->port->machine, "MJ0");
@ -231,7 +227,8 @@ static WRITE32_HANDLER( ms32_sound_w )
static READ32_HANDLER( ms32_sound_r )
{
return to_main^0xff;
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->to_main^0xff;
}
static WRITE32_HANDLER( reset_sub_w )
@ -245,26 +242,110 @@ static WRITE32_HANDLER( reset_sub_w )
/********** MEMORY MAP **********/
static READ8_HANDLER( ms32_nvram_r8 ) { return ms32_nvram_8[offset]; }
static WRITE8_HANDLER( ms32_nvram_w8 ) { ms32_nvram_8[offset] = data; }
static READ8_HANDLER( ms32_priram_r8 ) { return ms32_priram_8[offset]; }
static WRITE8_HANDLER( ms32_priram_w8 ) { ms32_priram_8[offset] = data; }
static READ16_HANDLER( ms32_palram_r16 ) { return ms32_palram_16[offset]; }
static WRITE16_HANDLER( ms32_palram_w16 ) { COMBINE_DATA(&ms32_palram_16[offset]); }
static READ16_HANDLER( ms32_rozram_r16 ) { return ms32_rozram_16[offset]; }
static WRITE16_HANDLER( ms32_rozram_w16 ) { COMBINE_DATA(&ms32_rozram_16[offset]); tilemap_mark_tile_dirty(ms32_roz_tilemap,offset/2); }
static READ16_HANDLER( ms32_lineram_r16 ) { return ms32_lineram_16[offset]; }
static WRITE16_HANDLER( ms32_lineram_w16 ) { COMBINE_DATA(&ms32_lineram_16[offset]); }
static READ16_HANDLER( ms32_sprram_r16 ) { return ms32_sprram_16[offset]; }
static WRITE16_HANDLER( ms32_sprram_w16 ) { COMBINE_DATA(&ms32_sprram_16[offset]); }
static READ16_HANDLER( ms32_txram_r16 ) { return ms32_txram_16[offset]; }
static WRITE16_HANDLER( ms32_txram_w16 ) { COMBINE_DATA(&ms32_txram_16[offset]); tilemap_mark_tile_dirty(ms32_tx_tilemap,offset/2); }
static READ16_HANDLER( ms32_bgram_r16 ) { return ms32_bgram_16[offset]; }
static WRITE16_HANDLER( ms32_bgram_w16 ) { COMBINE_DATA(&ms32_bgram_16[offset]); tilemap_mark_tile_dirty(ms32_bg_tilemap,offset/2); tilemap_mark_tile_dirty(ms32_bg_tilemap_alt,offset/2); }
static READ8_HANDLER( ms32_nvram_r8 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->nvram_8[offset];
}
static WRITE8_HANDLER( ms32_nvram_w8 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
state->nvram_8[offset] = data;
}
static READ8_HANDLER( ms32_priram_r8 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->priram_8[offset];
}
static WRITE8_HANDLER( ms32_priram_w8 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
state->priram_8[offset] = data;
}
static READ16_HANDLER( ms32_palram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->palram_16[offset];
}
static WRITE16_HANDLER( ms32_palram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->palram_16[offset]);
}
static READ16_HANDLER( ms32_rozram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->rozram_16[offset];
}
static WRITE16_HANDLER( ms32_rozram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->rozram_16[offset]);
tilemap_mark_tile_dirty(state->roz_tilemap,offset/2);
}
static READ16_HANDLER( ms32_lineram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->lineram_16[offset];
}
static WRITE16_HANDLER( ms32_lineram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->lineram_16[offset]);
}
static READ16_HANDLER( ms32_sprram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->sprram_16[offset];
}
static WRITE16_HANDLER( ms32_sprram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->sprram_16[offset]);
}
static READ16_HANDLER( ms32_txram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->txram_16[offset];
}
static WRITE16_HANDLER( ms32_txram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->txram_16[offset]);
tilemap_mark_tile_dirty(state->tx_tilemap,offset/2);
}
static READ16_HANDLER( ms32_bgram_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->bgram_16[offset];
}
static WRITE16_HANDLER( ms32_bgram_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->bgram_16[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap,offset/2);
tilemap_mark_tile_dirty(state->bg_tilemap_alt,offset/2);
}
static WRITE32_HANDLER( pip_w )
{
ms32_tilemaplayoutcontrol = data;
ms32_state *state = space->machine->driver_data<ms32_state>();
state->tilemaplayoutcontrol = data;
if ((data) && (data != 1))
popmessage("fce00a7c = %02x",data);
@ -288,7 +369,7 @@ static ADDRESS_MAP_START( ms32_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0xc2c00000, 0xc2c07fff) AM_READWRITE16(ms32_txram_r16, ms32_txram_w16, 0x0000ffff) AM_MIRROR(0x3c1f0000) /* txram is 16-bit wide, 0x4000 in size */
AM_RANGE(0xc2c08000, 0xc2c0ffff) AM_READWRITE16(ms32_bgram_r16, ms32_bgram_w16, 0x0000ffff) AM_MIRROR(0x3c1f0000) /* bgram is 16-bit wide, 0x4000 in size */
/* AM_RANGE(0xc2c10000, 0xc2dfffff) // mirrors of txram / bg, handled above */
AM_RANGE(0xc2e00000, 0xc2e1ffff) AM_RAM AM_BASE(&ms32_mainram) AM_MIRROR(0x3c0e0000) /* mainram is 32-bit wide, 0x20000 in size */
AM_RANGE(0xc2e00000, 0xc2e1ffff) AM_RAM AM_BASE_MEMBER(ms32_state, mainram) AM_MIRROR(0x3c0e0000) /* mainram is 32-bit wide, 0x20000 in size */
AM_RANGE(0xc3e00000, 0xc3ffffff) AM_ROMBANK("bank1") AM_MIRROR(0x3c000000) // ROM is 32-bit wide, 0x200000 in size */
/* todo: clean up the mapping of these */
@ -302,21 +383,30 @@ static ADDRESS_MAP_START( ms32_map, ADDRESS_SPACE_PROGRAM, 32 )
// AM_RANGE(0xfce00000, 0xfce0007f) AM_WRITEONLY AM_BASE(&ms32_fce00000) /* registers not ram? */
AM_RANGE(0xfce00000, 0xfce00003) AM_WRITE(ms32_gfxctrl_w) /* flip screen + other unknown bits */
AM_RANGE(0xfce00280, 0xfce0028f) AM_WRITE(ms32_brightness_w) // global brightness control
/**/AM_RANGE(0xfce00600, 0xfce0065f) AM_RAM AM_BASE(&ms32_roz_ctrl) /* roz control registers */
/**/AM_RANGE(0xfce00a00, 0xfce00a17) AM_RAM AM_BASE(&ms32_tx_scroll) /* tx layer scroll */
/**/AM_RANGE(0xfce00a20, 0xfce00a37) AM_RAM AM_BASE(&ms32_bg_scroll) /* bg layer scroll */
/**/AM_RANGE(0xfce00600, 0xfce0065f) AM_RAM AM_BASE_MEMBER(ms32_state, roz_ctrl) /* roz control registers */
/**/AM_RANGE(0xfce00a00, 0xfce00a17) AM_RAM AM_BASE_MEMBER(ms32_state, tx_scroll) /* tx layer scroll */
/**/AM_RANGE(0xfce00a20, 0xfce00a37) AM_RAM AM_BASE_MEMBER(ms32_state, bg_scroll) /* bg layer scroll */
AM_RANGE(0xfce00a7c, 0xfce00a7f) AM_WRITE(pip_w) // ??? layer related? seems to be always 0
// AM_RANGE(0xfce00e00, 0xfce00e03) coin counters + something else
AM_RANGE(0xfd000000, 0xfd000003) AM_READ(ms32_sound_r)
AM_RANGE(0xfd1c0000, 0xfd1c0003) AM_WRITEONLY AM_BASE(&ms32_mahjong_input_select)
AM_RANGE(0xfd1c0000, 0xfd1c0003) AM_WRITEONLY AM_BASE_MEMBER(ms32_state, mahjong_input_select)
ADDRESS_MAP_END
/* F1 Super Battle has an extra linemap for the road, and am unknown maths chip (mcu?) handling perspective calculations for the road / corners etc. */
/* it should use it's own memory map */
static WRITE16_HANDLER( ms32_extra_w16 ) { COMBINE_DATA(&f1superb_extraram_16[offset]); tilemap_mark_tile_dirty(ms32_extra_tilemap,offset/2); }
static READ16_HANDLER( ms32_extra_r16 ) { return f1superb_extraram_16[offset]; }
static WRITE16_HANDLER( ms32_extra_w16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
COMBINE_DATA(&state->f1superb_extraram_16[offset]);
tilemap_mark_tile_dirty(state->extra_tilemap,offset/2);
}
static READ16_HANDLER( ms32_extra_r16 )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
return state->f1superb_extraram_16[offset];
}
static void irq_raise(running_machine *machine, int level);
@ -1205,28 +1295,30 @@ GFXDECODE_END
10 - 6d4 - big, vbl?
*/
static UINT16 irqreq;
static IRQ_CALLBACK(irq_callback)
{
ms32_state *state = device->machine->driver_data<ms32_state>();
int i;
for(i=15; i>=0 && !(irqreq & (1<<i)); i--);
irqreq &= ~(1<<i);
if(!irqreq)
for(i=15; i>=0 && !(state->irqreq & (1<<i)); i--);
state->irqreq &= ~(1<<i);
if(!state->irqreq)
cpu_set_input_line(device, 0, CLEAR_LINE);
return i;
}
static void irq_init(running_machine *machine)
{
irqreq = 0;
ms32_state *state = machine->driver_data<ms32_state>();
state->irqreq = 0;
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
cpu_set_irq_callback(machine->device("maincpu"), irq_callback);
}
static void irq_raise(running_machine *machine, int level)
{
irqreq |= (1<<level);
ms32_state *state = machine->driver_data<ms32_state>();
state->irqreq |= (1<<level);
cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE);
}
@ -1282,7 +1374,8 @@ static WRITE8_HANDLER( ms32_snd_bank_w )
static WRITE8_HANDLER( to_main_w )
{
to_main=data;
ms32_state *state = space->machine->driver_data<ms32_state>();
state->to_main=data;
irq_raise(space->machine, 1);
}
@ -1313,7 +1406,7 @@ static MACHINE_RESET( ms32 )
/********** MACHINE DRIVER **********/
static MACHINE_CONFIG_START( ms32, driver_device )
static MACHINE_CONFIG_START( ms32, ms32_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V70, 20000000) // 20MHz
@ -2125,14 +2218,16 @@ ROM_END
static void configure_banks(running_machine *machine)
{
state_save_register_global(machine, to_main);
ms32_state *state = machine->driver_data<ms32_state>();
state_save_register_global(machine, state->to_main);
memory_configure_bank(machine, "bank4", 0, 16, machine->region("audiocpu")->base() + 0x14000, 0x4000);
memory_configure_bank(machine, "bank5", 0, 16, machine->region("audiocpu")->base() + 0x14000, 0x4000);
}
static DRIVER_INIT( ms32_common )
{
ms32_nvram_8 = auto_alloc_array(machine, UINT8, 0x2000);
ms32_state *state = machine->driver_data<ms32_state>();
state->nvram_8 = auto_alloc_array(machine, UINT8, 0x2000);
configure_banks(machine);
}

View File

@ -168,13 +168,6 @@ OSC3: 48.384MHz
#include "includes/namcofl.h"
static emu_timer *raster_interrupt_timer;
static UINT32 *namcofl_workram;
static UINT16 *namcofl_shareram;
static UINT8 mcu_port6;
static READ32_HANDLER( fl_unk1_r )
{
return 0xffffffff;
@ -192,23 +185,25 @@ static READ32_HANDLER( namcofl_sysreg_r )
static WRITE32_HANDLER( namcofl_sysreg_w )
{
namcofl_state *state = space->machine->driver_data<namcofl_state>();
if ((offset == 2) && ACCESSING_BITS_0_7) // address space configuration
{
if (data == 0) // RAM at 00000000, ROM at 10000000
{
memory_set_bankptr(space->machine, "bank1", namcofl_workram );
memory_set_bankptr(space->machine, "bank1", state->workram );
memory_set_bankptr(space->machine, "bank2", space->machine->region("maincpu")->base() );
}
else // ROM at 00000000, RAM at 10000000
{
memory_set_bankptr(space->machine, "bank1", space->machine->region("maincpu")->base() );
memory_set_bankptr(space->machine, "bank2", namcofl_workram );
memory_set_bankptr(space->machine, "bank2", state->workram );
}
}
}
static WRITE32_HANDLER( namcofl_paletteram_w )
{
namcofl_state *state = space->machine->driver_data<namcofl_state>();
COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
if ((offset == 0x1808/4) && ACCESSING_BITS_16_31)
@ -216,21 +211,23 @@ static WRITE32_HANDLER( namcofl_paletteram_w )
UINT16 v = space->machine->generic.paletteram.u32[offset] >> 16;
UINT16 triggerscanline=(((v>>8)&0xff)|((v&0xff)<<8))-(32+1);
raster_interrupt_timer->adjust(space->machine->primary_screen->time_until_pos(triggerscanline));
state->raster_interrupt_timer->adjust(space->machine->primary_screen->time_until_pos(triggerscanline));
}
}
static READ32_HANDLER( namcofl_share_r )
{
return (namcofl_shareram[offset*2+1] << 16) | namcofl_shareram[offset*2];
namcofl_state *state = space->machine->driver_data<namcofl_state>();
return (state->shareram[offset*2+1] << 16) | state->shareram[offset*2];
}
static WRITE32_HANDLER( namcofl_share_w )
{
COMBINE_DATA(namcofl_shareram+offset*2);
namcofl_state *state = space->machine->driver_data<namcofl_state>();
COMBINE_DATA(state->shareram+offset*2);
data >>= 16;
mem_mask >>= 16;
COMBINE_DATA(namcofl_shareram+offset*2+1);
COMBINE_DATA(state->shareram+offset*2+1);
}
static ADDRESS_MAP_START( namcofl_mem, ADDRESS_SPACE_PROGRAM, 32 )
@ -256,6 +253,7 @@ ADDRESS_MAP_END
static WRITE16_HANDLER( mcu_shared_w )
{
namcofl_state *state = space->machine->driver_data<namcofl_state>();
// HACK! Many games data ROM routines redirect the vector from the sound command read to an RTS.
// This needs more investigation. nebulray and vshoot do NOT do this.
// Timers A2 and A3 are set up in "external input counter" mode, this may be related.
@ -266,7 +264,7 @@ static WRITE16_HANDLER( mcu_shared_w )
}
#endif
COMBINE_DATA(&namcofl_shareram[offset]);
COMBINE_DATA(&state->shareram[offset]);
// C75 BIOS has a very short window on the CPU sync signal, so immediately let the i960 at it
if ((offset == 0x6000/2) && (data & 0x80))
@ -278,17 +276,20 @@ static WRITE16_HANDLER( mcu_shared_w )
static READ8_HANDLER( port6_r )
{
return mcu_port6;
namcofl_state *state = space->machine->driver_data<namcofl_state>();
return state->mcu_port6;
}
static WRITE8_HANDLER( port6_w )
{
mcu_port6 = data;
namcofl_state *state = space->machine->driver_data<namcofl_state>();
state->mcu_port6 = data;
}
static READ8_HANDLER( port7_r )
{
switch (mcu_port6 & 0xf0)
namcofl_state *state = space->machine->driver_data<namcofl_state>();
switch (state->mcu_port6 & 0xf0)
{
case 0x00:
return input_port_read(space->machine, "IN0");
@ -332,7 +333,7 @@ static READ8_HANDLER(dac0_r) { return 0xff; }
static ADDRESS_MAP_START( namcoc75_am, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x002000, 0x002fff) AM_DEVREADWRITE("c352", c352_r, c352_w)
AM_RANGE(0x004000, 0x00bfff) AM_RAM_WRITE(mcu_shared_w) AM_BASE(&namcofl_shareram)
AM_RANGE(0x004000, 0x00bfff) AM_RAM_WRITE(mcu_shared_w) AM_BASE_MEMBER(namcofl_state, shareram)
AM_RANGE(0x00c000, 0x00ffff) AM_ROM AM_REGION("c75", 0)
AM_RANGE(0x200000, 0x27ffff) AM_ROM AM_REGION("c75data", 0)
ADDRESS_MAP_END
@ -548,9 +549,10 @@ static TIMER_CALLBACK( vblank_interrupt_callback )
static TIMER_CALLBACK( raster_interrupt_callback )
{
namcofl_state *state = machine->driver_data<namcofl_state>();
machine->primary_screen->update_partial(machine->primary_screen->vpos());
cputag_set_input_line(machine, "maincpu", I960_IRQ1, ASSERT_LINE);
raster_interrupt_timer->adjust(machine->primary_screen->frame_period());
state->raster_interrupt_timer->adjust(machine->primary_screen->frame_period());
}
static INTERRUPT_GEN( mcu_interrupt )
@ -571,23 +573,25 @@ static INTERRUPT_GEN( mcu_interrupt )
static MACHINE_START( namcofl )
{
raster_interrupt_timer = machine->scheduler().timer_alloc(FUNC(raster_interrupt_callback));
namcofl_state *state = machine->driver_data<namcofl_state>();
state->raster_interrupt_timer = machine->scheduler().timer_alloc(FUNC(raster_interrupt_callback));
}
static MACHINE_RESET( namcofl )
{
namcofl_state *state = machine->driver_data<namcofl_state>();
machine->scheduler().timer_set(machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 3), FUNC(network_interrupt_callback));
machine->scheduler().timer_set(machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 1), FUNC(vblank_interrupt_callback));
memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() );
memory_set_bankptr(machine, "bank2", namcofl_workram );
memory_set_bankptr(machine, "bank2", state->workram );
memset(namcofl_workram, 0x00, 0x100000);
memset(state->workram, 0x00, 0x100000);
}
static MACHINE_CONFIG_START( namcofl, driver_device )
static MACHINE_CONFIG_START( namcofl, namcofl_state )
MCFG_CPU_ADD("maincpu", I960, 20000000) // i80960KA-20 == 20 MHz part
MCFG_CPU_PROGRAM_MAP(namcofl_mem)
@ -806,10 +810,11 @@ ROM_END
static void namcofl_common_init(running_machine *machine)
{
namcofl_workram = auto_alloc_array(machine, UINT32, 0x100000/4);
namcofl_state *state = machine->driver_data<namcofl_state>();
state->workram = auto_alloc_array(machine, UINT32, 0x100000/4);
memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() );
memory_set_bankptr(machine, "bank2", namcofl_workram );
memory_set_bankptr(machine, "bank2", state->workram );
}
static DRIVER_INIT(speedrcr)

View File

@ -703,7 +703,7 @@ nth_byte32( const UINT32 *pSource, int which )
/**************************************************************************************************************/
static int (*mpCodeToTile)( int code ); /* sprite banking callback */
static int (*mpCodeToTile)( running_machine *machine, int code ); /* sprite banking callback */
static int mGfxC355; /* gfx bank for sprites */
/**
@ -877,7 +877,7 @@ draw_spriteC355(running_machine *machine, bitmap_t *bitmap, const rectangle *cli
bitmap,
&clip,
machine->gfx[mGfxC355],
mpCodeToTile(tile) + offset,
mpCodeToTile(machine, tile) + offset,
color,
flipx,flipy,
sx,sy,
@ -900,13 +900,13 @@ draw_spriteC355(running_machine *machine, bitmap_t *bitmap, const rectangle *cli
} /* draw_spriteC355 */
static int DefaultCodeToTile( int code )
static int DefaultCodeToTile( running_machine *machine, int code )
{
return code;
}
void
namco_obj_init( running_machine *machine, int gfxbank, int palXOR, int (*codeToTile)( int code ) )
namco_obj_init( running_machine *machine, int gfxbank, int palXOR, int (*codeToTile)( running_machine *machine, int code ) )
{
mGfxC355 = gfxbank;
mPalXOR = palXOR;

View File

@ -347,8 +347,6 @@ C - uses sub board with support for player 3 and 4 controls
#include "machine/nvram.h"
#include "includes/namcos1.h"
static int dac0_value, dac1_value, dac0_gain, dac1_gain;
/**********************************************************************/
@ -385,41 +383,46 @@ static WRITE8_HANDLER( namcos1_coin_w )
static void namcos1_update_DACs(running_machine *machine)
{
dac_signed_data_16_w(machine->device("dac"),0x8000 + (dac0_value * dac0_gain) + (dac1_value * dac1_gain));
namcos1_state *state = machine->driver_data<namcos1_state>();
dac_signed_data_16_w(machine->device("dac"),0x8000 + (state->dac0_value * state->dac0_gain) + (state->dac1_value * state->dac1_gain));
}
void namcos1_init_DACs(void)
void namcos1_init_DACs(running_machine *machine)
{
dac0_value = 0;
dac1_value = 0;
dac0_gain=0x80;
dac1_gain=0x80;
namcos1_state *state = machine->driver_data<namcos1_state>();
state->dac0_value = 0;
state->dac1_value = 0;
state->dac0_gain=0x80;
state->dac1_gain=0x80;
}
static WRITE8_HANDLER( namcos1_dac_gain_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
int value;
/* DAC0 (bits 0,2) */
value = (data & 1) | ((data >> 1) & 2); /* GAIN0,GAIN1 */
dac0_gain = 0x20 * (value+1);
state->dac0_gain = 0x20 * (value+1);
/* DAC1 (bits 3,4) */
value = (data >> 3) & 3; /* GAIN2,GAIN3 */
dac1_gain = 0x20 * (value+1);
state->dac1_gain = 0x20 * (value+1);
namcos1_update_DACs(space->machine);
}
static WRITE8_HANDLER( namcos1_dac0_w )
{
dac0_value = data - 0x80; /* shift zero point */
namcos1_state *state = space->machine->driver_data<namcos1_state>();
state->dac0_value = data - 0x80; /* shift zero point */
namcos1_update_DACs(space->machine);
}
static WRITE8_HANDLER( namcos1_dac1_w )
{
dac1_value = data - 0x80; /* shift zero point */
namcos1_state *state = space->machine->driver_data<namcos1_state>();
state->dac1_value = data - 0x80; /* shift zero point */
namcos1_update_DACs(space->machine);
}
@ -1078,7 +1081,7 @@ static const namco_interface namco_config =
LPF info : Fco = 3.3KHz , g = -12dB/oct
*/
static MACHINE_CONFIG_START( ns1, driver_device )
static MACHINE_CONFIG_START( ns1, namcos1_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6809,49152000/32)

View File

@ -143,12 +143,7 @@ TODO:
//#define NE555_FREQUENCY (1.0f / (0.693 * (560 + 2*51) * 0.1e-6)) // theoretical: this gives 21.8kHz which is too high
static const INT16* ninjakd2_sampledata;
static UINT8 omegaf_io_protection[3];
static UINT8 omegaf_io_protection_input;
static int omegaf_io_protection_tic;
static void omegaf_io_protection_reset(void);
static void omegaf_io_protection_reset(running_machine *machine);
static INTERRUPT_GEN( ninjakd2_interrupt )
@ -181,7 +176,7 @@ static MACHINE_RESET( omegaf )
{
robokid_init_banks(machine);
omegaf_io_protection_reset();
omegaf_io_protection_reset(machine);
}
@ -211,6 +206,7 @@ static WRITE8_HANDLER( ninjakd2_soundreset_w )
static SAMPLES_START( ninjakd2_init_samples )
{
ninjakd2_state *state = device->machine->driver_data<ninjakd2_state>();
running_machine *machine = device->machine;
const UINT8* const rom = machine->region("pcm")->base();
const int length = machine->region("pcm")->bytes();
@ -222,11 +218,12 @@ static SAMPLES_START( ninjakd2_init_samples )
for (i = 0; i < length; ++i)
sampledata[i] = rom[i] << 7;
ninjakd2_sampledata = sampledata;
state->sampledata = sampledata;
}
static WRITE8_HANDLER( ninjakd2_pcm_play_w )
{
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
device_t *samples = space->machine->device("pcm");
const UINT8* const rom = space->machine->region("pcm")->base();
@ -245,7 +242,7 @@ static WRITE8_HANDLER( ninjakd2_pcm_play_w )
++end;
if (end - start)
sample_start_raw(samples, 0, &ninjakd2_sampledata[start], end - start, NE555_FREQUENCY, 0);
sample_start_raw(samples, 0, &state->sampledata[start], end - start, NE555_FREQUENCY, 0);
else
sample_stop(samples, 0);
}
@ -259,36 +256,38 @@ static WRITE8_HANDLER( ninjakd2_pcm_play_w )
*
*************************************/
void omegaf_io_protection_reset(void)
static void omegaf_io_protection_reset(running_machine *machine)
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
// make sure protection starts in a known state
omegaf_io_protection[0] = 0;
omegaf_io_protection[1] = 0;
omegaf_io_protection[2] = 0;
omegaf_io_protection_input = 0;
omegaf_io_protection_tic = 0;
state->omegaf_io_protection[0] = 0;
state->omegaf_io_protection[1] = 0;
state->omegaf_io_protection[2] = 0;
state->omegaf_io_protection_input = 0;
state->omegaf_io_protection_tic = 0;
}
static READ8_HANDLER( omegaf_io_protection_r )
{
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
UINT8 result = 0xff;
switch (omegaf_io_protection[1] & 3)
switch (state->omegaf_io_protection[1] & 3)
{
case 0:
switch (offset)
{
case 1:
switch (omegaf_io_protection[0] & 0xe0)
switch (state->omegaf_io_protection[0] & 0xe0)
{
case 0x00:
if (++omegaf_io_protection_tic & 1)
if (++state->omegaf_io_protection_tic & 1)
{
result = 0x00;
}
else
{
switch (omegaf_io_protection_input)
switch (state->omegaf_io_protection_input)
{
// first interrogation
// this happens just after setting mode 0.
@ -319,11 +318,11 @@ static READ8_HANDLER( omegaf_io_protection_r )
break;
case 0x80:
result = 0x20 | (omegaf_io_protection_input & 0x1f);
result = 0x20 | (state->omegaf_io_protection_input & 0x1f);
break;
case 0xc0:
result = 0x60 | (omegaf_io_protection_input & 0x1f);
result = 0x60 | (state->omegaf_io_protection_input & 0x1f);
break;
}
break;
@ -354,14 +353,15 @@ static READ8_HANDLER( omegaf_io_protection_r )
static WRITE8_HANDLER( omegaf_io_protection_w )
{
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
// load parameter on c006 bit 0 rise transition
if (offset == 2 && (data & 1) && !(omegaf_io_protection[2] & 1))
if (offset == 2 && (data & 1) && !(state->omegaf_io_protection[2] & 1))
{
logerror("loading protection input %02x\n", omegaf_io_protection[0]);
omegaf_io_protection_input = omegaf_io_protection[0];
logerror("loading protection input %02x\n", state->omegaf_io_protection[0]);
state->omegaf_io_protection_input = state->omegaf_io_protection[0];
}
omegaf_io_protection[offset] = data;
state->omegaf_io_protection[offset] = data;
}
@ -386,8 +386,8 @@ static ADDRESS_MAP_START( ninjakd2_main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc203, 0xc203) AM_WRITE(ninjakd2_sprite_overdraw_w)
AM_RANGE(0xc208, 0xc20c) AM_WRITE(ninjakd2_bg_ctrl_w) // scroll + enable
AM_RANGE(0xc800, 0xcdff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_be_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE(&ninjakd2_fg_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(ninjakd2_bgvideoram_w) AM_BASE(&ninjakd2_bg_videoram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, fg_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(ninjakd2_bgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, bg_videoram)
AM_RANGE(0xe000, 0xf9ff) AM_RAM
AM_RANGE(0xfa00, 0xffff) AM_RAM AM_BASE_GENERIC(spriteram)
ADDRESS_MAP_END
@ -398,8 +398,8 @@ static ADDRESS_MAP_START( mnight_main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xd9ff) AM_RAM
AM_RANGE(0xda00, 0xdfff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ninjakd2_bgvideoram_w) AM_BASE(&ninjakd2_bg_videoram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE(&ninjakd2_fg_videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ninjakd2_bgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, bg_videoram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, fg_videoram)
AM_RANGE(0xf000, 0xf5ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_be_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xf800, 0xf800) AM_READ_PORT("KEYCOIN")
AM_RANGE(0xf801, 0xf801) AM_READ_PORT("PAD1")
@ -418,7 +418,7 @@ static ADDRESS_MAP_START( robokid_main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_be_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE(&ninjakd2_fg_videoram)
AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, fg_videoram)
AM_RANGE(0xd000, 0xd3ff) AM_READWRITE(robokid_bg2_videoram_r, robokid_bg2_videoram_w) // banked
AM_RANGE(0xd400, 0xd7ff) AM_READWRITE(robokid_bg1_videoram_r, robokid_bg1_videoram_w) // banked
AM_RANGE(0xd800, 0xdbff) AM_READWRITE(robokid_bg0_videoram_r, robokid_bg0_videoram_w) // banked
@ -462,7 +462,7 @@ static ADDRESS_MAP_START( omegaf_main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc400, 0xc7ff) AM_READWRITE(robokid_bg0_videoram_r, robokid_bg0_videoram_w) // banked
AM_RANGE(0xc800, 0xcbff) AM_READWRITE(robokid_bg1_videoram_r, robokid_bg1_videoram_w) // banked
AM_RANGE(0xcc00, 0xcfff) AM_READWRITE(robokid_bg2_videoram_r, robokid_bg2_videoram_w) // banked
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE(&ninjakd2_fg_videoram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ninjakd2_fgvideoram_w) AM_BASE_MEMBER(ninjakd2_state, fg_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_be_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xe000, 0xf9ff) AM_RAM
AM_RANGE(0xfa00, 0xffff) AM_RAM AM_BASE_GENERIC(spriteram)
@ -905,7 +905,7 @@ static const samples_interface ninjakd2_samples_interface =
*
*************************************/
static MACHINE_CONFIG_START( ninjakd2, driver_device )
static MACHINE_CONFIG_START( ninjakd2, ninjakd2_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK_12/2) /* verified */

View File

@ -132,23 +132,25 @@ e000 - e7ff R/W Work RAM
*
*************************************/
static UINT8 ninjakun_io_a002_ctrl;
static CUSTOM_INPUT( ninjakun_io_A002_ctrl_r )
{
return ninjakun_io_a002_ctrl;
nova2001_state *state = field->port->machine->driver_data<nova2001_state>();
return state->ninjakun_io_a002_ctrl;
}
static WRITE8_HANDLER( ninjakun_cpu1_io_A002_w )
{
if( data == 0x80 ) ninjakun_io_a002_ctrl |= 0x01;
if( data == 0x40 ) ninjakun_io_a002_ctrl &= ~0x02;
nova2001_state *state = space->machine->driver_data<nova2001_state>();
if( data == 0x80 ) state->ninjakun_io_a002_ctrl |= 0x01;
if( data == 0x40 ) state->ninjakun_io_a002_ctrl &= ~0x02;
}
static WRITE8_HANDLER( ninjakun_cpu2_io_A002_w )
{
if( data == 0x40 ) ninjakun_io_a002_ctrl |= 0x02;
if( data == 0x80 ) ninjakun_io_a002_ctrl &= ~0x01;
nova2001_state *state = space->machine->driver_data<nova2001_state>();
if( data == 0x40 ) state->ninjakun_io_a002_ctrl |= 0x02;
if( data == 0x80 ) state->ninjakun_io_a002_ctrl &= ~0x01;
}
@ -161,8 +163,9 @@ static WRITE8_HANDLER( ninjakun_cpu2_io_A002_w )
static MACHINE_START( ninjakun )
{
nova2001_state *state = machine->driver_data<nova2001_state>();
/* Save State Stuff */
state_save_register_global(machine, ninjakun_io_a002_ctrl);
state_save_register_global(machine, state->ninjakun_io_a002_ctrl);
}
@ -175,8 +178,8 @@ static MACHINE_START( ninjakun )
static ADDRESS_MAP_START( nova2001_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE(&nova2001_fg_videoram)
AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(nova2001_bg_videoram_w) AM_BASE(&nova2001_bg_videoram)
AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE_MEMBER(nova2001_state, fg_videoram)
AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(nova2001_bg_videoram_w) AM_BASE_MEMBER(nova2001_state, bg_videoram)
AM_RANGE(0xb000, 0xb7ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xb800, 0xbfff) AM_WRITE(nova2001_flipscreen_w)
AM_RANGE(0xc000, 0xc000) AM_DEVREADWRITE("ay1", ay8910_r, ay8910_data_w)
@ -202,8 +205,8 @@ static ADDRESS_MAP_START( ninjakun_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1")
AM_RANGE(0xa002, 0xa002) AM_READ_PORT("IN2") AM_WRITE(ninjakun_cpu1_io_A002_w)
AM_RANGE(0xa003, 0xa003) AM_WRITE(pkunwar_flipscreen_w)
AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE(&nova2001_fg_videoram) AM_SHARE("share1")
AM_RANGE(0xc800, 0xcfff) AM_READWRITE(ninjakun_bg_videoram_r, ninjakun_bg_videoram_w) AM_BASE(&nova2001_bg_videoram) AM_SHARE("share2")
AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE_MEMBER(nova2001_state, fg_videoram) AM_SHARE("share1")
AM_RANGE(0xc800, 0xcfff) AM_READWRITE(ninjakun_bg_videoram_r, ninjakun_bg_videoram_w) AM_BASE_MEMBER(nova2001_state, bg_videoram) AM_SHARE("share2")
AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_GENERIC(spriteram) AM_SHARE("share3")
AM_RANGE(0xd800, 0xd9ff) AM_RAM_WRITE(ninjakun_paletteram_w) AM_BASE_GENERIC(paletteram) AM_SHARE("share4")
AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_SHARE("share5")
@ -233,7 +236,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( pkunwar_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(nova2001_bg_videoram_w) AM_BASE(&nova2001_bg_videoram)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(nova2001_bg_videoram_w) AM_BASE_MEMBER(nova2001_state, bg_videoram)
AM_RANGE(0xa000, 0xa001) AM_DEVWRITE("ay1", ay8910_address_data_w)
AM_RANGE(0xa001, 0xa001) AM_DEVREAD("ay1", ay8910_r)
AM_RANGE(0xa002, 0xa003) AM_DEVWRITE("ay2", ay8910_address_data_w)
@ -251,8 +254,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( raiders5_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE(&nova2001_fg_videoram)
AM_RANGE(0x9000, 0x97ff) AM_READWRITE(ninjakun_bg_videoram_r, ninjakun_bg_videoram_w) AM_BASE(&nova2001_bg_videoram)
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(nova2001_fg_videoram_w) AM_BASE_MEMBER(nova2001_state, fg_videoram)
AM_RANGE(0x9000, 0x97ff) AM_READWRITE(ninjakun_bg_videoram_r, ninjakun_bg_videoram_w) AM_BASE_MEMBER(nova2001_state, bg_videoram)
AM_RANGE(0xa000, 0xa000) AM_WRITE(nova2001_scroll_x_w)
AM_RANGE(0xa001, 0xa001) AM_WRITE(nova2001_scroll_y_w)
AM_RANGE(0xa002, 0xa002) AM_WRITE(pkunwar_flipscreen_w)
@ -680,7 +683,7 @@ static const ay8910_interface pkunwar_ay8910_interface_2 =
*
*************************************/
static MACHINE_CONFIG_START( nova2001, driver_device )
static MACHINE_CONFIG_START( nova2001, nova2001_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz verified on schematics
@ -713,7 +716,7 @@ static MACHINE_CONFIG_START( nova2001, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( ninjakun, driver_device )
static MACHINE_CONFIG_START( ninjakun, nova2001_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz
@ -754,7 +757,7 @@ static MACHINE_CONFIG_START( ninjakun, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( pkunwar, driver_device )
static MACHINE_CONFIG_START( pkunwar, nova2001_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz
@ -788,7 +791,7 @@ static MACHINE_CONFIG_START( pkunwar, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( raiders5, driver_device )
static MACHINE_CONFIG_START( raiders5, nova2001_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz

View File

@ -112,7 +112,8 @@ $8000 - $ffff ROM
/********************************************************************************************/
static struct renegade_adpcm_state
typedef struct _renegade_adpcm_state renegade_adpcm_state;
struct _renegade_adpcm_state
{
adpcm_state adpcm;
sound_stream *stream;
@ -120,11 +121,21 @@ static struct renegade_adpcm_state
UINT8 nibble;
UINT8 playing;
UINT8 *base;
} renegade_adpcm;
};
DECLARE_LEGACY_SOUND_DEVICE(RENEGADE_ADPCM, renegade_adpcm);
INLINE renegade_adpcm_state *get_safe_token(device_t *device)
{
assert(device != NULL);
assert(device->type() == RENEGADE_ADPCM);
return (renegade_adpcm_state *)downcast<legacy_device_base *>(device)->token();
}
static STREAM_UPDATE( renegade_adpcm_callback )
{
struct renegade_adpcm_state *state = (struct renegade_adpcm_state *)param;
renegade_adpcm_state *state = (renegade_adpcm_state *)param;
stream_sample_t *dest = outputs[0];
while (state->playing && samples > 0)
@ -151,11 +162,10 @@ static STREAM_UPDATE( renegade_adpcm_callback )
static DEVICE_START( renegade_adpcm )
{
running_machine *machine = device->machine;
struct renegade_adpcm_state *state = &renegade_adpcm;
renegade_adpcm_state *state = get_safe_token(device);
state->playing = 0;
state->stream = device->machine->sound().stream_alloc(*device, 0, 1, device->clock(), state, renegade_adpcm_callback);
state->base = machine->region("adpcm")->base();
state->base = device->machine->region("adpcm")->base();
state->adpcm.reset();
}
@ -163,6 +173,9 @@ DEVICE_GET_INFO( renegade_adpcm )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(renegade_adpcm_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(renegade_adpcm);break;
@ -172,12 +185,12 @@ DEVICE_GET_INFO( renegade_adpcm )
}
}
DECLARE_LEGACY_SOUND_DEVICE(RENEGADE_ADPCM, renegade_adpcm);
DEFINE_LEGACY_SOUND_DEVICE(RENEGADE_ADPCM, renegade_adpcm);
static WRITE8_HANDLER( adpcm_play_w )
static WRITE8_DEVICE_HANDLER( adpcm_play_w )
{
renegade_adpcm_state *state = get_safe_token(device);
int offs = (data - 0x2c) * 0x2000;
int len = 0x2000 * 2;
@ -187,13 +200,13 @@ static WRITE8_HANDLER( adpcm_play_w )
if (offs >= 0 && offs+len <= 0x20000)
{
renegade_adpcm.stream->update();
renegade_adpcm.adpcm.reset();
state->stream->update();
state->adpcm.reset();
renegade_adpcm.current = offs;
renegade_adpcm.end = offs + len/2;
renegade_adpcm.nibble = 4;
renegade_adpcm.playing = 1;
state->current = offs;
state->end = offs + len/2;
state->nibble = 4;
state->playing = 1;
}
else
logerror("out of range adpcm command: 0x%02x\n", data);
@ -681,7 +694,7 @@ static ADDRESS_MAP_START( renegade_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0fff) AM_RAM
AM_RANGE(0x1000, 0x1000) AM_READ(soundlatch_r)
AM_RANGE(0x1800, 0x1800) AM_WRITENOP // this gets written the same values as 0x2000
AM_RANGE(0x2000, 0x2000) AM_WRITE(adpcm_play_w)
AM_RANGE(0x2000, 0x2000) AM_DEVWRITE("adpcm", adpcm_play_w)
AM_RANGE(0x2800, 0x2801) AM_DEVREADWRITE("ymsnd", ym3526_r,ym3526_w)
AM_RANGE(0x3000, 0x3000) AM_WRITENOP /* adpcm related? stereo pan? */
AM_RANGE(0x8000, 0xffff) AM_ROM

View File

@ -116,13 +116,6 @@
#define MASTER_CLOCK 16000000
static UINT8 sound_data;
static UINT8 sound_busy;
static UINT8 ym2151_irq;
static UINT8 upd_rom_bank;
/*************************************
*
* Interrupt handling
@ -131,8 +124,9 @@ static UINT8 upd_rom_bank;
static void ym2151_irq_gen(device_t *device, int state)
{
ym2151_irq = state;
cputag_set_input_line(device->machine, "audiocpu", 0, (ym2151_irq | sound_busy) ? ASSERT_LINE : CLEAR_LINE);
rpunch_state *drvstate = device->machine->driver_data<rpunch_state>();
drvstate->ym2151_irq = state;
cputag_set_input_line(device->machine, "audiocpu", 0, (drvstate->ym2151_irq | drvstate->sound_busy) ? ASSERT_LINE : CLEAR_LINE);
}
@ -164,9 +158,10 @@ static CUSTOM_INPUT( hi_bits_r )
static TIMER_CALLBACK( sound_command_w_callback )
{
sound_busy = 1;
sound_data = param;
cputag_set_input_line(machine, "audiocpu", 0, (ym2151_irq | sound_busy) ? ASSERT_LINE : CLEAR_LINE);
rpunch_state *state = machine->driver_data<rpunch_state>();
state->sound_busy = 1;
state->sound_data = param;
cputag_set_input_line(machine, "audiocpu", 0, (state->ym2151_irq | state->sound_busy) ? ASSERT_LINE : CLEAR_LINE);
}
@ -179,15 +174,17 @@ static WRITE16_HANDLER( sound_command_w )
static READ8_HANDLER( sound_command_r )
{
sound_busy = 0;
cputag_set_input_line(space->machine, "audiocpu", 0, (ym2151_irq | sound_busy) ? ASSERT_LINE : CLEAR_LINE);
return sound_data;
rpunch_state *state = space->machine->driver_data<rpunch_state>();
state->sound_busy = 0;
cputag_set_input_line(space->machine, "audiocpu", 0, (state->ym2151_irq | state->sound_busy) ? ASSERT_LINE : CLEAR_LINE);
return state->sound_data;
}
static READ16_HANDLER( sound_busy_r )
{
return sound_busy;
rpunch_state *state = space->machine->driver_data<rpunch_state>();
return state->sound_busy;
}
@ -200,11 +197,12 @@ static READ16_HANDLER( sound_busy_r )
static WRITE8_DEVICE_HANDLER( upd_control_w )
{
if ((data & 1) != upd_rom_bank)
rpunch_state *state = device->machine->driver_data<rpunch_state>();
if ((data & 1) != state->upd_rom_bank)
{
UINT8 *snd = device->machine->region("upd")->base();
upd_rom_bank = data & 1;
memcpy(snd, snd + 0x20000 * (upd_rom_bank + 1), 0x20000);
state->upd_rom_bank = data & 1;
memcpy(snd, snd + 0x20000 * (state->upd_rom_bank + 1), 0x20000);
}
upd7759_reset_w(device, data >> 7);
}
@ -228,7 +226,7 @@ static WRITE8_DEVICE_HANDLER( upd_data_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
ADDRESS_MAP_GLOBAL_MASK(0xfffff)
AM_RANGE(0x000000, 0x03ffff) AM_ROM
AM_RANGE(0x040000, 0x04ffff) AM_RAM AM_BASE(&rpunch_bitmapram) AM_SIZE(&rpunch_bitmapram_size)
AM_RANGE(0x040000, 0x04ffff) AM_RAM AM_BASE_MEMBER(rpunch_state, bitmapram) AM_SIZE_MEMBER(rpunch_state, bitmapram_size)
AM_RANGE(0x060000, 0x060fff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x080000, 0x083fff) AM_RAM_WRITE(rpunch_videoram_w) AM_BASE_MEMBER(rpunch_state, videoram)
AM_RANGE(0x0a0000, 0x0a07ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
@ -699,16 +697,18 @@ ROM_END
static DRIVER_INIT( rabiolep )
{
rpunch_sprite_palette = 0x300;
rpunch_state *state = machine->driver_data<rpunch_state>();
state->sprite_palette = 0x300;
}
static DRIVER_INIT( svolley )
{
rpunch_state *state = machine->driver_data<rpunch_state>();
/* the main differences between Super Volleyball and Rabbit Punch are */
/* the lack of direct-mapped bitmap and a different palette base for sprites */
rpunch_sprite_palette = 0x080;
rpunch_bitmapram = NULL;
state->sprite_palette = 0x080;
state->bitmapram = NULL;
}

View File

@ -269,16 +269,14 @@ Stephh's notes (based on the games Z80 code and some tests) :
#include "sound/ay8910.h"
#include "includes/slapfght.h"
int getstar_id;
static ADDRESS_MAP_START( perfrman_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x880f) AM_RAM AM_SHARE("share1")
AM_RANGE(0x8810, 0x8fff) AM_RAMBANK("bank1") /* Shared RAM with sound CPU */
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_MEMBER(slapfght_state, slapfight_videoram)
AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_MEMBER(slapfght_state, slapfight_colorram)
AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
ADDRESS_MAP_END
@ -287,14 +285,14 @@ static ADDRESS_MAP_START( tigerh_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
AM_RANGE(0xc810, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_MEMBER(slapfght_state, slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_MEMBER(slapfght_state, slapfight_colorram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_lo)
AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrolly)
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixcolorram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( slapfght_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -303,15 +301,15 @@ static ADDRESS_MAP_START( slapfght_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
AM_RANGE(0xc810, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_MEMBER(slapfght_state, slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_MEMBER(slapfght_state, slapfight_colorram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_lo)
AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrolly)
// AM_RANGE(0xe803, 0xe803) AM_READWRITE(slapfight_mcu_r, slapfight_mcu_w)
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixcolorram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( slapfighb2_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -320,15 +318,15 @@ static ADDRESS_MAP_START( slapfighb2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
AM_RANGE(0xc810, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_MEMBER(slapfght_state, slapfight_videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_MEMBER(slapfght_state, slapfight_colorram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
AM_RANGE(0xe803, 0xe803) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_hi)
AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrolly)
AM_RANGE(0xe803, 0xe803) AM_WRITEONLY AM_BASE_MEMBER(slapfght_state, slapfight_scrollx_lo)
AM_RANGE(0xec00, 0xefff) AM_ROM // it reads a copy of the logo from here!
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixvideoram)
AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE_MEMBER(slapfght_state, slapfight_fixcolorram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( slapfght_io_map, ADDRESS_SPACE_IO, 8 )
@ -743,7 +741,7 @@ static SCREEN_EOF( perfrman )
buffer_spriteram_w(space, 0, 0);
}
static MACHINE_CONFIG_START( perfrman, driver_device )
static MACHINE_CONFIG_START( perfrman, slapfght_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,16000000/4) /* 4MHz ???, 16MHz Oscillator */
@ -790,7 +788,7 @@ static MACHINE_CONFIG_START( perfrman, driver_device )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( tigerhb, driver_device )
static MACHINE_CONFIG_START( tigerhb, slapfght_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 6000000)
@ -836,7 +834,7 @@ static MACHINE_CONFIG_START( tigerhb, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( tigerh, driver_device )
static MACHINE_CONFIG_START( tigerh, slapfght_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL_36MHz/6) /* verified on pcb */
@ -886,7 +884,7 @@ static MACHINE_CONFIG_START( tigerh, driver_device )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( slapfigh, driver_device )
static MACHINE_CONFIG_START( slapfigh, slapfght_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",Z80, XTAL_36MHz/6) /* verified on pcb */
@ -1815,21 +1813,24 @@ static void getstar_init( running_machine *machine )
static DRIVER_INIT( getstar )
{
getstar_id = GETSTAR;
slapfght_state *state = machine->driver_data<slapfght_state>();
state->getstar_id = GETSTAR;
getstar_init(machine);
}
static DRIVER_INIT( getstarj )
{
getstar_id = GETSTARJ;
slapfght_state *state = machine->driver_data<slapfght_state>();
state->getstar_id = GETSTARJ;
getstar_init(machine);
}
static DRIVER_INIT( gtstarb1 )
{
slapfght_state *state = machine->driver_data<slapfght_state>();
UINT8 *ROM = machine->region("maincpu")->base();
getstar_id = GTSTARB1;
state->getstar_id = GTSTARB1;
getstar_init(machine);
/* specific handlers for this bootleg */
@ -1843,7 +1844,8 @@ static DRIVER_INIT( gtstarb1 )
static DRIVER_INIT( gtstarb2 )
{
getstar_id = GTSTARB2;
slapfght_state *state = machine->driver_data<slapfght_state>();
state->getstar_id = GTSTARB2;
getstar_init(machine);
}

View File

@ -570,22 +570,24 @@ A trojan could be used on the board to verify the exact behaviour.
*****************************************************************************/
static int hf_posy, hf_posx;
static WRITE8_HANDLER( hardflags_scrollx_w )
{
hf_posx = (hf_posx & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->hf_posx = (state->hf_posx & ~0xff) | data;
}
static WRITE8_HANDLER( hardflags_scrolly_w )
{
hf_posy = (hf_posy & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->hf_posy = (state->hf_posy & ~0xff) | data;
}
static WRITE8_HANDLER( hardflags_scroll_msb_w )
{
hf_posx = (hf_posx & 0xff) | ((data & 0x80) << 1);
hf_posy = (hf_posy & 0xff) | ((data & 0x40) << 2);
snk_state *state = space->machine->driver_data<snk_state>();
state->hf_posx = (state->hf_posx & 0xff) | ((data & 0x80) << 1);
state->hf_posy = (state->hf_posy & 0xff) | ((data & 0x40) << 2);
// low 6 bits might indicate radius, but it's not clear
}
@ -597,8 +599,8 @@ static int hardflags_check(running_machine *machine, int num)
int x = sr[2] + ((sr[3] & 0x80) << 1);
int y = sr[0] + ((sr[3] & 0x10) << 4);
int dx = (x - hf_posx) & 0x1ff;
int dy = (y - hf_posy) & 0x1ff;
int dx = (x - state->hf_posx) & 0x1ff;
int dy = (y - state->hf_posy) & 0x1ff;
if (dx > 0x20 && dx <= 0x1e0 && dy > 0x20 && dy <= 0x1e0)
return 0;
@ -652,34 +654,38 @@ A trojan could be used on the board to verify the exact behaviour.
*****************************************************************************/
static int tc16_posy, tc16_posx, tc32_posy, tc32_posx;
static WRITE8_HANDLER( turbocheck16_1_w )
{
tc16_posy = (tc16_posy & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->tc16_posy = (state->tc16_posy & ~0xff) | data;
}
static WRITE8_HANDLER( turbocheck16_2_w )
{
tc16_posx = (tc16_posx & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->tc16_posx = (state->tc16_posx & ~0xff) | data;
}
static WRITE8_HANDLER( turbocheck32_1_w )
{
tc32_posy = (tc32_posy & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->tc32_posy = (state->tc32_posy & ~0xff) | data;
}
static WRITE8_HANDLER( turbocheck32_2_w )
{
tc32_posx = (tc32_posx & ~0xff) | data;
snk_state *state = space->machine->driver_data<snk_state>();
state->tc32_posx = (state->tc32_posx & ~0xff) | data;
}
static WRITE8_HANDLER( turbocheck_msb_w )
{
tc16_posx = (tc16_posx & 0xff) | ((data & 0x80) << 1);
tc16_posy = (tc16_posy & 0xff) | ((data & 0x40) << 2);
tc32_posx = (tc32_posx & 0xff) | ((data & 0x80) << 1);
tc32_posy = (tc32_posy & 0xff) | ((data & 0x40) << 2);
snk_state *state = space->machine->driver_data<snk_state>();
state->tc16_posx = (state->tc16_posx & 0xff) | ((data & 0x80) << 1);
state->tc16_posy = (state->tc16_posy & 0xff) | ((data & 0x40) << 2);
state->tc32_posx = (state->tc32_posx & 0xff) | ((data & 0x80) << 1);
state->tc32_posy = (state->tc32_posy & 0xff) | ((data & 0x40) << 2);
// low 6 bits might indicate radius, but it's not clear
}
@ -691,8 +697,8 @@ static int turbofront_check(running_machine *machine, int small, int num)
int x = sr[2] + ((sr[3] & 0x80) << 1);
int y = sr[0] + ((sr[3] & 0x10) << 4);
int dx = (x - (small ? tc16_posx : tc32_posx)) & 0x1ff;
int dy = (y - (small ? tc16_posy : tc32_posy)) & 0x1ff;
int dx = (x - (small ? state->tc16_posx : state->tc32_posx)) & 0x1ff;
int dy = (y - (small ? state->tc16_posy : state->tc32_posy)) & 0x1ff;
if (dx > 0x20 && dx <= 0x1e0 && dy > 0x20 && dy <= 0x1e0)
return 0;

View File

@ -73,6 +73,20 @@ out of the sprite list at that point.. (verify on real hw)
#include "video/kan_panb.h" // for bootlegs / non-original hw
#include "cpu/mcs51/mcs51.h" // for semicom mcu
class snowbros_state : public driver_device
{
public:
snowbros_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 *hyperpac_ram;
int sb3_music_is_playing;
int sb3_music;
UINT8 semicom_prot_offset;
};
static WRITE16_HANDLER( snowbros_flipscreen_w )
{
if (ACCESSING_BITS_8_15)
@ -98,9 +112,6 @@ static SCREEN_EOF( snowbros )
}
static UINT16 *hyperpac_ram;
static int sb3_music_is_playing;
static int sb3_music;
static WRITE16_HANDLER( snowbros_irq4_ack_w )
{
@ -124,16 +135,17 @@ static INTERRUPT_GEN( snowbros_interrupt )
static INTERRUPT_GEN( snowbro3_interrupt )
{
snowbros_state *state = device->machine->driver_data<snowbros_state>();
okim6295_device *adpcm = device->machine->device<okim6295_device>("oki");
int status = adpcm->read_status();
cpu_set_input_line(device, cpu_getiloops(device) + 2, ASSERT_LINE); /* IRQs 4, 3, and 2 */
if (sb3_music_is_playing)
if (state->sb3_music_is_playing)
{
if ((status&0x08)==0x00)
{
adpcm->write_command(0x80|sb3_music);
adpcm->write_command(0x80|state->sb3_music);
adpcm->write_command(0x00|0x82);
}
@ -208,32 +220,32 @@ static READ8_HANDLER( prot_io_r )
return 0x00;
}
static UINT8 semicom_prot_offset = 0x00;
// probably not endian safe
static WRITE8_HANDLER( prot_io_w )
{
snowbros_state *state = space->machine->driver_data<snowbros_state>();
switch (offset)
{
case 0x00:
{
UINT16 word = hyperpac_ram[(0xe000/2)+semicom_prot_offset];
UINT16 word = state->hyperpac_ram[(0xe000/2)+state->semicom_prot_offset];
word = (word & 0xff00) | (data << 0);
hyperpac_ram[(0xe000/2)+semicom_prot_offset] = word;
state->hyperpac_ram[(0xe000/2)+state->semicom_prot_offset] = word;
break;
}
case 0x01:
{
UINT16 word = hyperpac_ram[(0xe000/2)+semicom_prot_offset];
UINT16 word = state->hyperpac_ram[(0xe000/2)+state->semicom_prot_offset];
word = (word & 0x00ff) | (data << 8);
hyperpac_ram[(0xe000/2)+semicom_prot_offset] = word;
state->hyperpac_ram[(0xe000/2)+state->semicom_prot_offset] = word;
break;
}
case 0x02: // offset
{
semicom_prot_offset = data;
state->semicom_prot_offset = data;
break;
}
@ -276,7 +288,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( honeydol_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x03ffff) AM_ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&hyperpac_ram)
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(snowbros_state, hyperpac_ram)
AM_RANGE(0x200000, 0x200001) AM_WRITENOP /* ? */
AM_RANGE(0x300000, 0x300001) AM_WRITE(snowbros_68000_sound_w) /* ? */
AM_RANGE(0x400000, 0x400001) AM_WRITE(snowbros_irq4_ack_w) /* IRQ 4 acknowledge */
@ -356,7 +368,7 @@ sound hardware is also different
static ADDRESS_MAP_START( hyperpac_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&hyperpac_ram)
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(snowbros_state, hyperpac_ram)
AM_RANGE(0x300000, 0x300001) AM_WRITE(semicom_soundcmd_w)
// AM_RANGE(0x400000, 0x400001) ???
AM_RANGE(0x500000, 0x500001) AM_READ_PORT("DSW1")
@ -387,10 +399,11 @@ static READ16_HANDLER( sb3_sound_r )
static void sb3_play_music(running_machine *machine, int data)
{
snowbros_state *state = machine->driver_data<snowbros_state>();
UINT8 *snd;
/* sample is actually played in interrupt function so it loops */
sb3_music = data;
state->sb3_music = data;
switch (data)
{
@ -398,13 +411,13 @@ static void sb3_play_music(running_machine *machine, int data)
case 0x26:
snd = machine->region("oki")->base();
memcpy(snd+0x20000, snd+0x80000+0x00000, 0x20000);
sb3_music_is_playing = 1;
state->sb3_music_is_playing = 1;
break;
case 0x24:
snd = machine->region("oki")->base();
memcpy(snd+0x20000, snd+0x80000+0x20000, 0x20000);
sb3_music_is_playing = 1;
state->sb3_music_is_playing = 1;
break;
case 0x25:
@ -417,11 +430,11 @@ static void sb3_play_music(running_machine *machine, int data)
case 0x2d:
snd = machine->region("oki")->base();
memcpy(snd+0x20000, snd+0x80000+0x40000, 0x20000);
sb3_music_is_playing = 1;
state->sb3_music_is_playing = 1;
break;
case 0x2e:
sb3_music_is_playing = 0;
state->sb3_music_is_playing = 0;
break;
}
}
@ -451,10 +464,11 @@ static void sb3_play_sound (okim6295_device *oki, int data)
static WRITE16_DEVICE_HANDLER( sb3_sound_w )
{
snowbros_state *state = device->machine->driver_data<snowbros_state>();
okim6295_device *oki = downcast<okim6295_device *>(device);
if (data == 0x00fe)
{
sb3_music_is_playing = 0;
state->sb3_music_is_playing = 0;
oki->write_command(0x78); /* Stop sounds */
}
else /* the alternating 0x00-0x2f or 0x30-0x5f might be something to do with the channels */
@ -507,7 +521,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( finalttr_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE(&hyperpac_ram)
AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_MEMBER(snowbros_state, hyperpac_ram)
AM_RANGE(0x300000, 0x300001) AM_WRITE(semicom_soundcmd_w)
// AM_RANGE(0x400000, 0x400001) ???
@ -1423,20 +1437,22 @@ static const ym2151_interface ym2151_config =
static MACHINE_RESET (semiprot)
{
snowbros_state *state = machine->driver_data<snowbros_state>();
UINT16 *PROTDATA = (UINT16*)machine->region("user1")->base();
int i;
for (i = 0;i < 0x200/2;i++)
hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
state->hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
}
static MACHINE_RESET (finalttr)
{
snowbros_state *state = machine->driver_data<snowbros_state>();
UINT16 *PROTDATA = (UINT16*)machine->region("user1")->base();
int i;
for (i = 0;i < 0x200/2;i++)
hyperpac_ram[0x2000/2 + i] = PROTDATA[i];
state->hyperpac_ram[0x2000/2 + i] = PROTDATA[i];
}
static const kaneko_pandora_interface snowbros_pandora_config =
@ -1446,7 +1462,7 @@ static const kaneko_pandora_interface snowbros_pandora_config =
0, 0 /* x_offs, y_offs */
};
static MACHINE_CONFIG_START( snowbros, driver_device )
static MACHINE_CONFIG_START( snowbros, snowbros_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 8000000) /* 8 Mhz - confirmed */
@ -1557,7 +1573,7 @@ CPU : 1 X MC68000P12
See included pics
*/
static MACHINE_CONFIG_START( honeydol, driver_device )
static MACHINE_CONFIG_START( honeydol, snowbros_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000)
@ -1594,7 +1610,7 @@ static MACHINE_CONFIG_START( honeydol, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( twinadv, driver_device )
static MACHINE_CONFIG_START( twinadv, snowbros_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000) // or 12
@ -1672,7 +1688,7 @@ static MACHINE_CONFIG_DERIVED( _4in1, semicom )
MCFG_GFXDECODE(snowbros)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( snowbro3, driver_device )
static MACHINE_CONFIG_START( snowbro3, snowbros_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000) /* 16mhz or 12mhz ? */
@ -2246,11 +2262,12 @@ static READ16_HANDLER ( moremorp_0a_read )
static DRIVER_INIT( moremorp )
{
//snowbros_state *state = machine->driver_data<snowbros_state>();
// UINT16 *PROTDATA = (UINT16*)machine->region("user1")->base();
// int i;
// for (i = 0;i < 0x200/2;i++)
// hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
// state->hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
/* explicit check in the code */
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x200001, 0, 0, moremorp_0a_read );
@ -2259,11 +2276,12 @@ static DRIVER_INIT( moremorp )
static DRIVER_INIT( cookbib2 )
{
//snowbros_state *state = machine->driver_data<snowbros_state>();
// UINT16 *HCROM = (UINT16*)machine->region("maincpu")->base();
// UINT16 *PROTDATA = (UINT16*)machine->region("user1")->base();
// int i;
// hyperpac_ram[0xf000/2] = 0x46fc;
// hyperpac_ram[0xf002/2] = 0x2700;
// state->hyperpac_ram[0xf000/2] = 0x46fc;
// state->hyperpac_ram[0xf002/2] = 0x2700;
// verified on real hardware, need to move this to a file really
@ -2276,18 +2294,18 @@ static DRIVER_INIT( cookbib2 )
//for (i = 0;i < sizeof(cookbib2_mcu68k)/sizeof(cookbib2_mcu68k[0]);i++)
// hyperpac_ram[0xf000/2 + i] = cookbib2_mcu68k[i];
// state->hyperpac_ram[0xf000/2 + i] = cookbib2_mcu68k[i];
// for (i = 0;i < 0x200/2;i++)
// hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
// state->hyperpac_ram[0xf000/2 + i] = PROTDATA[i];
// trojan is actually buggy and gfx flicker like crazy
// but we can pause the system after bootup with HALT line of 68k to get the table before
// it goes nuts
// hyperpac_ram[0xf07a/2] = 0x4e73;
// hyperpac_ram[0xf000/2] = 0x4e73;
// state->hyperpac_ram[0xf07a/2] = 0x4e73;
// state->hyperpac_ram[0xf000/2] = 0x4e73;
#if 0
@ -2603,6 +2621,8 @@ static DRIVER_INIT( cookbib2 )
#if 0
static DRIVER_INIT( hyperpac )
{
snowbros_state *state = machine->driver_data<snowbros_state>();
UINT16 *hyperpac_ram = state->hyperpac_ram;
/* simulate RAM initialization done by the protection MCU */
/* not verified on real hardware */
hyperpac_ram[0xe000/2] = 0x4ef9;

View File

@ -62,11 +62,6 @@ Note:
#include "includes/srmp2.h"
#include "machine/nvram.h"
static struct
{
int reset,ff_event,ff_1,protcheck[4],protlatch[4];
}iox;
/***************************************************************************
Interrupt(s)
@ -90,6 +85,9 @@ static INTERRUPT_GEN( srmp2_interrupt )
static MACHINE_START( srmp2 )
{
srmp2_state *state = machine->driver_data<srmp2_state>();
iox_t &iox = state->iox;
iox.reset = 0x1f;
iox.ff_event = -1;
iox.ff_1 = 0x00;
@ -102,6 +100,9 @@ static MACHINE_START( srmp2 )
static MACHINE_START( srmp3 )
{
srmp2_state *state = machine->driver_data<srmp2_state>();
iox_t &iox = state->iox;
iox.reset = 0xc8;
iox.ff_event = 0xef;
iox.ff_1 = -1;
@ -113,6 +114,9 @@ static MACHINE_START( srmp3 )
static MACHINE_START( rmgoldyh )
{
srmp2_state *state = machine->driver_data<srmp2_state>();
iox_t &iox = state->iox;
iox.reset = 0xc8;
iox.ff_event = 0xff;
iox.ff_1 = -1;
@ -285,6 +289,8 @@ static UINT8 iox_key_matrix_calc(running_machine *machine,UINT8 p_side)
static READ8_HANDLER( iox_mux_r )
{
srmp2_state *state = space->machine->driver_data<srmp2_state>();
iox_t &iox = state->iox;
/* first off check any pending protection value */
{
int i;
@ -294,21 +300,21 @@ static READ8_HANDLER( iox_mux_r )
if(iox.protcheck[i] == -1)
continue; //skip
if(state->iox_data == iox.protcheck[i])
if(iox.data == iox.protcheck[i])
{
state->iox_data = 0; //clear write latch
iox.data = 0; //clear write latch
return iox.protlatch[i];
}
}
}
if(state->iox_ff == 0)
if(iox.ff == 0)
{
if(state->iox_mux != 1 && state->iox_mux != 2 && state->iox_mux != 4)
if(iox.mux != 1 && iox.mux != 2 && iox.mux != 4)
return 0xff; //unknown command
/* both side checks */
if(state->iox_mux == 1)
if(iox.mux == 1)
{
UINT8 p1_side = iox_key_matrix_calc(space->machine,0);
UINT8 p2_side = iox_key_matrix_calc(space->machine,4);
@ -320,7 +326,7 @@ static READ8_HANDLER( iox_mux_r )
}
/* check individual input side */
return iox_key_matrix_calc(space->machine,(state->iox_mux == 2) ? 0 : 4);
return iox_key_matrix_calc(space->machine,(iox.mux == 2) ? 0 : 4);
}
return input_port_read(space->machine,"SERVICE") & 0xff;
@ -334,6 +340,7 @@ static READ8_HANDLER( iox_status_r )
static WRITE8_HANDLER( iox_command_w )
{
srmp2_state *state = space->machine->driver_data<srmp2_state>();
iox_t &iox = state->iox;
/*
bit wise command port apparently
0x01: selects both sides
@ -341,23 +348,24 @@ static WRITE8_HANDLER( iox_command_w )
0x04: selects p2 side
*/
state->iox_mux = data;
state->iox_ff = 0; // this also set flip flop back to 0
iox.mux = data;
iox.ff = 0; // this also set flip flop back to 0
}
static WRITE8_HANDLER( iox_data_w )
{
srmp2_state *state = space->machine->driver_data<srmp2_state>();
state->iox_data = data;
iox_t &iox = state->iox;
iox.data = data;
if(data == iox.reset && iox.reset != -1) //resets device
state->iox_ff = 0;
iox.ff = 0;
if(data == iox.ff_event && iox.ff_event != -1) // flip flop event
state->iox_ff ^= 1;
iox.ff ^= 1;
if(data == iox.ff_1 && iox.ff_1 != -1) // set flip flop to 1
state->iox_ff = 1;
iox.ff = 1;
}
static WRITE8_HANDLER( srmp3_rombank_w )

View File

@ -84,10 +84,6 @@
#include "includes/suprridr.h"
#include "sound/ay8910.h"
static UINT8 nmi_enable;
static UINT8 sound_data;
/*************************************
*
@ -97,13 +93,15 @@ static UINT8 sound_data;
static WRITE8_HANDLER( nmi_enable_w )
{
nmi_enable = data;
suprridr_state *state = space->machine->driver_data<suprridr_state>();
state->nmi_enable = data;
}
static INTERRUPT_GEN( main_nmi_gen )
{
if (nmi_enable)
suprridr_state *state = device->machine->driver_data<suprridr_state>();
if (state->nmi_enable)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
@ -117,7 +115,8 @@ static INTERRUPT_GEN( main_nmi_gen )
static TIMER_CALLBACK( delayed_sound_w )
{
sound_data = param;
suprridr_state *state = machine->driver_data<suprridr_state>();
state->sound_data = param;
cputag_set_input_line(machine, "audiocpu", 0, ASSERT_LINE);
}
@ -130,7 +129,8 @@ static WRITE8_HANDLER( sound_data_w )
static READ8_DEVICE_HANDLER( sound_data_r )
{
return sound_data;
suprridr_state *state = device->machine->driver_data<suprridr_state>();
return state->sound_data;
}
@ -164,8 +164,8 @@ static WRITE8_HANDLER( coin_lock_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(suprridr_bgram_w) AM_BASE(&suprridr_bgram)
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(suprridr_fgram_w) AM_BASE(&suprridr_fgram)
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(suprridr_bgram_w) AM_BASE_MEMBER(suprridr_state, bgram)
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(suprridr_fgram_w) AM_BASE_MEMBER(suprridr_state, fgram)
AM_RANGE(0x9800, 0x983f) AM_RAM
AM_RANGE(0x9840, 0x987f) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x9880, 0x9bff) AM_RAM
@ -228,7 +228,7 @@ static CUSTOM_INPUT( suprridr_control_r )
UINT32 ret;
/* screen flip multiplexes controls */
if (suprridr_is_screen_flipped())
if (suprridr_is_screen_flipped(field->port->machine))
ret = input_port_read(field->port->machine, SUPRRIDR_P2_CONTROL_PORT_TAG);
else
ret = input_port_read(field->port->machine, SUPRRIDR_P1_CONTROL_PORT_TAG);
@ -354,7 +354,7 @@ static const ay8910_interface ay8910_config =
*
*************************************/
static MACHINE_CONFIG_START( suprridr, driver_device )
static MACHINE_CONFIG_START( suprridr, suprridr_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL_49_152MHz/16) /* 3 MHz */

View File

@ -23,11 +23,11 @@ To do:
//port A of ay8910#0
static int latch;
static TIMER_CALLBACK( soundlatch_callback )
{
latch = param;
tankbust_state *state = machine->driver_data<tankbust_state>();
state->latch = param;
}
static WRITE8_HANDLER( tankbust_soundlatch_w )
@ -37,17 +37,18 @@ static WRITE8_HANDLER( tankbust_soundlatch_w )
static READ8_DEVICE_HANDLER( tankbust_soundlatch_r )
{
return latch;
tankbust_state *state = device->machine->driver_data<tankbust_state>();
return state->latch;
}
//port B of ay8910#0
static UINT32 timer1 = 0;
static READ8_DEVICE_HANDLER( tankbust_soundtimer_r )
{
tankbust_state *state = device->machine->driver_data<tankbust_state>();
int ret;
timer1++;
ret = timer1;
state->timer1++;
ret = state->timer1;
return ret;
}
@ -60,18 +61,18 @@ static TIMER_CALLBACK( soundirqline_callback )
}
static int e0xx_data[8] = { 0,0,0,0, 0,0,0,0 };
static WRITE8_HANDLER( tankbust_e0xx_w )
{
e0xx_data[offset] = data;
tankbust_state *state = space->machine->driver_data<tankbust_state>();
state->e0xx_data[offset] = data;
#if 0
popmessage("e0: %x %x (%x cnt) %x %x %x %x",
e0xx_data[0], e0xx_data[1],
e0xx_data[2], e0xx_data[3],
e0xx_data[4], e0xx_data[5],
e0xx_data[6] );
state->e0xx_data[0], state->e0xx_data[1],
state->e0xx_data[2], state->e0xx_data[3],
state->e0xx_data[4], state->e0xx_data[5],
state->e0xx_data[6] );
#endif
switch (offset)
@ -107,7 +108,8 @@ static WRITE8_HANDLER( tankbust_e0xx_w )
static READ8_HANDLER( debug_output_area_r )
{
return e0xx_data[offset];
tankbust_state *state = space->machine->driver_data<tankbust_state>();
return state->e0xx_data[offset];
}
@ -170,20 +172,20 @@ static READ8_HANDLER( read_from_unmapped_memory )
}
#endif
static UINT8 variable_data;
static READ8_HANDLER( some_changing_input )
{
variable_data += 8;
return variable_data;
tankbust_state *state = space->machine->driver_data<tankbust_state>();
state->variable_data += 8;
return state->variable_data;
}
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x9fff) AM_ROMBANK("bank1")
AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank2")
AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(tankbust_background_videoram_r, tankbust_background_videoram_w) AM_BASE(&tankbust_videoram)
AM_RANGE(0xc800, 0xcfff) AM_READWRITE(tankbust_background_colorram_r, tankbust_background_colorram_w) AM_BASE(&tankbust_colorram)
AM_RANGE(0xd000, 0xd7ff) AM_READWRITE(tankbust_txtram_r, tankbust_txtram_w) AM_BASE(&tankbust_txtram)
AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(tankbust_background_videoram_r, tankbust_background_videoram_w) AM_BASE_MEMBER(tankbust_state, videoram)
AM_RANGE(0xc800, 0xcfff) AM_READWRITE(tankbust_background_colorram_r, tankbust_background_colorram_w) AM_BASE_MEMBER(tankbust_state, colorram)
AM_RANGE(0xd000, 0xd7ff) AM_READWRITE(tankbust_txtram_r, tankbust_txtram_w) AM_BASE_MEMBER(tankbust_state, txtram)
AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xe000, 0xe007) AM_READWRITE(debug_output_area_r, tankbust_e0xx_w)
AM_RANGE(0xe800, 0xe800) AM_READ_PORT("INPUTS") AM_WRITE(tankbust_yscroll_w)
@ -318,11 +320,12 @@ static const ay8910_interface ay8910_config =
static MACHINE_RESET( tankbust )
{
variable_data = 0x11;
tankbust_state *state = machine->driver_data<tankbust_state>();
state->variable_data = 0x11;
}
static MACHINE_CONFIG_START( tankbust, driver_device )
static MACHINE_CONFIG_START( tankbust, tankbust_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL_14_31818MHz/2) /* Verified on PCB */

View File

@ -71,31 +71,32 @@ zooming might be wrong
#define TAOTAIDO_SHOW_ALL_INPUTS 0
static int pending_command;
static READ16_HANDLER( pending_command_r )
{
taotaido_state *state = space->machine->driver_data<taotaido_state>();
/* Only bit 0 is tested */
return pending_command;
return state->pending_command;
}
static WRITE16_HANDLER( sound_command_w )
{
taotaido_state *state = space->machine->driver_data<taotaido_state>();
if (ACCESSING_BITS_0_7)
{
pending_command = 1;
state->pending_command = 1;
soundlatch_w(space, offset, data & 0xff);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
}
}
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(taotaido_bgvideoram_w) AM_BASE(&taotaido_bgram) // bg ram?
AM_RANGE(0xa00000, 0xa01fff) AM_RAM AM_BASE(&taotaido_spriteram) // sprite ram
AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE(&taotaido_spriteram2) // sprite tile lookup ram
AM_RANGE(0x800000, 0x803fff) AM_RAM_WRITE(taotaido_bgvideoram_w) AM_BASE_MEMBER(taotaido_state, bgram) // bg ram?
AM_RANGE(0xa00000, 0xa01fff) AM_RAM AM_BASE_MEMBER(taotaido_state, spriteram) // sprite ram
AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE_MEMBER(taotaido_state, spriteram2) // sprite tile lookup ram
AM_RANGE(0xfe0000, 0xfeffff) AM_RAM // main ram
AM_RANGE(0xffc000, 0xffcfff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // palette ram
AM_RANGE(0xffe000, 0xffe3ff) AM_RAM AM_BASE(&taotaido_scrollram) // rowscroll / rowselect / scroll ram
AM_RANGE(0xffe000, 0xffe3ff) AM_RAM AM_BASE_MEMBER(taotaido_state, scrollram) // rowscroll / rowselect / scroll ram
AM_RANGE(0xffff80, 0xffff81) AM_READ_PORT("P1")
AM_RANGE(0xffff82, 0xffff83) AM_READ_PORT("P2")
AM_RANGE(0xffff84, 0xffff85) AM_READ_PORT("SYSTEM")
@ -119,7 +120,8 @@ ADDRESS_MAP_END
static WRITE8_HANDLER( pending_command_clear_w )
{
pending_command = 0;
taotaido_state *state = space->machine->driver_data<taotaido_state>();
state->pending_command = 0;
}
static WRITE8_HANDLER( taotaido_sh_bankswitch_w )
@ -330,7 +332,7 @@ static const ym2610_interface ym2610_config =
irqhandler
};
static MACHINE_CONFIG_START( taotaido, driver_device )
static MACHINE_CONFIG_START( taotaido, taotaido_state )
MCFG_CPU_ADD("maincpu", M68000, 32000000/2)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)

View File

@ -137,7 +137,8 @@ HT-01B
static READ8_HANDLER( thepit_colorram_r )
{
return thepit_colorram[offset];
thepit_state *state = space->machine->driver_data<thepit_state>();
return state->colorram[offset];
}
static WRITE8_HANDLER( thepit_sound_enable_w )
@ -149,10 +150,10 @@ static WRITE8_HANDLER( thepit_sound_enable_w )
static ADDRESS_MAP_START( thepit_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x4fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8bff) AM_MIRROR(0x0400) AM_RAM_WRITE(thepit_colorram_w) AM_BASE(&thepit_colorram)
AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM_WRITE(thepit_videoram_w) AM_BASE(&thepit_videoram)
AM_RANGE(0x9800, 0x983f) AM_MIRROR(0x0700) AM_RAM AM_BASE(&thepit_attributesram)
AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&thepit_spriteram) AM_SIZE(&thepit_spriteram_size)
AM_RANGE(0x8800, 0x8bff) AM_MIRROR(0x0400) AM_RAM_WRITE(thepit_colorram_w) AM_BASE_MEMBER(thepit_state, colorram)
AM_RANGE(0x9000, 0x93ff) AM_MIRROR(0x0400) AM_RAM_WRITE(thepit_videoram_w) AM_BASE_MEMBER(thepit_state, videoram)
AM_RANGE(0x9800, 0x983f) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(thepit_state, attributesram)
AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(thepit_state, spriteram) AM_SIZE_MEMBER(thepit_state, spriteram_size)
AM_RANGE(0x9860, 0x98ff) AM_RAM
AM_RANGE(0xa000, 0xa000) AM_READ(thepit_input_port_0_r) AM_WRITENOP // Not hooked up according to the schematics
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("IN1")
@ -170,10 +171,10 @@ static ADDRESS_MAP_START( intrepid_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8c00, 0x8fff) AM_READWRITE(thepit_colorram_r, thepit_colorram_w) /* mirror for intrepi2 */
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(thepit_videoram_w) AM_BASE(&thepit_videoram)
AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(thepit_colorram_w) AM_BASE(&thepit_colorram)
AM_RANGE(0x9800, 0x983f) AM_MIRROR(0x0700) AM_RAM AM_BASE(&thepit_attributesram)
AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&thepit_spriteram) AM_SIZE(&thepit_spriteram_size)
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(thepit_videoram_w) AM_BASE_MEMBER(thepit_state, videoram)
AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(thepit_colorram_w) AM_BASE_MEMBER(thepit_state, colorram)
AM_RANGE(0x9800, 0x983f) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(thepit_state, attributesram)
AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(thepit_state, spriteram) AM_SIZE_MEMBER(thepit_state, spriteram_size)
AM_RANGE(0x9860, 0x98ff) AM_RAM
AM_RANGE(0xa000, 0xa000) AM_READ(thepit_input_port_0_r)
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("IN1")
@ -630,7 +631,7 @@ static const ay8910_interface ay8910_config =
};
static MACHINE_CONFIG_START( thepit, driver_device )
static MACHINE_CONFIG_START( thepit, thepit_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, PIXEL_CLOCK/2) /* 3.072 MHz */
@ -1012,22 +1013,20 @@ ROM_END
Romar Triv questions read handler
*/
static int question_address = 0;
static int question_rom = 0;
static int remap_address[16];
static READ8_HANDLER( rtriv_question_r )
{
thepit_state *state = space->machine->driver_data<thepit_state>();
// Set-up the remap table for every 16 bytes
if((offset & 0xc00) == 0x800)
{
remap_address[offset & 0x0f] = ((offset & 0xf0) >> 4) ^ 0x0f;
state->remap_address[offset & 0x0f] = ((offset & 0xf0) >> 4) ^ 0x0f;
}
// Select which rom to read and the high 5 bits of address
else if((offset & 0xc00) == 0x400)
{
question_rom = (offset & 0x70) >> 4;
question_address = ((offset & 0x80) << 3) | ((offset & 0x0f) << 11);
state->question_rom = (offset & 0x70) >> 4;
state->question_address = ((offset & 0x80) << 3) | ((offset & 0x0f) << 11);
}
// Read the actual byte from question roms
else if((offset & 0xc00) == 0xc00)
@ -1035,7 +1034,7 @@ static READ8_HANDLER( rtriv_question_r )
UINT8 *ROM = space->machine->region("user1")->base();
int real_address;
real_address = (0x8000 * question_rom) | question_address | (offset & 0x3f0) | remap_address[offset & 0x0f];
real_address = (0x8000 * state->question_rom) | state->question_address | (offset & 0x3f0) | state->remap_address[offset & 0x0f];
return ROM[real_address];
}

View File

@ -17,7 +17,6 @@ Notes:
/***************************************************************************/
static int nmi_enabled = 0;
static MACHINE_START( timelimt )
{
@ -26,12 +25,14 @@ static MACHINE_START( timelimt )
static MACHINE_RESET( timelimt )
{
nmi_enabled = 0;
timelimt_state *state = machine->driver_data<timelimt_state>();
state->nmi_enabled = 0;
}
static WRITE8_HANDLER( nmi_enable_w )
{
nmi_enabled = data & 1; /* bit 0 = nmi enable */
timelimt_state *state = space->machine->driver_data<timelimt_state>();
state->nmi_enabled = data & 1; /* bit 0 = nmi enable */
}
static WRITE8_HANDLER( sound_reset_w )
@ -46,7 +47,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM /* rom */
AM_RANGE(0x8000, 0x87ff) AM_RAM /* ram */
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(timelimt_videoram_w) AM_BASE_MEMBER(timelimt_state, videoram) /* video ram */
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(timelimt_bg_videoram_w) AM_BASE(&timelimt_bg_videoram) AM_SIZE(&timelimt_bg_videoram_size)/* background ram */
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(timelimt_bg_videoram_w) AM_BASE_MEMBER(timelimt_state, bg_videoram) AM_SIZE_MEMBER(timelimt_state, bg_videoram_size)/* background ram */
AM_RANGE(0x9800, 0x98ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */
AM_RANGE(0xa000, 0xa000) AM_READ_PORT("INPUTS")
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("SYSTEM")
@ -221,8 +222,10 @@ static const ay8910_interface ay8910_config =
DEVCB_NULL
};
static INTERRUPT_GEN( timelimt_irq ) {
if ( nmi_enabled )
static INTERRUPT_GEN( timelimt_irq )
{
timelimt_state *state = device->machine->driver_data<timelimt_state>();
if ( state->nmi_enabled )
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}

View File

@ -288,7 +288,7 @@ static TIMER_CALLBACK( tubep_scanline_callback )
if (scanline == 16)
{
logerror("/nmi CPU#3\n");
tubep_vblank_end(machine); /* switch buffered sprite RAM state->page */
tubep_vblank_end(machine); /* switch buffered sprite RAM page */
cputag_set_input_line(machine, "mcu", INPUT_LINE_NMI, ASSERT_LINE);
}
/* CPU #3 MS2010-A NMI */
@ -474,7 +474,7 @@ static TIMER_CALLBACK( rjammer_scanline_callback )
if (scanline == 16)
{
logerror("/nmi CPU#3\n");
tubep_vblank_end(machine); /* switch buffered sprite RAM state->page */
tubep_vblank_end(machine); /* switch buffered sprite RAM page */
cputag_set_input_line(machine, "mcu", INPUT_LINE_NMI, ASSERT_LINE);
}
/* CPU #3 MS2010-A NMI */

View File

@ -65,20 +65,13 @@ static ADDRESS_MAP_START( burglarx_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x80001a, 0x80001b) AM_READ_PORT("DSW1")
AM_RANGE(0x80001c, 0x80001d) AM_READ_PORT("DSW2")
AM_RANGE(0x800030, 0x800031) AM_WRITENOP // ? 0
AM_RANGE(0x80010c, 0x80010d) AM_WRITEONLY AM_BASE(&unico_scrollx_0) // Scroll
AM_RANGE(0x80010e, 0x80010f) AM_WRITEONLY AM_BASE(&unico_scrolly_0) //
AM_RANGE(0x800110, 0x800111) AM_WRITEONLY AM_BASE(&unico_scrolly_2) //
AM_RANGE(0x800114, 0x800115) AM_WRITEONLY AM_BASE(&unico_scrollx_2) //
AM_RANGE(0x800116, 0x800117) AM_WRITEONLY AM_BASE(&unico_scrollx_1) //
AM_RANGE(0x800120, 0x800121) AM_WRITEONLY AM_BASE(&unico_scrolly_1) //
AM_RANGE(0x80010c, 0x800121) AM_WRITEONLY AM_BASE_MEMBER(unico_state, scroll) // Scroll
AM_RANGE(0x800188, 0x800189) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff) // Sound
AM_RANGE(0x80018a, 0x80018b) AM_DEVWRITE8("ymsnd", ym3812_write_port_w, 0xff00 ) //
AM_RANGE(0x80018c, 0x80018d) AM_DEVREADWRITE8("ymsnd", ym3812_status_port_r, ym3812_control_port_w, 0xff00 ) //
AM_RANGE(0x80018e, 0x80018f) AM_DEVWRITE("oki", burglarx_sound_bank_w) //
AM_RANGE(0x8001e0, 0x8001e1) AM_WRITENOP // IRQ Ack
AM_RANGE(0x904000, 0x907fff) AM_RAM_WRITE(unico_vram_1_w) AM_BASE(&unico_vram_1 ) // Layers
AM_RANGE(0x908000, 0x90bfff) AM_RAM_WRITE(unico_vram_2_w) AM_BASE(&unico_vram_2 ) //
AM_RANGE(0x90c000, 0x90ffff) AM_RAM_WRITE(unico_vram_0_w) AM_BASE(&unico_vram_0 ) //
AM_RANGE(0x904000, 0x90ffff) AM_RAM_WRITE(unico_vram_w) AM_BASE_MEMBER(unico_state, vram) // Layers 1, 2, 0
AM_RANGE(0x920000, 0x923fff) AM_RAM // ? 0
AM_RANGE(0x930000, 0x9307ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites
AM_RANGE(0x940000, 0x947fff) AM_RAM_WRITE(unico_palette_w) AM_BASE_GENERIC(paletteram) // Palette
@ -156,12 +149,7 @@ static ADDRESS_MAP_START( zeropnt_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x800018, 0x800019) AM_READ_PORT("INPUTS")
AM_RANGE(0x80001a, 0x80001b) AM_READ_PORT("DSW1")
AM_RANGE(0x80001c, 0x80001d) AM_READ_PORT("DSW2")
AM_RANGE(0x80010c, 0x80010d) AM_WRITEONLY AM_BASE(&unico_scrollx_0 ) // Scroll
AM_RANGE(0x80010e, 0x80010f) AM_WRITEONLY AM_BASE(&unico_scrolly_0 ) //
AM_RANGE(0x800110, 0x800111) AM_WRITEONLY AM_BASE(&unico_scrolly_2 ) //
AM_RANGE(0x800114, 0x800115) AM_WRITEONLY AM_BASE(&unico_scrollx_2 ) //
AM_RANGE(0x800116, 0x800117) AM_WRITEONLY AM_BASE(&unico_scrollx_1 ) //
AM_RANGE(0x800120, 0x800121) AM_WRITEONLY AM_BASE(&unico_scrolly_1 ) //
AM_RANGE(0x80010c, 0x800121) AM_WRITEONLY AM_BASE_MEMBER(unico_state, scroll) // Scroll
AM_RANGE(0x800170, 0x800171) AM_READ(unico_guny_0_msb_r ) // Light Guns
AM_RANGE(0x800174, 0x800175) AM_READ(unico_gunx_0_msb_r ) //
AM_RANGE(0x800178, 0x800179) AM_READ(unico_guny_1_msb_r ) //
@ -171,9 +159,7 @@ static ADDRESS_MAP_START( zeropnt_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x80018c, 0x80018d) AM_DEVREADWRITE8("ymsnd", ym3812_status_port_r, ym3812_control_port_w, 0xff00 ) //
AM_RANGE(0x80018e, 0x80018f) AM_WRITE(zeropnt_sound_bank_w ) //
AM_RANGE(0x8001e0, 0x8001e1) AM_WRITEONLY // ? IRQ Ack
AM_RANGE(0x904000, 0x907fff) AM_RAM_WRITE(unico_vram_1_w) AM_BASE(&unico_vram_1 ) // Layers
AM_RANGE(0x908000, 0x90bfff) AM_RAM_WRITE(unico_vram_2_w) AM_BASE(&unico_vram_2 ) //
AM_RANGE(0x90c000, 0x90ffff) AM_RAM_WRITE(unico_vram_0_w) AM_BASE(&unico_vram_0 ) //
AM_RANGE(0x904000, 0x90ffff) AM_RAM_WRITE(unico_vram_w) AM_BASE_MEMBER(unico_state, vram) // Layers 1, 2, 0
AM_RANGE(0x920000, 0x923fff) AM_RAM // ? 0
AM_RANGE(0x930000, 0x9307ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites
AM_RANGE(0x940000, 0x947fff) AM_RAM_WRITE(unico_palette_w) AM_BASE_GENERIC(paletteram) // Palette
@ -236,7 +222,7 @@ static ADDRESS_MAP_START( zeropnt2_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x800030, 0x800033) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff0000 ) //
AM_RANGE(0x800034, 0x800037) AM_WRITE(zeropnt2_sound_bank_w ) //
AM_RANGE(0x800038, 0x80003b) AM_WRITE(zeropnt2_leds_w ) // ?
AM_RANGE(0x80010c, 0x800123) AM_WRITEONLY AM_BASE(&unico_scroll32 ) // Scroll
AM_RANGE(0x80010c, 0x800123) AM_WRITEONLY AM_BASE_MEMBER(unico_state, scroll32 ) // Scroll
AM_RANGE(0x800140, 0x800143) AM_READ(zeropnt2_guny_0_msb_r ) // Light Guns
AM_RANGE(0x800144, 0x800147) AM_READ(zeropnt2_gunx_0_msb_r ) //
AM_RANGE(0x800148, 0x80014b) AM_READ(zeropnt2_guny_1_msb_r ) //
@ -246,9 +232,7 @@ static ADDRESS_MAP_START( zeropnt2_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x80015c, 0x80015f) AM_READ_PORT("BUTTONS")
AM_RANGE(0x8001e0, 0x8001e3) AM_WRITENOP // ? IRQ Ack
AM_RANGE(0x8001f0, 0x8001f3) AM_DEVWRITE("eeprom", zeropnt2_eeprom_w) // EEPROM
AM_RANGE(0x904000, 0x907fff) AM_RAM_WRITE(unico_vram32_1_w) AM_BASE(&unico_vram32_1 ) // Layers
AM_RANGE(0x908000, 0x90bfff) AM_RAM_WRITE(unico_vram32_2_w) AM_BASE(&unico_vram32_2 ) //
AM_RANGE(0x90c000, 0x90ffff) AM_RAM_WRITE(unico_vram32_0_w) AM_BASE(&unico_vram32_0 ) //
AM_RANGE(0x904000, 0x90ffff) AM_RAM_WRITE(unico_vram32_w) AM_BASE_MEMBER(unico_state, vram32) // Layers 1, 2, 0
AM_RANGE(0x920000, 0x923fff) AM_RAM // ? 0
AM_RANGE(0x930000, 0x9307ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites
AM_RANGE(0x940000, 0x947fff) AM_RAM_WRITE(unico_palette32_w) AM_BASE_GENERIC(paletteram ) // Palette
@ -601,7 +585,7 @@ static const eeprom_interface zeropnt2_eeprom_interface =
Burglar X
***************************************************************************/
static MACHINE_CONFIG_START( burglarx, driver_device )
static MACHINE_CONFIG_START( burglarx, unico_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000)
@ -647,7 +631,7 @@ static MACHINE_RESET( zeropt )
MACHINE_RESET_CALL(unico);
}
static MACHINE_CONFIG_START( zeropnt, driver_device )
static MACHINE_CONFIG_START( zeropnt, unico_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000)
@ -688,7 +672,7 @@ MACHINE_CONFIG_END
Zero Point 2
***************************************************************************/
static MACHINE_CONFIG_START( zeropnt2, driver_device )
static MACHINE_CONFIG_START( zeropnt2, unico_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000)
@ -1016,7 +1000,7 @@ DIPSW-B
| V.Hard | |on |on |
------------------------------------------------------------------
* Denotes Factory Defualts
* Denotes Factory Defaults
BrianT

View File

@ -132,11 +132,20 @@ out:
#include "sound/3812intf.h"
class wardner_state : public driver_device
{
public:
wardner_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *rambase_ae00;
UINT8 *rambase_c000;
};
static UINT8 *rambase_ae00, *rambase_c000;
static WRITE8_HANDLER( wardner_ramrom_bank_sw )
{
wardner_state *state = space->machine->driver_data<wardner_state>();
if (wardner_membank != data) {
int bankaddress = 0;
@ -169,8 +178,8 @@ static WRITE8_HANDLER( wardner_ramrom_bank_sw )
memory_install_read_bank(mainspace, 0xae00, 0xafff, 0, 0, "bank2");
memory_install_read_bank(mainspace, 0xc000, 0xc7ff, 0, 0, "bank3");
memory_set_bankptr(space->machine, "bank1", &RAM[0x0000]);
memory_set_bankptr(space->machine, "bank2", rambase_ae00);
memory_set_bankptr(space->machine, "bank3", rambase_c000);
memory_set_bankptr(space->machine, "bank2", state->rambase_ae00);
memory_set_bankptr(space->machine, "bank3", state->rambase_c000);
memory_set_bankptr(space->machine, "bank4", space->machine->generic.paletteram.v);
}
}
@ -196,9 +205,9 @@ static ADDRESS_MAP_START( main_program_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x8fff) AM_WRITE(wardner_sprite_w) AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x9000, 0x9fff) AM_ROM
AM_RANGE(0xa000, 0xadff) AM_WRITE(paletteram_xBBBBBGGGGGRRRRR_le_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xae00, 0xafff) AM_RAM AM_BASE(&rambase_ae00)
AM_RANGE(0xae00, 0xafff) AM_RAM AM_BASE_MEMBER(wardner_state, rambase_ae00)
AM_RANGE(0xb000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE(&rambase_c000) AM_SHARE("share1") /* Shared RAM with Sound Z80 */
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE_MEMBER(wardner_state, rambase_c000) AM_SHARE("share1") /* Shared RAM with Sound Z80 */
AM_RANGE(0xc800, 0xffff) AM_ROM
ADDRESS_MAP_END
@ -392,7 +401,7 @@ GFXDECODE_END
static MACHINE_CONFIG_START( wardner, driver_device )
static MACHINE_CONFIG_START( wardner, wardner_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, XTAL_24MHz/4) /* 6MHz */

View File

@ -195,30 +195,36 @@ TODO :
#include "sound/2203intf.h"
#include "machine/nvram.h"
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;
};
#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;
static UINT8 *sprite_ram;
static int scrollx=0;
static int scrolly=0;
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);
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(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);
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 )

View File

@ -14,7 +14,6 @@ XX Mission (c) 1986 UPL
#include "sound/2203intf.h"
#include "includes/xxmissio.h"
static UINT8 xxmissio_status;
static WRITE8_HANDLER( xxmissio_bank_sel_w )
{
@ -23,43 +22,46 @@ static WRITE8_HANDLER( xxmissio_bank_sel_w )
static CUSTOM_INPUT( xxmissio_status_r )
{
xxmissio_state *state = field->port->machine->driver_data<xxmissio_state>();
int bit_mask = (FPTR)param;
return (xxmissio_status & bit_mask) ? 1 : 0;
return (state->status & bit_mask) ? 1 : 0;
}
static WRITE8_HANDLER ( xxmissio_status_m_w )
{
xxmissio_state *state = space->machine->driver_data<xxmissio_state>();
switch (data)
{
case 0x00:
xxmissio_status |= 0x20;
state->status |= 0x20;
break;
case 0x40:
xxmissio_status &= ~0x08;
state->status &= ~0x08;
cputag_set_input_line_and_vector(space->machine, "sub", 0, HOLD_LINE, 0x10);
break;
case 0x80:
xxmissio_status |= 0x04;
state->status |= 0x04;
break;
}
}
static WRITE8_HANDLER ( xxmissio_status_s_w )
{
xxmissio_state *state = space->machine->driver_data<xxmissio_state>();
switch (data)
{
case 0x00:
xxmissio_status |= 0x10;
state->status |= 0x10;
break;
case 0x40:
xxmissio_status |= 0x08;
state->status |= 0x08;
break;
case 0x80:
xxmissio_status &= ~0x04;
state->status &= ~0x04;
cputag_set_input_line_and_vector(space->machine, "maincpu", 0, HOLD_LINE, 0x10);
break;
}
@ -67,13 +69,15 @@ static WRITE8_HANDLER ( xxmissio_status_s_w )
static INTERRUPT_GEN( xxmissio_interrupt_m )
{
xxmissio_status &= ~0x20;
xxmissio_state *state = device->machine->driver_data<xxmissio_state>();
state->status &= ~0x20;
cpu_set_input_line(device, 0, HOLD_LINE);
}
static INTERRUPT_GEN( xxmissio_interrupt_s )
{
xxmissio_status &= ~0x10;
xxmissio_state *state = device->machine->driver_data<xxmissio_state>();
state->status &= ~0x10;
cpu_set_input_line(device, 0, HOLD_LINE);
}
@ -97,9 +101,9 @@ static ADDRESS_MAP_START( map1, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa002, 0xa002) AM_WRITE(xxmissio_status_m_w)
AM_RANGE(0xa003, 0xa003) AM_WRITE(xxmissio_flipscreen_w)
AM_RANGE(0xc000, 0xc7ff) AM_SHARE("share1") AM_RAM AM_BASE(&xxmissio_fgram)
AM_RANGE(0xc800, 0xcfff) AM_SHARE("share2") AM_READWRITE(xxmissio_bgram_r, xxmissio_bgram_w) AM_BASE(&xxmissio_bgram)
AM_RANGE(0xd000, 0xd7ff) AM_SHARE("share3") AM_RAM AM_BASE(&xxmissio_spriteram)
AM_RANGE(0xc000, 0xc7ff) AM_SHARE("share1") AM_RAM AM_BASE_MEMBER(xxmissio_state, fgram)
AM_RANGE(0xc800, 0xcfff) AM_SHARE("share2") AM_READWRITE(xxmissio_bgram_r, xxmissio_bgram_w) AM_BASE_MEMBER(xxmissio_state, bgram)
AM_RANGE(0xd000, 0xd7ff) AM_SHARE("share3") AM_RAM AM_BASE_MEMBER(xxmissio_state, spriteram)
AM_RANGE(0xd800, 0xdaff) AM_SHARE("share4") AM_RAM_WRITE(xxmissio_paletteram_w) AM_BASE_GENERIC(paletteram)
@ -287,7 +291,7 @@ static const ym2203_interface ym2203_interface_2 =
NULL
};
static MACHINE_CONFIG_START( xxmissio, driver_device )
static MACHINE_CONFIG_START( xxmissio, xxmissio_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,12000000/4) /* 3.0MHz */

View File

@ -27,7 +27,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1e82, 0x1e82) AM_READ_PORT("1E82")
AM_RANGE(0x1e85, 0x1e85) AM_READ_PORT("1E85") /* Dodgem Only */
AM_RANGE(0x1e86, 0x1e86) AM_READ_PORT("1E86") AM_WRITENOP /* Dodgem Only */
AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, zac_s2636_w) AM_BASE(&zac2650_s2636_0_ram)
AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, zac_s2636_w) AM_BASE_MEMBER(zac2650_state, s2636_0_ram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( port_map, ADDRESS_SPACE_IO, 8 )

View File

@ -48,24 +48,21 @@ Notes:
#include "includes/zaccaria.h"
static int dsw;
static int active_8910, port0a, acs;
static int last_port0b;
static WRITE8_DEVICE_HANDLER( zaccaria_dsw_sel_w )
{
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
switch (data & 0xf0)
{
case 0xe0:
dsw = 0;
state->dsw = 0;
break;
case 0xd0:
dsw = 1;
state->dsw = 1;
break;
case 0xb0:
dsw = 2;
state->dsw = 2;
break;
default:
@ -76,9 +73,10 @@ static WRITE8_DEVICE_HANDLER( zaccaria_dsw_sel_w )
static READ8_HANDLER( zaccaria_dsw_r )
{
zaccaria_state *state = space->machine->driver_data<zaccaria_state>();
static const char *const dswnames[] = { "IN0", "DSW0", "DSW1" };
return input_port_read(space->machine, dswnames[dsw]);
return input_port_read(space->machine, dswnames[state->dsw]);
}
@ -116,56 +114,60 @@ static WRITE_LINE_DEVICE_HANDLER( zaccaria_irq0b )
static READ8_DEVICE_HANDLER( zaccaria_port0a_r )
{
return ay8910_r(device->machine->device((active_8910 == 0) ? "ay1" : "ay2"), 0);
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
return ay8910_r(device->machine->device((state->active_8910 == 0) ? "ay1" : "ay2"), 0);
}
static WRITE8_DEVICE_HANDLER( zaccaria_port0a_w )
{
port0a = data;
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
state->port0a = data;
}
static WRITE8_DEVICE_HANDLER( zaccaria_port0b_w )
{
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
/* bit 1 goes to 8910 #0 BDIR pin */
if ((last_port0b & 0x02) == 0x02 && (data & 0x02) == 0x00)
if ((state->last_port0b & 0x02) == 0x02 && (data & 0x02) == 0x00)
{
/* bit 0 goes to the 8910 #0 BC1 pin */
ay8910_data_address_w(device->machine->device("ay1"), last_port0b, port0a);
ay8910_data_address_w(device->machine->device("ay1"), state->last_port0b, state->port0a);
}
else if ((last_port0b & 0x02) == 0x00 && (data & 0x02) == 0x02)
else if ((state->last_port0b & 0x02) == 0x00 && (data & 0x02) == 0x02)
{
/* bit 0 goes to the 8910 #0 BC1 pin */
if (last_port0b & 0x01)
active_8910 = 0;
if (state->last_port0b & 0x01)
state->active_8910 = 0;
}
/* bit 3 goes to 8910 #1 BDIR pin */
if ((last_port0b & 0x08) == 0x08 && (data & 0x08) == 0x00)
if ((state->last_port0b & 0x08) == 0x08 && (data & 0x08) == 0x00)
{
/* bit 2 goes to the 8910 #1 BC1 pin */
ay8910_data_address_w(device->machine->device("ay2"), last_port0b >> 2, port0a);
ay8910_data_address_w(device->machine->device("ay2"), state->last_port0b >> 2, state->port0a);
}
else if ((last_port0b & 0x08) == 0x00 && (data & 0x08) == 0x08)
else if ((state->last_port0b & 0x08) == 0x00 && (data & 0x08) == 0x08)
{
/* bit 2 goes to the 8910 #1 BC1 pin */
if (last_port0b & 0x04)
active_8910 = 1;
if (state->last_port0b & 0x04)
state->active_8910 = 1;
}
last_port0b = data;
state->last_port0b = data;
}
static INTERRUPT_GEN( zaccaria_cb1_toggle )
{
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
device_t *pia0 = device->machine->device("pia0");
static int toggle = 0;
pia6821_cb1_w(pia0, toggle & 1);
toggle ^= 1;
pia6821_cb1_w(pia0, state->toggle & 1);
state->toggle ^= 1;
}
static WRITE8_DEVICE_HANDLER( zaccaria_port1b_w )
{
zaccaria_state *state = device->machine->driver_data<zaccaria_state>();
device_t *tms = device->machine->device("tms");
// bit 0 = /RS
@ -174,7 +176,7 @@ static WRITE8_DEVICE_HANDLER( zaccaria_port1b_w )
tms5220_wsq_w(tms, (data >> 1) & 0x01);
// bit 3 = "ACS" (goes, inverted, to input port 6 bit 3)
acs = ~data & 0x08;
state->acs = ~data & 0x08;
// bit 4 = led (for testing?)
set_led_status(device->machine, 0,~data & 0x10);
@ -260,8 +262,8 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0x6000, 0x63ff) AM_READONLY
AM_RANGE(0x6400, 0x6407) AM_READ(zaccaria_prot1_r)
AM_RANGE(0x6000, 0x67ff) AM_WRITE(zaccaria_videoram_w) AM_BASE(&zaccaria_videoram) /* 6400-67ff is 4 bits wide */
AM_RANGE(0x6800, 0x683f) AM_WRITE(zaccaria_attributes_w) AM_BASE(&zaccaria_attributesram)
AM_RANGE(0x6000, 0x67ff) AM_WRITE(zaccaria_videoram_w) AM_BASE_MEMBER(zaccaria_state, videoram) /* 6400-67ff is 4 bits wide */
AM_RANGE(0x6800, 0x683f) AM_WRITE(zaccaria_attributes_w) AM_BASE_MEMBER(zaccaria_state, attributesram)
AM_RANGE(0x6840, 0x685f) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x6881, 0x68c0) AM_RAM AM_BASE_GENERIC(spriteram2)
AM_RANGE(0x6c00, 0x6c00) AM_WRITE(zaccaria_flip_screen_x_w)
@ -340,7 +342,8 @@ ADDRESS_MAP_END
static CUSTOM_INPUT( acs_r )
{
return (acs & 0x08) ? 1 : 0;
zaccaria_state *state = field->port->machine->driver_data<zaccaria_state>();
return (state->acs & 0x08) ? 1 : 0;
}
static INPUT_PORTS_START( monymony )
@ -576,7 +579,7 @@ static const tms5220_interface tms5220_config =
static MACHINE_CONFIG_START( zaccaria, driver_device )
static MACHINE_CONFIG_START( zaccaria, zaccaria_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,XTAL_18_432MHz/6) /* verified on pcb */

View File

@ -1,4 +1,32 @@
class bagman_state : public driver_device
{
public:
bagman_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 ls259_buf[8];
UINT8 p1_res;
UINT8 p1_old_val;
UINT8 p2_res;
UINT8 p2_old_val;
UINT8 *videoram;
UINT8 *colorram;
UINT8 *video_enable;
/*table holds outputs of all ANDs (after AND map)*/
UINT8 andmap[64];
/*table holds inputs (ie. not x, x, not q, q) to the AND map*/
UINT8 columnvalue[32];
/*8 output pins (actually 6 output and 2 input/output)*/
UINT8 outvalue[8];
tilemap_t *bg_tilemap;
};
/*----------- timings -----------*/
#define BAGMAN_MAIN_CLOCK XTAL_18_432MHz
@ -28,10 +56,6 @@ WRITE8_HANDLER( bagman_pal16r6_w );
/*----------- defined in video/bagman.c -----------*/
extern UINT8 *bagman_videoram;
extern UINT8 *bagman_colorram;
extern UINT8 *bagman_video_enable;
WRITE8_HANDLER( bagman_videoram_w );
WRITE8_HANDLER( bagman_colorram_w );
WRITE8_HANDLER( bagman_flipscreen_w );

View File

@ -9,6 +9,17 @@
#include "devlegcy.h"
#define GRIDLEE_MASTER_CLOCK (20000000)
#define GRIDLEE_CPU_CLOCK (GRIDLEE_MASTER_CLOCK / 16)
#define GRIDLEE_PIXEL_CLOCK (GRIDLEE_MASTER_CLOCK / 4)
#define GRIDLEE_HTOTAL (0x140)
#define GRIDLEE_HBEND (0x000)
#define GRIDLEE_HBSTART (0x100)
#define GRIDLEE_VTOTAL (0x108)
#define GRIDLEE_VBEND (0x010)
#define GRIDLEE_VBSTART (0x100)
class gridlee_state : public driver_device
{
public:

View File

@ -1,10 +1,6 @@
#ifndef __GSTRIKER_H
#define __GSTRIKER_H
/*----------- defined in video/gstriker.c -----------*/
extern UINT16 *gstriker_lineram;
/*** VS920A **********************************************/
#define MAX_VS920A 2
@ -15,18 +11,9 @@ typedef struct
UINT16* vram;
UINT16 pal_base;
UINT8 gfx_region;
} sVS920A;
extern sVS920A VS920A[MAX_VS920A];
#define VS920A_0_vram (VS920A[0].vram)
#define VS920A_1_vram (VS920A[1].vram)
extern WRITE16_HANDLER( VS920A_0_vram_w );
extern WRITE16_HANDLER( VS920A_1_vram_w );
/*** MB60553 **********************************************/
#define MAX_MB60553 2
@ -42,18 +29,6 @@ typedef struct
} tMB60553;
extern tMB60553 MB60553[MAX_MB60553];
#define MB60553_0_vram (MB60553[0].vram)
#define MB60553_1_vram (MB60553[1].vram)
extern WRITE16_HANDLER(MB60553_0_regs_w);
extern WRITE16_HANDLER(MB60553_1_regs_w);
extern WRITE16_HANDLER(MB60553_0_vram_w);
extern WRITE16_HANDLER(MB60553_1_vram_w);
/*** CG10103 **********************************************/
#define MAX_CG10103 2
@ -67,10 +42,36 @@ typedef struct
} tCG10103;
extern tCG10103 CG10103[MAX_CG10103];
class gstriker_state : public driver_device
{
public:
gstriker_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
#define CG10103_0_vram (CG10103[0].vram)
#define CG10103_1_vram (CG10103[1].vram)
UINT16 dmmy_8f_ret;
int pending_command;
UINT16 *work_ram;
int gametype;
UINT16 mcu_data;
UINT16 prot_reg[2];
UINT16 *lineram;
sVS920A VS920A[MAX_VS920A];
tMB60553 MB60553[MAX_MB60553];
tCG10103 CG10103[MAX_CG10103];
sVS920A* VS920A_cur_chip;
tMB60553 *MB60553_cur_chip;
tCG10103* CG10103_cur_chip;
};
/*----------- defined in video/gstriker.c -----------*/
WRITE16_HANDLER( VS920A_0_vram_w );
WRITE16_HANDLER( VS920A_1_vram_w );
WRITE16_HANDLER( MB60553_0_regs_w );
WRITE16_HANDLER( MB60553_1_regs_w );
WRITE16_HANDLER( MB60553_0_vram_w );
WRITE16_HANDLER( MB60553_1_vram_w );
SCREEN_UPDATE( gstriker );
VIDEO_START( gstriker );

View File

@ -1,24 +1,47 @@
class ms32_state : public driver_device
{
public:
ms32_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *nvram_8;
UINT32 *mahjong_input_select;
UINT32 to_main;
UINT16 irqreq;
tilemap_t *tx_tilemap;
tilemap_t *roz_tilemap;
tilemap_t *bg_tilemap;
tilemap_t *bg_tilemap_alt;
UINT8* priram_8;
UINT16* palram_16;
UINT16* rozram_16;
UINT16* lineram_16;
UINT16* sprram_16;
UINT16* txram_16;
UINT16* bgram_16;
UINT32 tilemaplayoutcontrol;
UINT16* f1superb_extraram_16;
tilemap_t* extra_tilemap;
UINT32 *roz_ctrl;
UINT32 *tx_scroll;
UINT32 *bg_scroll;
UINT32 *mainram;
bitmap_t* temp_bitmap_tilemaps;
bitmap_t* temp_bitmap_sprites;
bitmap_t* temp_bitmap_sprites_pri;
int reverse_sprite_order;
int flipscreen;
UINT32 brt[4];
int brt_r;
int brt_g;
int brt_b;
};
/*----------- defined in video/ms32.c -----------*/
extern tilemap_t *ms32_tx_tilemap, *ms32_roz_tilemap, *ms32_bg_tilemap, *ms32_bg_tilemap_alt;
extern UINT8* ms32_priram_8;
extern UINT16* ms32_palram_16;
extern UINT16* ms32_rozram_16;
extern UINT16* ms32_lineram_16;
extern UINT16* ms32_sprram_16;
extern UINT16* ms32_txram_16;
extern UINT16* ms32_bgram_16;
extern UINT32 ms32_tilemaplayoutcontrol;
extern UINT16* f1superb_extraram_16;
extern tilemap_t* ms32_extra_tilemap;
//extern UINT32 *ms32_fce00000;
extern UINT32 *ms32_roz_ctrl;
extern UINT32 *ms32_tx_scroll;
extern UINT32 *ms32_bg_scroll;
extern UINT32 *ms32_mainram;
WRITE32_HANDLER( ms32_brightness_w );

View File

@ -5,8 +5,9 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
emu_timer *clear_irq_timer;
tilemap_t *bg_tilemap;
int control_byte;
};

View File

@ -1,3 +1,17 @@
class namcofl_state : public driver_device
{
public:
namcofl_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
emu_timer *raster_interrupt_timer;
UINT32 *workram;
UINT16 *shareram;
UINT8 mcu_port6;
UINT32 sprbank;
};
/*----------- defined in video/namcofl.c -----------*/
VIDEO_START( namcofl );

View File

@ -113,16 +113,16 @@ WRITE32_HANDLER( namco_tilemapcontrol32_le_w );
/***********************************************************************************/
/* Namco System II Sprite Rendering */
void namcos2_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int control );
void namcos2_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri, int control );
void namcos2_draw_sprites_metalhawk(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
void namcos2_draw_sprites_metalhawk( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
/***********************************************************************************/
/* C355 Motion Object Emulation */
/* for palXOR, supply either 0x0 (normal) or 0xf (palette mapping reversed) */
void namco_obj_init( running_machine *machine, int gfxbank, int palXOR, int (*code2tile)( int code ) );
void namco_obj_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
void namco_obj_init( running_machine *machine, int gfxbank, int palXOR, int (*code2tile)( running_machine *machine, int code ) );
void namco_obj_draw( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
WRITE16_HANDLER( namco_obj16_w );
READ16_HANDLER( namco_obj16_r );
@ -163,9 +163,9 @@ WRITE32_HANDLER( namco_rozvideoram32_le_w );
/***********************************************************************************/
/* C45 Land (Road) Emulation */
void namco_road_init(running_machine *machine, int gfxbank );
void namco_road_init( running_machine *machine, int gfxbank );
void namco_road_set_transparent_color(pen_t pen);
void namco_road_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
void namco_road_draw( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri );
READ16_HANDLER( namco_road16_r );
WRITE16_HANDLER( namco_road16_w );

View File

@ -1,12 +1,62 @@
#define NAMCOS1_MAX_BANK 0x400
/* Bank handler definitions */
typedef struct
{
read8_space_func bank_handler_r;
write8_space_func bank_handler_w;
int bank_offset;
UINT8 *bank_pointer;
} bankhandler;
class namcos1_state : public driver_device
{
public:
namcos1_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
int dac0_value;
int dac1_value;
int dac0_gain;
int dac1_gain;
UINT8 *paletteram;
UINT8 *triram;
UINT8 *s1ram;
bankhandler bank_element[NAMCOS1_MAX_BANK];
bankhandler active_bank[16];
int key_id;
int key_reg;
int key_rng;
int key_swap4_arg;
int key_swap4;
int key_bottom4;
int key_top4;
unsigned int key_quotient;
unsigned int key_reminder;
unsigned int key_numerator_high_word;
UINT8 key[8];
int mcu_patch_data;
int reset;
int wdog;
int chip[16];
UINT8 *videoram;
UINT8 cus116[0x10];
UINT8 *spriteram;
UINT8 playfield_control[0x20];
tilemap_t *bg_tilemap[6];
UINT8 *tilemap_maskdata;
int copy_sprites;
UINT8 drawmode_table[16];
};
/*----------- defined in drivers/namcos1.c -----------*/
void namcos1_init_DACs(void);
void namcos1_init_DACs(running_machine *machine);
/*----------- defined in machine/namcos1.c -----------*/
extern UINT8 *namcos1_paletteram;
WRITE8_HANDLER( namcos1_bankswitch_w );
WRITE8_HANDLER( namcos1_subcpu_bank_w );

View File

@ -1,3 +1,35 @@
class ninjakd2_state : public driver_device
{
public:
ninjakd2_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
const INT16* sampledata;
UINT8 omegaf_io_protection[3];
UINT8 omegaf_io_protection_input;
int omegaf_io_protection_tic;
UINT8* bg_videoram;
UINT8* fg_videoram;
int next_sprite_overdraw_enabled;
int (*stencil_compare_function) (UINT16 pal);
int sprites_updated;
bitmap_t *sp_bitmap;
int robokid_sprites;
tilemap_t* fg_tilemap;
tilemap_t* bg_tilemap;
tilemap_t* bg0_tilemap;
tilemap_t* bg1_tilemap;
tilemap_t* bg2_tilemap;
int bank_mask;
int robokid_bg0_bank;
int robokid_bg1_bank;
int robokid_bg2_bank;
UINT8* robokid_bg0_videoram;
UINT8* robokid_bg1_videoram;
UINT8* robokid_bg2_videoram;
};
/*----------- defined in video/ninjakd2.c -----------*/
extern WRITE8_HANDLER( ninjakd2_bgvideoram_w );
@ -28,5 +60,3 @@ extern SCREEN_UPDATE( robokid );
extern SCREEN_UPDATE( omegaf );
extern SCREEN_EOF( ninjakd2 );
extern UINT8* ninjakd2_bg_videoram;
extern UINT8* ninjakd2_fg_videoram;

View File

@ -1,6 +1,18 @@
/*----------- defined in video/nova2001.c -----------*/
class nova2001_state : public driver_device
{
public:
nova2001_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *nova2001_fg_videoram, *nova2001_bg_videoram;
UINT8 ninjakun_io_a002_ctrl;
UINT8 *fg_videoram;
UINT8 *bg_videoram;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
};
/*----------- defined in video/nova2001.c -----------*/
extern WRITE8_HANDLER( nova2001_fg_videoram_w );
extern WRITE8_HANDLER( nova2001_bg_videoram_w );

View File

@ -5,15 +5,24 @@ public:
: driver_device(machine, config) { }
UINT16 *videoram;
UINT8 sound_data;
UINT8 sound_busy;
UINT8 ym2151_irq;
UINT8 upd_rom_bank;
UINT16 *bitmapram;
size_t bitmapram_size;
int sprite_palette;
tilemap_t *background[2];
UINT16 videoflags;
UINT8 crtc_register;
emu_timer *crtc_timer;
UINT8 bins;
UINT8 gins;
};
/*----------- defined in video/rpunch.c -----------*/
extern UINT16 *rpunch_bitmapram;
extern size_t rpunch_bitmapram_size;
extern int rpunch_sprite_palette;
VIDEO_START( rpunch );
SCREEN_UPDATE( rpunch );

View File

@ -11,23 +11,62 @@ enum {
};
class slapfght_state : public driver_device
{
public:
slapfght_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
int getstar_id;
UINT8 *slapfight_videoram;
UINT8 *slapfight_colorram;
UINT8 *slapfight_fixvideoram;
UINT8 *slapfight_fixcolorram;
UINT8 *slapfight_scrollx_lo;
UINT8 *slapfight_scrollx_hi;
UINT8 *slapfight_scrolly;
int slapfight_status;
int getstar_sequence_index;
int getstar_sh_intenabled;
int slapfight_status_state;
UINT8 mcu_val;
UINT8 getstar_cmd;
UINT8 gs_a;
UINT8 gs_d;
UINT8 gs_e;
UINT8 tigerhb_cmd;
UINT8 from_main;
UINT8 from_mcu;
int mcu_sent;
int main_sent;
UINT8 portA_in;
UINT8 portA_out;
UINT8 ddrA;
UINT8 portB_in;
UINT8 portB_out;
UINT8 ddrB;
UINT8 portC_in;
UINT8 portC_out;
UINT8 ddrC;
int flipscreen;
int slapfight_palette_bank;
tilemap_t *pf1_tilemap;
tilemap_t *fix_tilemap;
};
/*----------- defines -----------*/
/* due to code at 0x108d (GUARDIAN) or 0x1152 (GETSTARJ),
register C is a unaltered copy of register A */
# define GS_SAVE_REGS gs_a = cpu_get_reg(space->cpu, Z80_BC) >> 0; \
gs_d = cpu_get_reg(space->cpu, Z80_DE) >> 8; \
gs_e = cpu_get_reg(space->cpu, Z80_DE) >> 0;
#define GS_SAVE_REGS state->gs_a = cpu_get_reg(space->cpu, Z80_BC) >> 0; \
state->gs_d = cpu_get_reg(space->cpu, Z80_DE) >> 8; \
state->gs_e = cpu_get_reg(space->cpu, Z80_DE) >> 0;
# define GS_RESET_REGS gs_a = 0; \
gs_d = 0; \
gs_e = 0;
/*----------- defined in drivers/slapfght.c -----------*/
extern int getstar_id;
#define GS_RESET_REGS state->gs_a = 0; \
state->gs_d = 0; \
state->gs_e = 0;
/*----------- defined in machine/slapfght.c -----------*/
@ -83,12 +122,6 @@ INTERRUPT_GEN( getstar_interrupt );
/*----------- defined in video/slapfght.c -----------*/
extern UINT8 *slapfight_videoram;
extern UINT8 *slapfight_colorram;
extern UINT8 *slapfight_fixvideoram;
extern UINT8 *slapfight_fixcolorram;
extern UINT8 *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly;
SCREEN_UPDATE( slapfight );
SCREEN_UPDATE( perfrman );
VIDEO_START( slapfight );

View File

@ -36,6 +36,12 @@ public:
UINT8 drawmode_table[16];
UINT8 empty_tile[16*16];
int hf_posy;
int hf_posx;
int tc16_posy;
int tc16_posx;
int tc32_posy;
int tc32_posx;
};

View File

@ -1,3 +1,11 @@
struct iox_t
{
int reset,ff_event,ff_1,protcheck[4],protlatch[4];
UINT8 data;
UINT8 mux;
UINT8 ff;
};
class srmp2_state : public driver_device
{
public:
@ -19,9 +27,8 @@ public:
UINT8 *u8;
UINT16 *u16;
} spriteram1, spriteram2, spriteram3;
UINT8 iox_data;
UINT8 iox_mux;
UINT8 iox_ff;
iox_t iox;
};

View File

@ -4,10 +4,25 @@
**************************************************************************/
/*----------- defined in video/suprridr.c -----------*/
class suprridr_state : public driver_device
{
public:
suprridr_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *suprridr_fgram;
extern UINT8 *suprridr_bgram;
UINT8 nmi_enable;
UINT8 sound_data;
UINT8 *fgram;
UINT8 *bgram;
tilemap_t *fg_tilemap;
tilemap_t *bg_tilemap;
tilemap_t *bg_tilemap_noscroll;
UINT8 flipx;
UINT8 flipy;
};
/*----------- defined in video/suprridr.c -----------*/
VIDEO_START( suprridr );
PALETTE_INIT( suprridr );
@ -17,7 +32,7 @@ WRITE8_HANDLER( suprridr_flipy_w );
WRITE8_HANDLER( suprridr_fgdisable_w );
WRITE8_HANDLER( suprridr_fgscrolly_w );
WRITE8_HANDLER( suprridr_bgscrolly_w );
int suprridr_is_screen_flipped(void);
int suprridr_is_screen_flipped(running_machine *machine);
WRITE8_HANDLER( suprridr_fgram_w );
WRITE8_HANDLER( suprridr_bgram_w );

View File

@ -1,8 +1,24 @@
/*----------- defined in video/tankbust.c -----------*/
class tankbust_state : public driver_device
{
public:
tankbust_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *tankbust_txtram;
extern UINT8 *tankbust_videoram;
extern UINT8 *tankbust_colorram;
int latch;
UINT32 timer1;
int e0xx_data[8];
UINT8 variable_data;
UINT8 *txtram;
UINT8 *videoram;
UINT8 *colorram;
tilemap_t *bg_tilemap;
tilemap_t *txt_tilemap;
UINT8 xscroll[2];
UINT8 yscroll[2];
};
/*----------- defined in video/tankbust.c -----------*/
VIDEO_START( tankbust );
SCREEN_UPDATE( tankbust );

View File

@ -1,9 +1,25 @@
/*----------- defined in video/taotaido.c -----------*/
class taotaido_state : public driver_device
{
public:
taotaido_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT16 *taotaido_spriteram;
extern UINT16 *taotaido_spriteram2;
extern UINT16 *taotaido_scrollram;
extern UINT16 *taotaido_bgram;
int pending_command;
UINT16 *spriteram;
UINT16 *spriteram2;
UINT16 *scrollram;
UINT16 *bgram;
UINT16 sprite_character_bank_select[8];
UINT16 video_bank_select[8];
tilemap_t *bg_tilemap;
UINT16 *spriteram_old;
UINT16 *spriteram_older;
UINT16 *spriteram2_old;
UINT16 *spriteram2_older;
};
/*----------- defined in video/taotaido.c -----------*/
WRITE16_HANDLER( taotaido_sprite_character_bank_select_w );
WRITE16_HANDLER( taotaido_tileregs_w );

View File

@ -1,10 +1,27 @@
/*----------- defined in video/thepit.c -----------*/
class thepit_state : public driver_device
{
public:
thepit_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *thepit_videoram;
extern UINT8 *thepit_colorram;
extern UINT8 *thepit_attributesram;
extern UINT8 *thepit_spriteram;
extern size_t thepit_spriteram_size;
int question_address;
int question_rom;
int remap_address[16];
UINT8 *videoram;
UINT8 *colorram;
UINT8 *attributesram;
UINT8 *spriteram;
size_t spriteram_size;
UINT8 graphics_bank;
UINT8 flip_screen_x;
UINT8 flip_screen_y;
tilemap_t *solid_tilemap;
tilemap_t *tilemap;
UINT8 *dummy_tile;
};
/*----------- defined in video/thepit.c -----------*/
PALETTE_INIT( thepit );
PALETTE_INIT( suprmous );

View File

@ -5,14 +5,18 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
int nmi_enabled;
UINT8 *bg_videoram;
size_t bg_videoram_size;
int scrollx;
int scrolly;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
};
/*----------- defined in video/timelimt.c -----------*/
extern UINT8 *timelimt_bg_videoram;
extern size_t timelimt_bg_videoram_size;
VIDEO_START( timelimt );
PALETTE_INIT( timelimt );
SCREEN_UPDATE( timelimt );

View File

@ -64,6 +64,7 @@ public:
UINT8 buckrog_fchg, buckrog_mov, buckrog_obch;
UINT8 buckrog_command;
UINT8 buckrog_myship;
int last_sound_a;
};

View File

@ -1,18 +1,25 @@
class unico_state : public driver_device
{
public:
unico_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 *vram;
UINT16 *scroll;
UINT32 *vram32;
UINT32 *scroll32;
tilemap_t *tilemap[3];
int sprites_scrolldx;
int sprites_scrolldy;
};
/*----------- defined in video/unico.c -----------*/
extern UINT16 *unico_vram_0, *unico_scrollx_0, *unico_scrolly_0;
extern UINT16 *unico_vram_1, *unico_scrollx_1, *unico_scrolly_1;
extern UINT16 *unico_vram_2, *unico_scrollx_2, *unico_scrolly_2;
extern UINT32 *unico_vram32_0, *unico_vram32_1, *unico_vram32_2, *unico_scroll32;
WRITE16_HANDLER( unico_vram_0_w );
WRITE16_HANDLER( unico_vram_1_w );
WRITE16_HANDLER( unico_vram_2_w );
WRITE16_HANDLER( unico_vram_w );
WRITE16_HANDLER( unico_palette_w );
WRITE32_HANDLER( unico_vram32_0_w );
WRITE32_HANDLER( unico_vram32_1_w );
WRITE32_HANDLER( unico_vram32_2_w );
WRITE32_HANDLER( unico_vram32_w );
WRITE32_HANDLER( unico_palette32_w );
VIDEO_START( unico );

View File

@ -1,8 +1,22 @@
/*----------- defined in video/xxmissio.c -----------*/
class xxmissio_state : public driver_device
{
public:
xxmissio_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *xxmissio_bgram;
extern UINT8 *xxmissio_fgram;
extern UINT8 *xxmissio_spriteram;
UINT8 status;
UINT8 *bgram;
UINT8 *fgram;
UINT8 *spriteram;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
UINT8 xscroll;
UINT8 yscroll;
UINT8 flipscreen;
};
/*----------- defined in video/xxmissio.c -----------*/
VIDEO_START( xxmissio );
SCREEN_UPDATE( xxmissio );

View File

@ -5,13 +5,16 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
UINT8 *s2636_0_ram;
bitmap_t *spritebitmap;
int CollisionBackground;
int CollisionSprite;
tilemap_t *bg_tilemap;
};
/*----------- defined in video/zac2650.c -----------*/
extern UINT8 *zac2650_s2636_0_ram;
WRITE8_HANDLER( tinvader_videoram_w );
READ8_HANDLER( zac_s2636_r );
WRITE8_HANDLER( zac_s2636_w );

View File

@ -1,6 +1,22 @@
/*----------- defined in video/zaccaria.c -----------*/
class zaccaria_state : public driver_device
{
public:
zaccaria_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *zaccaria_videoram,*zaccaria_attributesram;
int dsw;
int active_8910;
int port0a;
int acs;
int last_port0b;
int toggle;
UINT8 *videoram;
UINT8 *attributesram;
tilemap_t *bg_tilemap;
};
/*----------- defined in video/zaccaria.c -----------*/
PALETTE_INIT( zaccaria );
VIDEO_START( zaccaria );

View File

@ -23,15 +23,6 @@
*/
/*table holds outputs of all ANDs (after AND map)*/
static UINT8 andmap[64];
/*table holds inputs (ie. not x, x, not q, q) to the AND map*/
static UINT8 columnvalue[32];
/*8 output pins (actually 6 output and 2 input/output)*/
static UINT8 outvalue[8];
/* 64 rows x 32 columns
** 1 - fuse blown: disconnected from input (equal to 1)
** 0 - fuse not blown: connected to input (ie. x, not x, q, not q accordingly)
@ -105,7 +96,7 @@ static const UINT8 fusemap[64*32]=
};
static void update_pal(void)
static void update_pal(bagman_state *state)
{
UINT16 rowoffs;
UINT8 row, column, val;
@ -118,91 +109,91 @@ UINT8 row, column, val;
for (column = 0; column < 32; column++)
{
if ( fusemap[ rowoffs + column ] == 0 )
val &= columnvalue[column];
val &= state->columnvalue[column];
}
andmap[row] = val;
state->andmap[row] = val;
}
/* I/O pin #19 */
val = 0; /*prepare for OR*/
for (row = 1; row < 8; row++)
val |= andmap[row];
if (andmap[0] == 1)
val |= state->andmap[row];
if (state->andmap[0] == 1)
{
columnvalue[2] = 1-val;
columnvalue[3] = val;
outvalue[0] = 1-val;
state->columnvalue[2] = 1-val;
state->columnvalue[3] = val;
state->outvalue[0] = 1-val;
}
else
{
/*pin is in INPUT configuration so it doesn't create output...*/
columnvalue[2] = 0;
columnvalue[3] = 1;
state->columnvalue[2] = 0;
state->columnvalue[3] = 1;
}
/* O pin #18 (D1) */
val = 0; /*prepare for OR*/
for (row = 8; row < 16; row++)
val |= andmap[row];
columnvalue[6] = 1-val;
columnvalue[7] = val;
outvalue[1] = 1-val;
val |= state->andmap[row];
state->columnvalue[6] = 1-val;
state->columnvalue[7] = val;
state->outvalue[1] = 1-val;
/* O pin #17 (D2) */
val = 0; /*prepare for OR*/
for (row = 16; row < 24; row++)
val |= andmap[row];
columnvalue[10] = 1-val;
columnvalue[11] = val;
outvalue[2] = 1-val;
val |= state->andmap[row];
state->columnvalue[10] = 1-val;
state->columnvalue[11] = val;
state->outvalue[2] = 1-val;
/* O pin #16 (D3) */
val = 0; /*prepare for OR*/
for (row = 24; row < 32; row++)
val |= andmap[row];
columnvalue[14] = 1-val;
columnvalue[15] = val;
outvalue[3] = 1-val;
val |= state->andmap[row];
state->columnvalue[14] = 1-val;
state->columnvalue[15] = val;
state->outvalue[3] = 1-val;
/* O pin #15 (D4) */
val = 0; /*prepare for OR*/
for (row = 32; row < 40; row++)
val |= andmap[row];
columnvalue[18] = 1-val;
columnvalue[19] = val;
outvalue[4] = 1-val;
val |= state->andmap[row];
state->columnvalue[18] = 1-val;
state->columnvalue[19] = val;
state->outvalue[4] = 1-val;
/* O pin #14 (D5) */
val = 0; /*prepare for OR*/
for (row = 40; row < 48; row++)
val |= andmap[row];
columnvalue[22] = 1-val;
columnvalue[23] = val;
outvalue[5] = 1-val;
val |= state->andmap[row];
state->columnvalue[22] = 1-val;
state->columnvalue[23] = val;
state->outvalue[5] = 1-val;
/* O pin #13 (D6) */
val = 0; /*prepare for OR*/
for (row = 48; row < 56; row++)
val |= andmap[row];
columnvalue[26] = 1-val;
columnvalue[27] = val;
outvalue[6] = 1-val;
val |= state->andmap[row];
state->columnvalue[26] = 1-val;
state->columnvalue[27] = val;
state->outvalue[6] = 1-val;
/* I/O pin #12 */
val = 0; /*prepare for OR*/
for (row = 57; row < 64; row++)
val |= andmap[row];
if (andmap[56] == 1)
val |= state->andmap[row];
if (state->andmap[56] == 1)
{
columnvalue[30] = 1-val;
columnvalue[31] = val;
outvalue[7] = 1-val;
state->columnvalue[30] = 1-val;
state->columnvalue[31] = val;
state->outvalue[7] = 1-val;
}
else
{
/*pin is in INPUT configuration so it doesn't create output...*/
columnvalue[30] = 0;
columnvalue[31] = 1;
state->columnvalue[30] = 0;
state->columnvalue[31] = 1;
}
}
@ -210,15 +201,17 @@ UINT8 row, column, val;
WRITE8_HANDLER( bagman_pal16r6_w )
{
bagman_state *state = space->machine->driver_data<bagman_state>();
UINT8 line;
line = offset * 4;
columnvalue[line ] = data & 1;
columnvalue[line + 1] = 1 - (data & 1);
state->columnvalue[line ] = data & 1;
state->columnvalue[line + 1] = 1 - (data & 1);
}
MACHINE_RESET( bagman )
{
bagman_state *state = machine->driver_data<bagman_state>();
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
bagman_pal16r6_w(space, 0, 1); /*pin 2*/
bagman_pal16r6_w(space, 1, 1); /*pin 3*/
@ -228,14 +221,15 @@ MACHINE_RESET( bagman )
bagman_pal16r6_w(space, 5, 1); /*pin 7*/
bagman_pal16r6_w(space, 6, 1); /*pin 8*/
bagman_pal16r6_w(space, 7, 1); /*pin 9*/
update_pal();
update_pal(state);
}
READ8_HANDLER( bagman_pal16r6_r )
{
update_pal();
return (outvalue[6]) + (outvalue[5] << 1) + (outvalue[4] << 2) +
(outvalue[3] << 3) + (outvalue[2] << 4) + (outvalue[1] << 5);
bagman_state *state = space->machine->driver_data<bagman_state>();
update_pal(state);
return (state->outvalue[6]) + (state->outvalue[5] << 1) + (state->outvalue[4] << 2) +
(state->outvalue[3] << 3) + (state->outvalue[2] << 4) + (state->outvalue[1] << 5);
/* Bagman schematics show that this is right mapping order of PAL outputs to bits.
** This is the PAL 16R6 shown almost in the middle of the schematics.

View File

@ -3,13 +3,6 @@
#include "sound/namco.h"
#include "includes/namcos1.h"
#define NAMCOS1_MAX_BANK 0x400
UINT8 *namcos1_paletteram;
static UINT8 *namcos1_triram;
static UINT8 *s1ram;
/*******************************************************************************
* *
@ -17,52 +10,53 @@ static UINT8 *s1ram;
* *
*******************************************************************************/
/* Bank handler definitions */
typedef struct
{
read8_space_func bank_handler_r;
write8_space_func bank_handler_w;
int bank_offset;
UINT8 *bank_pointer;
} bankhandler;
/* hardware elements of 1Mbytes physical memory space */
static bankhandler namcos1_bank_element[NAMCOS1_MAX_BANK];
static bankhandler namcos1_active_bank[16];
static READ8_HANDLER( bank1_r ) { return (*namcos1_active_bank[0].bank_handler_r )(space, offset + namcos1_active_bank[0].bank_offset); }
static READ8_HANDLER( bank2_r ) { return (*namcos1_active_bank[1].bank_handler_r )(space, offset + namcos1_active_bank[1].bank_offset); }
static READ8_HANDLER( bank3_r ) { return (*namcos1_active_bank[2].bank_handler_r )(space, offset + namcos1_active_bank[2].bank_offset); }
static READ8_HANDLER( bank4_r ) { return (*namcos1_active_bank[3].bank_handler_r )(space, offset + namcos1_active_bank[3].bank_offset); }
static READ8_HANDLER( bank5_r ) { return (*namcos1_active_bank[4].bank_handler_r )(space, offset + namcos1_active_bank[4].bank_offset); }
static READ8_HANDLER( bank6_r ) { return (*namcos1_active_bank[5].bank_handler_r )(space, offset + namcos1_active_bank[5].bank_offset); }
static READ8_HANDLER( bank7_r ) { return (*namcos1_active_bank[6].bank_handler_r )(space, offset + namcos1_active_bank[6].bank_offset); }
static READ8_HANDLER( bank8_r ) { return (*namcos1_active_bank[7].bank_handler_r )(space, offset + namcos1_active_bank[7].bank_offset); }
static READ8_HANDLER( bank9_r ) { return (*namcos1_active_bank[8].bank_handler_r )(space, offset + namcos1_active_bank[8].bank_offset); }
static READ8_HANDLER( bank10_r ) { return (*namcos1_active_bank[9].bank_handler_r )(space, offset + namcos1_active_bank[9].bank_offset); }
static READ8_HANDLER( bank11_r ) { return (*namcos1_active_bank[10].bank_handler_r)(space, offset + namcos1_active_bank[10].bank_offset); }
static READ8_HANDLER( bank12_r ) { return (*namcos1_active_bank[11].bank_handler_r)(space, offset + namcos1_active_bank[11].bank_offset); }
static READ8_HANDLER( bank13_r ) { return (*namcos1_active_bank[12].bank_handler_r)(space, offset + namcos1_active_bank[12].bank_offset); }
static READ8_HANDLER( bank14_r ) { return (*namcos1_active_bank[13].bank_handler_r)(space, offset + namcos1_active_bank[13].bank_offset); }
static READ8_HANDLER( bank15_r ) { return (*namcos1_active_bank[14].bank_handler_r)(space, offset + namcos1_active_bank[14].bank_offset); }
static READ8_HANDLER( bank16_r ) { return (*namcos1_active_bank[15].bank_handler_r)(space, offset + namcos1_active_bank[15].bank_offset); }
INLINE UINT8 bank_r(address_space *space, offs_t offset, int bank)
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
return (*state->active_bank[bank].bank_handler_r )(space, offset + state->active_bank[bank].bank_offset);
}
static WRITE8_HANDLER( bank1_w ) { (*namcos1_active_bank[0].bank_handler_w )(space, offset + namcos1_active_bank[0].bank_offset, data); }
static WRITE8_HANDLER( bank2_w ) { (*namcos1_active_bank[1].bank_handler_w )(space, offset + namcos1_active_bank[1].bank_offset, data); }
static WRITE8_HANDLER( bank3_w ) { (*namcos1_active_bank[2].bank_handler_w )(space, offset + namcos1_active_bank[2].bank_offset, data); }
static WRITE8_HANDLER( bank4_w ) { (*namcos1_active_bank[3].bank_handler_w )(space, offset + namcos1_active_bank[3].bank_offset, data); }
static WRITE8_HANDLER( bank5_w ) { (*namcos1_active_bank[4].bank_handler_w )(space, offset + namcos1_active_bank[4].bank_offset, data); }
static WRITE8_HANDLER( bank6_w ) { (*namcos1_active_bank[5].bank_handler_w )(space, offset + namcos1_active_bank[5].bank_offset, data); }
static WRITE8_HANDLER( bank7_w ) { (*namcos1_active_bank[6].bank_handler_w )(space, offset + namcos1_active_bank[6].bank_offset, data); }
static WRITE8_HANDLER( bank8_w ) { (*namcos1_active_bank[7].bank_handler_w )(space, offset + namcos1_active_bank[7].bank_offset, data); }
static WRITE8_HANDLER( bank9_w ) { (*namcos1_active_bank[8].bank_handler_w )(space, offset + namcos1_active_bank[8].bank_offset, data); }
static WRITE8_HANDLER( bank10_w ) { (*namcos1_active_bank[9].bank_handler_w )(space, offset + namcos1_active_bank[9].bank_offset, data); }
static WRITE8_HANDLER( bank11_w ) { (*namcos1_active_bank[10].bank_handler_w)(space, offset + namcos1_active_bank[10].bank_offset, data); }
static WRITE8_HANDLER( bank12_w ) { (*namcos1_active_bank[11].bank_handler_w)(space, offset + namcos1_active_bank[11].bank_offset, data); }
static WRITE8_HANDLER( bank13_w ) { (*namcos1_active_bank[12].bank_handler_w)(space, offset + namcos1_active_bank[12].bank_offset, data); }
static WRITE8_HANDLER( bank14_w ) { (*namcos1_active_bank[13].bank_handler_w)(space, offset + namcos1_active_bank[13].bank_offset, data); }
static WRITE8_HANDLER( bank15_w ) { (*namcos1_active_bank[14].bank_handler_w)(space, offset + namcos1_active_bank[14].bank_offset, data); }
static WRITE8_HANDLER( bank16_w ) { (*namcos1_active_bank[15].bank_handler_w)(space, offset + namcos1_active_bank[15].bank_offset, data); }
static READ8_HANDLER( bank1_r ) { return bank_r(space, offset, 0); }
static READ8_HANDLER( bank2_r ) { return bank_r(space, offset, 1); }
static READ8_HANDLER( bank3_r ) { return bank_r(space, offset, 2); }
static READ8_HANDLER( bank4_r ) { return bank_r(space, offset, 3); }
static READ8_HANDLER( bank5_r ) { return bank_r(space, offset, 4); }
static READ8_HANDLER( bank6_r ) { return bank_r(space, offset, 5); }
static READ8_HANDLER( bank7_r ) { return bank_r(space, offset, 6); }
static READ8_HANDLER( bank8_r ) { return bank_r(space, offset, 7); }
static READ8_HANDLER( bank9_r ) { return bank_r(space, offset, 8); }
static READ8_HANDLER( bank10_r ) { return bank_r(space, offset, 9); }
static READ8_HANDLER( bank11_r ) { return bank_r(space, offset, 10); }
static READ8_HANDLER( bank12_r ) { return bank_r(space, offset, 11); }
static READ8_HANDLER( bank13_r ) { return bank_r(space, offset, 12); }
static READ8_HANDLER( bank14_r ) { return bank_r(space, offset, 13); }
static READ8_HANDLER( bank15_r ) { return bank_r(space, offset, 14); }
static READ8_HANDLER( bank16_r ) { return bank_r(space, offset, 15); }
INLINE void bank_w(address_space *space, offs_t offset, UINT8 data, int bank)
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
(*state->active_bank[bank].bank_handler_w )(space, offset + state->active_bank[bank].bank_offset, data);
}
static WRITE8_HANDLER( bank1_w ) { bank_w(space, offset, data, 0); }
static WRITE8_HANDLER( bank2_w ) { bank_w(space, offset, data, 1); }
static WRITE8_HANDLER( bank3_w ) { bank_w(space, offset, data, 2); }
static WRITE8_HANDLER( bank4_w ) { bank_w(space, offset, data, 3); }
static WRITE8_HANDLER( bank5_w ) { bank_w(space, offset, data, 4); }
static WRITE8_HANDLER( bank6_w ) { bank_w(space, offset, data, 5); }
static WRITE8_HANDLER( bank7_w ) { bank_w(space, offset, data, 6); }
static WRITE8_HANDLER( bank8_w ) { bank_w(space, offset, data, 7); }
static WRITE8_HANDLER( bank9_w ) { bank_w(space, offset, data, 8); }
static WRITE8_HANDLER( bank10_w ) { bank_w(space, offset, data, 9); }
static WRITE8_HANDLER( bank11_w ) { bank_w(space, offset, data, 10); }
static WRITE8_HANDLER( bank12_w ) { bank_w(space, offset, data, 11); }
static WRITE8_HANDLER( bank13_w ) { bank_w(space, offset, data, 12); }
static WRITE8_HANDLER( bank14_w ) { bank_w(space, offset, data, 13); }
static WRITE8_HANDLER( bank15_w ) { bank_w(space, offset, data, 14); }
static WRITE8_HANDLER( bank16_w ) { bank_w(space, offset, data, 15); }
static const read8_space_func io_bank_handler_r[16] =
{
@ -89,11 +83,6 @@ static WRITE8_HANDLER( namcos1_3dcs_w )
}
static int key_id, key_reg, key_rng, key_swap4_arg, key_swap4, key_bottom4, key_top4;
static unsigned int key_quotient, key_reminder, key_numerator_high_word;
static UINT8 key[8];
// used by faceoff and tankforce 4 player (input multiplex)
static READ8_HANDLER( faceoff_inputs_r );
@ -210,12 +199,13 @@ CPU #0 PC e3d4: keychip read 0003 [AND #$37 = key no.]
*/
static READ8_HANDLER( key_type1_r )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("CPU %s PC %04x: keychip read %04x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset);
if (offset < 3)
{
int d = key[0];
int n = (key[1] << 8) | key[2];
int d = state->key[0];
int n = (state->key[1] << 8) | state->key[2];
int q,r;
if (d)
@ -234,17 +224,18 @@ static READ8_HANDLER( key_type1_r )
if (offset == 2) return q & 0xff;
}
else if (offset == 3)
return key_id;
return state->key_id;
return 0;
}
static WRITE8_HANDLER( key_type1_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("CPU %s PC %04x: keychip write %04x=%02x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset, data);
if (offset < 4)
key[offset] = data;
state->key[offset] = data;
}
@ -393,50 +384,52 @@ CPU #0 PC e574: keychip read 0001
static READ8_HANDLER( key_type2_r )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("CPU %s PC %04x: keychip read %04x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset);
key_numerator_high_word = 0;
state->key_numerator_high_word = 0;
if (offset < 4)
{
if (offset == 0) return key_reminder >> 8;
if (offset == 1) return key_reminder & 0xff;
if (offset == 2) return key_quotient >> 8;
if (offset == 3) return key_quotient & 0xff;
if (offset == 0) return state->key_reminder >> 8;
if (offset == 1) return state->key_reminder & 0xff;
if (offset == 2) return state->key_quotient >> 8;
if (offset == 3) return state->key_quotient & 0xff;
}
else if (offset == 4)
return key_id;
return state->key_id;
return 0;
}
static WRITE8_HANDLER( key_type2_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("CPU %s PC %04x: keychip write %04x=%02x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset, data);
if (offset < 5)
{
key[offset] = data;
state->key[offset] = data;
if (offset == 3)
{
unsigned int d = (key[0] << 8) | key[1];
unsigned int n = (key_numerator_high_word << 16) | (key[2] << 8) | key[3];
unsigned int d = (state->key[0] << 8) | state->key[1];
unsigned int n = (state->key_numerator_high_word << 16) | (state->key[2] << 8) | state->key[3];
if (d)
{
key_quotient = n / d;
key_reminder = n % d;
state->key_quotient = n / d;
state->key_reminder = n % d;
}
else
{
key_quotient = 0xffff;
key_reminder = 0x0000;
state->key_quotient = 0xffff;
state->key_reminder = 0x0000;
}
// logerror("calculating division: %08x / %04x = %04x, %04x\n", n, d, key_quotient, key_reminder);
// logerror("calculating division: %08x / %04x = %04x, %04x\n", n, d, key_quotient, state->key_reminder);
key_numerator_high_word = (key[2] << 8) | key[3];
state->key_numerator_high_word = (state->key[2] << 8) | state->key[3];
}
}
}
@ -519,6 +512,7 @@ CPU #0 PC e45a: keychip read 0030 [discarded]
static READ8_HANDLER( key_type3_r )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
int op;
// logerror("CPU %s PC %04x: keychip read %04x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset);
@ -531,11 +525,11 @@ static READ8_HANDLER( key_type3_r )
op = (offset & 0x70) >> 4;
if (op == key_reg) return key_id;
if (op == key_rng) return space->machine->rand();
if (op == key_swap4) return (key[key_swap4_arg] << 4) | (key[key_swap4_arg] >> 4);
if (op == key_bottom4) return (offset << 4) | (key[key_swap4_arg] & 0x0f);
if (op == key_top4) return (offset << 4) | (key[key_swap4_arg] >> 4);
if (op == state->key_reg) return state->key_id;
if (op == state->key_rng) return space->machine->rand();
if (op == state->key_swap4) return (state->key[state->key_swap4_arg] << 4) | (state->key[state->key_swap4_arg] >> 4);
if (op == state->key_bottom4) return (offset << 4) | (state->key[state->key_swap4_arg] & 0x0f);
if (op == state->key_top4) return (offset << 4) | (state->key[state->key_swap4_arg] >> 4);
popmessage("CPU %s PC %08x: keychip read %04x", space->cpu->tag(), cpu_get_pc(space->cpu), offset);
@ -544,9 +538,10 @@ static READ8_HANDLER( key_type3_r )
static WRITE8_HANDLER( key_type3_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("CPU %s PC %04x: keychip write %04x=%02x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset, data);
key[(offset & 0x70) >> 4] = data;
state->key[(offset & 0x70) >> 4] = data;
}
@ -573,18 +568,15 @@ WRITE8_HANDLER( namcos1_sound_bankswitch_w )
* *
*******************************************************************************/
static int mcu_patch_data;
static int namcos1_reset = 0;
static int wdog;
static int chip[16];
WRITE8_HANDLER( namcos1_cpu_control_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
// logerror("reset control pc=%04x %02x\n",cpu_get_pc(space->cpu),data);
if ((data & 1) ^ namcos1_reset)
if ((data & 1) ^ state->reset)
{
mcu_patch_data = 0;
namcos1_reset = data & 1;
state->mcu_patch_data = 0;
state->reset = data & 1;
}
cputag_set_input_line(space->machine, "sub", INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE);
@ -596,16 +588,17 @@ WRITE8_HANDLER( namcos1_cpu_control_w )
WRITE8_HANDLER( namcos1_watchdog_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
if (space->cpu == space->machine->device("maincpu"))
wdog |= 1;
state->wdog |= 1;
else if (space->cpu == space->machine->device("sub"))
wdog |= 2;
state->wdog |= 2;
else if (space->cpu == space->machine->device("audiocpu"))
wdog |= 4;
state->wdog |= 4;
if (wdog == 7 || !namcos1_reset)
if (state->wdog == 7 || !state->reset)
{
wdog = 0;
state->wdog = 0;
watchdog_reset_w(space,0,0);
}
}
@ -614,6 +607,7 @@ WRITE8_HANDLER( namcos1_watchdog_w )
static READ8_HANDLER( soundram_r )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
if (offset < 0x1000)
{
offset &= 0x3ff;
@ -626,12 +620,13 @@ static READ8_HANDLER( soundram_r )
offset &= 0x7ff;
/* shared ram */
return namcos1_triram[offset];
return state->triram[offset];
}
}
static WRITE8_HANDLER( soundram_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
if (offset < 0x1000)
{
offset &= 0x3ff;
@ -644,7 +639,7 @@ static WRITE8_HANDLER( soundram_w )
offset &= 0x7ff;
/* shared ram */
namcos1_triram[offset] = data;
state->triram[offset] = data;
return;
}
}
@ -673,6 +668,7 @@ static WRITE8_HANDLER( unknown_w )
/* Main bankswitching routine */
static void set_bank(running_machine *machine, int banknum, const bankhandler *handler)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
static const char *const banktags[] = {
"bank1", "bank2", "bank3", "bank4", "bank5", "bank6", "bank7", "bank8",
"bank9", "bank10", "bank11", "bank12", "bank13", "bank14", "bank15", "bank16"
@ -688,12 +684,12 @@ static void set_bank(running_machine *machine, int banknum, const bankhandler *h
/* read handlers */
if (!handler->bank_handler_r)
{
if (namcos1_active_bank[banknum].bank_handler_r)
if (state->active_bank[banknum].bank_handler_r)
memory_install_read_bank(space, bankstart, bankstart + 0x1fff, 0, 0, banktags[banknum]);
}
else
{
if (!namcos1_active_bank[banknum].bank_handler_r)
if (!state->active_bank[banknum].bank_handler_r)
memory_install_read8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_r[banknum]);
}
@ -702,42 +698,43 @@ static void set_bank(running_machine *machine, int banknum, const bankhandler *h
{
if (!handler->bank_handler_w)
{
if (namcos1_active_bank[banknum].bank_handler_w)
if (state->active_bank[banknum].bank_handler_w)
memory_install_write_bank(space, bankstart, bankstart + 0x1fff, 0, 0, banktags[banknum]);
}
else
{
if (!namcos1_active_bank[banknum].bank_handler_r)
if (!state->active_bank[banknum].bank_handler_r)
memory_install_write8_handler(space, bankstart, bankstart + 0x1fff, 0, 0, io_bank_handler_w[banknum]);
}
}
/* Remember this bank handler */
namcos1_active_bank[banknum] = *handler;
state->active_bank[banknum] = *handler;
}
static void namcos1_bankswitch(running_machine *machine, int cpu, offs_t offset, UINT8 data)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
int bank = (cpu*8) + (( offset >> 9) & 0x07);
if (offset & 1)
{
chip[bank] &= 0x0300;
chip[bank] |= (data & 0xff);
state->chip[bank] &= 0x0300;
state->chip[bank] |= (data & 0xff);
}
else
{
chip[bank] &= 0x00ff;
chip[bank] |= (data & 0x03) << 8;
state->chip[bank] &= 0x00ff;
state->chip[bank] |= (data & 0x03) << 8;
}
set_bank(machine, bank, &namcos1_bank_element[chip[bank]]);
set_bank(machine, bank, &state->bank_element[state->chip[bank]]);
/* unmapped bank warning */
if( namcos1_active_bank[bank].bank_handler_r == unknown_r)
if( state->active_bank[bank].bank_handler_r == unknown_r)
{
logerror("%s:warning unknown chip selected bank %x=$%04x\n", machine->describe_context(), bank , chip[bank] );
// if (chip) popmessage("%s:unknown chip selected bank %x=$%04x", cpu , machine->describe_context(), bank , chip[bank] );
logerror("%s:warning unknown chip selected bank %x=$%04x\n", machine->describe_context(), bank , state->chip[bank] );
// if (state->chip) popmessage("%s:unknown chip selected bank %x=$%04x", cpu , machine->describe_context(), bank , state->chip[bank] );
}
}
@ -764,16 +761,16 @@ WRITE8_HANDLER( namcos1_subcpu_bank_w )
* *
*******************************************************************************/
static void namcos1_install_bank(int start,int end,read8_space_func hr,write8_space_func hw,
static void namcos1_install_bank(namcos1_state *state, int start,int end,read8_space_func hr,write8_space_func hw,
int offset,UINT8 *pointer)
{
int i;
for(i=start;i<=end;i++)
{
namcos1_bank_element[i].bank_handler_r = hr;
namcos1_bank_element[i].bank_handler_w = hw;
namcos1_bank_element[i].bank_offset = offset;
namcos1_bank_element[i].bank_pointer = pointer;
state->bank_element[i].bank_handler_r = hr;
state->bank_element[i].bank_handler_w = hw;
state->bank_element[i].bank_offset = offset;
state->bank_element[i].bank_pointer = pointer;
offset += 0x2000;
if(pointer) pointer += 0x2000;
}
@ -783,6 +780,7 @@ static void namcos1_install_bank(int start,int end,read8_space_func hr,write8_sp
static void namcos1_build_banks(running_machine *machine,read8_space_func key_r,write8_space_func key_w)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
int i;
/**** kludge alert ****/
@ -806,30 +804,30 @@ static void namcos1_build_banks(running_machine *machine,read8_space_func key_r,
/* clear all banks to unknown area */
for(i = 0;i < NAMCOS1_MAX_BANK;i++)
namcos1_install_bank(i,i,0,unknown_w,0,dummyrom);
namcos1_install_bank(state,i,i,0,unknown_w,0,dummyrom);
/**** end of kludge alert ****/
/* 3D glasses */
namcos1_install_bank(0x160,0x160,0,namcos1_3dcs_w,0,0);
namcos1_install_bank(state,0x160,0x160,0,namcos1_3dcs_w,0,0);
/* RAM 6 banks - palette */
namcos1_install_bank(0x170,0x173,0,namcos1_paletteram_w,0,namcos1_paletteram);
namcos1_install_bank(state,0x170,0x173,0,namcos1_paletteram_w,0,state->paletteram);
/* RAM 5 banks - videoram */
namcos1_install_bank(0x178,0x17b,namcos1_videoram_r,namcos1_videoram_w,0,0);
namcos1_install_bank(state,0x178,0x17b,namcos1_videoram_r,namcos1_videoram_w,0,0);
/* key chip bank */
namcos1_install_bank(0x17c,0x17c,key_r,key_w,0,0);
namcos1_install_bank(state,0x17c,0x17c,key_r,key_w,0,0);
/* RAM 7 banks - display control, playfields, sprites */
namcos1_install_bank(0x17e,0x17e,namcos1_spriteram_r,namcos1_spriteram_w,0,0);
namcos1_install_bank(state,0x17e,0x17e,namcos1_spriteram_r,namcos1_spriteram_w,0,0);
/* RAM 1 shared ram, PSG device */
namcos1_install_bank(0x17f,0x17f,soundram_r,soundram_w,0,0);
namcos1_install_bank(state,0x17f,0x17f,soundram_r,soundram_w,0,0);
/* RAM 3 banks */
namcos1_install_bank(0x180,0x183,0,0,0,s1ram);
namcos1_install_bank(state,0x180,0x183,0,0,0,state->s1ram);
/* PRG0-PRG7 */
{
UINT8 *rom = machine->region("user1")->base();
namcos1_install_bank(0x200,0x3ff,0,rom_w,0,rom);
namcos1_install_bank(state,0x200,0x3ff,0,rom_w,0,rom);
/* bit 16 of the address is inverted for PRG7 (and bits 17,18 just not connected) */
for (i = 0x380000;i < 0x400000;i++)
@ -846,6 +844,7 @@ static void namcos1_build_banks(running_machine *machine,read8_space_func key_r,
MACHINE_RESET( namcos1 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
static const bankhandler unknown_handler = { unknown_r, unknown_w, 0, NULL };
int bank;
@ -876,13 +875,13 @@ MACHINE_RESET( namcos1 )
cputag_set_input_line(machine, "mcu", INPUT_LINE_RESET, ASSERT_LINE);
/* mcu patch data clear */
mcu_patch_data = 0;
namcos1_reset = 0;
state->mcu_patch_data = 0;
state->reset = 0;
namcos1_init_DACs();
memset(key, 0, sizeof(key));
memset(chip, 0, sizeof(chip));
wdog = 0;
namcos1_init_DACs(machine);
memset(state->key, 0, sizeof(state->key));
memset(state->chip, 0, sizeof(state->chip));
state->wdog = 0;
}
@ -938,10 +937,11 @@ WRITE8_HANDLER( namcos1_mcu_bankswitch_w )
WRITE8_HANDLER( namcos1_mcu_patch_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
//logerror("mcu C000 write pc=%04x data=%02x\n",cpu_get_pc(space->cpu),data);
if (mcu_patch_data == 0xa6) return;
mcu_patch_data = data;
namcos1_triram[0] = data;
if (state->mcu_patch_data == 0xa6) return;
state->mcu_patch_data = data;
state->triram[0] = data;
}
@ -967,6 +967,7 @@ struct namcos1_specific
static void namcos1_driver_init( running_machine *machine, const struct namcos1_specific *specific )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
static const struct namcos1_specific no_key =
{
no_key_r,no_key_w
@ -975,28 +976,28 @@ static void namcos1_driver_init( running_machine *machine, const struct namcos1_
if (!specific) specific = &no_key;
/* keychip id */
key_id = specific->key_id;
state->key_id = specific->key_id;
/* for key type 3 */
key_reg = specific->key_reg1;
key_rng = specific->key_reg2;
key_swap4_arg = specific->key_reg3;
key_swap4 = specific->key_reg4;
key_bottom4 = specific->key_reg5;
key_top4 = specific->key_reg6;
state->key_reg = specific->key_reg1;
state->key_rng = specific->key_reg2;
state->key_swap4_arg = specific->key_reg3;
state->key_swap4 = specific->key_reg4;
state->key_bottom4 = specific->key_reg5;
state->key_top4 = specific->key_reg6;
/* S1 RAM pointer set */
s1ram = auto_alloc_array(machine, UINT8, 0x8000);
namcos1_triram = auto_alloc_array(machine, UINT8, 0x800);
namcos1_paletteram = auto_alloc_array(machine, UINT8, 0x8000);
state->s1ram = auto_alloc_array(machine, UINT8, 0x8000);
state->triram = auto_alloc_array(machine, UINT8, 0x800);
state->paletteram = auto_alloc_array(machine, UINT8, 0x8000);
/* Register volatile user memory for save state */
state_save_register_global_pointer(machine, s1ram, 0x8000);
state_save_register_global_pointer(machine, namcos1_triram, 0x800);
state_save_register_global_pointer(machine, namcos1_paletteram, 0x8000);
state_save_register_global_pointer(machine, state->s1ram, 0x8000);
state_save_register_global_pointer(machine, state->triram, 0x800);
state_save_register_global_pointer(machine, state->paletteram, 0x8000);
/* Point mcu & sound shared RAM to destination */
memory_set_bankptr(machine, "bank18", namcos1_triram );
memory_set_bankptr(machine, "bank19", namcos1_triram );
memory_set_bankptr(machine, "bank18", state->triram );
memory_set_bankptr(machine, "bank19", state->triram );
/* build bank elements */
namcos1_build_banks(machine,specific->key_r,specific->key_w);

View File

@ -11,47 +11,23 @@
#include "includes/slapfght.h"
static int slapfight_status;
static int getstar_sequence_index;
static int getstar_sh_intenabled;
static int slapfight_status_state;
static UINT8 mcu_val;
/* used for MCU simulation of 'getstar' and its clones */
static UINT8 getstar_cmd;
/* copy of some Z80 registers for 'getstar' and its clones */
static UINT8 gs_a, gs_d, gs_e;
/* used for MCU simulation of 'tigerhb1' */
static UINT8 tigerhb_cmd;
static UINT8 from_main, from_mcu;
static int mcu_sent = 0, main_sent = 0;
static UINT8 portA_in, portA_out, ddrA;
static UINT8 portB_in, portB_out, ddrB;
static UINT8 portC_in, portC_out, ddrC;
/* Perform basic machine initialisation */
MACHINE_RESET( slapfight )
{
slapfght_state *state = machine->driver_data<slapfght_state>();
/* MAIN CPU */
slapfight_status_state=0;
slapfight_status = 0xc7;
state->slapfight_status_state=0;
state->slapfight_status = 0xc7;
getstar_sequence_index = 0;
getstar_sh_intenabled = 0; /* disable sound cpu interrupts */
state->getstar_sequence_index = 0;
state->getstar_sh_intenabled = 0; /* disable sound cpu interrupts */
/* SOUND CPU */
cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
/* MCU */
mcu_val = 0;
state->mcu_val = 0;
}
/* Slapfight CPU input/output ports
@ -63,8 +39,9 @@ MACHINE_RESET( slapfight )
/* Reset and hold sound CPU */
WRITE8_HANDLER( slapfight_port_00_w )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
getstar_sh_intenabled = 0;
state->getstar_sh_intenabled = 0;
}
/* Release reset on sound CPU */
@ -103,111 +80,124 @@ WRITE8_HANDLER( slapfight_port_09_w )
/* Status register */
READ8_HANDLER( slapfight_port_00_r )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
static const int states[3]={ 0xc7, 0x55, 0x00 };
slapfight_status = states[slapfight_status_state];
state->slapfight_status = states[state->slapfight_status_state];
slapfight_status_state++;
if (slapfight_status_state > 2) slapfight_status_state = 0;
state->slapfight_status_state++;
if (state->slapfight_status_state > 2) state->slapfight_status_state = 0;
return slapfight_status;
return state->slapfight_status;
}
READ8_HANDLER( slapfight_68705_portA_r )
{
return (portA_out & ddrA) | (portA_in & ~ddrA);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
return (state->portA_out & state->ddrA) | (state->portA_in & ~state->ddrA);
}
WRITE8_HANDLER( slapfight_68705_portA_w )
{
portA_out = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portA_out = data;
}
WRITE8_HANDLER( slapfight_68705_ddrA_w )
{
ddrA = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrA = data;
}
READ8_HANDLER( slapfight_68705_portB_r )
{
return (portB_out & ddrB) | (portB_in & ~ddrB);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
return (state->portB_out & state->ddrB) | (state->portB_in & ~state->ddrB);
}
WRITE8_HANDLER( slapfight_68705_portB_w )
{
if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
slapfght_state *state = space->machine->driver_data<slapfght_state>();
if ((state->ddrB & 0x02) && (~data & 0x02) && (state->portB_out & 0x02))
{
portA_in = from_main;
state->portA_in = state->from_main;
if (main_sent)
if (state->main_sent)
cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
main_sent = 0;
state->main_sent = 0;
}
if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
if ((state->ddrB & 0x04) && (data & 0x04) && (~state->portB_out & 0x04))
{
from_mcu = portA_out;
mcu_sent = 1;
state->from_mcu = state->portA_out;
state->mcu_sent = 1;
}
if ((ddrB & 0x08) && (~data & 0x08) && (portB_out & 0x08))
if ((state->ddrB & 0x08) && (~data & 0x08) && (state->portB_out & 0x08))
{
*slapfight_scrollx_lo = portA_out;
*state->slapfight_scrollx_lo = state->portA_out;
}
if ((ddrB & 0x10) && (~data & 0x10) && (portB_out & 0x10))
if ((state->ddrB & 0x10) && (~data & 0x10) && (state->portB_out & 0x10))
{
*slapfight_scrollx_hi = portA_out;
*state->slapfight_scrollx_hi = state->portA_out;
}
portB_out = data;
state->portB_out = data;
}
WRITE8_HANDLER( slapfight_68705_ddrB_w )
{
ddrB = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrB = data;
}
READ8_HANDLER( slapfight_68705_portC_r )
{
portC_in = 0;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portC_in = 0;
if (main_sent)
portC_in |= 0x01;
if (!mcu_sent)
portC_in |= 0x02;
if (state->main_sent)
state->portC_in |= 0x01;
if (!state->mcu_sent)
state->portC_in |= 0x02;
return (portC_out & ddrC) | (portC_in & ~ddrC);
return (state->portC_out & state->ddrC) | (state->portC_in & ~state->ddrC);
}
WRITE8_HANDLER( slapfight_68705_portC_w )
{
portC_out = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portC_out = data;
}
WRITE8_HANDLER( slapfight_68705_ddrC_w )
{
ddrC = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrC = data;
}
WRITE8_HANDLER( slapfight_mcu_w )
{
from_main = data;
main_sent = 1;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->from_main = data;
state->main_sent = 1;
cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
}
READ8_HANDLER( slapfight_mcu_r )
{
mcu_sent = 0;
return from_mcu;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->mcu_sent = 0;
return state->from_mcu;
}
READ8_HANDLER( slapfight_mcu_status_r )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
int res = 0;
if (!main_sent)
if (!state->main_sent)
res |= 0x02;
if (!mcu_sent)
if (!state->mcu_sent)
res |= 0x04;
return res;
@ -221,80 +211,81 @@ READ8_HANDLER( slapfight_mcu_status_r )
READ8_HANDLER( getstar_e803_r )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
UINT16 tmp = 0; /* needed for values computed on 16 bits */
UINT8 getstar_val = 0;
UINT8 phase_lookup_table[] = {0x00, 0x01, 0x03, 0xff, 0xff, 0x02, 0x05, 0xff, 0xff, 0x05}; /* table at 0x0e05 in 'gtstarb1' */
UINT8 lives_lookup_table[] = {0x03, 0x05, 0x01, 0x02}; /* table at 0x0e62 in 'gtstarb1' */
UINT8 lgsb2_lookup_table[] = {0x00, 0x03, 0x04, 0x05}; /* fake tanle for "test mode" in 'gtstarb2' */
switch (getstar_id)
switch (state->getstar_id)
{
case GETSTAR:
case GETSTARJ:
switch (getstar_cmd)
switch (state->getstar_cmd)
{
case 0x20: /* continue play */
getstar_val = ((gs_a & 0x30) == 0x30) ? 0x20 : 0x80;
getstar_val = ((state->gs_a & 0x30) == 0x30) ? 0x20 : 0x80;
break;
case 0x21: /* lose life */
getstar_val = (gs_a << 1) | (gs_a >> 7);
getstar_val = (state->gs_a << 1) | (state->gs_a >> 7);
break;
case 0x22: /* starting difficulty */
getstar_val = ((gs_a & 0x0c) >> 2) + 1;
getstar_val = ((state->gs_a & 0x0c) >> 2) + 1;
break;
case 0x23: /* starting lives */
getstar_val = lives_lookup_table[gs_a];
getstar_val = lives_lookup_table[state->gs_a];
break;
case 0x24: /* game phase */
getstar_val = phase_lookup_table[((gs_a & 0x18) >> 1) | (gs_a & 0x03)];
getstar_val = phase_lookup_table[((state->gs_a & 0x18) >> 1) | (state->gs_a & 0x03)];
break;
case 0x25: /* players inputs */
getstar_val = BITSWAP8(gs_a, 3, 2, 1, 0, 7, 5, 6, 4);
getstar_val = BITSWAP8(state->gs_a, 3, 2, 1, 0, 7, 5, 6, 4);
break;
case 0x26: /* background (1st read) */
tmp = 0x8800 + (0x001f * gs_a);
tmp = 0x8800 + (0x001f * state->gs_a);
getstar_val = (tmp & 0x00ff) >> 0;
getstar_cmd |= 0x80; /* to allow a second consecutive read */
state->getstar_cmd |= 0x80; /* to allow a second consecutive read */
break;
case 0xa6: /* background (2nd read) */
tmp = 0x8800 + (0x001f * gs_a);
tmp = 0x8800 + (0x001f * state->gs_a);
getstar_val = (tmp & 0xff00) >> 8;
break;
case 0x29: /* unknown effect */
getstar_val = 0x00;
break;
case 0x2a: /* change player (if 2 players game) */
getstar_val = (gs_a ^ 0x40);
getstar_val = (state->gs_a ^ 0x40);
break;
case 0x37: /* foreground (1st read) */
tmp = ((0xd0 + ((gs_e >> 2) & 0x0f)) << 8) | (0x40 * (gs_e & 03) + gs_d);
tmp = ((0xd0 + ((state->gs_e >> 2) & 0x0f)) << 8) | (0x40 * (state->gs_e & 03) + state->gs_d);
getstar_val = (tmp & 0x00ff) >> 0;
getstar_cmd |= 0x80; /* to allow a second consecutive read */
state->getstar_cmd |= 0x80; /* to allow a second consecutive read */
break;
case 0xb7: /* foreground (2nd read) */
tmp = ((0xd0 + ((gs_e >> 2) & 0x0f)) << 8) | (0x40 * (gs_e & 03) + gs_d);
tmp = ((0xd0 + ((state->gs_e >> 2) & 0x0f)) << 8) | (0x40 * (state->gs_e & 03) + state->gs_d);
getstar_val = (tmp & 0xff00) >> 8;
break;
case 0x38: /* laser position (1st read) */
tmp = 0xf740 - (((gs_e >> 4) << 8) | ((gs_e & 0x08) ? 0x80 : 0x00)) + (0x02 + (gs_d >> 2));
tmp = 0xf740 - (((state->gs_e >> 4) << 8) | ((state->gs_e & 0x08) ? 0x80 : 0x00)) + (0x02 + (state->gs_d >> 2));
getstar_val = (tmp & 0x00ff) >> 0;
getstar_cmd |= 0x80; /* to allow a second consecutive read */
state->getstar_cmd |= 0x80; /* to allow a second consecutive read */
break;
case 0xb8: /* laser position (2nd read) */
tmp = 0xf740 - (((gs_e >> 4) << 8) | ((gs_e & 0x08) ? 0x80 : 0x00)) + (0x02 + (gs_d >> 2));
tmp = 0xf740 - (((state->gs_e >> 4) << 8) | ((state->gs_e & 0x08) ? 0x80 : 0x00)) + (0x02 + (state->gs_d >> 2));
getstar_val = (tmp & 0xff00) >> 8;
break;
case 0x73: /* avoid "BAD HW" message */
getstar_val = 0x76;
break;
default:
logerror("%04x: getstar_e803_r - cmd = %02x\n",cpu_get_pc(space->cpu),getstar_cmd);
logerror("%04x: getstar_e803_r - cmd = %02x\n",cpu_get_pc(space->cpu),state->getstar_cmd);
break;
}
break;
case GTSTARB1:
/* value isn't computed by the bootleg but we want to please the "test mode" */
if (cpu_get_pc(space->cpu) == 0x6b04) return (lives_lookup_table[gs_a]);
if (cpu_get_pc(space->cpu) == 0x6b04) return (lives_lookup_table[state->gs_a]);
break;
case GTSTARB2:
/*
@ -311,10 +302,10 @@ READ8_HANDLER( getstar_e803_r )
if (cpu_get_pc(space->cpu) == 0x0570) return (getstar_val+1);
if (cpu_get_pc(space->cpu) == 0x0577) return ((getstar_val+0x05) ^ 0x56);
/* value isn't computed by the bootleg but we want to please the "test mode" */
if (cpu_get_pc(space->cpu) == 0x6b04) return (lgsb2_lookup_table[gs_a]);
if (cpu_get_pc(space->cpu) == 0x6b04) return (lgsb2_lookup_table[state->gs_a]);
break;
default:
logerror("%04x: getstar_e803_r - cmd = %02x - unknown set !\n",cpu_get_pc(space->cpu),getstar_cmd);
logerror("%04x: getstar_e803_r - cmd = %02x - unknown set !\n",cpu_get_pc(space->cpu),state->getstar_cmd);
break;
}
return getstar_val;
@ -322,189 +313,190 @@ READ8_HANDLER( getstar_e803_r )
WRITE8_HANDLER( getstar_e803_w )
{
switch (getstar_id)
slapfght_state *state = space->machine->driver_data<slapfght_state>();
switch (state->getstar_id)
{
case GETSTAR:
/* unknown effect - not read back */
if (cpu_get_pc(space->cpu) == 0x00bf)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_RESET_REGS
}
/* players inputs */
if (cpu_get_pc(space->cpu) == 0x0560)
{
getstar_cmd = 0x25;
state->getstar_cmd = 0x25;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x056d)
{
getstar_cmd = 0x25;
state->getstar_cmd = 0x25;
GS_SAVE_REGS
}
/* lose life */
if (cpu_get_pc(space->cpu) == 0x0a0a)
{
getstar_cmd = 0x21;
state->getstar_cmd = 0x21;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0a17)
{
getstar_cmd = 0x21;
state->getstar_cmd = 0x21;
GS_SAVE_REGS
}
/* unknown effect */
if (cpu_get_pc(space->cpu) == 0x0a51)
{
getstar_cmd = 0x29;
state->getstar_cmd = 0x29;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0a6e)
{
getstar_cmd = 0x29;
state->getstar_cmd = 0x29;
GS_SAVE_REGS
}
/* continue play */
if (cpu_get_pc(space->cpu) == 0x0ae3)
{
getstar_cmd = 0x20;
state->getstar_cmd = 0x20;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0af0)
{
getstar_cmd = 0x20;
state->getstar_cmd = 0x20;
GS_SAVE_REGS
}
/* unknown effect - not read back */
if (cpu_get_pc(space->cpu) == 0x0b62)
{
getstar_cmd = 0x00; /* 0x1f */
state->getstar_cmd = 0x00; /* 0x1f */
GS_RESET_REGS
}
/* change player (if 2 players game) */
if (cpu_get_pc(space->cpu) == 0x0bab)
{
getstar_cmd = 0x2a;
state->getstar_cmd = 0x2a;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0bb8)
{
getstar_cmd = 0x2a;
state->getstar_cmd = 0x2a;
GS_SAVE_REGS
}
/* game phase */
if (cpu_get_pc(space->cpu) == 0x0d37)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0d44)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_SAVE_REGS
}
/* starting lives */
if (cpu_get_pc(space->cpu) == 0x0d79)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0d8a)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
/* starting difficulty */
if (cpu_get_pc(space->cpu) == 0x0dc1)
{
getstar_cmd = 0x22;
state->getstar_cmd = 0x22;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0dd0)
{
getstar_cmd = 0x22;
state->getstar_cmd = 0x22;
GS_SAVE_REGS
}
/* starting lives (again) */
if (cpu_get_pc(space->cpu) == 0x1011)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x101e)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
/* hardware test */
if (cpu_get_pc(space->cpu) == 0x107a)
{
getstar_cmd = 0x73;
state->getstar_cmd = 0x73;
GS_RESET_REGS
}
/* game phase (again) */
if (cpu_get_pc(space->cpu) == 0x10c6)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x10d3)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_SAVE_REGS
}
/* background */
if (cpu_get_pc(space->cpu) == 0x1910)
{
getstar_cmd = 0x26;
state->getstar_cmd = 0x26;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x191d)
{
getstar_cmd = 0x26;
state->getstar_cmd = 0x26;
GS_SAVE_REGS
}
/* foreground */
if (cpu_get_pc(space->cpu) == 0x19d5)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x19e4)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
GS_SAVE_REGS
}
if (cpu_get_pc(space->cpu) == 0x19f1)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
/* do NOT update the registers because there are 2 writes before 2 reads ! */
}
/* laser position */
if (cpu_get_pc(space->cpu) == 0x26af)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x26be)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
GS_SAVE_REGS
}
if (cpu_get_pc(space->cpu) == 0x26cb)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
/* do NOT update the registers because there are 2 writes before 2 reads ! */
}
/* starting lives (for "test mode") */
if (cpu_get_pc(space->cpu) == 0x6a27)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x6a38)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
break;
@ -512,183 +504,183 @@ WRITE8_HANDLER( getstar_e803_w )
/* unknown effect - not read back */
if (cpu_get_pc(space->cpu) == 0x00bf)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_RESET_REGS
}
/* players inputs */
if (cpu_get_pc(space->cpu) == 0x0560)
{
getstar_cmd = 0x25;
state->getstar_cmd = 0x25;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x056d)
{
getstar_cmd = 0x25;
state->getstar_cmd = 0x25;
GS_SAVE_REGS
}
/* lose life */
if (cpu_get_pc(space->cpu) == 0x0ad5)
{
getstar_cmd = 0x21;
state->getstar_cmd = 0x21;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0ae2)
{
getstar_cmd = 0x21;
state->getstar_cmd = 0x21;
GS_SAVE_REGS
}
/* unknown effect */
if (cpu_get_pc(space->cpu) == 0x0b1c)
{
getstar_cmd = 0x29;
state->getstar_cmd = 0x29;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0b29)
{
getstar_cmd = 0x29;
state->getstar_cmd = 0x29;
GS_SAVE_REGS
}
/* continue play */
if (cpu_get_pc(space->cpu) == 0x0bae)
{
getstar_cmd = 0x20;
state->getstar_cmd = 0x20;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0bbb)
{
getstar_cmd = 0x20;
state->getstar_cmd = 0x20;
GS_SAVE_REGS
}
/* unknown effect - not read back */
if (cpu_get_pc(space->cpu) == 0x0c2d)
{
getstar_cmd = 0x00; /* 0x1f */
state->getstar_cmd = 0x00; /* 0x1f */
GS_RESET_REGS
}
/* change player (if 2 players game) */
if (cpu_get_pc(space->cpu) == 0x0c76)
{
getstar_cmd = 0x2a;
state->getstar_cmd = 0x2a;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0c83)
{
getstar_cmd = 0x2a;
state->getstar_cmd = 0x2a;
GS_SAVE_REGS
}
/* game phase */
if (cpu_get_pc(space->cpu) == 0x0e02)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0e0f)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_SAVE_REGS
}
/* starting lives */
if (cpu_get_pc(space->cpu) == 0x0e44)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0e55)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
/* starting difficulty */
if (cpu_get_pc(space->cpu) == 0x0e8c)
{
getstar_cmd = 0x22;
state->getstar_cmd = 0x22;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x0e9b)
{
getstar_cmd = 0x22;
state->getstar_cmd = 0x22;
GS_SAVE_REGS
}
/* starting lives (again) */
if (cpu_get_pc(space->cpu) == 0x10d6)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x10e3)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
/* hardware test */
if (cpu_get_pc(space->cpu) == 0x113f)
{
getstar_cmd = 0x73;
state->getstar_cmd = 0x73;
GS_RESET_REGS
}
/* game phase (again) */
if (cpu_get_pc(space->cpu) == 0x118b)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x1198)
{
getstar_cmd = 0x24;
state->getstar_cmd = 0x24;
GS_SAVE_REGS
}
/* background */
if (cpu_get_pc(space->cpu) == 0x19f8)
{
getstar_cmd = 0x26;
state->getstar_cmd = 0x26;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x1a05)
{
getstar_cmd = 0x26;
state->getstar_cmd = 0x26;
GS_SAVE_REGS
}
/* foreground */
if (cpu_get_pc(space->cpu) == 0x1abd)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x1acc)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
GS_SAVE_REGS
}
if (cpu_get_pc(space->cpu) == 0x1ad9)
{
getstar_cmd = 0x37;
state->getstar_cmd = 0x37;
/* do NOT update the registers because there are 2 writes before 2 reads ! */
}
/* laser position */
if (cpu_get_pc(space->cpu) == 0x2792)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x27a1)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
GS_SAVE_REGS
}
if (cpu_get_pc(space->cpu) == 0x27ae)
{
getstar_cmd = 0x38;
state->getstar_cmd = 0x38;
/* do NOT update the registers because there are 2 writes before 2 reads ! */
}
/* starting lives (for "test mode") */
if (cpu_get_pc(space->cpu) == 0x6ae2)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x6af3)
{
getstar_cmd = 0x23;
state->getstar_cmd = 0x23;
GS_SAVE_REGS
}
break;
@ -720,12 +712,12 @@ WRITE8_HANDLER( getstar_e803_w )
*/
if (cpu_get_pc(space->cpu) == 0x6ae2)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x6af3)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_SAVE_REGS
}
break;
@ -759,12 +751,12 @@ WRITE8_HANDLER( getstar_e803_w )
*/
if (cpu_get_pc(space->cpu) == 0x6ae2)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_RESET_REGS
}
if (cpu_get_pc(space->cpu) == 0x6af3)
{
getstar_cmd = 0x00;
state->getstar_cmd = 0x00;
GS_SAVE_REGS
}
break;
@ -777,7 +769,8 @@ WRITE8_HANDLER( getstar_e803_w )
/* Enable hardware interrupt of sound cpu */
WRITE8_HANDLER( getstar_sh_intenable_w )
{
getstar_sh_intenabled = 1;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->getstar_sh_intenabled = 1;
logerror("cpu #1 PC=%d: %d written to a0e0\n",cpu_get_pc(space->cpu),data);
}
@ -786,7 +779,8 @@ WRITE8_HANDLER( getstar_sh_intenable_w )
/* Generate interrups only if they have been enabled */
INTERRUPT_GEN( getstar_interrupt )
{
if (getstar_sh_intenabled)
slapfght_state *state = device->machine->driver_data<slapfght_state>();
if (state->getstar_sh_intenabled)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
@ -806,101 +800,114 @@ WRITE8_HANDLER( getstar_port_04_w )
READ8_HANDLER( tigerh_68705_portA_r )
{
return (portA_out & ddrA) | (portA_in & ~ddrA);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
return (state->portA_out & state->ddrA) | (state->portA_in & ~state->ddrA);
}
WRITE8_HANDLER( tigerh_68705_portA_w )
{
portA_out = data;//?
from_mcu = portA_out;
mcu_sent = 1;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portA_out = data;//?
state->from_mcu = state->portA_out;
state->mcu_sent = 1;
}
WRITE8_HANDLER( tigerh_68705_ddrA_w )
{
ddrA = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrA = data;
}
READ8_HANDLER( tigerh_68705_portB_r )
{
return (portB_out & ddrB) | (portB_in & ~ddrB);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
return (state->portB_out & state->ddrB) | (state->portB_in & ~state->ddrB);
}
WRITE8_HANDLER( tigerh_68705_portB_w )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
if ((state->ddrB & 0x02) && (~data & 0x02) && (state->portB_out & 0x02))
{
portA_in = from_main;
if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
main_sent = 0;
state->portA_in = state->from_main;
if (state->main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
state->main_sent = 0;
}
if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
if ((state->ddrB & 0x04) && (data & 0x04) && (~state->portB_out & 0x04))
{
from_mcu = portA_out;
mcu_sent = 1;
state->from_mcu = state->portA_out;
state->mcu_sent = 1;
}
portB_out = data;
state->portB_out = data;
}
WRITE8_HANDLER( tigerh_68705_ddrB_w )
{
ddrB = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrB = data;
}
READ8_HANDLER( tigerh_68705_portC_r )
{
portC_in = 0;
if (!main_sent) portC_in |= 0x01;
if (mcu_sent) portC_in |= 0x02;
return (portC_out & ddrC) | (portC_in & ~ddrC);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portC_in = 0;
if (!state->main_sent) state->portC_in |= 0x01;
if (state->mcu_sent) state->portC_in |= 0x02;
return (state->portC_out & state->ddrC) | (state->portC_in & ~state->ddrC);
}
WRITE8_HANDLER( tigerh_68705_portC_w )
{
portC_out = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->portC_out = data;
}
WRITE8_HANDLER( tigerh_68705_ddrC_w )
{
ddrC = data;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->ddrC = data;
}
WRITE8_HANDLER( tigerh_mcu_w )
{
from_main = data;
main_sent = 1;
mcu_sent = 0;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->from_main = data;
state->main_sent = 1;
state->mcu_sent = 0;
cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
}
READ8_HANDLER( tigerh_mcu_r )
{
mcu_sent = 0;
return from_mcu;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->mcu_sent = 0;
return state->from_mcu;
}
READ8_HANDLER( tigerh_mcu_status_r )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
int res = 0;
if (!main_sent) res |= 0x02;
if (!mcu_sent) res |= 0x04;
if (!state->main_sent) res |= 0x02;
if (!state->mcu_sent) res |= 0x04;
return res;
}
READ8_HANDLER( tigerhb_e803_r )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
UINT8 tigerhb_val = 0;
switch (tigerhb_cmd)
switch (state->tigerhb_cmd)
{
case 0x73: /* avoid "BAD HW" message */
tigerhb_val = 0x83;
break;
default:
logerror("%04x: tigerhb_e803_r - cmd = %02x\n",cpu_get_pc(space->cpu),getstar_cmd);
logerror("%04x: tigerhb_e803_r - cmd = %02x\n",cpu_get_pc(space->cpu),state->getstar_cmd);
break;
}
return tigerhb_val;
@ -908,15 +915,16 @@ READ8_HANDLER( tigerhb_e803_r )
WRITE8_HANDLER( tigerhb_e803_w )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
switch (data)
{
/* hardware test */
case 0x73:
tigerhb_cmd = 0x73;
state->tigerhb_cmd = 0x73;
break;
default:
logerror("%04x: tigerhb_e803_w - data = %02x\n",cpu_get_pc(space->cpu),data);
tigerhb_cmd = 0x00;
state->tigerhb_cmd = 0x00;
break;
}
}

View File

@ -234,8 +234,8 @@ static void run_mproc(running_machine *machine)
IP6_0 = state->PROM_MAS[state->MPA];
#if (MATHDEBUG)
mame_printf_debug("\n(state->MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",state->MPA, IP15_8, IP7, IP6_0);
mame_printf_debug("(state->BIC: %x), state->A: %x, state->B: %x, state->C: %x, state->ACC: %x\n",state->BIC,state->A,state->B,state->C,state->ACC);
mame_printf_debug("\n(MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",state->MPA, IP15_8, IP7, IP6_0);
mame_printf_debug("(BIC: %x), A: %x, B: %x, C: %x, ACC: %x\n",state->BIC,state->A,state->B,state->C,state->ACC);
#endif
/* construct the current RAM address */

View File

@ -11,23 +11,18 @@
#include "includes/bagman.h"
UINT8 *bagman_video_enable;
UINT8 *bagman_videoram;
UINT8 *bagman_colorram;
static tilemap_t *bg_tilemap;
WRITE8_HANDLER( bagman_videoram_w )
{
bagman_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
bagman_state *state = space->machine->driver_data<bagman_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( bagman_colorram_w )
{
bagman_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
bagman_state *state = space->machine->driver_data<bagman_state>();
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
/***************************************************************************
@ -88,28 +83,31 @@ PALETTE_INIT( bagman )
WRITE8_HANDLER( bagman_flipscreen_w )
{
bagman_state *state = space->machine->driver_data<bagman_state>();
if ((flip_screen_get(space->machine) ^ data) & 1)
{
flip_screen_set(space->machine, data & 0x01);
tilemap_mark_all_tiles_dirty(bg_tilemap);
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
}
static TILE_GET_INFO( get_bg_tile_info )
{
int gfxbank = (machine->gfx[2] && (bagman_colorram[tile_index] & 0x10)) ? 2 : 0;
int code = bagman_videoram[tile_index] + 8 * (bagman_colorram[tile_index] & 0x20);
int color = bagman_colorram[tile_index] & 0x0f;
bagman_state *state = machine->driver_data<bagman_state>();
int gfxbank = (machine->gfx[2] && (state->colorram[tile_index] & 0x10)) ? 2 : 0;
int code = state->videoram[tile_index] + 8 * (state->colorram[tile_index] & 0x20);
int color = state->colorram[tile_index] & 0x0f;
SET_TILE_INFO(gfxbank, code, color, 0);
}
VIDEO_START( bagman )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
bagman_state *state = machine->driver_data<bagman_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
tilemap_set_scrolldy(bg_tilemap, -1, -1);
tilemap_set_scrolldy(state->bg_tilemap, -1, -1);
}
@ -149,12 +147,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( bagman )
{
bagman_state *state = screen->machine->driver_data<bagman_state>();
bitmap_fill(bitmap,cliprect,0);
if (*bagman_video_enable == 0)
if (*state->video_enable == 0)
return 0;
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -237,7 +237,7 @@ WRITE8_HANDLER( HuC6270_data_w )
}
break;
}
logerror("%04x: unknown write to state->VDC_register %02x (%02x) at %02x\n",cpu_get_pc(space->cpu),state->VDC_register,data,offset);
logerror("%04x: unknown write to VDC_register %02x (%02x) at %02x\n",cpu_get_pc(space->cpu),state->VDC_register,data,offset);
}
/******************************************************************************/

View File

@ -10,7 +10,6 @@
#include "emu.h"
#include "includes/gridlee.h"
#include "includes/balsente.h"
/*************************************
@ -118,7 +117,7 @@ WRITE8_HANDLER( gridlee_palette_select_w )
{
gridlee_state *state = space->machine->driver_data<gridlee_state>();
/* update the scanline palette */
space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1 + BALSENTE_VBEND);
space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1 + GRIDLEE_VBEND);
state->palettebank_vis = data & 0x3f;
}
@ -130,7 +129,7 @@ WRITE8_HANDLER( gridlee_palette_select_w )
*
*************************************/
/* all the BALSENTE_VBEND adjustments are needed because the hardware has a seperate counting chain
/* all the GRIDLEE_VBEND adjustments are needed because the hardware has a seperate counting chain
to address the video memory instead of using the video chain directly */
SCREEN_UPDATE( gridlee )
@ -145,12 +144,12 @@ SCREEN_UPDATE( gridlee )
{
/* non-flipped: draw directly from the bitmap */
if (!state->cocktail_flip)
draw_scanline8(bitmap, 0, y, 256, &state->local_videoram[(y - BALSENTE_VBEND) * 256], pens + 16);
draw_scanline8(bitmap, 0, y, 256, &state->local_videoram[(y - GRIDLEE_VBEND) * 256], pens + 16);
/* flipped: x-flip the scanline into a temp buffer and draw that */
else
{
int srcy = BALSENTE_VBSTART - 1 - y;
int srcy = GRIDLEE_VBSTART - 1 - y;
UINT8 temp[256];
int xx;
@ -167,7 +166,7 @@ SCREEN_UPDATE( gridlee )
UINT8 *sprite = screen->machine->generic.spriteram.u8 + i * 4;
UINT8 *src;
int image = sprite[0];
int ypos = sprite[2] + 17 + BALSENTE_VBEND;
int ypos = sprite[2] + 17 + GRIDLEE_VBEND;
int xpos = sprite[3];
/* get a pointer to the source image */
@ -185,7 +184,7 @@ SCREEN_UPDATE( gridlee )
currxor = 0xff;
}
if (ypos >= (16 + BALSENTE_VBEND) && ypos >= cliprect->min_y && ypos <= cliprect->max_y)
if (ypos >= (16 + GRIDLEE_VBEND) && ypos >= cliprect->min_y && ypos <= cliprect->max_y)
{
int currx = xpos;

View File

@ -1,10 +1,6 @@
#include "emu.h"
#include "includes/gstriker.h"
//UINT16 *gs_videoram3;
//UINT16 *gs_mixer_regs;
UINT16 *gstriker_lineram;
/*** VS920A (score tilemap) **********************************************/
@ -28,36 +24,38 @@ t=tile, p=palette
*/
sVS920A VS920A[MAX_VS920A];
static sVS920A* VS920A_cur_chip;
static TILE_GET_INFO( VS920A_get_tile_info )
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int data;
int tileno, pal;
data = VS920A_cur_chip->vram[tile_index];
data = state->VS920A_cur_chip->vram[tile_index];
tileno = data & 0xFFF;
pal = (data >> 12) & 0xF;
SET_TILE_INFO(VS920A_cur_chip->gfx_region, tileno, VS920A_cur_chip->pal_base + pal, 0);
SET_TILE_INFO(state->VS920A_cur_chip->gfx_region, tileno, state->VS920A_cur_chip->pal_base + pal, 0);
}
WRITE16_HANDLER( VS920A_0_vram_w )
{
COMBINE_DATA(&VS920A[0].vram[offset]);
tilemap_mark_tile_dirty(VS920A[0].tmap, offset);
gstriker_state *state = space->machine->driver_data<gstriker_state>();
COMBINE_DATA(&state->VS920A[0].vram[offset]);
tilemap_mark_tile_dirty(state->VS920A[0].tmap, offset);
}
WRITE16_HANDLER( VS920A_1_vram_w )
{
COMBINE_DATA(&VS920A[1].vram[offset]);
tilemap_mark_tile_dirty(VS920A[1].tmap, offset);
gstriker_state *state = space->machine->driver_data<gstriker_state>();
COMBINE_DATA(&state->VS920A[1].vram[offset]);
tilemap_mark_tile_dirty(state->VS920A[1].tmap, offset);
}
static void VS920A_init(running_machine *machine, int numchips)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int i;
if (numchips > MAX_VS920A)
@ -65,32 +63,32 @@ static void VS920A_init(running_machine *machine, int numchips)
for (i=0;i<numchips;i++)
{
VS920A[i].tmap = tilemap_create(machine, VS920A_get_tile_info,tilemap_scan_rows,8,8,64,32);
state->VS920A[i].tmap = tilemap_create(machine, VS920A_get_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_transparent_pen(VS920A[i].tmap, 0);
tilemap_set_transparent_pen(state->VS920A[i].tmap, 0);
}
}
static tilemap_t* VS920A_get_tilemap(int numchip)
static tilemap_t* VS920A_get_tilemap(gstriker_state *state, int numchip)
{
return VS920A[numchip].tmap;
return state->VS920A[numchip].tmap;
}
static void VS920A_set_pal_base(int numchip, int pal_base)
static void VS920A_set_pal_base(gstriker_state *state, int numchip, int pal_base)
{
VS920A[numchip].pal_base = pal_base;
state->VS920A[numchip].pal_base = pal_base;
}
static void VS920A_set_gfx_region(int numchip, int gfx_region)
static void VS920A_set_gfx_region(gstriker_state *state, int numchip, int gfx_region)
{
VS920A[numchip].gfx_region = gfx_region;
state->VS920A[numchip].gfx_region = gfx_region;
}
static void VS920A_draw(int numchip, bitmap_t* screen, const rectangle* cliprect, int priority)
static void VS920A_draw(gstriker_state *state, int numchip, bitmap_t* screen, const rectangle* cliprect, int priority)
{
VS920A_cur_chip = &VS920A[numchip];
state->VS920A_cur_chip = &state->VS920A[numchip];
tilemap_draw(screen, cliprect, VS920A_cur_chip->tmap, 0, priority);
tilemap_draw(screen, cliprect, state->VS920A_cur_chip->tmap, 0, priority);
}
@ -141,27 +139,26 @@ index is in the MSB. gstriker uses 5 bits for banking, but the chips could be ab
*/
tMB60553 MB60553[MAX_MB60553];
static tMB60553 *MB60553_cur_chip;
static TILE_GET_INFO( MB60553_get_tile_info )
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int data, bankno;
int tileno, pal;
data = MB60553_cur_chip->vram[tile_index];
data = state->MB60553_cur_chip->vram[tile_index];
tileno = data & 0x1FF;
pal = (data >> 12) & 0xF;
bankno = (data >> 9) & 0x7;
SET_TILE_INFO(MB60553->gfx_region, tileno + MB60553_cur_chip->bank[bankno] * 0x200, pal + MB60553->pal_base, 0);
SET_TILE_INFO(state->MB60553->gfx_region, tileno + state->MB60553_cur_chip->bank[bankno] * 0x200, pal + state->MB60553->pal_base, 0);
}
static void MB60553_reg_written(int numchip, int num_reg)
static void MB60553_reg_written(gstriker_state *state, int numchip, int num_reg)
{
tMB60553* cur = &MB60553[numchip];
tMB60553* cur = &state->MB60553[numchip];
switch (num_reg)
{
@ -216,6 +213,7 @@ static TILEMAP_MAPPER( twc94_scan )
static void MB60553_init(running_machine *machine, int numchips)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int i;
if (numchips > MAX_MB60553)
@ -223,28 +221,29 @@ static void MB60553_init(running_machine *machine, int numchips)
for (i=0;i<numchips;i++)
{
MB60553[i].tmap = tilemap_create(machine, MB60553_get_tile_info,twc94_scan, 16,16,128,64);
state->MB60553[i].tmap = tilemap_create(machine, MB60553_get_tile_info,twc94_scan, 16,16,128,64);
tilemap_set_transparent_pen(MB60553[i].tmap, 0);
tilemap_set_transparent_pen(state->MB60553[i].tmap, 0);
}
}
static void MB60553_set_pal_base(int numchip, int pal_base)
static void MB60553_set_pal_base(gstriker_state *state, int numchip, int pal_base)
{
MB60553[numchip].pal_base = pal_base;
state->MB60553[numchip].pal_base = pal_base;
}
static void MB60553_set_gfx_region(int numchip, int gfx_region)
static void MB60553_set_gfx_region(gstriker_state *state, int numchip, int gfx_region)
{
MB60553[numchip].gfx_region = gfx_region;
state->MB60553[numchip].gfx_region = gfx_region;
}
/* THIS IS STILL WRONG! */
static void MB60553_draw(running_machine *machine, int numchip, bitmap_t* screen, const rectangle* cliprect, int priority)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int line;
rectangle clip;
MB60553_cur_chip = &MB60553[numchip];
state->MB60553_cur_chip = &state->MB60553[numchip];
clip.min_x = machine->primary_screen->visible_area().min_x;
clip.max_x = machine->primary_screen->visible_area().max_x;
@ -258,19 +257,19 @@ static void MB60553_draw(running_machine *machine, int numchip, bitmap_t* screen
UINT32 incxx,incyy;
startx = MB60553_cur_chip->regs[0];
starty = MB60553_cur_chip->regs[1];
startx = state->MB60553_cur_chip->regs[0];
starty = state->MB60553_cur_chip->regs[1];
startx += (24<<4); // maybe not..
startx -= gstriker_lineram[(line)*8+7]/2;
startx -= state->lineram[(line)*8+7]/2;
incxx = gstriker_lineram[(line)*8+0]<<4;
incyy = gstriker_lineram[(line)*8+3]<<4;
incxx = state->lineram[(line)*8+0]<<4;
incyy = state->lineram[(line)*8+3]<<4;
clip.min_y = clip.max_y = line;
tilemap_draw_roz(screen,&clip,MB60553_cur_chip->tmap,startx<<12,starty<<12,
tilemap_draw_roz(screen,&clip,state->MB60553_cur_chip->tmap,startx<<12,starty<<12,
incxx,0,0,incyy,
1,
0,priority);
@ -281,44 +280,48 @@ static void MB60553_draw(running_machine *machine, int numchip, bitmap_t* screen
}
static tilemap_t* MB60553_get_tilemap(int numchip)
static tilemap_t* MB60553_get_tilemap(gstriker_state *state, int numchip)
{
return MB60553[numchip].tmap;
return state->MB60553[numchip].tmap;
}
WRITE16_HANDLER(MB60553_0_regs_w)
{
UINT16 oldreg = MB60553[0].regs[offset];
gstriker_state *state = space->machine->driver_data<gstriker_state>();
UINT16 oldreg = state->MB60553[0].regs[offset];
COMBINE_DATA(&MB60553[0].regs[offset]);
COMBINE_DATA(&state->MB60553[0].regs[offset]);
if (MB60553[0].regs[offset] != oldreg)
MB60553_reg_written(0, offset);
if (state->MB60553[0].regs[offset] != oldreg)
MB60553_reg_written(state, 0, offset);
}
WRITE16_HANDLER(MB60553_1_regs_w)
{
UINT16 oldreg = MB60553[1].regs[offset];
gstriker_state *state = space->machine->driver_data<gstriker_state>();
UINT16 oldreg = state->MB60553[1].regs[offset];
COMBINE_DATA(&MB60553[1].regs[offset]);
COMBINE_DATA(&state->MB60553[1].regs[offset]);
if (MB60553[1].regs[offset] != oldreg)
MB60553_reg_written(1, offset);
if (state->MB60553[1].regs[offset] != oldreg)
MB60553_reg_written(state, 1, offset);
}
WRITE16_HANDLER(MB60553_0_vram_w)
{
COMBINE_DATA(&MB60553[0].vram[offset]);
gstriker_state *state = space->machine->driver_data<gstriker_state>();
COMBINE_DATA(&state->MB60553[0].vram[offset]);
tilemap_mark_tile_dirty(MB60553[0].tmap, offset);
tilemap_mark_tile_dirty(state->MB60553[0].tmap, offset);
}
WRITE16_HANDLER(MB60553_1_vram_w)
{
COMBINE_DATA(&MB60553[1].vram[offset]);
gstriker_state *state = space->machine->driver_data<gstriker_state>();
COMBINE_DATA(&state->MB60553[1].vram[offset]);
tilemap_mark_tile_dirty(MB60553[1].tmap, offset);
tilemap_mark_tile_dirty(state->MB60553[1].tmap, offset);
}
@ -379,11 +382,10 @@ Abstracts the VS9210
*/
tCG10103 CG10103[MAX_CG10103];
static tCG10103* CG10103_cur_chip;
static void CG10103_draw_sprite(running_machine *machine, bitmap_t* screen, const rectangle* cliprect, UINT16* spr, int drawpri)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
int ypos = spr[0] & 0x1FF;
int xpos = (spr[1] & 0x1FF);
UINT32 tile = (spr[3] & 0xFFFF) | ((spr[2] & 1) << 16);
@ -433,7 +435,7 @@ static void CG10103_draw_sprite(running_machine *machine, bitmap_t* screen, cons
// @@@ Add here optional connection to the VS9210 for extra level of tile number indirection
#if 0
if (CG10103_cur_chip->connected_vs9210)
if (state->CG10103_cur_chip->connected_vs9210)
{
// ...
}
@ -447,8 +449,8 @@ static void CG10103_draw_sprite(running_machine *machine, bitmap_t* screen, cons
for (x=0;x<xnum;x++)
{
// Hack to handle horizontal wrapping
drawgfxzoom_transpen(screen, cliprect, machine->gfx[CG10103_cur_chip->gfx_region], tile, color+CG10103_cur_chip->pal_base, flipx, flipy, xp>>16, ypos>>16, xfact, yfact, CG10103_cur_chip->transpen);
drawgfxzoom_transpen(screen, cliprect, machine->gfx[CG10103_cur_chip->gfx_region], tile, color+CG10103_cur_chip->pal_base, flipx, flipy, (xp>>16) - 0x200, ypos>>16, xfact, yfact, CG10103_cur_chip->transpen);
drawgfxzoom_transpen(screen, cliprect, machine->gfx[state->CG10103_cur_chip->gfx_region], tile, color+state->CG10103_cur_chip->pal_base, flipx, flipy, xp>>16, ypos>>16, xfact, yfact, state->CG10103_cur_chip->transpen);
drawgfxzoom_transpen(screen, cliprect, machine->gfx[state->CG10103_cur_chip->gfx_region], tile, color+state->CG10103_cur_chip->pal_base, flipx, flipy, (xp>>16) - 0x200, ypos>>16, xfact, yfact, state->CG10103_cur_chip->transpen);
xp += xstep;
tile++;
}
@ -460,12 +462,13 @@ static void CG10103_draw_sprite(running_machine *machine, bitmap_t* screen, cons
static void CG10103_draw(running_machine *machine, int numchip, bitmap_t* screen, const rectangle* cliprect, int priority)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
UINT16* splist;
int i;
CG10103_cur_chip = &CG10103[numchip];
state->CG10103_cur_chip = &state->CG10103[numchip];
splist = CG10103_cur_chip->vram;
splist = state->CG10103_cur_chip->vram;
// Parse the sorting list
for (i=0;i<0x400;i++)
@ -483,7 +486,7 @@ static void CG10103_draw(running_machine *machine, int numchip, bitmap_t* screen
int num = cmd & 0xFF;
// Draw the sprite
CG10103_draw_sprite(machine, screen, cliprect, CG10103_cur_chip->vram + 0x400 + num*4, priority);
CG10103_draw_sprite(machine, screen, cliprect, state->CG10103_cur_chip->vram + 0x400 + num*4, priority);
}
}
}
@ -502,19 +505,19 @@ static void CG10103_init(int numchips)
}
}
static void CG10103_set_pal_base(int numchip, int pal_base)
static void CG10103_set_pal_base(gstriker_state *state, int numchip, int pal_base)
{
CG10103[numchip].pal_base = pal_base;
state->CG10103[numchip].pal_base = pal_base;
}
static void CG10103_set_gfx_region(int numchip, int gfx_region)
static void CG10103_set_gfx_region(gstriker_state *state, int numchip, int gfx_region)
{
CG10103[numchip].gfx_region = gfx_region;
state->CG10103[numchip].gfx_region = gfx_region;
}
static void CG10103_set_transpen(int numchip, int transpen)
static void CG10103_set_transpen(gstriker_state *state, int numchip, int transpen)
{
CG10103[numchip].transpen = transpen;
state->CG10103[numchip].transpen = transpen;
}
@ -532,6 +535,7 @@ WRITE16_HANDLER( gsx_videoram3_w )
SCREEN_UPDATE(gstriker)
{
gstriker_state *state = screen->machine->driver_data<gstriker_state>();
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
// Sandwitched screen/sprite0/score/sprite1. Surely wrong, probably
@ -540,14 +544,14 @@ SCREEN_UPDATE(gstriker)
CG10103_draw(screen->machine, 0, bitmap, cliprect, 0);
VS920A_draw(0, bitmap, cliprect, 0);
VS920A_draw(state, 0, bitmap, cliprect, 0);
CG10103_draw(screen->machine, 0, bitmap, cliprect, 1);
#if 0
popmessage("%04x %04x %04x %04x %04x %04x %04x %04x",
(UINT16)MB60553[0].regs[0], (UINT16)MB60553[0].regs[1], (UINT16)MB60553[0].regs[2], (UINT16)MB60553[0].regs[3],
(UINT16)MB60553[0].regs[4], (UINT16)MB60553[0].regs[5], (UINT16)MB60553[0].regs[6], (UINT16)MB60553[0].regs[7]
(UINT16)state->MB60553[0].regs[0], (UINT16)state->MB60553[0].regs[1], (UINT16)state->MB60553[0].regs[2], (UINT16)state->MB60553[0].regs[3],
(UINT16)state->MB60553[0].regs[4], (UINT16)state->MB60553[0].regs[5], (UINT16)state->MB60553[0].regs[6], (UINT16)state->MB60553[0].regs[7]
);
#endif
@ -562,69 +566,75 @@ SCREEN_UPDATE(gstriker)
VIDEO_START(gstriker)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
// Palette bases are hardcoded, but should be probably extracted from the mixer registers
// Initalize the chip for the score plane
VS920A_init(machine, 1);
VS920A_set_gfx_region(0, 0);
VS920A_set_pal_base(0, 0x30);
tilemap_set_transparent_pen(VS920A_get_tilemap(0), 0xf);
VS920A_set_gfx_region(state, 0, 0);
VS920A_set_pal_base(state, 0, 0x30);
tilemap_set_transparent_pen(VS920A_get_tilemap(state, 0), 0xf);
// Initalize the chip for the screen plane
MB60553_init(machine, 1);
MB60553_set_gfx_region(0, 1);
MB60553_set_pal_base(0, 0);
tilemap_set_transparent_pen(MB60553_get_tilemap(0), 0xf);
MB60553_set_gfx_region(state, 0, 1);
MB60553_set_pal_base(state, 0, 0);
tilemap_set_transparent_pen(MB60553_get_tilemap(state, 0), 0xf);
// Initialize the sprite generator
CG10103_init(1);
CG10103_set_gfx_region(0, 2);
CG10103_set_pal_base(0, 0x10);
CG10103_set_transpen(0, 0x0);
CG10103_set_gfx_region(state, 0, 2);
CG10103_set_pal_base(state, 0, 0x10);
CG10103_set_transpen(state, 0, 0x0);
}
VIDEO_START(twrldc94)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
// Palette bases are hardcoded, but should be probably extracted from the mixer registers
// Initalize the chip for the score plane
VS920A_init(machine, 1);
VS920A_set_gfx_region(0, 0);
VS920A_set_pal_base(0, 0x40);
tilemap_set_transparent_pen(VS920A_get_tilemap(0), 0xf);
VS920A_set_gfx_region(state, 0, 0);
VS920A_set_pal_base(state, 0, 0x40);
tilemap_set_transparent_pen(VS920A_get_tilemap(state, 0), 0xf);
// Initalize the chip for the screen plane
MB60553_init(machine, 1);
MB60553_set_gfx_region(0, 1);
MB60553_set_pal_base(0, 0x50);
tilemap_set_transparent_pen(MB60553_get_tilemap(0), 0xf);
MB60553_set_gfx_region(state, 0, 1);
MB60553_set_pal_base(state, 0, 0x50);
tilemap_set_transparent_pen(MB60553_get_tilemap(state, 0), 0xf);
// Initialize the sprite generator
CG10103_init(1);
CG10103_set_gfx_region(0, 2);
CG10103_set_pal_base(0, 0x60);
CG10103_set_transpen(0, 0x0);
CG10103_set_gfx_region(state, 0, 2);
CG10103_set_pal_base(state, 0, 0x60);
CG10103_set_transpen(state, 0, 0x0);
}
VIDEO_START(vgoalsoc)
{
gstriker_state *state = machine->driver_data<gstriker_state>();
// Palette bases are hardcoded, but should be probably extracted from the mixer registers
// Initalize the chip for the score plane
VS920A_init(machine, 1);
VS920A_set_gfx_region(0, 0);
VS920A_set_pal_base(0, 0x30);
tilemap_set_transparent_pen(VS920A_get_tilemap(0), 0xf);
VS920A_set_gfx_region(state, 0, 0);
VS920A_set_pal_base(state, 0, 0x30);
tilemap_set_transparent_pen(VS920A_get_tilemap(state, 0), 0xf);
// Initalize the chip for the screen plane
MB60553_init(machine, 1);
MB60553_set_gfx_region(0, 1);
MB60553_set_pal_base(0, 0x20);
tilemap_set_transparent_pen(MB60553_get_tilemap(0), 0xf);
MB60553_set_gfx_region(state, 0, 1);
MB60553_set_pal_base(state, 0, 0x20);
tilemap_set_transparent_pen(MB60553_get_tilemap(state, 0), 0xf);
// Initialize the sprite generator
CG10103_init(1);
CG10103_set_gfx_region(0, 2);
CG10103_set_pal_base(0, 0x00);
CG10103_set_transpen(0, 0xf);
CG10103_set_gfx_region(state, 0, 2);
CG10103_set_pal_base(state, 0, 0x00);
CG10103_set_transpen(state, 0, 0xf);
}

View File

@ -16,144 +16,113 @@ priority should be given to
#include "includes/tetrisp2.h"
#include "includes/ms32.h"
static bitmap_t* temp_bitmap_tilemaps;
static bitmap_t* temp_bitmap_sprites;
static bitmap_t* temp_bitmap_sprites_pri;
//UINT32 *ms32_fce00000;
UINT32 *ms32_roz_ctrl;
UINT32 *ms32_tx_scroll;
UINT32 *ms32_bg_scroll;
//UINT32 *ms32_priram;
//UINT32 *ms32_palram;
//UINT32 *ms32_rozram;
//UINT32 *ms32_lineram;
//UINT32 *ms32_spram;
//UINT32 *ms32_bgram;
//UINT32 *ms32_txram;
UINT32 *ms32_mainram;
UINT8* ms32_priram_8;
UINT16* ms32_palram_16;
UINT16* ms32_rozram_16;
UINT16 *ms32_lineram_16;
UINT16 *ms32_sprram_16;
UINT16 *ms32_bgram_16;
UINT16 *ms32_txram_16;
UINT32 ms32_tilemaplayoutcontrol;
UINT16* f1superb_extraram_16;
// kirarast, tp2m32, and 47pie2 require the sprites in a different order
static int ms32_reverse_sprite_order;
/********** Tilemaps **********/
tilemap_t *ms32_tx_tilemap, *ms32_roz_tilemap, *ms32_bg_tilemap, *ms32_bg_tilemap_alt;
tilemap_t *ms32_extra_tilemap;
static int flipscreen;
static TILE_GET_INFO( get_ms32_tx_tile_info )
{
ms32_state *state = machine->driver_data<ms32_state>();
int tileno, colour;
tileno = ms32_txram_16[tile_index *2] & 0xffff;
colour = ms32_txram_16[tile_index *2+1] & 0x000f;
tileno = state->txram_16[tile_index *2] & 0xffff;
colour = state->txram_16[tile_index *2+1] & 0x000f;
SET_TILE_INFO(3,tileno,colour,0);
}
static TILE_GET_INFO( get_ms32_roz_tile_info )
{
ms32_state *state = machine->driver_data<ms32_state>();
int tileno,colour;
tileno = ms32_rozram_16[tile_index *2] & 0xffff;
colour = ms32_rozram_16[tile_index *2+1] & 0x000f;
tileno = state->rozram_16[tile_index *2] & 0xffff;
colour = state->rozram_16[tile_index *2+1] & 0x000f;
SET_TILE_INFO(1,tileno,colour,0);
}
static TILE_GET_INFO( get_ms32_bg_tile_info )
{
ms32_state *state = machine->driver_data<ms32_state>();
int tileno,colour;
tileno = ms32_bgram_16[tile_index *2] & 0xffff;
colour = ms32_bgram_16[tile_index *2+1] & 0x000f;
tileno = state->bgram_16[tile_index *2] & 0xffff;
colour = state->bgram_16[tile_index *2+1] & 0x000f;
SET_TILE_INFO(2,tileno,colour,0);
}
static TILE_GET_INFO( get_ms32_extra_tile_info )
{
ms32_state *state = machine->driver_data<ms32_state>();
int tileno,colour;
tileno = f1superb_extraram_16[tile_index *2] & 0xffff;
colour = f1superb_extraram_16[tile_index *2+1] & 0x000f;
tileno = state->f1superb_extraram_16[tile_index *2] & 0xffff;
colour = state->f1superb_extraram_16[tile_index *2+1] & 0x000f;
SET_TILE_INFO(4,tileno,colour+0x50,0);
}
static UINT32 brt[4];
static int brt_r,brt_g,brt_b;
VIDEO_START( ms32 )
{
ms32_state *state = machine->driver_data<ms32_state>();
int width = machine->primary_screen->width();
int height = machine->primary_screen->height();
ms32_priram_8 = auto_alloc_array_clear(machine, UINT8, 0x2000);
ms32_palram_16 = auto_alloc_array_clear(machine, UINT16, 0x20000);
ms32_rozram_16 = auto_alloc_array_clear(machine, UINT16, 0x10000);
ms32_lineram_16 = auto_alloc_array_clear(machine, UINT16, 0x1000);
ms32_sprram_16 = auto_alloc_array_clear(machine, UINT16, 0x20000);
ms32_bgram_16 = auto_alloc_array_clear(machine, UINT16, 0x4000);
ms32_txram_16 = auto_alloc_array_clear(machine, UINT16, 0x4000);
state->priram_8 = auto_alloc_array_clear(machine, UINT8, 0x2000);
state->palram_16 = auto_alloc_array_clear(machine, UINT16, 0x20000);
state->rozram_16 = auto_alloc_array_clear(machine, UINT16, 0x10000);
state->lineram_16 = auto_alloc_array_clear(machine, UINT16, 0x1000);
state->sprram_16 = auto_alloc_array_clear(machine, UINT16, 0x20000);
state->bgram_16 = auto_alloc_array_clear(machine, UINT16, 0x4000);
state->txram_16 = auto_alloc_array_clear(machine, UINT16, 0x4000);
ms32_tx_tilemap = tilemap_create(machine, get_ms32_tx_tile_info,tilemap_scan_rows,8, 8,64,64);
ms32_bg_tilemap = tilemap_create(machine, get_ms32_bg_tile_info,tilemap_scan_rows,16,16,64,64);
ms32_bg_tilemap_alt = tilemap_create(machine, get_ms32_bg_tile_info,tilemap_scan_rows,16,16,256,16); // alt layout, controller by register?
ms32_roz_tilemap = tilemap_create(machine, get_ms32_roz_tile_info,tilemap_scan_rows,16,16,128,128);
state->tx_tilemap = tilemap_create(machine, get_ms32_tx_tile_info,tilemap_scan_rows,8, 8,64,64);
state->bg_tilemap = tilemap_create(machine, get_ms32_bg_tile_info,tilemap_scan_rows,16,16,64,64);
state->bg_tilemap_alt = tilemap_create(machine, get_ms32_bg_tile_info,tilemap_scan_rows,16,16,256,16); // alt layout, controller by register?
state->roz_tilemap = tilemap_create(machine, get_ms32_roz_tile_info,tilemap_scan_rows,16,16,128,128);
/* set up tile layers */
temp_bitmap_tilemaps = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
temp_bitmap_sprites = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
temp_bitmap_sprites_pri = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); // not actually being used for rendering, we embed pri info in the raw colour bitmap
state->temp_bitmap_tilemaps = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
state->temp_bitmap_sprites = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
state->temp_bitmap_sprites_pri = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); // not actually being used for rendering, we embed pri info in the raw colour bitmap
bitmap_fill(temp_bitmap_tilemaps,0,0);
bitmap_fill(temp_bitmap_sprites,0,0);
bitmap_fill(temp_bitmap_sprites_pri,0,0);
bitmap_fill(state->temp_bitmap_tilemaps,0,0);
bitmap_fill(state->temp_bitmap_sprites,0,0);
bitmap_fill(state->temp_bitmap_sprites_pri,0,0);
tilemap_set_transparent_pen(ms32_tx_tilemap,0);
tilemap_set_transparent_pen(ms32_bg_tilemap,0);
tilemap_set_transparent_pen(ms32_bg_tilemap_alt,0);
tilemap_set_transparent_pen(ms32_roz_tilemap,0);
tilemap_set_transparent_pen(state->tx_tilemap,0);
tilemap_set_transparent_pen(state->bg_tilemap,0);
tilemap_set_transparent_pen(state->bg_tilemap_alt,0);
tilemap_set_transparent_pen(state->roz_tilemap,0);
ms32_reverse_sprite_order = 1;
state->reverse_sprite_order = 1;
/* i hate per game patches...how should priority really work? tetrisp2.c ? i can't follow it */
if (!strcmp(machine->gamedrv->name,"kirarast")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"tp2m32")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"47pie2")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"47pie2o")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"hayaosi3")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"bnstars")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"wpksocv2")) ms32_reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"kirarast")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"tp2m32")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"47pie2")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"47pie2o")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"hayaosi3")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"bnstars")) state->reverse_sprite_order = 0;
if (!strcmp(machine->gamedrv->name,"wpksocv2")) state->reverse_sprite_order = 0;
// tp2m32 doesn't set the brightness registers so we need sensible defaults
brt[0] = brt[1] = 0xffff;
state->brt[0] = state->brt[1] = 0xffff;
}
VIDEO_START( f1superb )
{
ms32_state *state = machine->driver_data<ms32_state>();
VIDEO_START_CALL( ms32 );
f1superb_extraram_16 = auto_alloc_array_clear(machine, UINT16, 0x10000);
ms32_extra_tilemap = tilemap_create(machine, get_ms32_extra_tile_info,tilemap_scan_rows,2048,1,1,0x400);
state->f1superb_extraram_16 = auto_alloc_array_clear(machine, UINT16, 0x10000);
state->extra_tilemap = tilemap_create(machine, get_ms32_extra_tile_info,tilemap_scan_rows,2048,1,1,0x400);
}
@ -162,6 +131,7 @@ VIDEO_START( f1superb )
static void update_color(running_machine *machine, int color)
{
ms32_state *state = machine->driver_data<ms32_state>();
int r,g,b;
/* I'm not sure how the brightness should be applied, currently I'm only
@ -170,15 +140,15 @@ static void update_color(running_machine *machine, int color)
*/
if (~color & 0x4000)
{
r = ((ms32_palram_16[color*2] & 0xff00) >>8 ) * brt_r / 0x100;
g = ((ms32_palram_16[color*2] & 0x00ff) >>0 ) * brt_g / 0x100;
b = ((ms32_palram_16[color*2+1] & 0x00ff) >>0 ) * brt_b / 0x100;
r = ((state->palram_16[color*2] & 0xff00) >>8 ) * state->brt_r / 0x100;
g = ((state->palram_16[color*2] & 0x00ff) >>0 ) * state->brt_g / 0x100;
b = ((state->palram_16[color*2+1] & 0x00ff) >>0 ) * state->brt_b / 0x100;
}
else
{
r = ((ms32_palram_16[color*2] & 0xff00) >>8 );
g = ((ms32_palram_16[color*2] & 0x00ff) >>0 );
b = ((ms32_palram_16[color*2+1] & 0x00ff) >>0 );
r = ((state->palram_16[color*2] & 0xff00) >>8 );
g = ((state->palram_16[color*2] & 0x00ff) >>0 );
b = ((state->palram_16[color*2+1] & 0x00ff) >>0 );
}
palette_set_color(machine,color,MAKE_RGB(r,g,b));
@ -186,26 +156,27 @@ static void update_color(running_machine *machine, int color)
WRITE32_HANDLER( ms32_brightness_w )
{
int oldword = brt[offset];
COMBINE_DATA(&brt[offset]);
ms32_state *state = space->machine->driver_data<ms32_state>();
int oldword = state->brt[offset];
COMBINE_DATA(&state->brt[offset]);
if (brt[offset] != oldword)
if (state->brt[offset] != oldword)
{
int bank = ((offset & 2) >> 1) * 0x4000;
//int i;
if (bank == 0)
{
brt_r = 0x100 - ((brt[0] & 0xff00) >> 8);
brt_g = 0x100 - ((brt[0] & 0x00ff) >> 0);
brt_b = 0x100 - ((brt[1] & 0x00ff) >> 0);
state->brt_r = 0x100 - ((state->brt[0] & 0xff00) >> 8);
state->brt_g = 0x100 - ((state->brt[0] & 0x00ff) >> 0);
state->brt_b = 0x100 - ((state->brt[1] & 0x00ff) >> 0);
// for (i = 0;i < 0x3000;i++) // colors 0x3000-0x3fff are not used
// update_color(space->machine, i);
}
}
//popmessage("%04x %04x %04x %04x",brt[0],brt[1],brt[2],brt[3]);
//popmessage("%04x %04x %04x %04x",state->brt[0],state->brt[1],state->brt[2],state->brt[3]);
}
@ -215,13 +186,14 @@ WRITE32_HANDLER( ms32_brightness_w )
WRITE32_HANDLER( ms32_gfxctrl_w )
{
ms32_state *state = space->machine->driver_data<ms32_state>();
if (ACCESSING_BITS_0_7)
{
/* bit 1 = flip screen */
flipscreen = data & 0x02;
tilemap_set_flip(ms32_tx_tilemap,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_flip(ms32_bg_tilemap,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_flip(ms32_bg_tilemap_alt,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
state->flipscreen = data & 0x02;
tilemap_set_flip(state->tx_tilemap,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_flip(state->bg_tilemap,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_flip(state->bg_tilemap_alt,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
/* bit 2 used by f1superb, unknown */
@ -240,11 +212,12 @@ WRITE32_HANDLER( ms32_gfxctrl_w )
static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
static void draw_roz(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,int priority)
{
ms32_state *state = machine->driver_data<ms32_state>();
/* TODO: registers 0x40/4 / 0x44/4 and 0x50/4 / 0x54/4 are used, meaning unknown */
if (ms32_roz_ctrl[0x5c/4] & 1) /* "super" mode */
if (state->roz_ctrl[0x5c/4] & 1) /* "super" mode */
{
rectangle my_clip;
int y,maxy;
@ -257,21 +230,21 @@ static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
while (y <= maxy)
{
UINT16 *lineaddr = ms32_lineram_16 + 8 * (y & 0xff);
UINT16 *lineaddr = state->lineram_16 + 8 * (y & 0xff);
int start2x = (lineaddr[0x00/4] & 0xffff) | ((lineaddr[0x04/4] & 3) << 16);
int start2y = (lineaddr[0x08/4] & 0xffff) | ((lineaddr[0x0c/4] & 3) << 16);
int incxx = (lineaddr[0x10/4] & 0xffff) | ((lineaddr[0x14/4] & 1) << 16);
int incxy = (lineaddr[0x18/4] & 0xffff) | ((lineaddr[0x1c/4] & 1) << 16);
int startx = (ms32_roz_ctrl[0x00/4] & 0xffff) | ((ms32_roz_ctrl[0x04/4] & 3) << 16);
int starty = (ms32_roz_ctrl[0x08/4] & 0xffff) | ((ms32_roz_ctrl[0x0c/4] & 3) << 16);
int offsx = ms32_roz_ctrl[0x30/4];
int offsy = ms32_roz_ctrl[0x34/4];
int startx = (state->roz_ctrl[0x00/4] & 0xffff) | ((state->roz_ctrl[0x04/4] & 3) << 16);
int starty = (state->roz_ctrl[0x08/4] & 0xffff) | ((state->roz_ctrl[0x0c/4] & 3) << 16);
int offsx = state->roz_ctrl[0x30/4];
int offsy = state->roz_ctrl[0x34/4];
my_clip.min_y = my_clip.max_y = y;
offsx += (ms32_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsy += (ms32_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsx += (state->roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsy += (state->roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1...
/* extend sign */
if (start2x & 0x20000) start2x |= ~0x3ffff;
@ -281,7 +254,7 @@ static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
if (incxx & 0x10000) incxx |= ~0x1ffff;
if (incxy & 0x10000) incxy |= ~0x1ffff;
tilemap_draw_roz(bitmap, &my_clip, ms32_roz_tilemap,
tilemap_draw_roz(bitmap, &my_clip, state->roz_tilemap,
(start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16,
incxx<<8, incxy<<8, 0, 0,
1, // Wrap
@ -292,17 +265,17 @@ static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
}
else /* "simple" mode */
{
int startx = (ms32_roz_ctrl[0x00/4] & 0xffff) | ((ms32_roz_ctrl[0x04/4] & 3) << 16);
int starty = (ms32_roz_ctrl[0x08/4] & 0xffff) | ((ms32_roz_ctrl[0x0c/4] & 3) << 16);
int incxx = (ms32_roz_ctrl[0x10/4] & 0xffff) | ((ms32_roz_ctrl[0x14/4] & 1) << 16);
int incxy = (ms32_roz_ctrl[0x18/4] & 0xffff) | ((ms32_roz_ctrl[0x1c/4] & 1) << 16);
int incyy = (ms32_roz_ctrl[0x20/4] & 0xffff) | ((ms32_roz_ctrl[0x24/4] & 1) << 16);
int incyx = (ms32_roz_ctrl[0x28/4] & 0xffff) | ((ms32_roz_ctrl[0x2c/4] & 1) << 16);
int offsx = ms32_roz_ctrl[0x30/4];
int offsy = ms32_roz_ctrl[0x34/4];
int startx = (state->roz_ctrl[0x00/4] & 0xffff) | ((state->roz_ctrl[0x04/4] & 3) << 16);
int starty = (state->roz_ctrl[0x08/4] & 0xffff) | ((state->roz_ctrl[0x0c/4] & 3) << 16);
int incxx = (state->roz_ctrl[0x10/4] & 0xffff) | ((state->roz_ctrl[0x14/4] & 1) << 16);
int incxy = (state->roz_ctrl[0x18/4] & 0xffff) | ((state->roz_ctrl[0x1c/4] & 1) << 16);
int incyy = (state->roz_ctrl[0x20/4] & 0xffff) | ((state->roz_ctrl[0x24/4] & 1) << 16);
int incyx = (state->roz_ctrl[0x28/4] & 0xffff) | ((state->roz_ctrl[0x2c/4] & 1) << 16);
int offsx = state->roz_ctrl[0x30/4];
int offsy = state->roz_ctrl[0x34/4];
offsx += (ms32_roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsy += (ms32_roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsx += (state->roz_ctrl[0x38/4] & 1) * 0x400; // ??? gratia, hayaosi1...
offsy += (state->roz_ctrl[0x3c/4] & 1) * 0x400; // ??? gratia, hayaosi1...
/* extend sign */
if (startx & 0x20000) startx |= ~0x3ffff;
@ -312,7 +285,7 @@ static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
if (incyy & 0x10000) incyy |= ~0x1ffff;
if (incyx & 0x10000) incyx |= ~0x1ffff;
tilemap_draw_roz(bitmap, cliprect, ms32_roz_tilemap,
tilemap_draw_roz(bitmap, cliprect, state->roz_tilemap,
(startx+offsx)<<16, (starty+offsy)<<16,
incxx<<8, incxy<<8, incyx<<8, incyy<<8,
1, // Wrap
@ -324,6 +297,7 @@ static void draw_roz(bitmap_t *bitmap, const rectangle *cliprect,int priority)
SCREEN_UPDATE( ms32 )
{
ms32_state *state = screen->machine->driver_data<ms32_state>();
int scrollx,scrolly;
int asc_pri;
int scr_pri;
@ -342,17 +316,17 @@ SCREEN_UPDATE( ms32 )
for (i = 0;i < 0x10000;i++) // colors 0x3000-0x3fff are not used
update_color(screen->machine, i);
scrollx = ms32_tx_scroll[0x00/4] + ms32_tx_scroll[0x08/4] + 0x18;
scrolly = ms32_tx_scroll[0x0c/4] + ms32_tx_scroll[0x14/4];
tilemap_set_scrollx(ms32_tx_tilemap, 0, scrollx);
tilemap_set_scrolly(ms32_tx_tilemap, 0, scrolly);
scrollx = state->tx_scroll[0x00/4] + state->tx_scroll[0x08/4] + 0x18;
scrolly = state->tx_scroll[0x0c/4] + state->tx_scroll[0x14/4];
tilemap_set_scrollx(state->tx_tilemap, 0, scrollx);
tilemap_set_scrolly(state->tx_tilemap, 0, scrolly);
scrollx = ms32_bg_scroll[0x00/4] + ms32_bg_scroll[0x08/4] + 0x10;
scrolly = ms32_bg_scroll[0x0c/4] + ms32_bg_scroll[0x14/4];
tilemap_set_scrollx(ms32_bg_tilemap, 0, scrollx);
tilemap_set_scrolly(ms32_bg_tilemap, 0, scrolly);
tilemap_set_scrollx(ms32_bg_tilemap_alt, 0, scrollx);
tilemap_set_scrolly(ms32_bg_tilemap_alt, 0, scrolly);
scrollx = state->bg_scroll[0x00/4] + state->bg_scroll[0x08/4] + 0x10;
scrolly = state->bg_scroll[0x0c/4] + state->bg_scroll[0x14/4];
tilemap_set_scrollx(state->bg_tilemap, 0, scrollx);
tilemap_set_scrolly(state->bg_tilemap, 0, scrolly);
tilemap_set_scrollx(state->bg_tilemap_alt, 0, scrollx);
tilemap_set_scrolly(state->bg_tilemap_alt, 0, scrolly);
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
@ -361,75 +335,75 @@ SCREEN_UPDATE( ms32 )
/* TODO: 0 is correct for gametngk, but break f1superb scrolling grid (text at
top and bottom of the screen becomes black on black) */
bitmap_fill(temp_bitmap_tilemaps,cliprect,0); /* bg color */
bitmap_fill(state->temp_bitmap_tilemaps,cliprect,0); /* bg color */
/* clear our sprite bitmaps */
bitmap_fill(temp_bitmap_sprites,cliprect,0);
bitmap_fill(temp_bitmap_sprites_pri,cliprect,0);
bitmap_fill(state->temp_bitmap_sprites,cliprect,0);
bitmap_fill(state->temp_bitmap_sprites_pri,cliprect,0);
tetrisp2_draw_sprites(screen->machine, temp_bitmap_sprites, temp_bitmap_sprites_pri, cliprect, NULL, ms32_sprram_16, 0x20000, 0, ms32_reverse_sprite_order, 0, 1 );
tetrisp2_draw_sprites(screen->machine, state->temp_bitmap_sprites, state->temp_bitmap_sprites_pri, cliprect, NULL, state->sprram_16, 0x20000, 0, state->reverse_sprite_order, 0, 1 );
asc_pri = scr_pri = rot_pri = 0;
if((ms32_priram_8[0x2b00 / 2] & 0x00ff) == 0x0034)
if((state->priram_8[0x2b00 / 2] & 0x00ff) == 0x0034)
asc_pri++;
else
rot_pri++;
if((ms32_priram_8[0x2e00 / 2] & 0x00ff) == 0x0034)
if((state->priram_8[0x2e00 / 2] & 0x00ff) == 0x0034)
asc_pri++;
else
scr_pri++;
if((ms32_priram_8[0x3a00 / 2] & 0x00ff) == 0x000c)
if((state->priram_8[0x3a00 / 2] & 0x00ff) == 0x000c)
scr_pri++;
else
rot_pri++;
if (rot_pri == 0)
draw_roz(temp_bitmap_tilemaps,cliprect, 1 << 1);
draw_roz(screen->machine, state->temp_bitmap_tilemaps, cliprect, 1 << 1);
else if (scr_pri == 0)
if (ms32_tilemaplayoutcontrol&1)
if (state->tilemaplayoutcontrol&1)
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap_alt, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap_alt, 0, 1 << 0);
}
else
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap, 0, 1 << 0);
}
else if (asc_pri == 0)
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_tx_tilemap, 0, 1 << 2);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->tx_tilemap, 0, 1 << 2);
if (rot_pri == 1)
draw_roz(temp_bitmap_tilemaps,cliprect, 1 << 1);
draw_roz(screen->machine, state->temp_bitmap_tilemaps, cliprect, 1 << 1);
else if (scr_pri == 1)
if (ms32_tilemaplayoutcontrol&1)
if (state->tilemaplayoutcontrol&1)
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap_alt, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap_alt, 0, 1 << 0);
}
else
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap, 0, 1 << 0);
}
else if (asc_pri == 1)
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_tx_tilemap, 0, 1 << 2);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->tx_tilemap, 0, 1 << 2);
if (rot_pri == 2)
draw_roz(temp_bitmap_tilemaps,cliprect, 1 << 1);
draw_roz(screen->machine, state->temp_bitmap_tilemaps, cliprect, 1 << 1);
else if (scr_pri == 2)
if (ms32_tilemaplayoutcontrol&1)
if (state->tilemaplayoutcontrol&1)
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap_alt, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap_alt, 0, 1 << 0);
}
else
{
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_bg_tilemap, 0, 1 << 0);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->bg_tilemap, 0, 1 << 0);
}
else if (asc_pri == 2)
tilemap_draw(temp_bitmap_tilemaps,cliprect, ms32_tx_tilemap, 0, 1 << 2);
tilemap_draw(state->temp_bitmap_tilemaps,cliprect, state->tx_tilemap, 0, 1 << 2);
/* MIX it! */
/* this mixing isn't 100% accurate, it should be using ALL the data in
@ -452,10 +426,10 @@ SCREEN_UPDATE( ms32 )
for (yy=0;yy<height;yy++)
{
srcptr_tile = BITMAP_ADDR16(temp_bitmap_tilemaps, yy, 0);
srcptr_tile = BITMAP_ADDR16(state->temp_bitmap_tilemaps, yy, 0);
srcptr_tilepri = BITMAP_ADDR8(screen->machine->priority_bitmap, yy, 0);
srcptr_spri = BITMAP_ADDR16(temp_bitmap_sprites, yy, 0);
//srcptr_spripri = BITMAP_ADDR8(temp_bitmap_sprites_pri, yy, 0);
srcptr_spri = BITMAP_ADDR16(state->temp_bitmap_sprites, yy, 0);
//srcptr_spripri = BITMAP_ADDR8(state->temp_bitmap_sprites_pri, yy, 0);
dstptr_bitmap = BITMAP_ADDR32(bitmap, yy, 0);
for (xx=0;xx<width;xx++)
{
@ -468,14 +442,14 @@ SCREEN_UPDATE( ms32 )
int primask = 0;
// get sprite priority value back out of bitmap/colour data (this is done in draw_sprite for standalone hw)
if (ms32_priram_8[(spritepri | 0x0a00 | 0x1500) / 2] & 0x38) primask |= 1 << 0;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x1400) / 2] & 0x38) primask |= 1 << 1;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x1100) / 2] & 0x38) primask |= 1 << 2;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x1000) / 2] & 0x38) primask |= 1 << 3;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x0500) / 2] & 0x38) primask |= 1 << 4;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x0400) / 2] & 0x38) primask |= 1 << 5;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x0100) / 2] & 0x38) primask |= 1 << 6;
if (ms32_priram_8[(spritepri | 0x0a00 | 0x0000) / 2] & 0x38) primask |= 1 << 7;
if (state->priram_8[(spritepri | 0x0a00 | 0x1500) / 2] & 0x38) primask |= 1 << 0;
if (state->priram_8[(spritepri | 0x0a00 | 0x1400) / 2] & 0x38) primask |= 1 << 1;
if (state->priram_8[(spritepri | 0x0a00 | 0x1100) / 2] & 0x38) primask |= 1 << 2;
if (state->priram_8[(spritepri | 0x0a00 | 0x1000) / 2] & 0x38) primask |= 1 << 3;
if (state->priram_8[(spritepri | 0x0a00 | 0x0500) / 2] & 0x38) primask |= 1 << 4;
if (state->priram_8[(spritepri | 0x0a00 | 0x0400) / 2] & 0x38) primask |= 1 << 5;
if (state->priram_8[(spritepri | 0x0a00 | 0x0100) / 2] & 0x38) primask |= 1 << 6;
if (state->priram_8[(spritepri | 0x0a00 | 0x0000) / 2] & 0x38) primask |= 1 << 7;
if (primask == 0x00)

View File

@ -9,8 +9,6 @@
#include "emu.h"
#include "includes/mustache.h"
static tilemap_t *bg_tilemap;
static int control_byte;
PALETTE_INIT(mustache)
{
@ -50,11 +48,12 @@ WRITE8_HANDLER( mustache_videoram_w )
mustache_state *state = space->machine->driver_data<mustache_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
WRITE8_HANDLER (mustache_video_control_w)
{
mustache_state *state = space->machine->driver_data<mustache_state>();
if (flip_screen_get(space->machine) != (data & 0x01))
{
flip_screen_set(space->machine, data & 0x01);
@ -63,19 +62,20 @@ WRITE8_HANDLER (mustache_video_control_w)
/* tile bank */
if ((control_byte ^ data) & 0x08)
if ((state->control_byte ^ data) & 0x08)
{
control_byte = data;
state->control_byte = data;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
}
WRITE8_HANDLER( mustache_scroll_w )
{
tilemap_set_scrollx(bg_tilemap, 0, 0x100 - data);
tilemap_set_scrollx(bg_tilemap, 1, 0x100 - data);
tilemap_set_scrollx(bg_tilemap, 2, 0x100 - data);
tilemap_set_scrollx(bg_tilemap, 3, 0x100);
mustache_state *state = space->machine->driver_data<mustache_state>();
tilemap_set_scrollx(state->bg_tilemap, 0, 0x100 - data);
tilemap_set_scrollx(state->bg_tilemap, 1, 0x100 - data);
tilemap_set_scrollx(state->bg_tilemap, 2, 0x100 - data);
tilemap_set_scrollx(state->bg_tilemap, 3, 0x100);
}
static TILE_GET_INFO( get_bg_tile_info )
@ -83,7 +83,7 @@ static TILE_GET_INFO( get_bg_tile_info )
mustache_state *state = machine->driver_data<mustache_state>();
UINT8 *videoram = state->videoram;
int attr = videoram[2 * tile_index + 1];
int code = videoram[2 * tile_index] + ((attr & 0x60) << 3) + ((control_byte & 0x08) << 7);
int code = videoram[2 * tile_index] + ((attr & 0x60) << 3) + ((state->control_byte & 0x08) << 7);
int color = attr & 0x0f;
SET_TILE_INFO(0, code, color, ((attr & 0x10) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0) );
@ -93,14 +93,16 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( mustache )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_x,
mustache_state *state = machine->driver_data<mustache_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_x,
8, 8, 64, 32);
tilemap_set_scroll_rows(bg_tilemap, 4);
tilemap_set_scroll_rows(state->bg_tilemap, 4);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
mustache_state *state = machine->driver_data<mustache_state>();
rectangle clip = *cliprect;
const gfx_element *gfx = machine->gfx[1];
const rectangle &visarea = machine->primary_screen->visible_area();
@ -119,7 +121,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
code+=(attr&0x0c)<<6;
if ((control_byte & 0xa))
if ((state->control_byte & 0xa))
clip.max_y = visarea.max_y;
else
if (flip_screen_get(machine))
@ -143,7 +145,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( mustache )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
mustache_state *state = screen->machine->driver_data<mustache_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -6,10 +6,6 @@
#include "includes/namcos2.h"
#include "includes/namcofl.h"
//UINT32 *namcofl_spritebank32;
//UINT32 *namcofl_tilebank32;
static UINT32 namcofl_sprbank;
/* nth_word32 is a general-purpose utility function, which allows us to
* read from 32-bit aligned memory as if it were an array of 16 bit words.
@ -110,12 +106,14 @@ SCREEN_UPDATE( namcofl )
WRITE32_HANDLER(namcofl_spritebank_w)
{
COMBINE_DATA(&namcofl_sprbank);
namcofl_state *state = space->machine->driver_data<namcofl_state>();
COMBINE_DATA(&state->sprbank);
}
static int FLobjcode2tile( int code )
static int FLobjcode2tile( running_machine *machine, int code )
{
if ((code & 0x2000) && (namcofl_sprbank & 2)) { code += 0x4000; }
namcofl_state *state = machine->driver_data<namcofl_state>();
if ((code & 0x2000) && (state->sprbank & 2)) { code += 0x4000; }
return code;
}

View File

@ -157,7 +157,7 @@ SCREEN_UPDATE( namconb1 )
}
static int
NB1objcode2tile( int code )
NB1objcode2tile( running_machine *machine, int code )
{
int bank = nth_word32( namconb1_spritebank32, code>>11 );
return (code&0x7ff) + bank*0x800;
@ -200,7 +200,7 @@ SCREEN_UPDATE( namconb2 )
}
static int
NB2objcode2tile( int code )
NB2objcode2tile( running_machine *machine, int code )
{
int bank = nth_byte32( namconb1_spritebank32, (code>>11)&0xf );
code &= 0x7ff;

View File

@ -21,7 +21,6 @@ Namco System 1 Video Hardware
7810-7fef : fixed playfield (5) : 36*28*2
7ff0-7fff : ?
*/
static UINT8 *namcos1_videoram;
/*
paletteram map (s1ram 0x0000-0x7fff)
@ -34,7 +33,6 @@ static UINT8 *namcos1_videoram;
so there is just 3x0x2000 RAM, plus the CUS116 internal registers.
*/
static UINT8 namcos1_cus116[0x10];
/*
spriteram map (s1ram 0x10000-0x10fff)
@ -44,17 +42,6 @@ static UINT8 namcos1_cus116[0x10];
1000-1fff : playfield control registers
*/
static UINT8 *namcos1_spriteram;
static UINT8 namcos1_playfield_control[0x20];
static tilemap_t *bg_tilemap[6];
static UINT8 *tilemap_maskdata;
static int copy_sprites;
static UINT8 drawmode_table[16];
/***************************************************************************
@ -65,30 +52,61 @@ static UINT8 drawmode_table[16];
INLINE void bg_get_info(running_machine *machine,tile_data *tileinfo,int tile_index,UINT8 *info_vram)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
int code;
tile_index <<= 1;
code = info_vram[tile_index + 1] + ((info_vram[tile_index] & 0x3f) << 8);
SET_TILE_INFO(0,code,0,0);
tileinfo->mask_data = &tilemap_maskdata[code << 3];
tileinfo->mask_data = &state->tilemap_maskdata[code << 3];
}
INLINE void fg_get_info(running_machine *machine,tile_data *tileinfo,int tile_index,UINT8 *info_vram)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
int code;
tile_index <<= 1;
code = info_vram[tile_index + 1] + ((info_vram[tile_index] & 0x3f) << 8);
SET_TILE_INFO(0,code,0,0);
tileinfo->mask_data = &tilemap_maskdata[code << 3];
tileinfo->mask_data = &state->tilemap_maskdata[code << 3];
}
static TILE_GET_INFO( bg_get_info0 ) { bg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x0000]); }
static TILE_GET_INFO( bg_get_info1 ) { bg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x2000]); }
static TILE_GET_INFO( bg_get_info2 ) { bg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x4000]); }
static TILE_GET_INFO( bg_get_info3 ) { bg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x6000]); }
static TILE_GET_INFO( fg_get_info4 ) { fg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x7010]); }
static TILE_GET_INFO( fg_get_info5 ) { fg_get_info(machine,tileinfo,tile_index,&namcos1_videoram[0x7810]); }
static TILE_GET_INFO( bg_get_info0 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
bg_get_info(machine,tileinfo,tile_index,&state->videoram[0x0000]);
}
static TILE_GET_INFO( bg_get_info1 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
bg_get_info(machine,tileinfo,tile_index,&state->videoram[0x2000]);
}
static TILE_GET_INFO( bg_get_info2 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
bg_get_info(machine,tileinfo,tile_index,&state->videoram[0x4000]);
}
static TILE_GET_INFO( bg_get_info3 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
bg_get_info(machine,tileinfo,tile_index,&state->videoram[0x6000]);
}
static TILE_GET_INFO( fg_get_info4 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
fg_get_info(machine,tileinfo,tile_index,&state->videoram[0x7010]);
}
static TILE_GET_INFO( fg_get_info5 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
fg_get_info(machine,tileinfo,tile_index,&state->videoram[0x7810]);
}
@ -100,41 +118,42 @@ static TILE_GET_INFO( fg_get_info5 ) { fg_get_info(machine,tileinfo,tile_index,&
VIDEO_START( namcos1 )
{
namcos1_state *state = machine->driver_data<namcos1_state>();
int i;
tilemap_maskdata = (UINT8 *)machine->region("gfx1")->base();
state->tilemap_maskdata = (UINT8 *)machine->region("gfx1")->base();
/* allocate videoram */
namcos1_videoram = auto_alloc_array(machine, UINT8, 0x8000);
namcos1_spriteram = auto_alloc_array(machine, UINT8, 0x1000);
state->videoram = auto_alloc_array(machine, UINT8, 0x8000);
state->spriteram = auto_alloc_array(machine, UINT8, 0x1000);
/* initialize playfields */
bg_tilemap[0] = tilemap_create(machine, bg_get_info0,tilemap_scan_rows,8,8,64,64);
bg_tilemap[1] = tilemap_create(machine, bg_get_info1,tilemap_scan_rows,8,8,64,64);
bg_tilemap[2] = tilemap_create(machine, bg_get_info2,tilemap_scan_rows,8,8,64,64);
bg_tilemap[3] = tilemap_create(machine, bg_get_info3,tilemap_scan_rows,8,8,64,32);
bg_tilemap[4] = tilemap_create(machine, fg_get_info4,tilemap_scan_rows,8,8,36,28);
bg_tilemap[5] = tilemap_create(machine, fg_get_info5,tilemap_scan_rows,8,8,36,28);
state->bg_tilemap[0] = tilemap_create(machine, bg_get_info0,tilemap_scan_rows,8,8,64,64);
state->bg_tilemap[1] = tilemap_create(machine, bg_get_info1,tilemap_scan_rows,8,8,64,64);
state->bg_tilemap[2] = tilemap_create(machine, bg_get_info2,tilemap_scan_rows,8,8,64,64);
state->bg_tilemap[3] = tilemap_create(machine, bg_get_info3,tilemap_scan_rows,8,8,64,32);
state->bg_tilemap[4] = tilemap_create(machine, fg_get_info4,tilemap_scan_rows,8,8,36,28);
state->bg_tilemap[5] = tilemap_create(machine, fg_get_info5,tilemap_scan_rows,8,8,36,28);
tilemap_set_scrolldx(bg_tilemap[4],73,512-73);
tilemap_set_scrolldx(bg_tilemap[5],73,512-73);
tilemap_set_scrolldy(bg_tilemap[4],0x10,0x110);
tilemap_set_scrolldy(bg_tilemap[5],0x10,0x110);
tilemap_set_scrolldx(state->bg_tilemap[4],73,512-73);
tilemap_set_scrolldx(state->bg_tilemap[5],73,512-73);
tilemap_set_scrolldy(state->bg_tilemap[4],0x10,0x110);
tilemap_set_scrolldy(state->bg_tilemap[5],0x10,0x110);
/* register videoram to the save state system (post-allocation) */
state_save_register_global_pointer(machine, namcos1_videoram, 0x8000);
state_save_register_global_array(machine, namcos1_cus116);
state_save_register_global_pointer(machine, namcos1_spriteram, 0x1000);
state_save_register_global_array(machine, namcos1_playfield_control);
state_save_register_global_pointer(machine, state->videoram, 0x8000);
state_save_register_global_array(machine, state->cus116);
state_save_register_global_pointer(machine, state->spriteram, 0x1000);
state_save_register_global_array(machine, state->playfield_control);
/* set table for sprite color == 0x7f */
for (i = 0;i < 15;i++)
drawmode_table[i] = DRAWMODE_SHADOW;
drawmode_table[15] = DRAWMODE_NONE;
state->drawmode_table[i] = DRAWMODE_SHADOW;
state->drawmode_table[15] = DRAWMODE_NONE;
/* clear paletteram */
memset(namcos1_paletteram, 0, 0x8000);
memset(namcos1_cus116, 0, 0x10);
memset(state->paletteram, 0, 0x8000);
memset(state->cus116, 0, 0x10);
for (i = 0; i < 0x2000; i++)
palette_set_color(machine, i, MAKE_RGB(0, 0, 0));
@ -145,10 +164,10 @@ VIDEO_START( namcos1 )
for (i = 0x0800;i < 0x1000;i++)
machine->shadow_table[i] = i + 0x0800;
machine->generic.spriteram.u8 = &namcos1_spriteram[0x800];
machine->generic.spriteram.u8 = &state->spriteram[0x800];
memset(namcos1_playfield_control, 0, sizeof(namcos1_playfield_control));
copy_sprites = 0;
memset(state->playfield_control, 0, sizeof(state->playfield_control));
state->copy_sprites = 0;
}
@ -161,31 +180,34 @@ VIDEO_START( namcos1 )
READ8_HANDLER( namcos1_videoram_r )
{
return namcos1_videoram[offset];
namcos1_state *state = space->machine->driver_data<namcos1_state>();
return state->videoram[offset];
}
WRITE8_HANDLER( namcos1_videoram_w )
{
namcos1_videoram[offset] = data;
namcos1_state *state = space->machine->driver_data<namcos1_state>();
state->videoram[offset] = data;
if (offset < 0x7000)
{ /* background 0-3 */
int layer = offset >> 13;
int num = (offset & 0x1fff) >> 1;
tilemap_mark_tile_dirty(bg_tilemap[layer],num);
tilemap_mark_tile_dirty(state->bg_tilemap[layer],num);
}
else
{ /* foreground 4-5 */
int layer = (offset >> 11 & 1) + 4;
int num = ((offset & 0x7ff) - 0x10) >> 1;
if (num >= 0 && num < 0x3f0)
tilemap_mark_tile_dirty(bg_tilemap[layer],num);
tilemap_mark_tile_dirty(state->bg_tilemap[layer],num);
}
}
WRITE8_HANDLER( namcos1_paletteram_w )
{
if (namcos1_paletteram[offset] == data)
namcos1_state *state = space->machine->driver_data<namcos1_state>();
if (state->paletteram[offset] == data)
return;
if ((offset & 0x1800) != 0x1800)
@ -193,26 +215,26 @@ WRITE8_HANDLER( namcos1_paletteram_w )
int r,g,b;
int color = ((offset & 0x6000) >> 2) | (offset & 0x7ff);
namcos1_paletteram[offset] = data;
state->paletteram[offset] = data;
offset &= ~0x1800;
r = namcos1_paletteram[offset];
g = namcos1_paletteram[offset + 0x0800];
b = namcos1_paletteram[offset + 0x1000];
r = state->paletteram[offset];
g = state->paletteram[offset + 0x0800];
b = state->paletteram[offset + 0x1000];
palette_set_color(space->machine,color,MAKE_RGB(r,g,b));
}
else
{
int i, j;
namcos1_cus116[offset & 0x0f] = data;
state->cus116[offset & 0x0f] = data;
for (i = 0x1800; i < 0x8000; i += 0x2000)
{
offset = (offset & 0x0f) | i;
for (j = 0; j < 0x80; j++, offset += 0x10)
namcos1_paletteram[offset] = data;
state->paletteram[offset] = data;
}
}
}
@ -222,30 +244,32 @@ WRITE8_HANDLER( namcos1_paletteram_w )
READ8_HANDLER( namcos1_spriteram_r )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
/* 0000-07ff work ram */
/* 0800-0fff sprite ram */
if (offset < 0x1000)
return namcos1_spriteram[offset];
return state->spriteram[offset];
/* 1xxx playfield control ram */
else
return namcos1_playfield_control[offset & 0x1f];
return state->playfield_control[offset & 0x1f];
}
WRITE8_HANDLER( namcos1_spriteram_w )
{
namcos1_state *state = space->machine->driver_data<namcos1_state>();
/* 0000-07ff work ram */
/* 0800-0fff sprite ram */
if (offset < 0x1000)
{
namcos1_spriteram[offset] = data;
state->spriteram[offset] = data;
/* a write to this offset tells the sprite chip to buffer the sprite list */
if (offset == 0x0ff2)
copy_sprites = 1;
state->copy_sprites = 1;
}
/* 1xxx playfield control ram */
else
namcos1_playfield_control[offset & 0x1f] = data;
state->playfield_control[offset & 0x1f] = data;
}
@ -278,6 +302,7 @@ sprite format:
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
namcos1_state *state = machine->driver_data<namcos1_state>();
const UINT8 *source = &machine->generic.spriteram.u8[0x0800-0x20]; /* the last is NOT a sprite */
const UINT8 *finish = &machine->generic.spriteram.u8[0];
gfx_element *gfx = machine->gfx[1];
@ -338,7 +363,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
sx & 0x1ff,
((sy + 16) & 0xff) - 16,
machine->priority_bitmap, pri_mask,
drawmode_table, machine->shadow_table);
state->drawmode_table, machine->shadow_table);
source -= 0x10;
}
@ -348,6 +373,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( namcos1 )
{
namcos1_state *state = screen->machine->driver_data<namcos1_state>();
int i, j, scrollx, scrolly, priority;
rectangle new_clip = *cliprect;
@ -361,13 +387,13 @@ SCREEN_UPDATE( namcos1 )
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
/* berabohm uses asymmetrical visibility windows to iris on the character */
i = ((namcos1_cus116[0] << 8) | namcos1_cus116[1]) - 1; // min x
i = ((state->cus116[0] << 8) | state->cus116[1]) - 1; // min x
if (new_clip.min_x < i) new_clip.min_x = i;
i = ((namcos1_cus116[2] << 8) | namcos1_cus116[3]) - 1 - 1; // max x
i = ((state->cus116[2] << 8) | state->cus116[3]) - 1 - 1; // max x
if (new_clip.max_x > i) new_clip.max_x = i;
i = ((namcos1_cus116[4] << 8) | namcos1_cus116[5]) - 0x11; // min y
i = ((state->cus116[4] << 8) | state->cus116[5]) - 0x11; // min y
if (new_clip.min_y < i) new_clip.min_y = i;
i = ((namcos1_cus116[6] << 8) | namcos1_cus116[7]) - 0x11 - 1; // max y
i = ((state->cus116[6] << 8) | state->cus116[7]) - 0x11 - 1; // max y
if (new_clip.max_y > i) new_clip.max_y = i;
if (new_clip.max_x < new_clip.min_x || new_clip.max_y < new_clip.min_y)
@ -376,15 +402,15 @@ SCREEN_UPDATE( namcos1 )
/* set palette base */
for (i = 0;i < 6;i++)
tilemap_set_palette_offset(bg_tilemap[i],(namcos1_playfield_control[i + 24] & 7) * 256);
tilemap_set_palette_offset(state->bg_tilemap[i],(state->playfield_control[i + 24] & 7) * 256);
for (i = 0;i < 4;i++)
{
static const int disp_x[] = { 25, 27, 28, 29 };
j = i << 2;
scrollx = ( namcos1_playfield_control[j+1] + (namcos1_playfield_control[j+0]<<8) ) - disp_x[i];
scrolly = ( namcos1_playfield_control[j+3] + (namcos1_playfield_control[j+2]<<8) ) + 8;
scrollx = ( state->playfield_control[j+1] + (state->playfield_control[j+0]<<8) ) - disp_x[i];
scrolly = ( state->playfield_control[j+3] + (state->playfield_control[j+2]<<8) ) + 8;
if (flip_screen_get(screen->machine))
{
@ -392,8 +418,8 @@ SCREEN_UPDATE( namcos1 )
scrolly = -scrolly;
}
tilemap_set_scrollx(bg_tilemap[i],0,scrollx);
tilemap_set_scrolly(bg_tilemap[i],0,scrolly);
tilemap_set_scrollx(state->bg_tilemap[i],0,scrollx);
tilemap_set_scrolly(state->bg_tilemap[i],0,scrolly);
}
@ -405,8 +431,8 @@ SCREEN_UPDATE( namcos1 )
{
for (i = 0;i < 6;i++)
{
if (namcos1_playfield_control[16 + i] == priority)
tilemap_draw_primask(bitmap,&new_clip,bg_tilemap[i],0,priority,0);
if (state->playfield_control[16 + i] == priority)
tilemap_draw_primask(bitmap,&new_clip,state->bg_tilemap[i],0,priority,0);
}
}
@ -417,7 +443,8 @@ SCREEN_UPDATE( namcos1 )
SCREEN_EOF( namcos1 )
{
if (copy_sprites)
namcos1_state *state = machine->driver_data<namcos1_state>();
if (state->copy_sprites)
{
UINT8 *spriteram = machine->generic.spriteram.u8;
int i,j;
@ -428,6 +455,6 @@ SCREEN_EOF( namcos1 )
spriteram[i+j] = spriteram[i+j - 6];
}
copy_sprites = 0;
state->copy_sprites = 0;
}
}

View File

@ -124,11 +124,6 @@ CopyVisiblePolyFrameBuffer( bitmap_t *bitmap, const rectangle *clip, int zlo, in
}
} /* CopyVisiblePolyFrameBuffer */
static int objcode2tile( int code )
{ /* callback for sprite drawing code in namcoic.c */
return code;
} /* objcode2tile */
VIDEO_START( namcos21 )
{
namcos21_state *state = machine->driver_data<namcos21_state>();
@ -140,7 +135,7 @@ VIDEO_START( namcos21 )
namco_obj_init(machine,
0, /* gfx bank */
0xf, /* reverse palette mapping */
objcode2tile );
NULL );
} /* VIDEO_START( namcos21 ) */
static void

View File

@ -1,29 +1,6 @@
#include "emu.h"
#include "includes/ninjakd2.h"
UINT8* ninjakd2_bg_videoram;
UINT8* ninjakd2_fg_videoram;
static int next_sprite_overdraw_enabled;
static int (*stencil_compare_function) (UINT16 pal);
static int sprites_updated;
static bitmap_t *sp_bitmap;
// in robokid and omegaf big sprites are laid out differently in ROM
static int robokid_sprites;
static tilemap_t* fg_tilemap;
static tilemap_t* bg_tilemap;
static tilemap_t* bg0_tilemap;
static tilemap_t* bg1_tilemap;
static tilemap_t* bg2_tilemap;
static int bank_mask;
static int robokid_bg0_bank = 0;
static int robokid_bg1_bank = 0;
static int robokid_bg2_bank = 0;
static UINT8* robokid_bg0_videoram;
static UINT8* robokid_bg1_videoram;
static UINT8* robokid_bg2_videoram;
#define TRANSPARENTCODE (15)
@ -35,8 +12,9 @@ static UINT8* robokid_bg2_videoram;
static TILE_GET_INFO( get_fg_tile_info )
{
int const lo = ninjakd2_fg_videoram[(tile_index << 1)];
int const hi = ninjakd2_fg_videoram[(tile_index << 1) | 1];
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
int const lo = state->fg_videoram[(tile_index << 1)];
int const hi = state->fg_videoram[(tile_index << 1) | 1];
int const tile = ((hi & 0xc0) << 2) | lo;
int const flipyx = (hi & 0x30) >> 4;
int const color = hi & 0x0f;
@ -50,8 +28,9 @@ static TILE_GET_INFO( get_fg_tile_info )
static TILE_GET_INFO( ninjakd2_get_bg_tile_info )
{
int const lo = ninjakd2_bg_videoram[(tile_index << 1)];
int const hi = ninjakd2_bg_videoram[(tile_index << 1) | 1];
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
int const lo = state->bg_videoram[(tile_index << 1)];
int const hi = state->bg_videoram[(tile_index << 1) | 1];
int const tile = ((hi & 0xc0) << 2) | lo;
int const flipyx = (hi & 0x30) >> 4;
int const color = hi & 0x0f;
@ -65,8 +44,9 @@ static TILE_GET_INFO( ninjakd2_get_bg_tile_info )
static TILE_GET_INFO( mnight_get_bg_tile_info )
{
int const lo = ninjakd2_bg_videoram[(tile_index << 1)];
int const hi = ninjakd2_bg_videoram[(tile_index << 1) | 1];
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
int const lo = state->bg_videoram[(tile_index << 1)];
int const hi = state->bg_videoram[(tile_index << 1) | 1];
int const tile = ((hi & 0x10) << 6) | ((hi & 0xc0) << 2) | lo;
int const flipy = (hi & 0x20) >> 5;
int const color = hi & 0x0f;
@ -106,17 +86,20 @@ static void robokid_get_bg_tile_info(running_machine* machine, tile_data* const
static TILE_GET_INFO( robokid_get_bg0_tile_info )
{
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 2, robokid_bg0_videoram);
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 2, state->robokid_bg0_videoram);
}
static TILE_GET_INFO( robokid_get_bg1_tile_info )
{
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 3, robokid_bg1_videoram);
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 3, state->robokid_bg1_videoram);
}
static TILE_GET_INFO( robokid_get_bg2_tile_info )
{
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 4, robokid_bg2_videoram);
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
robokid_get_bg_tile_info(machine, tileinfo, tile_index, 4, state->robokid_bg2_videoram);
}
@ -129,15 +112,16 @@ static TILE_GET_INFO( robokid_get_bg2_tile_info )
static void videoram_alloc(running_machine* machine, int const size)
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
if (size)
{
/* create video ram */
robokid_bg0_videoram = auto_alloc_array_clear(machine, UINT8, size);
robokid_bg1_videoram = auto_alloc_array_clear(machine, UINT8, size);
robokid_bg2_videoram = auto_alloc_array_clear(machine, UINT8, size);
state->robokid_bg0_videoram = auto_alloc_array_clear(machine, UINT8, size);
state->robokid_bg1_videoram = auto_alloc_array_clear(machine, UINT8, size);
state->robokid_bg2_videoram = auto_alloc_array_clear(machine, UINT8, size);
}
sp_bitmap = machine->primary_screen->alloc_compatible_bitmap();
state->sp_bitmap = machine->primary_screen->alloc_compatible_bitmap();
}
static int stencil_ninjakd2( UINT16 pal );
@ -148,80 +132,85 @@ static int stencil_omegaf( UINT16 pal );
VIDEO_START( ninjakd2 )
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
videoram_alloc(machine, 0);
fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
bg_tilemap = tilemap_create(machine, ninjakd2_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
state->fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg_tilemap = tilemap_create(machine, ninjakd2_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->fg_tilemap, TRANSPARENTCODE);
robokid_sprites = 0;
stencil_compare_function = stencil_ninjakd2 ;
state->robokid_sprites = 0;
state->stencil_compare_function = stencil_ninjakd2;
}
VIDEO_START( mnight )
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
videoram_alloc(machine, 0);
fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
bg_tilemap = tilemap_create(machine, mnight_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
state->fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg_tilemap = tilemap_create(machine, mnight_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->fg_tilemap, TRANSPARENTCODE);
robokid_sprites = 0;
stencil_compare_function = stencil_mnight ;
state->robokid_sprites = 0;
state->stencil_compare_function = stencil_mnight;
}
VIDEO_START( arkarea )
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
videoram_alloc(machine, 0);
fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
bg_tilemap = tilemap_create(machine, mnight_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
state->fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg_tilemap = tilemap_create(machine, mnight_get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->fg_tilemap, TRANSPARENTCODE);
robokid_sprites = 0;
stencil_compare_function = stencil_arkarea ;
state->robokid_sprites = 0;
state->stencil_compare_function = stencil_arkarea;
}
VIDEO_START( robokid )
{
bank_mask = 1;
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
state->bank_mask = 1;
videoram_alloc(machine, 0x0800);
fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
bg0_tilemap = tilemap_create(machine, robokid_get_bg0_tile_info, robokid_bg_scan, 16, 16, 32, 32);
bg1_tilemap = tilemap_create(machine, robokid_get_bg1_tile_info, robokid_bg_scan, 16, 16, 32, 32);
bg2_tilemap = tilemap_create(machine, robokid_get_bg2_tile_info, robokid_bg_scan, 16, 16, 32, 32);
state->fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg0_tilemap = tilemap_create(machine, robokid_get_bg0_tile_info, robokid_bg_scan, 16, 16, 32, 32);
state->bg1_tilemap = tilemap_create(machine, robokid_get_bg1_tile_info, robokid_bg_scan, 16, 16, 32, 32);
state->bg2_tilemap = tilemap_create(machine, robokid_get_bg2_tile_info, robokid_bg_scan, 16, 16, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(bg1_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(bg2_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->bg1_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->bg2_tilemap, TRANSPARENTCODE);
robokid_sprites = 1;
stencil_compare_function = stencil_robokid ;
state->robokid_sprites = 1;
state->stencil_compare_function = stencil_robokid;
}
VIDEO_START( omegaf )
{
bank_mask = 7;
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
state->bank_mask = 7;
videoram_alloc(machine, 0x2000);
fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
bg0_tilemap = tilemap_create(machine, robokid_get_bg0_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
bg1_tilemap = tilemap_create(machine, robokid_get_bg1_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
bg2_tilemap = tilemap_create(machine, robokid_get_bg2_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
state->fg_tilemap = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->bg0_tilemap = tilemap_create(machine, robokid_get_bg0_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
state->bg1_tilemap = tilemap_create(machine, robokid_get_bg1_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
state->bg2_tilemap = tilemap_create(machine, robokid_get_bg2_tile_info, omegaf_bg_scan, 16, 16, 128, 32);
tilemap_set_transparent_pen(fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(bg0_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(bg1_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(bg2_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->fg_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->bg0_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->bg1_tilemap, TRANSPARENTCODE);
tilemap_set_transparent_pen(state->bg2_tilemap, TRANSPARENTCODE);
robokid_sprites = 1;
stencil_compare_function = stencil_omegaf ;
state->robokid_sprites = 1;
state->stencil_compare_function = stencil_omegaf;
}
@ -234,70 +223,81 @@ VIDEO_START( omegaf )
WRITE8_HANDLER( ninjakd2_bgvideoram_w )
{
ninjakd2_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset >> 1);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset >> 1);
}
WRITE8_HANDLER( ninjakd2_fgvideoram_w )
{
ninjakd2_fg_videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset >> 1);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->fg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset >> 1);
}
WRITE8_HANDLER( robokid_bg0_bank_w )
{
robokid_bg0_bank = data & bank_mask;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->robokid_bg0_bank = data & state->bank_mask;
}
WRITE8_HANDLER( robokid_bg1_bank_w )
{
robokid_bg1_bank = data & bank_mask;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->robokid_bg1_bank = data & state->bank_mask;
}
WRITE8_HANDLER( robokid_bg2_bank_w )
{
robokid_bg2_bank = data & bank_mask;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->robokid_bg2_bank = data & state->bank_mask;
}
READ8_HANDLER( robokid_bg0_videoram_r )
{
return robokid_bg0_videoram[(robokid_bg0_bank << 10) | offset];
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
return state->robokid_bg0_videoram[(state->robokid_bg0_bank << 10) | offset];
}
READ8_HANDLER( robokid_bg1_videoram_r )
{
return robokid_bg1_videoram[(robokid_bg1_bank << 10) | offset];
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
return state->robokid_bg1_videoram[(state->robokid_bg1_bank << 10) | offset];
}
READ8_HANDLER( robokid_bg2_videoram_r )
{
return robokid_bg2_videoram[(robokid_bg2_bank << 10) | offset];
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
return state->robokid_bg2_videoram[(state->robokid_bg2_bank << 10) | offset];
}
WRITE8_HANDLER( robokid_bg0_videoram_w )
{
int const address = (robokid_bg0_bank << 10 ) | offset;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
int const address = (state->robokid_bg0_bank << 10 ) | offset;
robokid_bg0_videoram[address] = data;
tilemap_mark_tile_dirty(bg0_tilemap, address >> 1);
state->robokid_bg0_videoram[address] = data;
tilemap_mark_tile_dirty(state->bg0_tilemap, address >> 1);
}
WRITE8_HANDLER( robokid_bg1_videoram_w )
{
int const address = (robokid_bg1_bank << 10 ) | offset;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
int const address = (state->robokid_bg1_bank << 10 ) | offset;
robokid_bg1_videoram[address] = data;
tilemap_mark_tile_dirty(bg1_tilemap, address >> 1);
state->robokid_bg1_videoram[address] = data;
tilemap_mark_tile_dirty(state->bg1_tilemap, address >> 1);
}
WRITE8_HANDLER( robokid_bg2_videoram_w )
{
int const address = (robokid_bg2_bank << 10 ) | offset;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
int const address = (state->robokid_bg2_bank << 10 ) | offset;
robokid_bg2_videoram[address] = data;
tilemap_mark_tile_dirty(bg2_tilemap, address >> 1);
state->robokid_bg2_videoram[address] = data;
tilemap_mark_tile_dirty(state->bg2_tilemap, address >> 1);
}
@ -322,29 +322,34 @@ static void bg_ctrl(int offset, int data, tilemap_t* tilemap)
WRITE8_HANDLER( ninjakd2_bg_ctrl_w )
{
bg_ctrl(offset, data, bg_tilemap);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
bg_ctrl(offset, data, state->bg_tilemap);
}
WRITE8_HANDLER( robokid_bg0_ctrl_w )
{
bg_ctrl(offset, data, bg0_tilemap);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
bg_ctrl(offset, data, state->bg0_tilemap);
}
WRITE8_HANDLER( robokid_bg1_ctrl_w )
{
bg_ctrl(offset, data, bg1_tilemap);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
bg_ctrl(offset, data, state->bg1_tilemap);
}
WRITE8_HANDLER( robokid_bg2_ctrl_w )
{
bg_ctrl(offset, data, bg2_tilemap);
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
bg_ctrl(offset, data, state->bg2_tilemap);
}
WRITE8_HANDLER( ninjakd2_sprite_overdraw_w )
{
next_sprite_overdraw_enabled = data & 1;
ninjakd2_state *state = space->machine->driver_data<ninjakd2_state>();
state->next_sprite_overdraw_enabled = data & 1;
}
@ -357,9 +362,10 @@ WRITE8_HANDLER( ninjakd2_sprite_overdraw_w )
static void draw_sprites(running_machine* machine, bitmap_t* bitmap)
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
const gfx_element* const gfx = machine->gfx[1];
int const big_xshift = robokid_sprites ? 1 : 0;
int const big_yshift = robokid_sprites ? 0 : 1;
int const big_xshift = state->robokid_sprites ? 1 : 0;
int const big_yshift = state->robokid_sprites ? 0 : 1;
UINT8* sprptr = &machine->generic.spriteram.u8[11];
int sprites_drawn = 0;
@ -452,20 +458,21 @@ static int stencil_omegaf( UINT16 pal ) { return( TRUE ); }
static void erase_sprites(running_machine* machine, bitmap_t* bitmap, const rectangle* cliprect)
{
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
// if sprite overdraw is disabled, clear the sprite framebuffer
if (!next_sprite_overdraw_enabled)
bitmap_fill(sp_bitmap, cliprect, TRANSPARENTCODE);
if (!state->next_sprite_overdraw_enabled)
bitmap_fill(state->sp_bitmap, cliprect, TRANSPARENTCODE);
else
{
int y;
for (y = 0; y < sp_bitmap->height; ++y)
for (y = 0; y < state->sp_bitmap->height; ++y)
{
int x;
for (x = 0; x < sp_bitmap->width; ++x)
for (x = 0; x < state->sp_bitmap->width; ++x)
{
UINT16* const ptr = BITMAP_ADDR16(sp_bitmap, y, x);
UINT16* const ptr = BITMAP_ADDR16(state->sp_bitmap, y, x);
if ( (*stencil_compare_function)(*ptr) ) *ptr = TRANSPARENTCODE ;
if ( (*state->stencil_compare_function)(*ptr) ) *ptr = TRANSPARENTCODE ;
}
}
}
@ -474,8 +481,9 @@ static void erase_sprites(running_machine* machine, bitmap_t* bitmap, const rect
static void update_sprites(running_machine* machine)
{
erase_sprites(machine, sp_bitmap, 0);
draw_sprites(machine, sp_bitmap);
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
erase_sprites(machine, state->sp_bitmap, 0);
draw_sprites(machine, state->sp_bitmap);
}
////// Before modified, this was written.
// we want to erase the sprites with the old setting and draw them with the
@ -486,58 +494,61 @@ static void update_sprites(running_machine* machine)
SCREEN_UPDATE( ninjakd2 )
{
ninjakd2_state *state = screen->machine->driver_data<ninjakd2_state>();
// updating sprites here instead than in screen_eof avoids a palette glitch
// at the end of the "rainbow sky" screens.
update_sprites(screen->machine);
sprites_updated = 1;
state->sprites_updated = 1;
bitmap_fill(bitmap, cliprect, 0);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
copybitmap_trans(bitmap, sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
copybitmap_trans(bitmap, state->sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
SCREEN_UPDATE( robokid )
{
ninjakd2_state *state = screen->machine->driver_data<ninjakd2_state>();
update_sprites(screen->machine);
sprites_updated = 1;
state->sprites_updated = 1;
bitmap_fill(bitmap, cliprect, 0);
tilemap_draw(bitmap, cliprect, bg0_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg0_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg1_tilemap, 0, 0);
copybitmap_trans(bitmap, sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
copybitmap_trans(bitmap, state->sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
tilemap_draw(bitmap, cliprect, bg2_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
SCREEN_UPDATE( omegaf )
{
ninjakd2_state *state = screen->machine->driver_data<ninjakd2_state>();
update_sprites(screen->machine);
sprites_updated = 1;
state->sprites_updated = 1;
bitmap_fill(bitmap, cliprect, 0);
tilemap_draw(bitmap, cliprect, bg0_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg0_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg1_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, bg2_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
copybitmap_trans(bitmap, sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
copybitmap_trans(bitmap, state->sp_bitmap, 0, 0, 0, 0, cliprect, TRANSPARENTCODE);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
@ -545,8 +556,9 @@ SCREEN_UPDATE( omegaf )
SCREEN_EOF( ninjakd2 )
{
if (!sprites_updated)
ninjakd2_state *state = machine->driver_data<ninjakd2_state>();
if (!state->sprites_updated)
update_sprites(machine);
sprites_updated = 0;
state->sprites_updated = 0;
}

View File

@ -1,10 +1,6 @@
#include "emu.h"
#include "includes/nova2001.h"
UINT8 *nova2001_fg_videoram, *nova2001_bg_videoram;
static tilemap_t *bg_tilemap, *fg_tilemap;
/*************************************
*
@ -82,16 +78,18 @@ WRITE8_HANDLER( ninjakun_paletteram_w )
static TILE_GET_INFO( nova2001_get_bg_tile_info )
{
int code = nova2001_bg_videoram[tile_index];
int color = nova2001_bg_videoram[tile_index + 0x400] & 0x0f;
nova2001_state *state = machine->driver_data<nova2001_state>();
int code = state->bg_videoram[tile_index];
int color = state->bg_videoram[tile_index + 0x400] & 0x0f;
SET_TILE_INFO(2, code, color, 0);
}
static TILE_GET_INFO( nova2001_get_fg_tile_info )
{
int attr = nova2001_fg_videoram[tile_index + 0x400];
int code = nova2001_fg_videoram[tile_index];
nova2001_state *state = machine->driver_data<nova2001_state>();
int attr = state->fg_videoram[tile_index + 0x400];
int code = state->fg_videoram[tile_index];
int color = attr & 0x0f;
SET_TILE_INFO(1, code, color, 0);
@ -101,8 +99,9 @@ static TILE_GET_INFO( nova2001_get_fg_tile_info )
static TILE_GET_INFO( ninjakun_get_bg_tile_info )
{
int attr = nova2001_bg_videoram[tile_index+0x400];
int code = nova2001_bg_videoram[tile_index] + ((attr & 0xc0) << 2);
nova2001_state *state = machine->driver_data<nova2001_state>();
int attr = state->bg_videoram[tile_index+0x400];
int code = state->bg_videoram[tile_index] + ((attr & 0xc0) << 2);
int color = attr & 0x0f;
SET_TILE_INFO(2, code, color, 0);
@ -110,8 +109,9 @@ static TILE_GET_INFO( ninjakun_get_bg_tile_info )
static TILE_GET_INFO( ninjakun_get_fg_tile_info )
{
int attr = nova2001_fg_videoram[tile_index+0x400];
int code = nova2001_fg_videoram[tile_index] + ((attr & 0x20) << 3);
nova2001_state *state = machine->driver_data<nova2001_state>();
int attr = state->fg_videoram[tile_index+0x400];
int code = state->fg_videoram[tile_index] + ((attr & 0x20) << 3);
int color = attr & 0x0f;
SET_TILE_INFO(1, code, color, 0);
@ -121,8 +121,9 @@ static TILE_GET_INFO( ninjakun_get_fg_tile_info )
static TILE_GET_INFO( pkunwar_get_bg_tile_info )
{
int attr = nova2001_bg_videoram[tile_index + 0x400];
int code = nova2001_bg_videoram[tile_index] + ((attr & 0x07) << 8);
nova2001_state *state = machine->driver_data<nova2001_state>();
int attr = state->bg_videoram[tile_index + 0x400];
int code = state->bg_videoram[tile_index] + ((attr & 0x07) << 8);
int color = (attr & 0xf0) >> 4;
SET_TILE_INFO(1, code, color, 0);
@ -132,8 +133,9 @@ static TILE_GET_INFO( pkunwar_get_bg_tile_info )
static TILE_GET_INFO( raiders5_get_bg_tile_info )
{
int attr = nova2001_bg_videoram[tile_index+0x400];
int code = nova2001_bg_videoram[tile_index] + ((attr & 0x01) << 8);
nova2001_state *state = machine->driver_data<nova2001_state>();
int attr = state->bg_videoram[tile_index+0x400];
int code = state->bg_videoram[tile_index] + ((attr & 0x01) << 8);
int color = (attr & 0xf0) >> 4;
SET_TILE_INFO(2, code, color, 0);
@ -141,8 +143,9 @@ static TILE_GET_INFO( raiders5_get_bg_tile_info )
static TILE_GET_INFO( raiders5_get_fg_tile_info )
{
int code = nova2001_fg_videoram[tile_index];
int color = (nova2001_fg_videoram[tile_index + 0x400] & 0xf0) >> 4;
nova2001_state *state = machine->driver_data<nova2001_state>();
int code = state->fg_videoram[tile_index];
int color = (state->fg_videoram[tile_index + 0x400] & 0xf0) >> 4;
SET_TILE_INFO(1, code, color, 0);
}
@ -157,32 +160,36 @@ static TILE_GET_INFO( raiders5_get_fg_tile_info )
VIDEO_START( nova2001 )
{
bg_tilemap = tilemap_create(machine, nova2001_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
fg_tilemap = tilemap_create(machine, nova2001_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_scrolldx(bg_tilemap, 0, -7);
nova2001_state *state = machine->driver_data<nova2001_state>();
state->bg_tilemap = tilemap_create(machine, nova2001_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, nova2001_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
tilemap_set_scrolldx(state->bg_tilemap, 0, -7);
}
VIDEO_START( pkunwar )
{
bg_tilemap = tilemap_create(machine, pkunwar_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(bg_tilemap, 0);
nova2001_state *state = machine->driver_data<nova2001_state>();
state->bg_tilemap = tilemap_create(machine, pkunwar_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->bg_tilemap, 0);
}
VIDEO_START( ninjakun )
{
bg_tilemap = tilemap_create(machine, ninjakun_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
fg_tilemap = tilemap_create(machine, ninjakun_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_scrolldx(bg_tilemap, 7, 0);
nova2001_state *state = machine->driver_data<nova2001_state>();
state->bg_tilemap = tilemap_create(machine, ninjakun_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, ninjakun_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
tilemap_set_scrolldx(state->bg_tilemap, 7, 0);
}
VIDEO_START( raiders5 )
{
bg_tilemap = tilemap_create(machine, raiders5_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
fg_tilemap = tilemap_create(machine, raiders5_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_scrolldx(bg_tilemap, 7, 0);
nova2001_state *state = machine->driver_data<nova2001_state>();
state->bg_tilemap = tilemap_create(machine, raiders5_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, raiders5_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
tilemap_set_scrolldx(state->bg_tilemap, 7, 0);
}
@ -195,47 +202,53 @@ VIDEO_START( raiders5 )
WRITE8_HANDLER( nova2001_fg_videoram_w )
{
nova2001_fg_videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset & 0x3ff);
nova2001_state *state = space->machine->driver_data<nova2001_state>();
state->fg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( nova2001_bg_videoram_w )
{
nova2001_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
nova2001_state *state = space->machine->driver_data<nova2001_state>();
state->bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff);
}
WRITE8_HANDLER( ninjakun_bg_videoram_w )
{
int x = tilemap_get_scrollx(bg_tilemap, 0) >> 3;
int y = tilemap_get_scrolly(bg_tilemap, 0) >> 3;
nova2001_state *state = space->machine->driver_data<nova2001_state>();
int x = tilemap_get_scrollx(state->bg_tilemap, 0) >> 3;
int y = tilemap_get_scrolly(state->bg_tilemap, 0) >> 3;
// add scroll registers to address
offset = ((offset + x + (y << 5)) & 0x3ff) + (offset & 0x400);
nova2001_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
state->bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff);
}
READ8_HANDLER( ninjakun_bg_videoram_r )
{
int x = tilemap_get_scrollx(bg_tilemap, 0) >> 3;
int y = tilemap_get_scrolly(bg_tilemap, 0) >> 3;
nova2001_state *state = space->machine->driver_data<nova2001_state>();
int x = tilemap_get_scrollx(state->bg_tilemap, 0) >> 3;
int y = tilemap_get_scrolly(state->bg_tilemap, 0) >> 3;
// add scroll registers to address
offset = ((offset + x + (y << 5)) & 0x3ff) + (offset & 0x400);
return nova2001_bg_videoram[offset];
return state->bg_videoram[offset];
}
WRITE8_HANDLER( nova2001_scroll_x_w )
{
tilemap_set_scrollx(bg_tilemap, 0, data);
nova2001_state *state = space->machine->driver_data<nova2001_state>();
tilemap_set_scrollx(state->bg_tilemap, 0, data);
}
WRITE8_HANDLER( nova2001_scroll_y_w )
{
tilemap_set_scrolly(bg_tilemap, 0, data);
nova2001_state *state = space->machine->driver_data<nova2001_state>();
tilemap_set_scrolly(state->bg_tilemap, 0, data);
}
WRITE8_HANDLER( nova2001_flipscreen_w )
@ -342,49 +355,53 @@ static void pkunwar_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
SCREEN_UPDATE( nova2001 )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
nova2001_state *state = screen->machine->driver_data<nova2001_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
nova2001_draw_sprites(screen->machine, bitmap, cliprect);
// according to the schematics, fg category 0 should be drawn behind sprites,
// but it doesn't look right that way
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, fg_tilemap, 1, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 1, 0);
return 0;
}
SCREEN_UPDATE( pkunwar )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0);
nova2001_state *state = screen->machine->driver_data<nova2001_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0);
pkunwar_draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, bg_tilemap, 1, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 1, 0);
return 0;
}
SCREEN_UPDATE( ninjakun )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
nova2001_state *state = screen->machine->driver_data<nova2001_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, fg_tilemap, 1, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 1, 0);
nova2001_draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
SCREEN_UPDATE( raiders5 )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
nova2001_state *state = screen->machine->driver_data<nova2001_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
pkunwar_draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}

View File

@ -15,25 +15,6 @@
#define BITMAP_XOFFSET 4
/*************************************
*
* Statics
*
*************************************/
UINT16 *rpunch_bitmapram;
size_t rpunch_bitmapram_size;
int rpunch_sprite_palette;
static tilemap_t *background[2];
static UINT16 videoflags;
static UINT8 crtc_register;
static emu_timer *crtc_timer;
static UINT8 bins, gins;
/*************************************
*
* Tilemap callbacks
@ -46,13 +27,13 @@ static TILE_GET_INFO( get_bg0_tile_info )
UINT16 *videoram = state->videoram;
int data = videoram[tile_index];
int code;
if (videoflags & 0x0400) code = (data & 0x0fff) | 0x2000;
if (state->videoflags & 0x0400) code = (data & 0x0fff) | 0x2000;
else code = (data & 0x1fff);
SET_TILE_INFO(
0,
code,
((videoflags & 0x0010) >> 1) | ((data >> 13) & 7),
((state->videoflags & 0x0010) >> 1) | ((data >> 13) & 7),
0);
}
@ -62,13 +43,13 @@ static TILE_GET_INFO( get_bg1_tile_info )
UINT16 *videoram = state->videoram;
int data = videoram[0x2000 / 2 + tile_index];
int code;
if (videoflags & 0x0800) code = (data & 0x0fff) | 0x2000;
if (state->videoflags & 0x0800) code = (data & 0x0fff) | 0x2000;
else code = (data & 0x1fff);
SET_TILE_INFO(
1,
code,
((videoflags & 0x0020) >> 2) | ((data >> 13) & 7),
((state->videoflags & 0x0020) >> 2) | ((data >> 13) & 7),
0);
}
@ -81,26 +62,28 @@ static TILE_GET_INFO( get_bg1_tile_info )
static TIMER_CALLBACK( crtc_interrupt_gen )
{
rpunch_state *state = machine->driver_data<rpunch_state>();
cputag_set_input_line(machine, "maincpu", 1, HOLD_LINE);
if (param != 0)
crtc_timer->adjust(machine->primary_screen->frame_period() / param, 0, machine->primary_screen->frame_period() / param);
state->crtc_timer->adjust(machine->primary_screen->frame_period() / param, 0, machine->primary_screen->frame_period() / param);
}
VIDEO_START( rpunch )
{
rpunch_state *state = machine->driver_data<rpunch_state>();
/* allocate tilemaps for the backgrounds */
background[0] = tilemap_create(machine, get_bg0_tile_info,tilemap_scan_cols,8,8,64,64);
background[1] = tilemap_create(machine, get_bg1_tile_info,tilemap_scan_cols,8,8,64,64);
state->background[0] = tilemap_create(machine, get_bg0_tile_info,tilemap_scan_cols,8,8,64,64);
state->background[1] = tilemap_create(machine, get_bg1_tile_info,tilemap_scan_cols,8,8,64,64);
/* configure the tilemaps */
tilemap_set_transparent_pen(background[1],15);
tilemap_set_transparent_pen(state->background[1],15);
if (rpunch_bitmapram)
memset(rpunch_bitmapram, 0xff, rpunch_bitmapram_size);
if (state->bitmapram)
memset(state->bitmapram, 0xff, state->bitmapram_size);
/* reset the timer */
crtc_timer = machine->scheduler().timer_alloc(FUNC(crtc_interrupt_gen));
state->crtc_timer = machine->scheduler().timer_alloc(FUNC(crtc_interrupt_gen));
}
@ -118,45 +101,47 @@ WRITE16_HANDLER( rpunch_videoram_w )
int tmap = offset >> 12;
int tile_index = offset & 0xfff;
COMBINE_DATA(&videoram[offset]);
tilemap_mark_tile_dirty(background[tmap],tile_index);
tilemap_mark_tile_dirty(state->background[tmap],tile_index);
}
WRITE16_HANDLER( rpunch_videoreg_w )
{
int oldword = videoflags;
COMBINE_DATA(&videoflags);
rpunch_state *state = space->machine->driver_data<rpunch_state>();
int oldword = state->videoflags;
COMBINE_DATA(&state->videoflags);
if (videoflags != oldword)
if (state->videoflags != oldword)
{
/* invalidate tilemaps */
if ((oldword ^ videoflags) & 0x0410)
tilemap_mark_all_tiles_dirty(background[0]);
if ((oldword ^ videoflags) & 0x0820)
tilemap_mark_all_tiles_dirty(background[1]);
if ((oldword ^ state->videoflags) & 0x0410)
tilemap_mark_all_tiles_dirty(state->background[0]);
if ((oldword ^ state->videoflags) & 0x0820)
tilemap_mark_all_tiles_dirty(state->background[1]);
}
}
WRITE16_HANDLER( rpunch_scrollreg_w )
{
rpunch_state *state = space->machine->driver_data<rpunch_state>();
if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
switch (offset)
{
case 0:
tilemap_set_scrolly(background[0], 0, data & 0x1ff);
tilemap_set_scrolly(state->background[0], 0, data & 0x1ff);
break;
case 1:
tilemap_set_scrollx(background[0], 0, data & 0x1ff);
tilemap_set_scrollx(state->background[0], 0, data & 0x1ff);
break;
case 2:
tilemap_set_scrolly(background[1], 0, data & 0x1ff);
tilemap_set_scrolly(state->background[1], 0, data & 0x1ff);
break;
case 3:
tilemap_set_scrollx(background[1], 0, data & 0x1ff);
tilemap_set_scrollx(state->background[1], 0, data & 0x1ff);
break;
}
}
@ -164,18 +149,19 @@ WRITE16_HANDLER( rpunch_scrollreg_w )
WRITE16_HANDLER( rpunch_crtc_data_w )
{
rpunch_state *state = space->machine->driver_data<rpunch_state>();
if (ACCESSING_BITS_0_7)
{
data &= 0xff;
switch (crtc_register)
switch (state->crtc_register)
{
/* only register we know about.... */
case 0x0b:
crtc_timer->adjust(space->machine->primary_screen->time_until_vblank_start(), (data == 0xc0) ? 2 : 1);
state->crtc_timer->adjust(space->machine->primary_screen->time_until_vblank_start(), (data == 0xc0) ? 2 : 1);
break;
default:
logerror("CRTC register %02X = %02X\n", crtc_register, data & 0xff);
logerror("CRTC register %02X = %02X\n", state->crtc_register, data & 0xff);
break;
}
}
@ -184,23 +170,25 @@ WRITE16_HANDLER( rpunch_crtc_data_w )
WRITE16_HANDLER( rpunch_crtc_register_w )
{
rpunch_state *state = space->machine->driver_data<rpunch_state>();
if (ACCESSING_BITS_0_7)
crtc_register = data & 0xff;
state->crtc_register = data & 0xff;
}
WRITE16_HANDLER( rpunch_ins_w )
{
rpunch_state *state = space->machine->driver_data<rpunch_state>();
if (ACCESSING_BITS_0_7)
{
if (offset == 0)
{
gins = data & 0x3f;
state->gins = data & 0x3f;
logerror("GINS = %02X\n", data & 0x3f);
}
else
{
bins = data & 0x3f;
state->bins = data & 0x3f;
logerror("BINS = %02X\n", data & 0x3f);
}
}
@ -215,6 +203,7 @@ WRITE16_HANDLER( rpunch_ins_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int start, int stop)
{
rpunch_state *state = machine->driver_data<rpunch_state>();
UINT16 *spriteram16 = machine->generic.spriteram.u16;
int offs;
@ -233,13 +222,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int y = 513 - (data0 & 0x1ff);
int xflip = data1 & 0x1000;
int yflip = data1 & 0x0800;
int color = ((data1 >> 13) & 7) | ((videoflags & 0x0040) >> 3);
int color = ((data1 >> 13) & 7) | ((state->videoflags & 0x0040) >> 3);
if (x >= BITMAP_WIDTH) x -= 512;
if (y >= BITMAP_HEIGHT) y -= 512;
drawgfx_transpen(bitmap, cliprect, machine->gfx[2],
code, color + (rpunch_sprite_palette / 16), xflip, yflip, x, y, 15);
code, color + (state->sprite_palette / 16), xflip, yflip, x, y, 15);
}
}
@ -250,14 +239,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
*
*************************************/
static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
static void draw_bitmap(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
rpunch_state *state = machine->driver_data<rpunch_state>();
int colourbase;
int xxx=512/4;
int yyy=256;
int x,y,count;
colourbase = 512 + ((videoflags & 15) * 16);
colourbase = 512 + ((state->videoflags & 15) * 16);
count = 0;
@ -266,10 +256,10 @@ static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
for(x=0;x<xxx;x++)
{
int coldat;
coldat = (rpunch_bitmapram[count]>>12)&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+0)-4)&0x1ff) = coldat+colourbase;
coldat = (rpunch_bitmapram[count]>>8 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+1)-4)&0x1ff) = coldat+colourbase;
coldat = (rpunch_bitmapram[count]>>4 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+2)-4)&0x1ff) = coldat+colourbase;
coldat = (rpunch_bitmapram[count]>>0 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+3)-4)&0x1ff) = coldat+colourbase;
coldat = (state->bitmapram[count]>>12)&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+0)-4)&0x1ff) = coldat+colourbase;
coldat = (state->bitmapram[count]>>8 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+1)-4)&0x1ff) = coldat+colourbase;
coldat = (state->bitmapram[count]>>4 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+2)-4)&0x1ff) = coldat+colourbase;
coldat = (state->bitmapram[count]>>0 )&0xf; if (coldat!=15) *BITMAP_ADDR16(bitmap, y, ((x*4+3)-4)&0x1ff) = coldat+colourbase;
count++;
}
}
@ -284,16 +274,17 @@ static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
SCREEN_UPDATE( rpunch )
{
rpunch_state *state = screen->machine->driver_data<rpunch_state>();
int effbins;
/* this seems like the most plausible explanation */
effbins = (bins > gins) ? gins : bins;
effbins = (state->bins > state->gins) ? state->gins : state->bins;
tilemap_draw(bitmap,cliprect, background[0], 0,0);
draw_sprites(screen->machine, bitmap,cliprect, 0, effbins);
tilemap_draw(bitmap,cliprect, background[1], 0,0);
draw_sprites(screen->machine, bitmap,cliprect, effbins, gins);
if (rpunch_bitmapram)
draw_bitmap(bitmap,cliprect);
tilemap_draw(bitmap, cliprect, state->background[0], 0,0);
draw_sprites(screen->machine, bitmap, cliprect, 0, effbins);
tilemap_draw(bitmap, cliprect, state->background[1], 0,0);
draw_sprites(screen->machine, bitmap, cliprect, effbins, state->gins);
if (state->bitmapram)
draw_bitmap(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -9,17 +9,6 @@
#include "emu.h"
#include "includes/slapfght.h"
UINT8 *slapfight_videoram;
UINT8 *slapfight_colorram;
UINT8 *slapfight_fixvideoram;
UINT8 *slapfight_fixcolorram;
UINT8 *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly;
static int flipscreen, slapfight_palette_bank = 0;
static tilemap_t *pf1_tilemap,*fix_tilemap;
/***************************************************************************
@ -29,10 +18,11 @@ static tilemap_t *pf1_tilemap,*fix_tilemap;
static TILE_GET_INFO( get_pf_tile_info ) /* For Performan only */
{
slapfght_state *state = machine->driver_data<slapfght_state>();
int tile,color;
tile=slapfight_videoram[tile_index] + ((slapfight_colorram[tile_index] & 0x03) << 8);
color=(slapfight_colorram[tile_index] >> 3) & 0x0f;
tile=state->slapfight_videoram[tile_index] + ((state->slapfight_colorram[tile_index] & 0x03) << 8);
color=(state->slapfight_colorram[tile_index] >> 3) & 0x0f;
SET_TILE_INFO(
0,
tile,
@ -42,10 +32,11 @@ static TILE_GET_INFO( get_pf_tile_info ) /* For Performan only */
static TILE_GET_INFO( get_pf1_tile_info )
{
slapfght_state *state = machine->driver_data<slapfght_state>();
int tile,color;
tile=slapfight_videoram[tile_index] + ((slapfight_colorram[tile_index] & 0x0f) << 8);
color=(slapfight_colorram[tile_index] & 0xf0) >> 4;
tile=state->slapfight_videoram[tile_index] + ((state->slapfight_colorram[tile_index] & 0x0f) << 8);
color=(state->slapfight_colorram[tile_index] & 0xf0) >> 4;
SET_TILE_INFO(
1,
@ -56,10 +47,11 @@ static TILE_GET_INFO( get_pf1_tile_info )
static TILE_GET_INFO( get_fix_tile_info )
{
slapfght_state *state = machine->driver_data<slapfght_state>();
int tile,color;
tile=slapfight_fixvideoram[tile_index] + ((slapfight_fixcolorram[tile_index] & 0x03) << 8);
color=(slapfight_fixcolorram[tile_index] & 0xfc) >> 2;
tile=state->slapfight_fixvideoram[tile_index] + ((state->slapfight_fixcolorram[tile_index] & 0x03) << 8);
color=(state->slapfight_fixcolorram[tile_index] & 0xfc) >> 2;
SET_TILE_INFO(
0,
@ -77,17 +69,19 @@ static TILE_GET_INFO( get_fix_tile_info )
VIDEO_START( perfrman )
{
pf1_tilemap = tilemap_create(machine, get_pf_tile_info,tilemap_scan_rows,8,8,64,32);
slapfght_state *state = machine->driver_data<slapfght_state>();
state->pf1_tilemap = tilemap_create(machine, get_pf_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_transparent_pen(pf1_tilemap,0);
tilemap_set_transparent_pen(state->pf1_tilemap,0);
}
VIDEO_START( slapfight )
{
pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows,8,8,64,32);
fix_tilemap = tilemap_create(machine, get_fix_tile_info,tilemap_scan_rows,8,8,64,32);
slapfght_state *state = machine->driver_data<slapfght_state>();
state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows,8,8,64,32);
state->fix_tilemap = tilemap_create(machine, get_fix_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_transparent_pen(fix_tilemap,0);
tilemap_set_transparent_pen(state->fix_tilemap,0);
}
@ -99,49 +93,56 @@ VIDEO_START( slapfight )
WRITE8_HANDLER( slapfight_videoram_w )
{
slapfight_videoram[offset]=data;
tilemap_mark_tile_dirty(pf1_tilemap,offset);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->slapfight_videoram[offset]=data;
tilemap_mark_tile_dirty(state->pf1_tilemap,offset);
}
WRITE8_HANDLER( slapfight_colorram_w )
{
slapfight_colorram[offset]=data;
tilemap_mark_tile_dirty(pf1_tilemap,offset);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->slapfight_colorram[offset]=data;
tilemap_mark_tile_dirty(state->pf1_tilemap,offset);
}
WRITE8_HANDLER( slapfight_fixram_w )
{
slapfight_fixvideoram[offset]=data;
tilemap_mark_tile_dirty(fix_tilemap,offset);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->slapfight_fixvideoram[offset]=data;
tilemap_mark_tile_dirty(state->fix_tilemap,offset);
}
WRITE8_HANDLER( slapfight_fixcol_w )
{
slapfight_fixcolorram[offset]=data;
tilemap_mark_tile_dirty(fix_tilemap,offset);
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->slapfight_fixcolorram[offset]=data;
tilemap_mark_tile_dirty(state->fix_tilemap,offset);
}
WRITE8_HANDLER( slapfight_flipscreen_w )
{
slapfght_state *state = space->machine->driver_data<slapfght_state>();
logerror("Writing %02x to flipscreen\n",offset);
if (offset==0) flipscreen=1; /* Port 0x2 is flipscreen */
else flipscreen=0; /* Port 0x3 is normal */
if (offset==0) state->flipscreen=1; /* Port 0x2 is flipscreen */
else state->flipscreen=0; /* Port 0x3 is normal */
}
WRITE8_HANDLER( slapfight_palette_bank_w )
{
slapfight_palette_bank = offset;
slapfght_state *state = space->machine->driver_data<slapfght_state>();
state->slapfight_palette_bank = offset;
}
static void slapfght_log_vram(running_machine *machine)
{
#ifdef MAME_DEBUG
slapfght_state *state = machine->driver_data<slapfght_state>();
if ( input_code_pressed_once(machine, KEYCODE_B) )
{
int i;
for (i=0; i<0x800; i++)
{
logerror("Offset:%03x TileRAM:%02x AttribRAM:%02x SpriteRAM:%02x\n",i, slapfight_videoram[i],slapfight_colorram[i],machine->generic.spriteram.u8[i]);
logerror("Offset:%03x TileRAM:%02x AttribRAM:%02x SpriteRAM:%02x\n",i, state->slapfight_videoram[i],state->slapfight_colorram[i],machine->generic.spriteram.u8[i]);
}
}
#endif
@ -154,6 +155,7 @@ static void slapfght_log_vram(running_machine *machine)
***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority_to_display )
{
slapfght_state *state = machine->driver_data<slapfght_state>();
UINT8 *buffered_spriteram = machine->generic.buffered_spriteram.u8;
int offs;
@ -163,7 +165,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
if ((buffered_spriteram[offs+2] & 0x80) == priority_to_display)
{
if (flipscreen)
if (state->flipscreen)
{
sx = 265 - buffered_spriteram[offs+1];
sy = 239 - buffered_spriteram[offs+3];
@ -177,8 +179,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
buffered_spriteram[offs],
((buffered_spriteram[offs+2] >> 1) & 3) |
((buffered_spriteram[offs+2] << 2) & 4) | (slapfight_palette_bank << 3),
flipscreen, flipscreen,
((buffered_spriteram[offs+2] << 2) & 4) | (state->slapfight_palette_bank << 3),
state->flipscreen, state->flipscreen,
sx, sy,0);
}
}
@ -187,18 +189,19 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( perfrman )
{
tilemap_set_flip( pf1_tilemap, flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_scrolly( pf1_tilemap ,0 , 0 );
if (flipscreen) {
tilemap_set_scrollx( pf1_tilemap ,0 , 264 );
slapfght_state *state = screen->machine->driver_data<slapfght_state>();
tilemap_set_flip( state->pf1_tilemap, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
tilemap_set_scrolly( state->pf1_tilemap ,0 , 0 );
if (state->flipscreen) {
tilemap_set_scrollx( state->pf1_tilemap ,0 , 264 );
}
else {
tilemap_set_scrollx( pf1_tilemap ,0 , -16 );
tilemap_set_scrollx( state->pf1_tilemap ,0 , -16 );
}
tilemap_draw(bitmap,cliprect,pf1_tilemap,TILEMAP_DRAW_OPAQUE,0);
tilemap_draw(bitmap,cliprect,state->pf1_tilemap,TILEMAP_DRAW_OPAQUE,0);
draw_sprites(screen->machine, bitmap,cliprect,0);
tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0);
draw_sprites(screen->machine, bitmap,cliprect,0x80);
slapfght_log_vram(screen->machine);
@ -208,29 +211,30 @@ SCREEN_UPDATE( perfrman )
SCREEN_UPDATE( slapfight )
{
slapfght_state *state = screen->machine->driver_data<slapfght_state>();
UINT8 *buffered_spriteram = screen->machine->generic.buffered_spriteram.u8;
int offs;
tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
if (flipscreen) {
tilemap_set_scrollx( fix_tilemap,0,296);
tilemap_set_scrollx( pf1_tilemap,0,(*slapfight_scrollx_lo + 256 * *slapfight_scrollx_hi)+296 );
tilemap_set_scrolly( pf1_tilemap,0, (*slapfight_scrolly)+15 );
tilemap_set_scrolly( fix_tilemap,0, -1 ); /* Glitch in Tiger Heli otherwise */
tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
if (state->flipscreen) {
tilemap_set_scrollx( state->fix_tilemap,0,296);
tilemap_set_scrollx( state->pf1_tilemap,0,(*state->slapfight_scrollx_lo + 256 * *state->slapfight_scrollx_hi)+296 );
tilemap_set_scrolly( state->pf1_tilemap,0, (*state->slapfight_scrolly)+15 );
tilemap_set_scrolly( state->fix_tilemap,0, -1 ); /* Glitch in Tiger Heli otherwise */
}
else {
tilemap_set_scrollx( fix_tilemap,0,0);
tilemap_set_scrollx( pf1_tilemap,0,(*slapfight_scrollx_lo + 256 * *slapfight_scrollx_hi) );
tilemap_set_scrolly( pf1_tilemap,0, (*slapfight_scrolly)-1 );
tilemap_set_scrolly( fix_tilemap,0, -1 ); /* Glitch in Tiger Heli otherwise */
tilemap_set_scrollx( state->fix_tilemap,0,0);
tilemap_set_scrollx( state->pf1_tilemap,0,(*state->slapfight_scrollx_lo + 256 * *state->slapfight_scrollx_hi) );
tilemap_set_scrolly( state->pf1_tilemap,0, (*state->slapfight_scrolly)-1 );
tilemap_set_scrolly( state->fix_tilemap,0, -1 ); /* Glitch in Tiger Heli otherwise */
}
tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0);
/* Draw the sprites */
for (offs = 0;offs < screen->machine->generic.spriteram_size;offs += 4)
{
if (flipscreen)
if (state->flipscreen)
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[2],
buffered_spriteram[offs] + ((buffered_spriteram[offs+2] & 0xc0) << 2),
(buffered_spriteram[offs+2] & 0x1e) >> 1,
@ -244,7 +248,7 @@ SCREEN_UPDATE( slapfight )
(buffered_spriteram[offs+1] + ((buffered_spriteram[offs+2] & 0x01) << 8)) - 13,buffered_spriteram[offs+3],0);
}
tilemap_draw(bitmap,cliprect,fix_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->fix_tilemap,0,0);
slapfght_log_vram(screen->machine);
return 0;

View File

@ -8,16 +8,6 @@
#include "includes/suprridr.h"
UINT8 *suprridr_bgram;
UINT8 *suprridr_fgram;
static tilemap_t *fg_tilemap;
static tilemap_t *bg_tilemap;
static tilemap_t *bg_tilemap_noscroll;
static UINT8 flipx, flipy;
/*************************************
*
* Tilemap callbacks
@ -26,14 +16,16 @@ static UINT8 flipx, flipy;
static TILE_GET_INFO( get_tile_info )
{
UINT8 code = suprridr_bgram[tile_index];
suprridr_state *state = machine->driver_data<suprridr_state>();
UINT8 code = state->bgram[tile_index];
SET_TILE_INFO(0, code, 0, 0);
}
static TILE_GET_INFO( get_tile_info2 )
{
UINT8 code = suprridr_fgram[tile_index];
suprridr_state *state = machine->driver_data<suprridr_state>();
UINT8 code = state->fgram[tile_index];
SET_TILE_INFO(1, code, 0, 0);
}
@ -47,11 +39,12 @@ static TILE_GET_INFO( get_tile_info2 )
VIDEO_START( suprridr )
{
fg_tilemap = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 8,8, 32,32);
bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 32,32);
bg_tilemap_noscroll = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 32,32);
suprridr_state *state = machine->driver_data<suprridr_state>();
state->fg_tilemap = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 8,8, 32,32);
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 32,32);
state->bg_tilemap_noscroll = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 32,32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
}
@ -100,39 +93,45 @@ PALETTE_INIT( suprridr )
WRITE8_HANDLER( suprridr_flipx_w )
{
flipx = data & 1;
tilemap_set_flip_all(space->machine, (flipx ? TILEMAP_FLIPX : 0) | (flipy ? TILEMAP_FLIPY : 0));
suprridr_state *state = space->machine->driver_data<suprridr_state>();
state->flipx = data & 1;
tilemap_set_flip_all(space->machine, (state->flipx ? TILEMAP_FLIPX : 0) | (state->flipy ? TILEMAP_FLIPY : 0));
}
WRITE8_HANDLER( suprridr_flipy_w )
{
flipy = data & 1;
tilemap_set_flip_all(space->machine, (flipx ? TILEMAP_FLIPX : 0) | (flipy ? TILEMAP_FLIPY : 0));
suprridr_state *state = space->machine->driver_data<suprridr_state>();
state->flipy = data & 1;
tilemap_set_flip_all(space->machine, (state->flipx ? TILEMAP_FLIPX : 0) | (state->flipy ? TILEMAP_FLIPY : 0));
}
WRITE8_HANDLER( suprridr_fgdisable_w )
{
tilemap_set_enable(fg_tilemap, ~data & 1);
suprridr_state *state = space->machine->driver_data<suprridr_state>();
tilemap_set_enable(state->fg_tilemap, ~data & 1);
}
WRITE8_HANDLER( suprridr_fgscrolly_w )
{
tilemap_set_scrolly(fg_tilemap, 0, data);
suprridr_state *state = space->machine->driver_data<suprridr_state>();
tilemap_set_scrolly(state->fg_tilemap, 0, data);
}
WRITE8_HANDLER( suprridr_bgscrolly_w )
{
tilemap_set_scrolly(bg_tilemap, 0, data);
suprridr_state *state = space->machine->driver_data<suprridr_state>();
tilemap_set_scrolly(state->bg_tilemap, 0, data);
}
int suprridr_is_screen_flipped(void)
int suprridr_is_screen_flipped(running_machine *machine)
{
return flipx; /* or is it flipy? */
suprridr_state *state = machine->driver_data<suprridr_state>();
return state->flipx; /* or is it flipy? */
}
@ -145,16 +144,18 @@ int suprridr_is_screen_flipped(void)
WRITE8_HANDLER( suprridr_bgram_w )
{
suprridr_bgram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
tilemap_mark_tile_dirty(bg_tilemap_noscroll, offset);
suprridr_state *state = space->machine->driver_data<suprridr_state>();
state->bgram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
tilemap_mark_tile_dirty(state->bg_tilemap_noscroll, offset);
}
WRITE8_HANDLER( suprridr_fgram_w )
{
suprridr_fgram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset);
suprridr_state *state = space->machine->driver_data<suprridr_state>();
state->fgram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
@ -167,6 +168,7 @@ WRITE8_HANDLER( suprridr_fgram_w )
SCREEN_UPDATE( suprridr )
{
suprridr_state *state = screen->machine->driver_data<suprridr_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
rectangle subclip;
int i;
@ -174,25 +176,25 @@ SCREEN_UPDATE( suprridr )
/* render left 4 columns with no scroll */
subclip = visarea;;
subclip.max_x = subclip.min_x + (flipx ? 1*8 : 4*8) - 1;
subclip.max_x = subclip.min_x + (state->flipx ? 1*8 : 4*8) - 1;
sect_rect(&subclip, cliprect);
tilemap_draw(bitmap, &subclip, bg_tilemap_noscroll, 0, 0);
tilemap_draw(bitmap, &subclip, state->bg_tilemap_noscroll, 0, 0);
/* render right 1 column with no scroll */
subclip = visarea;;
subclip.min_x = subclip.max_x - (flipx ? 4*8 : 1*8) + 1;
subclip.min_x = subclip.max_x - (state->flipx ? 4*8 : 1*8) + 1;
sect_rect(&subclip, cliprect);
tilemap_draw(bitmap, &subclip, bg_tilemap_noscroll, 0, 0);
tilemap_draw(bitmap, &subclip, state->bg_tilemap_noscroll, 0, 0);
/* render the middle columns normally */
subclip = visarea;;
subclip.min_x += flipx ? 1*8 : 4*8;
subclip.max_x -= flipx ? 4*8 : 1*8;
subclip.min_x += state->flipx ? 1*8 : 4*8;
subclip.max_x -= state->flipx ? 4*8 : 1*8;
sect_rect(&subclip, cliprect);
tilemap_draw(bitmap, &subclip, bg_tilemap, 0, 0);
tilemap_draw(bitmap, &subclip, state->bg_tilemap, 0, 0);
/* render the top layer */
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
/* draw the sprites */
for (i = 0; i < 48; i++)
@ -204,12 +206,12 @@ SCREEN_UPDATE( suprridr )
int x = spriteram[i*4+3];
int y = 240 - spriteram[i*4+0];
if (flipx)
if (state->flipx)
{
fx = !fx;
x = 240 - x;
}
if (flipy)
if (state->flipy)
{
fy = !fy;
y = 240 - y;

View File

@ -5,16 +5,6 @@
#include "emu.h"
#include "includes/tankbust.h"
/*
* variables
*/
UINT8 * tankbust_videoram;
UINT8 * tankbust_colorram;
static tilemap_t *bg_tilemap;
static tilemap_t *txt_tilemap;
UINT8 * tankbust_txtram;
/***************************************************************************
@ -38,8 +28,9 @@ note:
static TILE_GET_INFO( get_bg_tile_info )
{
int code = tankbust_videoram[tile_index];
int attr = tankbust_colorram[tile_index];
tankbust_state *state = machine->driver_data<tankbust_state>();
int code = state->videoram[tile_index];
int attr = state->colorram[tile_index];
int color = ((attr>>4) & 0x07);
@ -68,7 +59,8 @@ static TILE_GET_INFO( get_bg_tile_info )
static TILE_GET_INFO( get_txt_tile_info )
{
int code = tankbust_txtram[tile_index];
tankbust_state *state = machine->driver_data<tankbust_state>();
int code = state->txtram[tile_index];
int color = ((code>>6) & 0x03);
SET_TILE_INFO( 2,
@ -86,14 +78,15 @@ static TILE_GET_INFO( get_txt_tile_info )
VIDEO_START( tankbust )
{
tankbust_state *state = machine->driver_data<tankbust_state>();
/* not scrollable */
txt_tilemap = tilemap_create(machine, get_txt_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
state->txt_tilemap = tilemap_create(machine, get_txt_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
/* scrollable */
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_transparent_pen(txt_tilemap, 0);
tilemap_set_transparent_pen(state->txt_tilemap, 0);
}
@ -105,66 +98,72 @@ VIDEO_START( tankbust )
WRITE8_HANDLER( tankbust_background_videoram_w )
{
tankbust_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
tankbust_state *state = space->machine->driver_data<tankbust_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
READ8_HANDLER( tankbust_background_videoram_r )
{
return tankbust_videoram[offset];
tankbust_state *state = space->machine->driver_data<tankbust_state>();
return state->videoram[offset];
}
WRITE8_HANDLER( tankbust_background_colorram_w )
{
tankbust_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
tankbust_state *state = space->machine->driver_data<tankbust_state>();
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
READ8_HANDLER( tankbust_background_colorram_r )
{
return tankbust_colorram[offset];
tankbust_state *state = space->machine->driver_data<tankbust_state>();
return state->colorram[offset];
}
WRITE8_HANDLER( tankbust_txtram_w )
{
tankbust_txtram[offset] = data;
tilemap_mark_tile_dirty(txt_tilemap, offset);
tankbust_state *state = space->machine->driver_data<tankbust_state>();
state->txtram[offset] = data;
tilemap_mark_tile_dirty(state->txt_tilemap, offset);
}
READ8_HANDLER( tankbust_txtram_r )
{
return tankbust_txtram[offset];
tankbust_state *state = space->machine->driver_data<tankbust_state>();
return state->txtram[offset];
}
static UINT8 xscroll[2];
WRITE8_HANDLER( tankbust_xscroll_w )
{
if( xscroll[offset] != data )
tankbust_state *state = space->machine->driver_data<tankbust_state>();
if( state->xscroll[offset] != data )
{
int x;
xscroll[offset] = data;
state->xscroll[offset] = data;
x = xscroll[0] + 256 * (xscroll[1]&1);
x = state->xscroll[0] + 256 * (state->xscroll[1]&1);
if (x>=0x100) x-=0x200;
tilemap_set_scrollx(bg_tilemap, 0, x );
tilemap_set_scrollx(state->bg_tilemap, 0, x );
}
//popmessage("x=%02x %02x", xscroll[0], xscroll[1]);
//popmessage("x=%02x %02x", state->xscroll[0], state->xscroll[1]);
}
static UINT8 yscroll[2];
WRITE8_HANDLER( tankbust_yscroll_w )
{
if( yscroll[offset] != data )
tankbust_state *state = space->machine->driver_data<tankbust_state>();
if( state->yscroll[offset] != data )
{
int y;
yscroll[offset] = data;
y = yscroll[0];
state->yscroll[offset] = data;
y = state->yscroll[0];
if (y>=0x80) y-=0x100;
tilemap_set_scrolly(bg_tilemap, 0, y );
tilemap_set_scrolly(state->bg_tilemap, 0, y );
}
//popmessage("y=%02x %02x", yscroll[0], yscroll[1]);
//popmessage("y=%02x %02x", state->yscroll[0], state->yscroll[1]);
}
/***************************************************************************
@ -234,24 +233,25 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( tankbust )
{
tankbust_state *state = screen->machine->driver_data<tankbust_state>();
#if 0
int i;
for (i=0; i<0x800; i++)
{
int tile_attrib = tankbust_colorram[i];
int tile_attrib = state->colorram[i];
if ( (tile_attrib&8) || (tile_attrib&0x80) )
{
tilemap_mark_tile_dirty(bg_tilemap, i);
tilemap_mark_tile_dirty(state->bg_tilemap, i);
}
}
#endif
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, bg_tilemap, 1, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 1, 0);
tilemap_draw(bitmap, cliprect, txt_tilemap, 0,0);
tilemap_draw(bitmap, cliprect, state->txt_tilemap, 0,0);
return 0;
}

View File

@ -11,25 +11,15 @@ zooming might be wrong (only used on title logo?)
#include "emu.h"
#include "includes/taotaido.h"
UINT16 *taotaido_spriteram;
UINT16 *taotaido_spriteram2;
UINT16 *taotaido_scrollram;
UINT16 *taotaido_bgram;
static UINT16 taotaido_sprite_character_bank_select[8];
static UINT16 taotaido_video_bank_select[8];
static tilemap_t *bg_tilemap;
static UINT16 *taotaido_spriteram_old, *taotaido_spriteram_older;
static UINT16 *taotaido_spriteram2_old, *taotaido_spriteram2_older;
/* sprite tile codes 0x4000 - 0x7fff get remapped according to the content of these registers */
WRITE16_HANDLER( taotaido_sprite_character_bank_select_w )
{
taotaido_state *state = space->machine->driver_data<taotaido_state>();
if(ACCESSING_BITS_8_15)
taotaido_sprite_character_bank_select[offset*2] = data >> 8;
state->sprite_character_bank_select[offset*2] = data >> 8;
if(ACCESSING_BITS_0_7)
taotaido_sprite_character_bank_select[offset*2+1] = data &0xff;
state->sprite_character_bank_select[offset*2+1] = data &0xff;
}
/* sprites are like the other video system / psikyo games, we can merge this with aerofgt and plenty of other
@ -37,6 +27,7 @@ WRITE16_HANDLER( taotaido_sprite_character_bank_select_w )
static void draw_sprite(running_machine *machine, UINT16 spriteno, bitmap_t *bitmap, const rectangle *cliprect )
{
taotaido_state *state = machine->driver_data<taotaido_state>();
/*- SPR RAM Format -**
4 words per sprite
@ -50,7 +41,7 @@ static void draw_sprite(running_machine *machine, UINT16 spriteno, bitmap_t *bit
int x,y;
UINT16 *source = &taotaido_spriteram_older[spriteno*4];
UINT16 *source = &state->spriteram_older[spriteno*4];
const gfx_element *gfx = machine->gfx[0];
@ -89,7 +80,7 @@ static void draw_sprite(running_machine *machine, UINT16 spriteno, bitmap_t *bit
/* this indirection is a bit different to the other video system games */
int realtile;
realtile = taotaido_spriteram2_older[tile&0x7fff];
realtile = state->spriteram2_older[tile&0x7fff];
if (realtile > 0x3fff)
{
@ -98,7 +89,7 @@ static void draw_sprite(running_machine *machine, UINT16 spriteno, bitmap_t *bit
block = (realtile & 0x3800)>>11;
realtile &= 0x07ff;
realtile |= taotaido_sprite_character_bank_select[block] * 0x800;
realtile |= state->sprite_character_bank_select[block] * 0x800;
}
if (xflip) sx = ((xpos + xzoom * (xsize - x) / 2 + 16) & 0x1ff) - 16;
@ -120,9 +111,10 @@ static void draw_sprite(running_machine *machine, UINT16 spriteno, bitmap_t *bit
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
taotaido_state *state = machine->driver_data<taotaido_state>();
/* first part of sprite ram is the list of sprites to draw, terminated with 0x4000 */
UINT16 *source = taotaido_spriteram_older;
UINT16 *finish = taotaido_spriteram_older + 0x2000/2;
UINT16 *source = state->spriteram_older;
UINT16 *finish = state->spriteram_older + 0x2000/2;
while( source<finish )
{
@ -139,6 +131,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
WRITE16_HANDLER( taotaido_tileregs_w )
{
taotaido_state *state = space->machine->driver_data<taotaido_state>();
switch (offset)
{
case 0: // would normally be x scroll?
@ -154,27 +147,29 @@ WRITE16_HANDLER( taotaido_tileregs_w )
case 6:
case 7:
if(ACCESSING_BITS_8_15)
taotaido_video_bank_select[(offset-4)*2] = data >> 8;
state->video_bank_select[(offset-4)*2] = data >> 8;
if(ACCESSING_BITS_0_7)
taotaido_video_bank_select[(offset-4)*2+1] = data &0xff;
tilemap_mark_all_tiles_dirty(bg_tilemap);
state->video_bank_select[(offset-4)*2+1] = data &0xff;
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
break;
}
}
WRITE16_HANDLER( taotaido_bgvideoram_w )
{
COMBINE_DATA(&taotaido_bgram[offset]);
tilemap_mark_tile_dirty(bg_tilemap,offset);
taotaido_state *state = space->machine->driver_data<taotaido_state>();
COMBINE_DATA(&state->bgram[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
}
static TILE_GET_INFO( taotaido_bg_tile_info )
{
int code = taotaido_bgram[tile_index]&0x01ff;
int bank = (taotaido_bgram[tile_index]&0x0e00)>>9;
int col = (taotaido_bgram[tile_index]&0xf000)>>12;
taotaido_state *state = machine->driver_data<taotaido_state>();
int code = state->bgram[tile_index]&0x01ff;
int bank = (state->bgram[tile_index]&0x0e00)>>9;
int col = (state->bgram[tile_index]&0xf000)>>12;
code |= taotaido_video_bank_select[bank]*0x200;
code |= state->video_bank_select[bank]*0x200;
SET_TILE_INFO(
1,
@ -191,20 +186,22 @@ static TILEMAP_MAPPER( taotaido_tilemap_scan_rows )
VIDEO_START(taotaido)
{
bg_tilemap = tilemap_create(machine, taotaido_bg_tile_info,taotaido_tilemap_scan_rows, 16,16,128,64);
taotaido_state *state = machine->driver_data<taotaido_state>();
state->bg_tilemap = tilemap_create(machine, taotaido_bg_tile_info,taotaido_tilemap_scan_rows, 16,16,128,64);
taotaido_spriteram_old = auto_alloc_array(machine, UINT16, 0x2000/2);
taotaido_spriteram_older = auto_alloc_array(machine, UINT16, 0x2000/2);
state->spriteram_old = auto_alloc_array(machine, UINT16, 0x2000/2);
state->spriteram_older = auto_alloc_array(machine, UINT16, 0x2000/2);
taotaido_spriteram2_old = auto_alloc_array(machine, UINT16, 0x10000/2);
taotaido_spriteram2_older = auto_alloc_array(machine, UINT16, 0x10000/2);
state->spriteram2_old = auto_alloc_array(machine, UINT16, 0x10000/2);
state->spriteram2_older = auto_alloc_array(machine, UINT16, 0x10000/2);
}
SCREEN_UPDATE(taotaido)
{
// tilemap_set_scrollx(bg_tilemap,0,(taotaido_scrollram[0x380/2]>>4)); // the values put here end up being wrong every other frame
// tilemap_set_scrolly(bg_tilemap,0,(taotaido_scrollram[0x382/2]>>4)); // the values put here end up being wrong every other frame
taotaido_state *state = screen->machine->driver_data<taotaido_state>();
// tilemap_set_scrollx(state->bg_tilemap,0,(state->scrollram[0x380/2]>>4)); // the values put here end up being wrong every other frame
// tilemap_set_scrolly(state->bg_tilemap,0,(state->scrollram[0x382/2]>>4)); // the values put here end up being wrong every other frame
/* not amazingly efficient however it should be functional for row select and linescroll */
int line;
@ -220,10 +217,10 @@ SCREEN_UPDATE(taotaido)
{
clip.min_y = clip.max_y = line;
tilemap_set_scrollx(bg_tilemap,0,((taotaido_scrollram[(0x00+4*line)/2])>>4)+30);
tilemap_set_scrolly(bg_tilemap,0,((taotaido_scrollram[(0x02+4*line)/2])>>4)-line);
tilemap_set_scrollx(state->bg_tilemap,0,((state->scrollram[(0x00+4*line)/2])>>4)+30);
tilemap_set_scrolly(state->bg_tilemap,0,((state->scrollram[(0x02+4*line)/2])>>4)-line);
tilemap_draw(bitmap,&clip,bg_tilemap,0,0);
tilemap_draw(bitmap,&clip,state->bg_tilemap,0,0);
}
draw_sprites(screen->machine, bitmap,cliprect);
@ -232,11 +229,12 @@ SCREEN_UPDATE(taotaido)
SCREEN_EOF( taotaido )
{
taotaido_state *state = machine->driver_data<taotaido_state>();
/* sprites need to be delayed by 2 frames? */
memcpy(taotaido_spriteram2_older,taotaido_spriteram2_old,0x10000);
memcpy(taotaido_spriteram2_old,taotaido_spriteram2,0x10000);
memcpy(state->spriteram2_older,state->spriteram2_old,0x10000);
memcpy(state->spriteram2_old,state->spriteram2,0x10000);
memcpy(taotaido_spriteram_older,taotaido_spriteram_old,0x2000);
memcpy(taotaido_spriteram_old,taotaido_spriteram,0x2000);
memcpy(state->spriteram_older,state->spriteram_old,0x2000);
memcpy(state->spriteram_old,state->spriteram,0x2000);
}

View File

@ -10,20 +10,6 @@
#include "includes/thepit.h"
UINT8 *thepit_videoram;
UINT8 *thepit_colorram;
UINT8 *thepit_attributesram;
UINT8 *thepit_spriteram;
size_t thepit_spriteram_size;
static UINT8 graphics_bank;
static UINT8 thepit_flip_screen_x;
static UINT8 thepit_flip_screen_y;
static tilemap_t *thepit_solid_tilemap;
static tilemap_t *thepit_tilemap;
static UINT8 *dummy_tile;
static const rectangle spritevisiblearea =
{
2*8+1, 32*8-1,
@ -123,9 +109,10 @@ PALETTE_INIT( suprmous )
static TILE_GET_INFO( solid_get_tile_info )
{
UINT8 back_color = (thepit_colorram[tile_index] & 0x70) >> 4;
int priority = (back_color != 0) && ((thepit_colorram[tile_index] & 0x80) == 0);
tileinfo->pen_data = dummy_tile;
thepit_state *state = machine->driver_data<thepit_state>();
UINT8 back_color = (state->colorram[tile_index] & 0x70) >> 4;
int priority = (back_color != 0) && ((state->colorram[tile_index] & 0x80) == 0);
tileinfo->pen_data = state->dummy_tile;
tileinfo->palette_base = back_color + 32;
tileinfo->category = priority;
}
@ -133,9 +120,10 @@ static TILE_GET_INFO( solid_get_tile_info )
static TILE_GET_INFO( get_tile_info )
{
UINT8 fore_color = thepit_colorram[tile_index] % machine->gfx[0]->total_colors;
UINT8 code = thepit_videoram[tile_index];
SET_TILE_INFO(2 * graphics_bank, code, fore_color, 0);
thepit_state *state = machine->driver_data<thepit_state>();
UINT8 fore_color = state->colorram[tile_index] % machine->gfx[0]->total_colors;
UINT8 code = state->videoram[tile_index];
SET_TILE_INFO(2 * state->graphics_bank, code, fore_color, 0);
}
@ -148,17 +136,18 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( thepit )
{
thepit_solid_tilemap = tilemap_create(machine, solid_get_tile_info,tilemap_scan_rows,8,8,32,32);
thepit_state *state = machine->driver_data<thepit_state>();
state->solid_tilemap = tilemap_create(machine, solid_get_tile_info,tilemap_scan_rows,8,8,32,32);
thepit_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(thepit_tilemap, 0);
state->tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(state->tilemap, 0);
tilemap_set_scroll_cols(thepit_solid_tilemap, 32);
tilemap_set_scroll_cols(thepit_tilemap, 32);
tilemap_set_scroll_cols(state->solid_tilemap, 32);
tilemap_set_scroll_cols(state->tilemap, 32);
dummy_tile = auto_alloc_array_clear(machine, UINT8, 8*8);
state->dummy_tile = auto_alloc_array_clear(machine, UINT8, 8*8);
graphics_bank = 0; /* only used in intrepid */
state->graphics_bank = 0; /* only used in intrepid */
}
@ -171,67 +160,73 @@ VIDEO_START( thepit )
WRITE8_HANDLER( thepit_videoram_w )
{
thepit_videoram[offset] = data;
tilemap_mark_tile_dirty(thepit_tilemap, offset);
thepit_state *state = space->machine->driver_data<thepit_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->tilemap, offset);
}
WRITE8_HANDLER( thepit_colorram_w )
{
thepit_colorram[offset] = data;
tilemap_mark_tile_dirty(thepit_tilemap, offset);
tilemap_mark_tile_dirty(thepit_solid_tilemap, offset);
thepit_state *state = space->machine->driver_data<thepit_state>();
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->tilemap, offset);
tilemap_mark_tile_dirty(state->solid_tilemap, offset);
}
WRITE8_HANDLER( thepit_flip_screen_x_w )
{
thepit_state *state = space->machine->driver_data<thepit_state>();
int flip;
thepit_flip_screen_x = data & 0x01;
state->flip_screen_x = data & 0x01;
flip = thepit_flip_screen_x ? TILEMAP_FLIPX : 0;
if (thepit_flip_screen_y)
flip = state->flip_screen_x ? TILEMAP_FLIPX : 0;
if (state->flip_screen_y)
flip |= TILEMAP_FLIPY ;
tilemap_set_flip(thepit_tilemap, flip);
tilemap_set_flip(thepit_solid_tilemap, flip);
tilemap_set_flip(state->tilemap, flip);
tilemap_set_flip(state->solid_tilemap, flip);
}
WRITE8_HANDLER( thepit_flip_screen_y_w )
{
thepit_state *state = space->machine->driver_data<thepit_state>();
int flip;
thepit_flip_screen_y = data & 0x01;
state->flip_screen_y = data & 0x01;
flip = thepit_flip_screen_x ? TILEMAP_FLIPX : 0;
if (thepit_flip_screen_y)
flip = state->flip_screen_x ? TILEMAP_FLIPX : 0;
if (state->flip_screen_y)
flip |= TILEMAP_FLIPY ;
tilemap_set_flip(thepit_tilemap, flip);
tilemap_set_flip(thepit_solid_tilemap, flip);
tilemap_set_flip(state->tilemap, flip);
tilemap_set_flip(state->solid_tilemap, flip);
}
WRITE8_HANDLER( intrepid_graphics_bank_w )
{
if (graphics_bank != (data & 0x01))
thepit_state *state = space->machine->driver_data<thepit_state>();
if (state->graphics_bank != (data & 0x01))
{
graphics_bank = data & 0x01;
state->graphics_bank = data & 0x01;
tilemap_mark_all_tiles_dirty(thepit_tilemap);
tilemap_mark_all_tiles_dirty(state->tilemap);
}
}
READ8_HANDLER( thepit_input_port_0_r )
{
thepit_state *state = space->machine->driver_data<thepit_state>();
/* Read either the real or the fake input ports depending on the
horizontal flip switch. (This is how the real PCB does it) */
if (thepit_flip_screen_x)
if (state->flip_screen_x)
{
return input_port_read(space->machine, "IN2");
}
@ -254,32 +249,33 @@ static void draw_sprites(running_machine *machine,
const rectangle *cliprect,
int priority_to_draw)
{
thepit_state *state = machine->driver_data<thepit_state>();
int offs;
for (offs = thepit_spriteram_size - 4; offs >= 0; offs -= 4)
for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
{
if (((thepit_spriteram[offs + 2] & 0x08) >> 3) == priority_to_draw)
if (((state->spriteram[offs + 2] & 0x08) >> 3) == priority_to_draw)
{
UINT8 y, x, flipx, flipy;
if ((thepit_spriteram[offs + 0] == 0) || (thepit_spriteram[offs + 3] == 0))
if ((state->spriteram[offs + 0] == 0) || (state->spriteram[offs + 3] == 0))
{
continue;
}
y = 240 - thepit_spriteram[offs];
x = thepit_spriteram[offs + 3] + 1;
y = 240 - state->spriteram[offs];
x = state->spriteram[offs + 3] + 1;
flipx = thepit_spriteram[offs + 1] & 0x40;
flipy = thepit_spriteram[offs + 1] & 0x80;
flipx = state->spriteram[offs + 1] & 0x40;
flipy = state->spriteram[offs + 1] & 0x80;
if (thepit_flip_screen_y)
if (state->flip_screen_y)
{
y = 240 - y;
flipy = !flipy;
}
if (thepit_flip_screen_x)
if (state->flip_screen_x)
{
x = 242 - x;
flipx = !flipx;
@ -288,10 +284,10 @@ static void draw_sprites(running_machine *machine,
/* sprites 0-3 are drawn one pixel down */
if (offs < 16) y++;
drawgfx_transpen(bitmap, thepit_flip_screen_x ? &spritevisibleareaflipx : &spritevisiblearea,
machine->gfx[2 * graphics_bank + 1],
thepit_spriteram[offs + 1] & 0x3f,
thepit_spriteram[offs + 2],
drawgfx_transpen(bitmap, state->flip_screen_x ? &spritevisibleareaflipx : &spritevisiblearea,
machine->gfx[2 * state->graphics_bank + 1],
state->spriteram[offs + 1] & 0x3f,
state->spriteram[offs + 2],
flipx, flipy, x, y, 0);
}
}
@ -300,29 +296,30 @@ static void draw_sprites(running_machine *machine,
SCREEN_UPDATE( thepit )
{
thepit_state *state = screen->machine->driver_data<thepit_state>();
offs_t offs;
for (offs = 0; offs < 32; offs++)
{
int xshift = thepit_flip_screen_x ? 128 : 0;
int yshift = thepit_flip_screen_y ? -8 : 0;
int xshift = state->flip_screen_x ? 128 : 0;
int yshift = state->flip_screen_y ? -8 : 0;
tilemap_set_scrollx(thepit_tilemap, offs, xshift);
tilemap_set_scrollx(thepit_solid_tilemap, offs, xshift);
tilemap_set_scrollx(state->tilemap, offs, xshift);
tilemap_set_scrollx(state->solid_tilemap, offs, xshift);
tilemap_set_scrolly(thepit_tilemap, offs, yshift + thepit_attributesram[offs << 1]);
tilemap_set_scrolly(thepit_solid_tilemap, offs, yshift + thepit_attributesram[offs << 1]);
tilemap_set_scrolly(state->tilemap, offs, yshift + state->attributesram[offs << 1]);
tilemap_set_scrolly(state->solid_tilemap, offs, yshift + state->attributesram[offs << 1]);
}
/* low priority tiles */
tilemap_draw(bitmap, cliprect, thepit_solid_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, thepit_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->solid_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
/* low priority sprites */
draw_sprites(screen->machine, bitmap, cliprect, 0);
/* high priority tiles */
tilemap_draw(bitmap, cliprect, thepit_solid_tilemap, 1, 1);
tilemap_draw(bitmap, cliprect, state->solid_tilemap, 1, 1);
/* high priority sprites */
draw_sprites(screen->machine, bitmap, cliprect, 1);

View File

@ -1,14 +1,6 @@
#include "emu.h"
#include "includes/timelimt.h"
/* globals */
UINT8 *timelimt_bg_videoram;
size_t timelimt_bg_videoram_size;
/* locals */
static int scrollx, scrolly;
static tilemap_t *bg_tilemap, *fg_tilemap;
/***************************************************************************
@ -63,7 +55,8 @@ PALETTE_INIT( timelimt ) {
static TILE_GET_INFO( get_bg_tile_info )
{
SET_TILE_INFO(1, timelimt_bg_videoram[tile_index], 0, 0);
timelimt_state *state = machine->driver_data<timelimt_state>();
SET_TILE_INFO(1, state->bg_videoram[tile_index], 0, 0);
}
static TILE_GET_INFO( get_fg_tile_info )
@ -75,13 +68,14 @@ static TILE_GET_INFO( get_fg_tile_info )
VIDEO_START( timelimt )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
timelimt_state *state = machine->driver_data<timelimt_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 64, 32);
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows,
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
}
/***************************************************************************/
@ -91,30 +85,34 @@ WRITE8_HANDLER( timelimt_videoram_w )
timelimt_state *state = space->machine->driver_data<timelimt_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset);
tilemap_mark_tile_dirty(state->fg_tilemap, offset);
}
WRITE8_HANDLER( timelimt_bg_videoram_w )
{
timelimt_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
timelimt_state *state = space->machine->driver_data<timelimt_state>();
state->bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( timelimt_scroll_x_lsb_w )
{
scrollx &= 0x100;
scrollx |= data & 0xff;
timelimt_state *state = space->machine->driver_data<timelimt_state>();
state->scrollx &= 0x100;
state->scrollx |= data & 0xff;
}
WRITE8_HANDLER( timelimt_scroll_x_msb_w )
{
scrollx &= 0xff;
scrollx |= ( data & 1 ) << 8;
timelimt_state *state = space->machine->driver_data<timelimt_state>();
state->scrollx &= 0xff;
state->scrollx |= ( data & 1 ) << 8;
}
WRITE8_HANDLER( timelimt_scroll_y_w )
{
scrolly = data;
timelimt_state *state = space->machine->driver_data<timelimt_state>();
state->scrolly = data;
}
@ -146,12 +144,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( timelimt )
{
tilemap_set_scrollx(bg_tilemap, 0, scrollx);
tilemap_set_scrolly(bg_tilemap, 0, scrolly);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
timelimt_state *state = screen->machine->driver_data<timelimt_state>();
tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx);
tilemap_set_scrolly(state->bg_tilemap, 0, state->scrolly);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}

View File

@ -83,7 +83,7 @@ WRITE16_HANDLER( twin16_video_register_w )
case 6: COMBINE_DATA( &state->scrolly[2] ); break;
default:
logerror("unknown state->video_register write:%d", data );
logerror("unknown video_register write:%d", data );
break;
}
}

View File

@ -39,13 +39,6 @@ Note: if MAME_DEBUG is defined, pressing Z with:
#include "emu.h"
#include "includes/unico.h"
/* Variables needed by drivers: */
UINT16 *unico_vram_0, *unico_scrollx_0, *unico_scrolly_0;
UINT16 *unico_vram_1, *unico_scrollx_1, *unico_scrolly_1;
UINT16 *unico_vram_2, *unico_scrollx_2, *unico_scrolly_2;
UINT32 *unico_vram32_0, *unico_vram32_1, *unico_vram32_2, *unico_scroll32;
/***************************************************************************
@ -94,37 +87,40 @@ WRITE32_HANDLER( unico_palette32_w )
***************************************************************************/
#define LAYER( _N_ ) \
static tilemap_t *tilemap_##_N_; \
\
static TILE_GET_INFO( get_tile_info_##_N_ ) \
{ \
UINT16 code = unico_vram_##_N_[ 2 * tile_index + 0 ]; \
UINT16 attr = unico_vram_##_N_[ 2 * tile_index + 1 ]; \
SET_TILE_INFO(1, code, attr & 0x1f, TILE_FLIPYX( attr >> 5 )); \
} \
\
static TILE_GET_INFO( get_tile_info32_##_N_ ) \
{ \
UINT32 code = unico_vram32_##_N_[tile_index]; \
SET_TILE_INFO(1, code >> 16, code & 0x1f, TILE_FLIPYX( code >> 5 )); \
} \
\
WRITE16_HANDLER( unico_vram_##_N_##_w ) \
{ \
COMBINE_DATA(&unico_vram_##_N_[offset]); \
tilemap_mark_tile_dirty(tilemap_##_N_,offset/2); \
} \
\
WRITE32_HANDLER( unico_vram32_##_N_##_w ) \
{ \
COMBINE_DATA(&unico_vram32_##_N_[offset]); \
tilemap_mark_tile_dirty(tilemap_##_N_,offset); \
static TILE_GET_INFO( get_tile_info )
{
UINT16 *vram = (UINT16 *)param;
UINT16 code = vram[2 * tile_index + 0 ];
UINT16 attr = vram[2 * tile_index + 1 ];
SET_TILE_INFO(1, code, attr & 0x1f, TILE_FLIPYX( attr >> 5 ));
}
LAYER( 0 )
LAYER( 1 )
LAYER( 2 )
static TILE_GET_INFO( get_tile_info32 )
{
UINT32 *vram = (UINT32 *)param;
UINT16 code = vram[tile_index] >> 16;
UINT16 attr = vram[tile_index] & 0xff;
SET_TILE_INFO(1, code, attr & 0x1f, TILE_FLIPYX( attr >> 5 ));
}
WRITE16_HANDLER( unico_vram_w )
{
unico_state *state = space->machine->driver_data<unico_state>();
UINT16 *vram = state->vram;
int tile = ((offset / 0x2000) + 1) % 3;
COMBINE_DATA(&vram[offset]);
tilemap_mark_tile_dirty(state->tilemap[tile],(offset & 0x3fff)/2);
}
WRITE32_HANDLER( unico_vram32_w )
{
unico_state *state = space->machine->driver_data<unico_state>();
UINT32 *vram = state->vram32;
int tile = ((offset / 0x1000) + 1) % 3;
COMBINE_DATA(&vram[offset]);
tilemap_mark_tile_dirty(state->tilemap[tile],(offset & 0x3fff));
}
@ -136,60 +132,69 @@ LAYER( 2 )
***************************************************************************/
static int sprites_scrolldx, sprites_scrolldy;
VIDEO_START( unico )
{
tilemap_0 = tilemap_create( machine, get_tile_info_0,tilemap_scan_rows,
unico_state *state = machine->driver_data<unico_state>();
state->tilemap[0] = tilemap_create( machine, get_tile_info,tilemap_scan_rows,
16,16, 0x40, 0x40);
tilemap_1 = tilemap_create( machine, get_tile_info_1,tilemap_scan_rows,
state->tilemap[1] = tilemap_create( machine, get_tile_info,tilemap_scan_rows,
16,16, 0x40, 0x40);
tilemap_2 = tilemap_create( machine, get_tile_info_2,tilemap_scan_rows,
state->tilemap[2] = tilemap_create( machine, get_tile_info,tilemap_scan_rows,
16,16, 0x40, 0x40);
sprites_scrolldx = -0x3f;
sprites_scrolldy = -0x0e;
tilemap_set_user_data(state->tilemap[0], &state->vram[0x8000/2]);
tilemap_set_user_data(state->tilemap[1], &state->vram[0x0000/2]);
tilemap_set_user_data(state->tilemap[2], &state->vram[0x4000/2]);
tilemap_set_scrolldx(tilemap_0,-0x32,0);
tilemap_set_scrolldx(tilemap_1,-0x30,0);
tilemap_set_scrolldx(tilemap_2,-0x2e,0);
state->sprites_scrolldx = -0x3f;
state->sprites_scrolldy = -0x0e;
tilemap_set_scrolldy(tilemap_0,-0x0f,0);
tilemap_set_scrolldy(tilemap_1,-0x0f,0);
tilemap_set_scrolldy(tilemap_2,-0x0f,0);
tilemap_set_scrolldx(state->tilemap[0],-0x32,0);
tilemap_set_scrolldx(state->tilemap[1],-0x30,0);
tilemap_set_scrolldx(state->tilemap[2],-0x2e,0);
tilemap_set_transparent_pen(tilemap_0,0x00);
tilemap_set_transparent_pen(tilemap_1,0x00);
tilemap_set_transparent_pen(tilemap_2,0x00);
tilemap_set_scrolldy(state->tilemap[0],-0x0f,0);
tilemap_set_scrolldy(state->tilemap[1],-0x0f,0);
tilemap_set_scrolldy(state->tilemap[2],-0x0f,0);
tilemap_set_transparent_pen(state->tilemap[0],0x00);
tilemap_set_transparent_pen(state->tilemap[1],0x00);
tilemap_set_transparent_pen(state->tilemap[2],0x00);
}
VIDEO_START( zeropnt2 )
{
tilemap_0 = tilemap_create( machine, get_tile_info32_0,tilemap_scan_rows,
unico_state *state = machine->driver_data<unico_state>();
state->tilemap[0] = tilemap_create( machine, get_tile_info32,tilemap_scan_rows,
16,16, 0x40, 0x40);
tilemap_1 = tilemap_create( machine, get_tile_info32_1,tilemap_scan_rows,
state->tilemap[1] = tilemap_create( machine, get_tile_info32,tilemap_scan_rows,
16,16, 0x40, 0x40);
tilemap_2 = tilemap_create( machine, get_tile_info32_2,tilemap_scan_rows,
state->tilemap[2] = tilemap_create( machine, get_tile_info32,tilemap_scan_rows,
16,16, 0x40, 0x40);
sprites_scrolldx = -0x3f;
sprites_scrolldy = -0x0e;
tilemap_set_user_data(state->tilemap[0], &state->vram32[0x8000/4]);
tilemap_set_user_data(state->tilemap[1], &state->vram32[0x0000/4]);
tilemap_set_user_data(state->tilemap[2], &state->vram32[0x4000/4]);
tilemap_set_scrolldx(tilemap_0,-0x32,0);
tilemap_set_scrolldx(tilemap_1,-0x30,0);
tilemap_set_scrolldx(tilemap_2,-0x2e,0);
state->sprites_scrolldx = -0x3f;
state->sprites_scrolldy = -0x0e;
tilemap_set_scrolldy(tilemap_0,-0x0f,0);
tilemap_set_scrolldy(tilemap_1,-0x0f,0);
tilemap_set_scrolldy(tilemap_2,-0x0f,0);
tilemap_set_scrolldx(state->tilemap[0],-0x32,0);
tilemap_set_scrolldx(state->tilemap[1],-0x30,0);
tilemap_set_scrolldx(state->tilemap[2],-0x2e,0);
tilemap_set_transparent_pen(tilemap_0,0x00);
tilemap_set_transparent_pen(tilemap_1,0x00);
tilemap_set_transparent_pen(tilemap_2,0x00);
tilemap_set_scrolldy(state->tilemap[0],-0x0f,0);
tilemap_set_scrolldy(state->tilemap[1],-0x0f,0);
tilemap_set_scrolldy(state->tilemap[2],-0x0f,0);
tilemap_set_transparent_pen(state->tilemap[0],0x00);
tilemap_set_transparent_pen(state->tilemap[1],0x00);
tilemap_set_transparent_pen(state->tilemap[2],0x00);
}
@ -218,6 +223,7 @@ VIDEO_START( zeropnt2 )
static void unico_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{
unico_state *state = machine->driver_data<unico_state>();
UINT16 *spriteram16 = machine->generic.spriteram.u16;
int offs;
@ -248,8 +254,8 @@ static void unico_draw_sprites(running_machine *machine, bitmap_t *bitmap,const
case 3: pri_mask = 0x00; // above all
}
sx += sprites_scrolldx;
sy += sprites_scrolldy;
sx += state->sprites_scrolldx;
sy += state->sprites_scrolldy;
sx = (sx & 0x1ff) - (sx & 0x200);
sy = (sy & 0x1ff) - (sy & 0x200);
@ -272,6 +278,7 @@ static void unico_draw_sprites(running_machine *machine, bitmap_t *bitmap,const
static void zeropnt2_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{
unico_state *state = machine->driver_data<unico_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
int offs;
@ -302,8 +309,8 @@ static void zeropnt2_draw_sprites(running_machine *machine, bitmap_t *bitmap,con
case 3: pri_mask = 0x00; // above all
}
sx += sprites_scrolldx;
sy += sprites_scrolldy;
sx += state->sprites_scrolldx;
sy += state->sprites_scrolldy;
sx = (sx & 0x1ff) - (sx & 0x200);
sy = (sy & 0x1ff) - (sy & 0x200);
@ -336,16 +343,17 @@ static void zeropnt2_draw_sprites(running_machine *machine, bitmap_t *bitmap,con
SCREEN_UPDATE( unico )
{
unico_state *state = screen->machine->driver_data<unico_state>();
int layers_ctrl = -1;
tilemap_set_scrollx(tilemap_0, 0, *unico_scrollx_0);
tilemap_set_scrolly(tilemap_0, 0, *unico_scrolly_0);
tilemap_set_scrollx(state->tilemap[0], 0, state->scroll[0x00]);
tilemap_set_scrolly(state->tilemap[0], 0, state->scroll[0x01]);
tilemap_set_scrollx(tilemap_1, 0, *unico_scrollx_1);
tilemap_set_scrolly(tilemap_1, 0, *unico_scrolly_1);
tilemap_set_scrollx(state->tilemap[1], 0, state->scroll[0x05]);
tilemap_set_scrolly(state->tilemap[1], 0, state->scroll[0x0a]);
tilemap_set_scrolly(tilemap_2, 0, *unico_scrolly_2);
tilemap_set_scrollx(tilemap_2, 0, *unico_scrollx_2);
tilemap_set_scrollx(state->tilemap[2], 0, state->scroll[0x04]);
tilemap_set_scrolly(state->tilemap[2], 0, state->scroll[0x02]);
#ifdef MAME_DEBUG
if ( input_code_pressed(screen->machine, KEYCODE_Z) || input_code_pressed(screen->machine, KEYCODE_X) )
@ -363,9 +371,9 @@ if ( input_code_pressed(screen->machine, KEYCODE_Z) || input_code_pressed(screen
bitmap_fill(bitmap,cliprect,0x1f00);
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
if (layers_ctrl & 1) tilemap_draw(bitmap,cliprect,tilemap_0,0,1);
if (layers_ctrl & 2) tilemap_draw(bitmap,cliprect,tilemap_1,0,2);
if (layers_ctrl & 4) tilemap_draw(bitmap,cliprect,tilemap_2,0,4);
if (layers_ctrl & 1) tilemap_draw(bitmap,cliprect,state->tilemap[0],0,1);
if (layers_ctrl & 2) tilemap_draw(bitmap,cliprect,state->tilemap[1],0,2);
if (layers_ctrl & 4) tilemap_draw(bitmap,cliprect,state->tilemap[2],0,4);
/* Sprites are drawn last, using pdrawgfx */
if (layers_ctrl & 8) unico_draw_sprites(screen->machine, bitmap,cliprect);
@ -375,16 +383,17 @@ if ( input_code_pressed(screen->machine, KEYCODE_Z) || input_code_pressed(screen
SCREEN_UPDATE( zeropnt2 )
{
unico_state *state = screen->machine->driver_data<unico_state>();
int layers_ctrl = -1;
tilemap_set_scrollx(tilemap_0, 0, unico_scroll32[0] >> 16);
tilemap_set_scrolly(tilemap_0, 0, unico_scroll32[0] & 0xffff);
tilemap_set_scrollx(state->tilemap[0], 0, state->scroll32[0] >> 16);
tilemap_set_scrolly(state->tilemap[0], 0, state->scroll32[0] & 0xffff);
tilemap_set_scrollx(tilemap_1, 0, unico_scroll32[2] & 0xffff);
tilemap_set_scrolly(tilemap_1, 0, unico_scroll32[5] >> 16);
tilemap_set_scrollx(state->tilemap[1], 0, state->scroll32[2] & 0xffff);
tilemap_set_scrolly(state->tilemap[1], 0, state->scroll32[5] >> 16);
tilemap_set_scrollx(tilemap_2, 0, unico_scroll32[2] >> 16);
tilemap_set_scrolly(tilemap_2, 0, unico_scroll32[1] >> 16);
tilemap_set_scrollx(state->tilemap[2], 0, state->scroll32[2] >> 16);
tilemap_set_scrolly(state->tilemap[2], 0, state->scroll32[1] >> 16);
#ifdef MAME_DEBUG
if ( input_code_pressed(screen->machine, KEYCODE_Z) || input_code_pressed(screen->machine, KEYCODE_X) )
@ -402,9 +411,9 @@ if ( input_code_pressed(screen->machine, KEYCODE_Z) || input_code_pressed(screen
bitmap_fill(bitmap,cliprect,0x1f00);
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
if (layers_ctrl & 1) tilemap_draw(bitmap,cliprect,tilemap_0,0,1);
if (layers_ctrl & 2) tilemap_draw(bitmap,cliprect,tilemap_1,0,2);
if (layers_ctrl & 4) tilemap_draw(bitmap,cliprect,tilemap_2,0,4);
if (layers_ctrl & 1) tilemap_draw(bitmap,cliprect,state->tilemap[0],0,1);
if (layers_ctrl & 2) tilemap_draw(bitmap,cliprect,state->tilemap[1],0,2);
if (layers_ctrl & 4) tilemap_draw(bitmap,cliprect,state->tilemap[2],0,4);
/* Sprites are drawn last, using pdrawgfx */
if (layers_ctrl & 8) zeropnt2_draw_sprites(screen->machine, bitmap,cliprect);

View File

@ -11,44 +11,39 @@ Video hardware driver by Uki
#include "emu.h"
#include "includes/xxmissio.h"
UINT8 *xxmissio_bgram;
UINT8 *xxmissio_fgram;
UINT8 *xxmissio_spriteram;
static tilemap_t *bg_tilemap;
static tilemap_t *fg_tilemap;
static UINT8 xscroll;
static UINT8 yscroll;
static UINT8 flipscreen;
WRITE8_DEVICE_HANDLER( xxmissio_scroll_x_w )
{
xscroll = data;
xxmissio_state *state = device->machine->driver_data<xxmissio_state>();
state->xscroll = data;
}
WRITE8_DEVICE_HANDLER( xxmissio_scroll_y_w )
{
yscroll = data;
xxmissio_state *state = device->machine->driver_data<xxmissio_state>();
state->yscroll = data;
}
WRITE8_HANDLER( xxmissio_flipscreen_w )
{
flipscreen = data & 0x01;
xxmissio_state *state = space->machine->driver_data<xxmissio_state>();
state->flipscreen = data & 0x01;
}
WRITE8_HANDLER( xxmissio_bgram_w )
{
int x = (offset + (xscroll >> 3)) & 0x1f;
xxmissio_state *state = space->machine->driver_data<xxmissio_state>();
int x = (offset + (state->xscroll >> 3)) & 0x1f;
offset = (offset & 0x7e0) | x;
xxmissio_bgram[offset] = data;
state->bgram[offset] = data;
}
READ8_HANDLER( xxmissio_bgram_r )
{
int x = (offset + (xscroll >> 3)) & 0x1f;
xxmissio_state *state = space->machine->driver_data<xxmissio_state>();
int x = (offset + (state->xscroll >> 3)) & 0x1f;
offset = (offset & 0x7e0) | x;
return xxmissio_bgram[offset];
return state->bgram[offset];
}
WRITE8_HANDLER( xxmissio_paletteram_w )
@ -60,54 +55,58 @@ WRITE8_HANDLER( xxmissio_paletteram_w )
static TILE_GET_INFO( get_bg_tile_info )
{
int code = ((xxmissio_bgram[0x400 | tile_index] & 0xc0) << 2) | xxmissio_bgram[0x000 | tile_index];
int color = xxmissio_bgram[0x400 | tile_index] & 0x0f;
xxmissio_state *state = machine->driver_data<xxmissio_state>();
int code = ((state->bgram[0x400 | tile_index] & 0xc0) << 2) | state->bgram[0x000 | tile_index];
int color = state->bgram[0x400 | tile_index] & 0x0f;
SET_TILE_INFO(2, code, color, 0);
}
static TILE_GET_INFO( get_fg_tile_info )
{
int code = xxmissio_fgram[0x000 | tile_index];
int color = xxmissio_fgram[0x400 | tile_index] & 0x07;
xxmissio_state *state = machine->driver_data<xxmissio_state>();
int code = state->fgram[0x000 | tile_index];
int color = state->fgram[0x400 | tile_index] & 0x07;
SET_TILE_INFO(0, code, color, 0);
}
VIDEO_START( xxmissio )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
xxmissio_state *state = machine->driver_data<xxmissio_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
tilemap_set_scroll_cols(bg_tilemap, 1);
tilemap_set_scroll_rows(bg_tilemap, 1);
tilemap_set_scrolldx(bg_tilemap, 2, 12);
tilemap_set_scroll_cols(state->bg_tilemap, 1);
tilemap_set_scroll_rows(state->bg_tilemap, 1);
tilemap_set_scrolldx(state->bg_tilemap, 2, 12);
tilemap_set_transparent_pen(fg_tilemap, 0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
}
static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx)
{
xxmissio_state *state = gfx->machine->driver_data<xxmissio_state>();
int offs;
int chr,col;
int x,y,px,py,fx,fy;
for (offs=0; offs<0x800; offs +=0x20)
{
chr = xxmissio_spriteram[offs];
col = xxmissio_spriteram[offs+3];
chr = state->spriteram[offs];
col = state->spriteram[offs+3];
fx = ((col & 0x10) >> 4) ^ flipscreen;
fy = ((col & 0x20) >> 5) ^ flipscreen;
fx = ((col & 0x10) >> 4) ^ state->flipscreen;
fy = ((col & 0x20) >> 5) ^ state->flipscreen;
x = xxmissio_spriteram[offs+1]*2;
y = xxmissio_spriteram[offs+2];
x = state->spriteram[offs+1]*2;
y = state->spriteram[offs+2];
chr = chr + ((col & 0x40) << 2);
col = col & 0x07;
if (flipscreen==0)
if (state->flipscreen==0)
{
px = x-8;
py = y;
@ -139,15 +138,16 @@ static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_
SCREEN_UPDATE( xxmissio )
{
xxmissio_state *state = screen->machine->driver_data<xxmissio_state>();
tilemap_mark_all_tiles_dirty_all(screen->machine);
tilemap_set_flip_all(screen->machine, flipscreen ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
tilemap_set_flip_all(screen->machine, state->flipscreen ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
tilemap_set_scrollx(bg_tilemap, 0, xscroll * 2);
tilemap_set_scrolly(bg_tilemap, 0, yscroll);
tilemap_set_scrollx(state->bg_tilemap, 0, state->xscroll * 2);
tilemap_set_scrolly(state->bg_tilemap, 0, state->yscroll);
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}

View File

@ -8,14 +8,6 @@
#include "sound/s2636.h"
#include "includes/zac2650.h"
UINT8 *zac2650_s2636_0_ram;
static bitmap_t *spritebitmap;
static int CollisionBackground;
static int CollisionSprite;
static tilemap_t *bg_tilemap;
/**************************************************************/
/* The S2636 is a standard sprite chip used by several boards */
@ -28,18 +20,20 @@ WRITE8_HANDLER( tinvader_videoram_w )
zac2650_state *state = space->machine->driver_data<zac2650_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
READ8_HANDLER( zac_s2636_r )
{
if(offset!=0xCB) return zac2650_s2636_0_ram[offset];
else return CollisionSprite;
zac2650_state *state = space->machine->driver_data<zac2650_state>();
if(offset!=0xCB) return state->s2636_0_ram[offset];
else return state->CollisionSprite;
}
WRITE8_HANDLER( zac_s2636_w )
{
zac2650_s2636_0_ram[offset] = data;
zac2650_state *state = space->machine->driver_data<zac2650_state>();
state->s2636_0_ram[offset] = data;
gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
gfx_element_mark_dirty(space->machine->gfx[2], offset/8);
if (offset == 0xc7)
@ -50,7 +44,8 @@ WRITE8_HANDLER( zac_s2636_w )
READ8_HANDLER( tinvader_port_0_r )
{
return input_port_read(space->machine, "1E80") - CollisionBackground;
zac2650_state *state = space->machine->driver_data<zac2650_state>();
return input_port_read(space->machine, "1E80") - state->CollisionBackground;
}
/*****************************************/
@ -59,19 +54,20 @@ READ8_HANDLER( tinvader_port_0_r )
static int SpriteCollision(running_machine *machine, int first,int second)
{
zac2650_state *state = machine->driver_data<zac2650_state>();
int Checksum=0;
int x,y;
const rectangle &visarea = machine->primary_screen->visible_area();
if((zac2650_s2636_0_ram[first * 0x10 + 10] < 0xf0) && (zac2650_s2636_0_ram[second * 0x10 + 10] < 0xf0))
if((state->s2636_0_ram[first * 0x10 + 10] < 0xf0) && (state->s2636_0_ram[second * 0x10 + 10] < 0xf0))
{
int fx = (zac2650_s2636_0_ram[first * 0x10 + 10] * 4)-22;
int fy = (zac2650_s2636_0_ram[first * 0x10 + 12] * 3)+3;
int fx = (state->s2636_0_ram[first * 0x10 + 10] * 4)-22;
int fy = (state->s2636_0_ram[first * 0x10 + 12] * 3)+3;
int expand = (first==1) ? 2 : 1;
/* Draw first sprite */
drawgfx_opaque(spritebitmap,0, machine->gfx[expand],
drawgfx_opaque(state->spritebitmap,0, machine->gfx[expand],
first * 2,
0,
0,0,
@ -91,17 +87,17 @@ static int SpriteCollision(running_machine *machine, int first,int second)
continue;
}
Checksum += *BITMAP_ADDR16(spritebitmap, y, x);
Checksum += *BITMAP_ADDR16(state->spritebitmap, y, x);
}
}
/* Blackout second sprite */
drawgfx_transpen(spritebitmap,0, machine->gfx[1],
drawgfx_transpen(state->spritebitmap,0, machine->gfx[1],
second * 2,
1,
0,0,
(zac2650_s2636_0_ram[second * 0x10 + 10] * 4)-22,(zac2650_s2636_0_ram[second * 0x10 + 12] * 3) + 3, 0);
(state->s2636_0_ram[second * 0x10 + 10] * 4)-22,(state->s2636_0_ram[second * 0x10 + 12] * 3) + 3, 0);
/* Remove fingerprint */
@ -117,13 +113,13 @@ static int SpriteCollision(running_machine *machine, int first,int second)
continue;
}
Checksum -= *BITMAP_ADDR16(spritebitmap, y, x);
Checksum -= *BITMAP_ADDR16(state->spritebitmap, y, x);
}
}
/* Zero bitmap */
drawgfx_opaque(spritebitmap,0, machine->gfx[expand],
drawgfx_opaque(state->spritebitmap,0, machine->gfx[expand],
first * 2,
1,
0,0,
@ -144,18 +140,20 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( tinvader )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
zac2650_state *state = machine->driver_data<zac2650_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
24, 24, 32, 32);
spritebitmap = machine->primary_screen->alloc_compatible_bitmap();
state->spritebitmap = machine->primary_screen->alloc_compatible_bitmap();
machine->generic.tmpbitmap = machine->primary_screen->alloc_compatible_bitmap();
gfx_element_set_source(machine->gfx[1], zac2650_s2636_0_ram);
gfx_element_set_source(machine->gfx[2], zac2650_s2636_0_ram);
gfx_element_set_source(machine->gfx[1], state->s2636_0_ram);
gfx_element_set_source(machine->gfx[2], state->s2636_0_ram);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
{
zac2650_state *state = machine->driver_data<zac2650_state>();
int offs;
const rectangle &visarea = machine->primary_screen->visible_area();
@ -170,19 +168,19 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
/* does not seem to be a fault of the emulation! */
/* -------------------------------------------------------------- */
CollisionBackground = 0; /* Read from 0x1e80 bit 7 */
state->CollisionBackground = 0; /* Read from 0x1e80 bit 7 */
// for collision detection checking
copybitmap(machine->generic.tmpbitmap,bitmap,0,0,0,0,&visarea);
for(offs=0;offs<0x50;offs+=0x10)
{
if((zac2650_s2636_0_ram[offs+10]<0xF0) && (offs!=0x30))
if((state->s2636_0_ram[offs+10]<0xF0) && (offs!=0x30))
{
int spriteno = (offs / 8);
int expand = ((zac2650_s2636_0_ram[0xc0] & (spriteno*2))!=0) ? 2 : 1;
int bx = (zac2650_s2636_0_ram[offs+10] * 4) - 22;
int by = (zac2650_s2636_0_ram[offs+12] * 3) + 3;
int expand = ((state->s2636_0_ram[0xc0] & (spriteno*2))!=0) ? 2 : 1;
int bx = (state->s2636_0_ram[offs+10] * 4) - 22;
int by = (state->s2636_0_ram[offs+12] * 3) + 3;
int x,y;
/* Sprite->Background collision detection */
@ -206,7 +204,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
if (*BITMAP_ADDR16(bitmap, y, x) != *BITMAP_ADDR16(machine->generic.tmpbitmap, y, x))
{
CollisionBackground = 0x80;
state->CollisionBackground = 0x80;
break;
}
}
@ -221,18 +219,19 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
}
/* Sprite->Sprite collision detection */
CollisionSprite = 0;
// if(SpriteCollision(machine, 0,1)) CollisionSprite |= 0x20; /* Not Used */
if(SpriteCollision(machine, 0,2)) CollisionSprite |= 0x10;
if(SpriteCollision(machine, 0,4)) CollisionSprite |= 0x08;
if(SpriteCollision(machine, 1,2)) CollisionSprite |= 0x04;
if(SpriteCollision(machine, 1,4)) CollisionSprite |= 0x02;
// if(SpriteCollision(machine, 2,4)) CollisionSprite |= 0x01; /* Not Used */
state->CollisionSprite = 0;
// if(SpriteCollision(machine, 0,1)) state->CollisionSprite |= 0x20; /* Not Used */
if(SpriteCollision(machine, 0,2)) state->CollisionSprite |= 0x10;
if(SpriteCollision(machine, 0,4)) state->CollisionSprite |= 0x08;
if(SpriteCollision(machine, 1,2)) state->CollisionSprite |= 0x04;
if(SpriteCollision(machine, 1,4)) state->CollisionSprite |= 0x02;
// if(SpriteCollision(machine, 2,4)) state->CollisionSprite |= 0x01; /* Not Used */
}
SCREEN_UPDATE( tinvader )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
zac2650_state *state = screen->machine->driver_data<zac2650_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap);
return 0;
}

View File

@ -11,13 +11,6 @@
#include "includes/zaccaria.h"
UINT8 *zaccaria_videoram,*zaccaria_attributesram;
static tilemap_t *bg_tilemap;
/***************************************************************************
Convert the color PROMs into a more useable format.
@ -121,11 +114,12 @@ PALETTE_INIT( zaccaria )
static TILE_GET_INFO( get_tile_info )
{
UINT8 attr = zaccaria_videoram[tile_index + 0x400];
zaccaria_state *state = machine->driver_data<zaccaria_state>();
UINT8 attr = state->videoram[tile_index + 0x400];
SET_TILE_INFO(
0,
zaccaria_videoram[tile_index] + ((attr & 0x03) << 8),
((attr & 0x0c) >> 2) + ((zaccaria_attributesram[2 * (tile_index % 32) + 1] & 0x07) << 2),
state->videoram[tile_index] + ((attr & 0x03) << 8),
((attr & 0x0c) >> 2) + ((state->attributesram[2 * (tile_index % 32) + 1] & 0x07) << 2),
0);
}
@ -139,9 +133,10 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( zaccaria )
{
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
zaccaria_state *state = machine->driver_data<zaccaria_state>();
state->bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_scroll_cols(bg_tilemap,32);
tilemap_set_scroll_cols(state->bg_tilemap,32);
}
@ -154,26 +149,28 @@ VIDEO_START( zaccaria )
WRITE8_HANDLER( zaccaria_videoram_w )
{
zaccaria_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
zaccaria_state *state = space->machine->driver_data<zaccaria_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff);
}
WRITE8_HANDLER( zaccaria_attributes_w )
{
zaccaria_state *state = space->machine->driver_data<zaccaria_state>();
if (offset & 1)
{
if (zaccaria_attributesram[offset] != data)
if (state->attributesram[offset] != data)
{
int i;
for (i = offset / 2;i < 0x400;i += 32)
tilemap_mark_tile_dirty(bg_tilemap,i);
tilemap_mark_tile_dirty(state->bg_tilemap,i);
}
}
else
tilemap_set_scrolly(bg_tilemap,offset / 2,data);
tilemap_set_scrolly(state->bg_tilemap,offset / 2,data);
zaccaria_attributesram[offset] = data;
state->attributesram[offset] = data;
}
WRITE8_HANDLER( zaccaria_flip_screen_x_w )
@ -248,7 +245,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
SCREEN_UPDATE( zaccaria )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
zaccaria_state *state = screen->machine->driver_data<zaccaria_state>();
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
// 3 layers of sprites, each with their own palette and priorities
// Not perfect yet, does spriteram(1) layer have a priority bit somewhere?